From 26775999536a4d5d9604bce99e376b2858828d65 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Mon, 18 Nov 2019 17:10:28 +1100 Subject: [PATCH] =?UTF-8?q?fix=20up=20the=20crash=20of=20mention.=E2=80=A8?= =?UTF-8?q?fix=20up=20the=20'@'=20issue.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../thoughtcrime/securesms/components/AvatarImageView.java | 2 +- .../securesms/conversation/ConversationActivity.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/org/thoughtcrime/securesms/components/AvatarImageView.java b/src/org/thoughtcrime/securesms/components/AvatarImageView.java index 28598f4700..ce11690664 100644 --- a/src/org/thoughtcrime/securesms/components/AvatarImageView.java +++ b/src/org/thoughtcrime/securesms/components/AvatarImageView.java @@ -109,7 +109,7 @@ public class AvatarImageView extends AppCompatImageView { public void update(String hexEncodedPublicKey) { Address address = Address.fromSerialized(hexEncodedPublicKey); - if (!address.equals(recipient.getAddress())) { + if (recipient == null || !address.equals(recipient.getAddress())) { this.recipient = Recipient.from(getContext(), address, false); updateImage(); } diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java index 6e761f90bc..f85824d589 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java @@ -2845,10 +2845,14 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity } int lastCharacterIndex = text.length() - 1; char lastCharacter = text.charAt(lastCharacterIndex); + char secondLastChar = ' '; + if (lastCharacterIndex > 0) { + secondLastChar = text.charAt(lastCharacterIndex - 1); + } String userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(ConversationActivity.this); LokiThreadDatabase threadDatabase = DatabaseFactory.getLokiThreadDatabase(ConversationActivity.this); LokiUserDatabase userDatabase = DatabaseFactory.getLokiUserDatabase(ConversationActivity.this); - if (lastCharacter == '@') { + if (lastCharacter == '@' && Character.isWhitespace(secondLastChar)) { List mentionCandidates = LokiAPI.Companion.getMentionCandidates("", threadId, userHexEncodedPublicKey, threadDatabase, userDatabase); currentMentionStartIndex = lastCharacterIndex; mentionCandidateSelectionView.show(mentionCandidates, threadId);