mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-22 04:59:34 +01:00
Fix mention coloring
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
3c184f7d52
commit
48fdee2a65
@ -155,7 +155,8 @@ public class MagicIncomingTextMessageViewHolder
|
|||||||
.nc_incoming_text_mention_others);
|
.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")) {
|
} else if (individualHashMap.get("type").equals("file")) {
|
||||||
itemView.setOnClickListener(v -> {
|
itemView.setOnClickListener(v -> {
|
||||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(individualHashMap.get("link")));
|
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("type").equals("user") || individualHashMap.get("type").equals("guest") || individualHashMap.get("type").equals("call")) {
|
||||||
if (!individualHashMap.get("id").equals(message.getActiveUserId())) {
|
if (!individualHashMap.get("id").equals(message.getActiveUserId())) {
|
||||||
messageString =
|
messageString =
|
||||||
DisplayUtils.searchAndColor(message.getText(),
|
DisplayUtils.searchAndColor(messageString,
|
||||||
"@" + individualHashMap.get("name"), NextcloudTalkApplication
|
"@" + individualHashMap.get("name"), NextcloudTalkApplication
|
||||||
.getSharedApplication().getResources().getColor(R.color.nc_outcoming_text_default));
|
.getSharedApplication().getResources().getColor(R.color.nc_outcoming_text_default));
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,8 @@ public class MagicSystemMessageViewHolder extends MessageHolders.IncomingTextMes
|
|||||||
}
|
}
|
||||||
|
|
||||||
messageString =
|
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);
|
Spannable spannableString = new SpannableString(text);
|
||||||
|
String stringText = text.toString();
|
||||||
if (TextUtils.isEmpty(text) || TextUtils.isEmpty(searchText)) {
|
if (TextUtils.isEmpty(text) || TextUtils.isEmpty(searchText)) {
|
||||||
return spannableString;
|
return spannableString;
|
||||||
}
|
}
|
||||||
@ -227,7 +227,7 @@ public class DisplayUtils {
|
|||||||
|
|
||||||
int lastStartIndex = -1;
|
int lastStartIndex = -1;
|
||||||
while (m.find()) {
|
while (m.find()) {
|
||||||
int start = text.indexOf(m.group(), lastStartIndex);
|
int start = stringText.indexOf(m.group(), lastStartIndex);
|
||||||
int end = start + m.group().length();
|
int end = start + m.group().length();
|
||||||
lastStartIndex = end;
|
lastStartIndex = end;
|
||||||
spannableString.setSpan(new ForegroundColorSpan(color), start, end,
|
spannableString.setSpan(new ForegroundColorSpan(color), start, end,
|
||||||
|
Loading…
Reference in New Issue
Block a user