Explorar el Código

Merge pull request #3736 from nextcloud/feature/noid/hideItemsForFederatedRooms

Feature/noid/hide items for federated rooms
Marcel Hibbe hace 1 año
padre
commit
e76166987f

+ 13 - 4
app/src/main/java/com/nextcloud/talk/conversationinfo/ConversationInfoActivity.kt

@@ -199,7 +199,7 @@ class ConversationInfoActivity :
         if (databaseStorageModule == null) {
             databaseStorageModule = DatabaseStorageModule(conversationUser, conversationToken)
         }
-        setUpNotificationSettings(databaseStorageModule!!)
+
         binding.deleteConversationAction.setOnClickListener { showDeleteConversationDialog() }
         binding.leaveConversationAction.setOnClickListener { leaveConversation() }
         binding.clearConversationHistory.setOnClickListener { showClearHistoryDialog() }
@@ -690,7 +690,11 @@ class ConversationInfoActivity :
     private fun handleConversation() {
         val conversationCopy = conversation!!
 
-        if (CapabilitiesUtil.hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.RICH_OBJECT_LIST_MEDIA)) {
+        setUpNotificationSettings(databaseStorageModule!!)
+
+        if (CapabilitiesUtil.hasSpreedFeatureCapability(spreedCapabilities, SpreedFeatures.RICH_OBJECT_LIST_MEDIA) &&
+            conversationCopy.remoteServer.isNullOrEmpty()
+        ) {
             binding.sharedItemsButton.setOnClickListener { showSharedItems() }
         } else {
             binding.sharedItems.visibility = GONE
@@ -1345,8 +1349,13 @@ class ConversationInfoActivity :
         binding.notificationSettingsView.importantConversationSwitch.isChecked = module
             .getBoolean("important_conversation_switch", false)
 
-        binding.notificationSettingsView.callNotificationsSwitch.isChecked = module
-            .getBoolean("call_notifications_switch", true)
+        if (conversation!!.remoteServer.isNullOrEmpty()) {
+            binding.notificationSettingsView.notificationSettingsCallNotifications.visibility = VISIBLE
+            binding.notificationSettingsView.callNotificationsSwitch.isChecked = module
+                .getBoolean("call_notifications_switch", true)
+        } else {
+            binding.notificationSettingsView.notificationSettingsCallNotifications.visibility = GONE
+        }
     }
 
     companion object {

+ 13 - 7
app/src/main/java/com/nextcloud/talk/shareditems/repositories/SharedItemsRepositoryImpl.kt

@@ -188,15 +188,20 @@ class SharedItemsRepositoryImpl @Inject constructor(private val ncApi: NcApi, pr
             1
         ).map {
             val types = mutableSetOf<SharedItemType>()
-            val typeMap = it.body()!!.ocs!!.data!!
-            for (t in typeMap) {
-                if (t.value.isNotEmpty()) {
-                    try {
-                        types += SharedItemType.typeFor(t.key)
-                    } catch (e: IllegalArgumentException) {
-                        Log.w(TAG, "Server responds an unknown shared item type: ${t.key}")
+
+            if (it.code() == HTTP_OK) {
+                val typeMap = it.body()!!.ocs!!.data!!
+                for (t in typeMap) {
+                    if (t.value.isNotEmpty()) {
+                        try {
+                            types += SharedItemType.typeFor(t.key)
+                        } catch (e: IllegalArgumentException) {
+                            Log.w(TAG, "Server responds an unknown shared item type: ${t.key}")
+                        }
                     }
                 }
+            } else {
+                Log.e(TAG, "Failed to getSharedItemsOverview")
             }
 
             types.toSet()
@@ -213,6 +218,7 @@ class SharedItemsRepositoryImpl @Inject constructor(private val ncApi: NcApi, pr
 
     companion object {
         const val BATCH_SIZE: Int = 28
+        private const val HTTP_OK: Int = 200
         private val TAG = SharedItemsRepositoryImpl::class.simpleName
     }
 }

+ 1 - 1
app/src/main/java/com/nextcloud/talk/shareditems/viewmodels/SharedItemsViewModel.kt

@@ -81,7 +81,7 @@ class SharedItemsViewModel @Inject constructor(
                 }
 
                 override fun onError(e: Throwable) {
-                    Log.d(TAG, "An error occurred: $e")
+                    Log.e(TAG, "An error occurred when loading available types", e)
                 }
 
                 override fun onComplete() {

+ 9 - 0
app/src/main/java/com/nextcloud/talk/ui/dialog/AttachmentDialog.kt

@@ -73,6 +73,15 @@ class AttachmentDialog(val activity: Activity, var chatActivity: ChatActivity) :
     }
 
     private fun initItemsVisibility() {
+        if (!chatActivity.currentConversation!!.remoteServer.isNullOrEmpty()) {
+            dialogAttachmentBinding.menuAttachContact.visibility = View.GONE
+            dialogAttachmentBinding.menuShareLocation.visibility = View.GONE
+            dialogAttachmentBinding.menuAttachPictureFromCam.visibility = View.GONE
+            dialogAttachmentBinding.menuAttachVideoFromCam.visibility = View.GONE
+            dialogAttachmentBinding.menuAttachFileFromLocal.visibility = View.GONE
+            dialogAttachmentBinding.menuAttachFileFromCloud.visibility = View.GONE
+        }
+
         if (!CapabilitiesUtil.hasSpreedFeatureCapability(
                 chatActivity.spreedCapabilities,
                 SpreedFeatures.GEO_LOCATION_SHARING