Making sure we don't pass in a null recipient name

This commit is contained in:
ThomasSession 2024-09-30 13:32:08 +10:00
parent b74d35e216
commit c956b2050c
6 changed files with 15 additions and 12 deletions

View File

@ -13,8 +13,8 @@ configurations.forEach {
it.exclude module: "commons-logging" it.exclude module: "commons-logging"
} }
def canonicalVersionCode = 382 def canonicalVersionCode = 383
def canonicalVersionName = "1.20.0" def canonicalVersionName = "1.20.1"
def postFixSize = 10 def postFixSize = 10
def abiPostFix = ['armeabi-v7a' : 1, def abiPostFix = ['armeabi-v7a' : 1,

View File

@ -813,7 +813,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
if (shouldShowLegacy) { if (shouldShowLegacy) {
val txt = Phrase.from(applicationContext, R.string.disappearingMessagesLegacy) val txt = Phrase.from(applicationContext, R.string.disappearingMessagesLegacy)
.put(NAME_KEY, legacyRecipient!!.name) .put(NAME_KEY, legacyRecipient!!.toShortString())
.format() .format()
binding?.outdatedBannerTextView?.text = txt binding?.outdatedBannerTextView?.text = txt
} }
@ -1191,14 +1191,14 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
title(R.string.block) title(R.string.block)
text( text(
Phrase.from(context, R.string.blockDescription) Phrase.from(context, R.string.blockDescription)
.put(NAME_KEY, recipient.name) .put(NAME_KEY, recipient.toShortString())
.format() .format()
) )
dangerButton(R.string.block, R.string.AccessibilityId_blockConfirm) { dangerButton(R.string.block, R.string.AccessibilityId_blockConfirm) {
viewModel.block() viewModel.block()
// Block confirmation toast added as per SS-64 // Block confirmation toast added as per SS-64
val txt = Phrase.from(context, R.string.blockBlockedUser).put(NAME_KEY, recipient.name).format().toString() val txt = Phrase.from(context, R.string.blockBlockedUser).put(NAME_KEY, recipient.toShortString()).format().toString()
Toast.makeText(context, txt, Toast.LENGTH_LONG).show() Toast.makeText(context, txt, Toast.LENGTH_LONG).show()
if (deleteThread) { if (deleteThread) {
@ -1249,7 +1249,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
title(R.string.blockUnblock) title(R.string.blockUnblock)
text( text(
Phrase.from(context, R.string.blockUnblockName) Phrase.from(context, R.string.blockUnblockName)
.put(NAME_KEY, recipient.name) .put(NAME_KEY, recipient.toShortString())
.format() .format()
) )
dangerButton(R.string.blockUnblock, R.string.AccessibilityId_unblockConfirm) { viewModel.unblock() } dangerButton(R.string.blockUnblock, R.string.AccessibilityId_unblockConfirm) { viewModel.unblock() }

View File

@ -35,7 +35,7 @@ class DownloadDialog(private val recipient: Recipient) : DialogFragment() {
title(getString(R.string.attachmentsAutoDownloadModalTitle)) title(getString(R.string.attachmentsAutoDownloadModalTitle))
val explanation = Phrase.from(context, R.string.attachmentsAutoDownloadModalDescription) val explanation = Phrase.from(context, R.string.attachmentsAutoDownloadModalDescription)
.put(CONVERSATION_NAME_KEY, recipient.name) .put(CONVERSATION_NAME_KEY, recipient.displayName)
.format() .format()
val spannable = SpannableStringBuilder(explanation) val spannable = SpannableStringBuilder(explanation)

View File

@ -71,6 +71,7 @@ import org.thoughtcrime.securesms.home.search.GlobalSearchViewModel
import org.thoughtcrime.securesms.messagerequests.MessageRequestsActivity import org.thoughtcrime.securesms.messagerequests.MessageRequestsActivity
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.RequestManager import com.bumptech.glide.RequestManager
import org.session.libsession.utilities.truncateIdForDisplay
import org.thoughtcrime.securesms.notifications.PushRegistry import org.thoughtcrime.securesms.notifications.PushRegistry
import org.thoughtcrime.securesms.permissions.Permissions import org.thoughtcrime.securesms.permissions.Permissions
import org.thoughtcrime.securesms.preferences.SettingsActivity import org.thoughtcrime.securesms.preferences.SettingsActivity
@ -507,7 +508,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
showSessionDialog { showSessionDialog {
title(R.string.block) title(R.string.block)
text(Phrase.from(context, R.string.blockDescription) text(Phrase.from(context, R.string.blockDescription)
.put(NAME_KEY, thread.recipient.name) .put(NAME_KEY, thread.recipient.toShortString())
.format()) .format())
dangerButton(R.string.block, R.string.AccessibilityId_blockConfirm) { dangerButton(R.string.block, R.string.AccessibilityId_blockConfirm) {
lifecycleScope.launch(Dispatchers.IO) { lifecycleScope.launch(Dispatchers.IO) {
@ -518,7 +519,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
} }
} }
// Block confirmation toast added as per SS-64 // Block confirmation toast added as per SS-64
val txt = Phrase.from(context, R.string.blockBlockedUser).put(NAME_KEY, thread.recipient.name).format().toString() val txt = Phrase.from(context, R.string.blockBlockedUser).put(NAME_KEY, thread.recipient.toShortString()).format().toString()
Toast.makeText(context, txt, Toast.LENGTH_LONG).show() Toast.makeText(context, txt, Toast.LENGTH_LONG).show()
} }
cancelButton() cancelButton()
@ -528,7 +529,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
private fun unblockConversation(thread: ThreadRecord) { private fun unblockConversation(thread: ThreadRecord) {
showSessionDialog { showSessionDialog {
title(R.string.blockUnblock) title(R.string.blockUnblock)
text(Phrase.from(context, R.string.blockUnblockName).put(NAME_KEY, thread.recipient.name).format()) text(Phrase.from(context, R.string.blockUnblockName).put(NAME_KEY, thread.recipient.toShortString()).format())
dangerButton(R.string.blockUnblock, R.string.AccessibilityId_unblockConfirm) { dangerButton(R.string.blockUnblock, R.string.AccessibilityId_unblockConfirm) {
lifecycleScope.launch(Dispatchers.IO) { lifecycleScope.launch(Dispatchers.IO) {
storage.setBlocked(listOf(thread.recipient), false) storage.setBlocked(listOf(thread.recipient), false)
@ -616,7 +617,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
if (recipient.name != null) { if (recipient.name != null) {
title = getString(R.string.conversationsDelete) title = getString(R.string.conversationsDelete)
message = Phrase.from(this.applicationContext, R.string.conversationsDeleteDescription) message = Phrase.from(this.applicationContext, R.string.conversationsDeleteDescription)
.put(NAME_KEY, recipient.name) .put(NAME_KEY, recipient.toShortString())
.format() .format()
} }
else { else {

View File

@ -87,7 +87,7 @@ class MessageRequestsActivity : PassphraseRequiredActionBarActivity(), Conversat
showSessionDialog { showSessionDialog {
title(R.string.block) title(R.string.block)
text(Phrase.from(context, R.string.blockDescription) text(Phrase.from(context, R.string.blockDescription)
.put(NAME_KEY, thread.recipient.name) .put(NAME_KEY, thread.recipient.toShortString())
.format()) .format())
dangerButton(R.string.block, R.string.AccessibilityId_blockConfirm) { dangerButton(R.string.block, R.string.AccessibilityId_blockConfirm) {
doBlock() doBlock()

View File

@ -17,6 +17,8 @@
*/ */
package org.session.libsession.utilities.recipients; package org.session.libsession.utilities.recipients;
import static org.session.libsession.utilities.IdUtilKt.truncateIdForDisplay;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;