From 5a2dac38c688e254689fc0690ca7c56d8a401914 Mon Sep 17 00:00:00 2001 From: 0x330a <92654767+0x330a@users.noreply.github.com> Date: Thu, 11 May 2023 17:43:55 +1000 Subject: [PATCH] refactor: disable edit text for non contacts --- .../thoughtcrime/securesms/home/UserDetailsBottomSheet.kt | 3 +++ .../securesms/messagerequests/MessageRequestsActivity.kt | 2 +- .../securesms/util/ConfigurationMessageUtilities.kt | 5 +---- .../main/res/layout/fragment_user_details_bottom_sheet.xml | 1 + .../main/java/org/session/libsession/utilities/Address.kt | 7 +++---- 5 files changed, 9 insertions(+), 9 deletions(-) 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 86193f9619..71d3a5fff3 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/home/UserDetailsBottomSheet.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/home/UserDetailsBottomSheet.kt @@ -60,6 +60,7 @@ class UserDetailsBottomSheet: BottomSheetDialogFragment() { profilePictureView.root.update(recipient) nameTextViewContainer.visibility = View.VISIBLE nameTextViewContainer.setOnClickListener { + if (recipient.isOpenGroupInboxRecipient) return@setOnClickListener nameTextViewContainer.visibility = View.INVISIBLE nameEditTextContainer.visibility = View.VISIBLE nicknameEditText.text = null @@ -86,6 +87,8 @@ class UserDetailsBottomSheet: BottomSheetDialogFragment() { } nameTextView.text = recipient.name ?: publicKey // Uses the Contact API internally + nameEditIcon.isVisible = threadRecipient.isContactRecipient + publicKeyTextView.isVisible = !threadRecipient.isOpenGroupRecipient && !threadRecipient.isOpenGroupInboxRecipient messageButton.isVisible = !threadRecipient.isOpenGroupRecipient || IdPrefix.fromValue(publicKey) == IdPrefix.BLINDED publicKeyTextView.text = publicKey diff --git a/app/src/main/java/org/thoughtcrime/securesms/messagerequests/MessageRequestsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/messagerequests/MessageRequestsActivity.kt index 50ed4628ea..aa2d98e6de 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/messagerequests/MessageRequestsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/messagerequests/MessageRequestsActivity.kt @@ -117,7 +117,7 @@ class MessageRequestsActivity : PassphraseRequiredActionBarActivity(), Conversat val dialog = AlertDialog.Builder(this) dialog.setMessage(resources.getString(R.string.message_requests_clear_all_message)) dialog.setPositiveButton(R.string.yes) { _, _ -> - viewModel.clearAllMessageRequests() + viewModel.clearAllMessageRequests(true) LoaderManager.getInstance(this).restartLoader(0, null, this) lifecycleScope.launch(Dispatchers.IO) { ConfigurationMessageUtilities.forceSyncConfigurationNowIfNeeded(this@MessageRequestsActivity) diff --git a/app/src/main/java/org/thoughtcrime/securesms/util/ConfigurationMessageUtilities.kt b/app/src/main/java/org/thoughtcrime/securesms/util/ConfigurationMessageUtilities.kt index 21cc7915ee..64ec59341d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/util/ConfigurationMessageUtilities.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/util/ConfigurationMessageUtilities.kt @@ -18,13 +18,11 @@ import org.session.libsession.messaging.jobs.JobQueue import org.session.libsession.messaging.messages.Destination import org.session.libsession.messaging.messages.control.ConfigurationMessage import org.session.libsession.messaging.sending_receiving.MessageSender -import org.session.libsession.messaging.utilities.SessionId import org.session.libsession.utilities.Address import org.session.libsession.utilities.GroupUtil import org.session.libsession.utilities.TextSecurePreferences import org.session.libsession.utilities.WindowDebouncer import org.session.libsignal.utilities.Hex -import org.session.libsignal.utilities.Log import org.session.libsignal.utilities.toHexString import org.thoughtcrime.securesms.dependencies.DatabaseComponent import java.util.Timer @@ -199,9 +197,8 @@ object ConfigurationMessageUtilities { convoConfig.getOrConstructLegacyGroup(groupPublicKey) } recipient.isContactRecipient -> { - val sessionId = SessionId(recipient.address.serialize()) if (recipient.isLocalNumber) null // this is handled by the user profile NTS data - if (recipient.isOpenGroupInboxRecipient) null // specifically exclude + else if (recipient.isOpenGroupInboxRecipient) null // specifically exclude else convoConfig.getOrConstructOneToOne(recipient.address.serialize()) } else -> null diff --git a/app/src/main/res/layout/fragment_user_details_bottom_sheet.xml b/app/src/main/res/layout/fragment_user_details_bottom_sheet.xml index 98c87331a6..eb04dbb274 100644 --- a/app/src/main/res/layout/fragment_user_details_bottom_sheet.xml +++ b/app/src/main/res/layout/fragment_user_details_bottom_sheet.xml @@ -52,6 +52,7 @@ android:text="Spiderman" />