mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-26 23:25:20 +03:00
Fix mention coloring
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
3c184f7d52
commit
48fdee2a65
4 changed files with 8 additions and 6 deletions
|
@ -155,7 +155,8 @@ public class MagicIncomingTextMessageViewHolder
|
|||
.nc_incoming_text_mention_others);
|
||||
}
|
||||
|
||||
messageString = DisplayUtils.searchAndColor(message.getText(), "@" + individualHashMap.get("name"), color);
|
||||
messageString = DisplayUtils.searchAndColor(messageString,
|
||||
"@" + individualHashMap.get("name"), color);
|
||||
} else if (individualHashMap.get("type").equals("file")) {
|
||||
itemView.setOnClickListener(v -> {
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(individualHashMap.get("link")));
|
||||
|
|
|
@ -92,7 +92,7 @@ public class MagicOutcomingTextMessageViewHolder extends MessageHolders.Outcomin
|
|||
if (individualHashMap.get("type").equals("user") || individualHashMap.get("type").equals("guest") || individualHashMap.get("type").equals("call")) {
|
||||
if (!individualHashMap.get("id").equals(message.getActiveUserId())) {
|
||||
messageString =
|
||||
DisplayUtils.searchAndColor(message.getText(),
|
||||
DisplayUtils.searchAndColor(messageString,
|
||||
"@" + individualHashMap.get("name"), NextcloudTalkApplication
|
||||
.getSharedApplication().getResources().getColor(R.color.nc_outcoming_text_default));
|
||||
}
|
||||
|
|
|
@ -68,7 +68,8 @@ public class MagicSystemMessageViewHolder extends MessageHolders.IncomingTextMes
|
|||
}
|
||||
|
||||
messageString =
|
||||
DisplayUtils.searchAndColor(message.getText(), "@" + individualHashMap.get("name"), color);
|
||||
DisplayUtils.searchAndColor(messageString,
|
||||
"@" + individualHashMap.get("name"), color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,10 +209,10 @@ public class DisplayUtils {
|
|||
}
|
||||
|
||||
|
||||
public static Spannable searchAndColor(String text, String searchText, @ColorInt int color) {
|
||||
public static Spannable searchAndColor(Spannable text, String searchText, @ColorInt int color) {
|
||||
|
||||
Spannable spannableString = new SpannableString(text);
|
||||
|
||||
String stringText = text.toString();
|
||||
if (TextUtils.isEmpty(text) || TextUtils.isEmpty(searchText)) {
|
||||
return spannableString;
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ public class DisplayUtils {
|
|||
|
||||
int lastStartIndex = -1;
|
||||
while (m.find()) {
|
||||
int start = text.indexOf(m.group(), lastStartIndex);
|
||||
int start = stringText.indexOf(m.group(), lastStartIndex);
|
||||
int end = start + m.group().length();
|
||||
lastStartIndex = end;
|
||||
spannableString.setSpan(new ForegroundColorSpan(color), start, end,
|
||||
|
|
Loading…
Reference in a new issue