|
|
@ -780,10 +780,10 @@ public class ConversationItem extends LinearLayout
|
|
|
|
Pattern pattern = Pattern.compile("@[0-9a-fA-F]*");
|
|
|
|
Pattern pattern = Pattern.compile("@[0-9a-fA-F]*");
|
|
|
|
Matcher matcher = pattern.matcher(text);
|
|
|
|
Matcher matcher = pattern.matcher(text);
|
|
|
|
ArrayList<Range<Integer>> mentions = new ArrayList<>();
|
|
|
|
ArrayList<Range<Integer>> mentions = new ArrayList<>();
|
|
|
|
if (matcher.find() && isGroupThread) {
|
|
|
|
int startIndex = 0;
|
|
|
|
|
|
|
|
if (matcher.find(startIndex) && isGroupThread) {
|
|
|
|
while (true) {
|
|
|
|
while (true) {
|
|
|
|
CharSequence userID = text.subSequence(matcher.start() + 1, matcher.end()); // +1 to get rid of the @
|
|
|
|
CharSequence userID = text.subSequence(matcher.start() + 1, matcher.end()); // +1 to get rid of the @
|
|
|
|
Integer matchEnd;
|
|
|
|
|
|
|
|
String userDisplayName;
|
|
|
|
String userDisplayName;
|
|
|
|
if (userID.equals(TextSecurePreferences.getLocalNumber(context))) {
|
|
|
|
if (userID.equals(TextSecurePreferences.getLocalNumber(context))) {
|
|
|
|
userDisplayName = TextSecurePreferences.getProfileName(context);
|
|
|
|
userDisplayName = TextSecurePreferences.getProfileName(context);
|
|
|
@ -792,14 +792,15 @@ public class ConversationItem extends LinearLayout
|
|
|
|
userDisplayName = DatabaseFactory.getLokiUserDatabase(context).getServerDisplayName(publicChatID, userID.toString());
|
|
|
|
userDisplayName = DatabaseFactory.getLokiUserDatabase(context).getServerDisplayName(publicChatID, userID.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (userDisplayName != null) {
|
|
|
|
if (userDisplayName != null) {
|
|
|
|
text = text.subSequence(0, matcher.start()) + "@" + userDisplayName + text.subSequence(matcher.end(), Math.max(text.length(), matcher.end()));
|
|
|
|
text = text.subSequence(0, matcher.start()) + "@" + userDisplayName + text.subSequence(matcher.end(), text.length());
|
|
|
|
matchEnd = matcher.start() + 1 + userDisplayName.length();
|
|
|
|
int endIndex = matcher.start() + 1 + userDisplayName.length();
|
|
|
|
mentions.add(Range.create(matcher.start(), matchEnd));
|
|
|
|
startIndex = endIndex;
|
|
|
|
|
|
|
|
mentions.add(Range.create(matcher.start(), endIndex));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
matchEnd = matcher.end();
|
|
|
|
startIndex = matcher.end();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
matcher = pattern.matcher(text.subSequence(matchEnd, Math.max(text.length(), matchEnd)));
|
|
|
|
matcher = pattern.matcher(text);
|
|
|
|
if (!matcher.find()) { break; }
|
|
|
|
if (!matcher.find(startIndex)) { break; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SpannableString result = new SpannableString(text);
|
|
|
|
SpannableString result = new SpannableString(text);
|
|
|
|