mirror of
https://github.com/nextcloud/talk-android
synced 2025-08-03 18:15:40 +01:00
theme user groups and mentions
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
9d834c2835
commit
c096c9bb6e
@ -20,6 +20,8 @@ import com.nextcloud.talk.models.json.participants.TalkBanOverall
|
||||
import com.nextcloud.talk.models.json.profile.ProfileOverall
|
||||
import com.nextcloud.talk.models.json.testNotification.TestNotificationOverall
|
||||
import com.nextcloud.talk.models.json.userAbsence.UserAbsenceOverall
|
||||
import com.nextcloud.talk.models.json.usercircles.UserCirclesOverall
|
||||
import com.nextcloud.talk.models.json.usergroups.UserGroupsOverall
|
||||
import okhttp3.MultipartBody
|
||||
import okhttp3.RequestBody
|
||||
import retrofit2.http.Body
|
||||
|
@ -196,6 +196,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_RECORDING_STATE
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_START_CALL_AFTER_ROOM_SWITCH
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SWITCH_TO_ROOM
|
||||
import com.nextcloud.talk.utils.message.MessageUtils
|
||||
import com.nextcloud.talk.utils.permissions.PlatformPermissionUtil
|
||||
import com.nextcloud.talk.utils.rx.DisposableSet
|
||||
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder
|
||||
@ -271,6 +272,9 @@ class ChatActivity :
|
||||
@Inject
|
||||
lateinit var networkMonitor: NetworkMonitor
|
||||
|
||||
@Inject
|
||||
lateinit var messageUtils: MessageUtils
|
||||
|
||||
lateinit var chatViewModel: ChatViewModel
|
||||
|
||||
lateinit var conversationInfoViewModel: ConversationInfoViewModel
|
||||
@ -669,6 +673,10 @@ class ChatActivity :
|
||||
}
|
||||
}
|
||||
|
||||
conversationUser?.let { user ->
|
||||
chatViewModel.fetchUserData(user)
|
||||
}
|
||||
|
||||
if (currentConversation?.objectType == ConversationEnums.ObjectType.EVENT &&
|
||||
hasSpreedFeatureCapability(
|
||||
conversationUser?.capabilities!!.spreedCapability!!,
|
||||
@ -1204,6 +1212,14 @@ class ChatActivity :
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lifecycleScope.launch {
|
||||
chatViewModel.userGroups.collect { userGroups ->
|
||||
chatViewModel.userCircles.collect { userCircles ->
|
||||
messageUtils.setUserData(userGroups, userCircles)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeUnreadMessagesMarker() {
|
||||
|
@ -77,4 +77,6 @@ interface ChatNetworkDataSource {
|
||||
): List<ChatMessageJson>
|
||||
suspend fun getOpenGraph(credentials: String, baseUrl: String, extractedLinkToPreview: String): Reference?
|
||||
suspend fun unbindRoom(credentials: String, baseUrl: String, roomToken: String): GenericOverall
|
||||
suspend fun getUserGroups(user: User): Set<String>
|
||||
suspend fun getUserCircles(user: User): Set<String>
|
||||
}
|
||||
|
@ -222,4 +222,25 @@ class RetrofitChatNetwork(
|
||||
val url = ApiUtils.getUrlForUnbindingRoom(baseUrl, roomToken)
|
||||
return ncApiCoroutines.unbindRoom(credentials, url)
|
||||
}
|
||||
|
||||
override suspend fun getUserGroups(user: User): Set<String> {
|
||||
val credentials: String = ApiUtils.getCredentials(user.username, user.token)!!
|
||||
val response = ncApiCoroutines.getUserGroups(
|
||||
credentials,
|
||||
ApiUtils.getUrlForUserGroups(
|
||||
user.baseUrl!!,
|
||||
user.userId!!
|
||||
)
|
||||
)
|
||||
return response.ocs?.data?.groups?.toSet() ?: emptySet()
|
||||
}
|
||||
|
||||
override suspend fun getUserCircles(user: User): Set<String> {
|
||||
val credentials: String = ApiUtils.getCredentials(user.username, user.token)!!
|
||||
val response = ncApiCoroutines.getUserCircles(
|
||||
credentials,
|
||||
ApiUtils.getUrlForUserCircles(user.baseUrl!!)
|
||||
)
|
||||
return response.ocs?.data?.map { it.displayName!! }?.toSet() ?: emptySet()
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,9 @@ import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.first
|
||||
@ -233,6 +236,12 @@ class ChatViewModel @Inject constructor(
|
||||
val leaveRoomViewState: LiveData<ViewState>
|
||||
get() = _leaveRoomViewState
|
||||
|
||||
private val _userGroups = MutableStateFlow<Set<String>>(emptySet())
|
||||
val userGroups: StateFlow<Set<String>> = _userGroups.asStateFlow()
|
||||
|
||||
private val _userCircles = MutableStateFlow<Set<String>>(emptySet())
|
||||
val userCircles: StateFlow<Set<String>> = _userCircles.asStateFlow()
|
||||
|
||||
object ChatMessageInitialState : ViewState
|
||||
object ChatMessageStartState : ViewState
|
||||
object ChatMessageUpdateState : ViewState
|
||||
@ -355,6 +364,13 @@ class ChatViewModel @Inject constructor(
|
||||
_getReminderExistState.value = GetReminderStateSet
|
||||
}
|
||||
|
||||
fun fetchUserData(user: User) {
|
||||
viewModelScope.launch {
|
||||
_userGroups.value = chatNetworkDataSource.getUserGroups(user)
|
||||
_userCircles.value = chatNetworkDataSource.getUserCircles(user)
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteReminder(user: User, roomToken: String, messageId: String, chatApiVersion: Int) {
|
||||
chatNetworkDataSource.deleteReminder(user, roomToken, messageId, chatApiVersion)
|
||||
.subscribeOn(Schedulers.io())
|
||||
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2025 Sowjanya Kota <sowjanya.kch@gmail.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.models.json.usergroups
|
||||
|
||||
import android.os.Parcelable
|
||||
import com.bluelinelabs.logansquare.annotation.JsonField
|
||||
import com.bluelinelabs.logansquare.annotation.JsonObject
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
@JsonObject
|
||||
data class UserGroupsData(
|
||||
@JsonField(name = ["groups"])
|
||||
var groups: List<String>?
|
||||
) : Parcelable {
|
||||
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||
constructor() : this(null)
|
||||
}
|
@ -19,7 +19,7 @@ data class UserGroupsOCS(
|
||||
@JsonField(name = ["meta"])
|
||||
var meta: GenericMeta?,
|
||||
@JsonField(name = ["data"])
|
||||
var data: List<String>?
|
||||
var data: UserGroupsData?
|
||||
) : Parcelable {
|
||||
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
|
||||
constructor() : this(null, null)
|
||||
|
@ -30,6 +30,7 @@ import io.noties.markwon.ext.tasklist.TaskListDrawable
|
||||
import io.noties.markwon.ext.tasklist.TaskListPlugin
|
||||
|
||||
class MessageUtils(val context: Context) {
|
||||
|
||||
fun enrichChatReplyMessageText(
|
||||
context: Context,
|
||||
message: ChatMessage,
|
||||
|
Loading…
Reference in New Issue
Block a user