From 2becf9fabe60a3171bb61efa24f5c104e63fb7af Mon Sep 17 00:00:00 2001 From: Harris Date: Mon, 26 Jul 2021 14:50:43 +1000 Subject: [PATCH] refactor: only display notification settings when the conversation is unmuted, notify the conversation list listeners when notify settings are updated --- .../conversation/v2/menus/ConversationMenuHelper.kt | 1 + .../thoughtcrime/securesms/database/RecipientDatabase.java | 1 + .../securesms/home/ConversationOptionsBottomSheet.kt | 2 +- app/src/main/res/menu/menu_conversation_closed_group.xml | 4 ---- .../res/menu/menu_conversation_notification_settings.xml | 6 ++++++ app/src/main/res/menu/menu_conversation_open_group.xml | 4 ---- 6 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 app/src/main/res/menu/menu_conversation_notification_settings.xml diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt index 713add9277..70e4737846 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt @@ -92,6 +92,7 @@ object ConversationMenuHelper { inflater.inflate(R.menu.menu_conversation_muted, menu) } else { inflater.inflate(R.menu.menu_conversation_unmuted, menu) + inflater.inflate(R.menu.menu_conversation_notification_settings, menu) } // Search diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/RecipientDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/RecipientDatabase.java index 8d7cedb61b..e1a3383d98 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/RecipientDatabase.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/RecipientDatabase.java @@ -237,6 +237,7 @@ public class RecipientDatabase extends Database { values.put(NOTIFY_TYPE, notifyType); updateOrInsert(recipient.getAddress(), values); recipient.resolve().setNotifyType(notifyType); + notifyConversationListListeners(); } public void setExpireMessages(@NonNull Recipient recipient, int expiration) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/ConversationOptionsBottomSheet.kt b/app/src/main/java/org/thoughtcrime/securesms/home/ConversationOptionsBottomSheet.kt index b82737932e..9d0f328473 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/ConversationOptionsBottomSheet.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/ConversationOptionsBottomSheet.kt @@ -59,7 +59,7 @@ public class ConversationOptionsBottomSheet : BottomSheetDialogFragment(), View. muteNotificationsTextView.isVisible = !recipient.isMuted && !recipient.isLocalNumber unMuteNotificationsTextView.setOnClickListener(this) muteNotificationsTextView.setOnClickListener(this) - notificationsTextView.isVisible = recipient.isGroupRecipient + notificationsTextView.isVisible = recipient.isGroupRecipient && !recipient.isMuted notificationsTextView.setOnClickListener(this) deleteTextView.setOnClickListener(this) } diff --git a/app/src/main/res/menu/menu_conversation_closed_group.xml b/app/src/main/res/menu/menu_conversation_closed_group.xml index 5e169f5e99..7ab02e07d9 100644 --- a/app/src/main/res/menu/menu_conversation_closed_group.xml +++ b/app/src/main/res/menu/menu_conversation_closed_group.xml @@ -13,8 +13,4 @@ android:title="@string/conversation__menu_leave_group" app:showAsAction="collapseActionView"/> - - \ No newline at end of file diff --git a/app/src/main/res/menu/menu_conversation_notification_settings.xml b/app/src/main/res/menu/menu_conversation_notification_settings.xml new file mode 100644 index 0000000000..2275db01f2 --- /dev/null +++ b/app/src/main/res/menu/menu_conversation_notification_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_conversation_open_group.xml b/app/src/main/res/menu/menu_conversation_open_group.xml index 3a022a8384..6ff025aadb 100644 --- a/app/src/main/res/menu/menu_conversation_open_group.xml +++ b/app/src/main/res/menu/menu_conversation_open_group.xml @@ -6,8 +6,4 @@ android:title="@string/ConversationActivity_invite_to_open_group" android:id="@+id/menu_invite_to_open_group" /> - - \ No newline at end of file