From aa43ab2a2e73f25af4392d757bb7fa4df0c33124 Mon Sep 17 00:00:00 2001 From: Harris Date: Tue, 13 Sep 2022 15:06:20 +1000 Subject: [PATCH] Display Note to self in conversation instead of your own Session ID (#929) * fix: display title bar in conversation as "Note to self" if it's the local user's session ID * docs: remove ID blinding comment as it's your own user and probably won't ever me a conversation with your blinded ID * fix: compile issue for missing recipient local var * refactor: use same logic for recipient modified listener --- .../conversation/v2/ConversationActivityV2.kt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index dcf7f11cf6..861b755c71 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -436,10 +436,14 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe private fun setUpToolBar() { setSupportActionBar(binding?.toolbar) val actionBar = supportActionBar ?: return + val recipient = viewModel.recipient ?: return actionBar.title = "" actionBar.setDisplayHomeAsUpEnabled(true) actionBar.setHomeButtonEnabled(true) - binding!!.toolbarContent.conversationTitleView.text = viewModel.recipient?.toShortString() + binding!!.toolbarContent.conversationTitleView.text = when { + recipient.isLocalNumber -> getString(R.string.note_to_self) + else -> recipient.toShortString() + } @DimenRes val sizeID: Int = if (viewModel.recipient?.isClosedGroupRecipient == true) { R.dimen.medium_profile_picture_size } else { @@ -629,18 +633,19 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe // region Animation & Updating override fun onModified(recipient: Recipient) { runOnUiThread { - val recipient = viewModel.recipient - if (recipient != null && recipient.isContactRecipient) { - binding?.blockedBanner?.isVisible = recipient.isBlocked + val threadRecipient = viewModel.recipient ?: return@runOnUiThread + if (threadRecipient.isContactRecipient) { + binding?.blockedBanner?.isVisible = threadRecipient.isBlocked } setUpMessageRequestsBar() invalidateOptionsMenu() updateSubtitle() showOrHideInputIfNeeded() - if (recipient != null) { - binding?.toolbarContent?.profilePictureView?.root?.update(recipient) + binding?.toolbarContent?.profilePictureView?.root?.update(threadRecipient) + binding!!.toolbarContent.conversationTitleView.text = when { + threadRecipient.isLocalNumber -> getString(R.string.note_to_self) + else -> threadRecipient.toShortString() } - binding?.toolbarContent?.conversationTitleView?.text = recipient?.toShortString() } }