mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-24 22:15:41 +03:00
Merge pull request #3698 from nextcloud/feature/noid/handleFederationFeaturesByCapabilities
hide some features if federation is not available
This commit is contained in:
commit
3832e84e80
4 changed files with 34 additions and 19 deletions
|
@ -601,6 +601,7 @@ class ChatActivity :
|
|||
spreedCapabilities = state.spreedCapabilities
|
||||
chatApiVersion = ApiUtils.getChatApiVersion(spreedCapabilities, intArrayOf(1))
|
||||
|
||||
invalidateOptionsMenu()
|
||||
initMessageInputView()
|
||||
|
||||
if (conversationUser?.userId != "?" &&
|
||||
|
@ -3923,17 +3924,16 @@ class ChatActivity :
|
|||
val searchItem = menu.findItem(R.id.conversation_search)
|
||||
searchItem.isVisible = CapabilitiesUtil.isUnifiedSearchAvailable(spreedCapabilities)
|
||||
|
||||
if (CapabilitiesUtil.hasSpreedFeatureCapability(
|
||||
spreedCapabilities,
|
||||
SpreedFeatures.RICH_OBJECT_LIST_MEDIA
|
||||
)
|
||||
if (currentConversation!!.remoteServer != null ||
|
||||
!CapabilitiesUtil.isSharedItemsAvailable(spreedCapabilities)
|
||||
) {
|
||||
conversationSharedItemsItem = menu.findItem(R.id.shared_items)
|
||||
} else {
|
||||
menu.removeItem(R.id.shared_items)
|
||||
}
|
||||
|
||||
if (CapabilitiesUtil.isAbleToCall(spreedCapabilities)) {
|
||||
if (currentConversation!!.remoteServer != null) {
|
||||
menu.removeItem(R.id.conversation_video_call)
|
||||
menu.removeItem(R.id.conversation_voice_call)
|
||||
} else if (CapabilitiesUtil.isAbleToCall(spreedCapabilities)) {
|
||||
conversationVoiceCallMenuItem = menu.findItem(R.id.conversation_voice_call)
|
||||
conversationVideoMenuItem = menu.findItem(R.id.conversation_video_call)
|
||||
|
||||
|
|
|
@ -754,16 +754,14 @@ class ConversationsListActivity :
|
|||
}
|
||||
|
||||
private fun fetchPendingInvitations() {
|
||||
if (hasSpreedFeatureCapability(currentUser!!.capabilities!!.spreedCapability!!, SpreedFeatures.FEDERATION_V1)) {
|
||||
binding.conversationListHintInclude.conversationListHintLayout.setOnClickListener {
|
||||
val intent = Intent(this, InvitationsActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
// TODO create mvvm, fetch pending invitations for all users and store in database for users, if current user
|
||||
// has invitation -> show hint, if one or more other users have invitations -> show badge
|
||||
|
||||
conversationsListViewModel.getFederationInvitations()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initOverallLayout(isConversationListNotEmpty: Boolean) {
|
||||
if (isConversationListNotEmpty) {
|
||||
|
|
|
@ -165,8 +165,9 @@ class MessageActionsDialog(
|
|||
!(message.isDeletedCommentMessage || message.isDeleted)
|
||||
)
|
||||
initMenuRemindMessage(
|
||||
!message.isDeleted && CapabilitiesUtil.hasSpreedFeatureCapability
|
||||
(spreedCapabilities, SpreedFeatures.REMIND_ME_LATER)
|
||||
!message.isDeleted &&
|
||||
hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.REMIND_ME_LATER) &&
|
||||
currentConversation!!.remoteServer.isNullOrEmpty()
|
||||
)
|
||||
initMenuMarkAsUnread(
|
||||
message.previousMessageId > NO_PREVIOUS_MESSAGE_ID &&
|
||||
|
@ -251,7 +252,8 @@ class MessageActionsDialog(
|
|||
private fun initEmojiBar(hasChatPermission: Boolean) {
|
||||
if (hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.REACTIONS) &&
|
||||
isPermitted(hasChatPermission) &&
|
||||
isReactableMessageType(message)
|
||||
isReactableMessageType(message) &&
|
||||
currentConversation!!.remoteServer.isNullOrEmpty()
|
||||
) {
|
||||
checkAndSetEmojiSelfReaction(dialogMessageActionsBinding.emojiThumbsUp)
|
||||
dialogMessageActionsBinding.emojiThumbsUp.setOnClickListener {
|
||||
|
|
|
@ -65,7 +65,8 @@ enum class SpreedFeatures(val value: String) {
|
|||
UNIFIED_SEARCH("unified-search"),
|
||||
LOCKED_ONE_TO_ONE("locked-one-to-one-rooms"),
|
||||
CHAT_PERMISSION("chat-permission"),
|
||||
CONVERSATION_PERMISSION("conversation-permissions")
|
||||
CONVERSATION_PERMISSION("conversation-permissions"),
|
||||
FEDERATION_V1("federation-v1")
|
||||
}
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
|
@ -102,6 +103,10 @@ object CapabilitiesUtil {
|
|||
return false
|
||||
}
|
||||
|
||||
fun isSharedItemsAvailable(spreedCapabilities: SpreedCapability): Boolean {
|
||||
return hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.RICH_OBJECT_LIST_MEDIA)
|
||||
}
|
||||
|
||||
fun getMessageMaxLength(spreedCapabilities: SpreedCapability): Int {
|
||||
if (spreedCapabilities.config?.containsKey("chat") == true) {
|
||||
val chatConfigHashMap = spreedCapabilities.config!!["chat"]
|
||||
|
@ -155,6 +160,9 @@ object CapabilitiesUtil {
|
|||
}
|
||||
|
||||
fun isUnifiedSearchAvailable(spreedCapabilities: SpreedCapability): Boolean {
|
||||
if (hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.FEDERATION_V1)) {
|
||||
return false
|
||||
}
|
||||
return hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.UNIFIED_SEARCH)
|
||||
}
|
||||
|
||||
|
@ -238,6 +246,13 @@ object CapabilitiesUtil {
|
|||
return false
|
||||
}
|
||||
|
||||
fun isFederationAvailable(user: User): Boolean {
|
||||
return hasSpreedFeatureCapability(user.capabilities!!.spreedCapability!!, SpreedFeatures.FEDERATION_V1) &&
|
||||
user.capabilities!!.spreedCapability!!.config?.containsKey("federation") == true &&
|
||||
user.capabilities!!.spreedCapability!!.config!!["federation"] != null &&
|
||||
user.capabilities!!.spreedCapability!!.config!!["federation"]!!.containsKey("enabled")
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
//region ThemingCapabilities
|
||||
|
|
Loading…
Reference in a new issue