From 0d0089e3d6f25332960908fa77d22349b4a83d66 Mon Sep 17 00:00:00 2001 From: Harris Date: Mon, 26 Jul 2021 13:44:04 +1000 Subject: [PATCH 1/3] refactor: visible message view and user details bottom sheet updates individual recipient. Remove "none" notifications style --- .../thoughtcrime/securesms/components/ProfilePictureView.kt | 6 +++--- .../conversation/v2/messages/VisibleMessageView.kt | 2 +- .../thoughtcrime/securesms/home/UserDetailsBottomSheet.kt | 4 ++-- app/src/main/res/values/arrays.xml | 1 - app/src/main/res/values/strings.xml | 1 - 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/ProfilePictureView.kt b/app/src/main/java/org/thoughtcrime/securesms/components/ProfilePictureView.kt index 41e3f510ee..c3929a236d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/ProfilePictureView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/ProfilePictureView.kt @@ -14,11 +14,11 @@ import org.session.libsession.avatars.ProfileContactPhoto import org.session.libsession.messaging.contacts.Contact import org.session.libsession.messaging.mentions.MentionsManager import org.session.libsession.utilities.Address -import org.session.libsession.utilities.recipients.Recipient import org.session.libsession.utilities.TextSecurePreferences +import org.session.libsession.utilities.recipients.Recipient import org.thoughtcrime.securesms.database.DatabaseFactory -import org.thoughtcrime.securesms.util.AvatarPlaceholderGenerator import org.thoughtcrime.securesms.mms.GlideRequests +import org.thoughtcrime.securesms.util.AvatarPlaceholderGenerator class ProfilePictureView : RelativeLayout { lateinit var glide: GlideRequests @@ -111,7 +111,7 @@ class ProfilePictureView : RelativeLayout { val avatar = (signalProfilePicture as? ProfileContactPhoto)?.avatarObject if (signalProfilePicture != null && avatar != "0" && avatar != "") { glide.clear(imageView) - glide.load(signalProfilePicture).diskCacheStrategy(DiskCacheStrategy.AUTOMATIC).circleCrop().into(imageView) + glide.load(signalProfilePicture).diskCacheStrategy(DiskCacheStrategy.NONE).circleCrop().into(imageView) profilePicturesCache[publicKey] = recipient.profileAvatar } else { val sizeInPX = resources.getDimensionPixelSize(sizeResId) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt index b5144d4da3..ad1864d055 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageView.kt @@ -94,7 +94,7 @@ class VisibleMessageView : LinearLayout { profilePictureContainer.visibility = if (isEndOfMessageCluster) View.VISIBLE else View.INVISIBLE profilePictureView.publicKey = senderSessionID profilePictureView.glide = glide - profilePictureView.update() + profilePictureView.update(message.individualRecipient, threadID) profilePictureView.setOnClickListener { showUserDetails(message.recipient.address.toString()) } if (thread.isOpenGroupRecipient) { val openGroup = DatabaseFactory.getLokiThreadDatabase(context).getOpenGroupChat(threadID) ?: return diff --git a/app/src/main/java/org/thoughtcrime/securesms/home/UserDetailsBottomSheet.kt b/app/src/main/java/org/thoughtcrime/securesms/home/UserDetailsBottomSheet.kt index fec96b5de8..f6010bb53d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/UserDetailsBottomSheet.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/UserDetailsBottomSheet.kt @@ -5,13 +5,13 @@ import android.content.ClipData import android.content.ClipboardManager import android.content.Context import android.os.Bundle -import com.google.android.material.bottomsheet.BottomSheetDialogFragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.view.inputmethod.EditorInfo import android.view.inputmethod.InputMethodManager import android.widget.Toast +import com.google.android.material.bottomsheet.BottomSheetDialogFragment import kotlinx.android.synthetic.main.fragment_user_details_bottom_sheet.* import network.loki.messenger.R import org.session.libsession.messaging.contacts.Contact @@ -34,7 +34,7 @@ class UserDetailsBottomSheet : BottomSheetDialogFragment() { profilePictureView.publicKey = publicKey profilePictureView.glide = GlideApp.with(this) profilePictureView.isLarge = true - profilePictureView.update() + profilePictureView.update(recipient, -1) nameTextViewContainer.visibility = View.VISIBLE nameTextViewContainer.setOnClickListener { nameTextViewContainer.visibility = View.INVISIBLE diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 1ab8459684..65a72b4600 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -247,7 +247,6 @@ @string/notify_type_all @string/notify_type_mentions - @string/notify_type_none diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d082a46d89..9fa0283acc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -893,5 +893,4 @@ Send All Mentions - None From 2becf9fabe60a3171bb61efa24f5c104e63fb7af Mon Sep 17 00:00:00 2001 From: Harris Date: Mon, 26 Jul 2021 14:50:43 +1000 Subject: [PATCH 2/3] 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 From 69e10caa102fcb50563de71f38bc889988d741dd Mon Sep 17 00:00:00 2001 From: Harris Date: Mon, 26 Jul 2021 15:26:55 +1000 Subject: [PATCH 3/3] refactor: revert glide cache strategy for separate task --- .../org/thoughtcrime/securesms/components/ProfilePictureView.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/ProfilePictureView.kt b/app/src/main/java/org/thoughtcrime/securesms/components/ProfilePictureView.kt index c3929a236d..6ae90d4270 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/ProfilePictureView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/ProfilePictureView.kt @@ -111,7 +111,7 @@ class ProfilePictureView : RelativeLayout { val avatar = (signalProfilePicture as? ProfileContactPhoto)?.avatarObject if (signalProfilePicture != null && avatar != "0" && avatar != "") { glide.clear(imageView) - glide.load(signalProfilePicture).diskCacheStrategy(DiskCacheStrategy.NONE).circleCrop().into(imageView) + glide.load(signalProfilePicture).diskCacheStrategy(DiskCacheStrategy.AUTOMATIC).circleCrop().into(imageView) profilePicturesCache[publicKey] = recipient.profileAvatar } else { val sizeInPX = resources.getDimensionPixelSize(sizeResId)