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

Feature/noid/hide items for federated rooms
This commit is contained in:
Marcel Hibbe 2024-03-21 16:07:21 +01:00 committed by GitHub
commit e76166987f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 36 additions and 12 deletions

View File

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

View File

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

View File

@ -81,7 +81,7 @@ class SharedItemsViewModel @Inject constructor(
} }
override fun onError(e: Throwable) { 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() { override fun onComplete() {

View File

@ -73,6 +73,15 @@ class AttachmentDialog(val activity: Activity, var chatActivity: ChatActivity) :
} }
private fun initItemsVisibility() { 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( if (!CapabilitiesUtil.hasSpreedFeatureCapability(
chatActivity.spreedCapabilities, chatActivity.spreedCapabilities,
SpreedFeatures.GEO_LOCATION_SHARING SpreedFeatures.GEO_LOCATION_SHARING