Fix mention colors
This commit is contained in:
parent
5663ff9fd7
commit
121baec44c
|
@ -922,38 +922,71 @@ public class Status implements Parcelable{
|
||||||
//Looping through accounts which are mentioned
|
//Looping through accounts which are mentioned
|
||||||
for (final Mention mention : mentions) {
|
for (final Mention mention : mentions) {
|
||||||
String targetedAccount = "@" + mention.getUsername();
|
String targetedAccount = "@" + mention.getUsername();
|
||||||
if (spannableStringT.toString().toLowerCase().contains(targetedAccount.toLowerCase())) {
|
if(spannableStringT.toString().toLowerCase().contains(("@" + mention.getAcct()).toLowerCase())) {
|
||||||
|
targetedAccount = "@" + mention.getAcct();
|
||||||
|
if (spannableStringT.toString().toLowerCase().contains(targetedAccount.toLowerCase())) {
|
||||||
|
//Accounts can be mentioned several times so we have to loop
|
||||||
|
for (int startPosition = -1; (startPosition = spannableStringT.toString().toLowerCase().indexOf(targetedAccount.toLowerCase(), startPosition + 1)) != -1; startPosition++) {
|
||||||
|
|
||||||
|
int endPosition = startPosition + targetedAccount.length();
|
||||||
|
if (endPosition <= spannableStringT.toString().length() && endPosition >= startPosition)
|
||||||
|
spannableStringT.setSpan(new ClickableSpan() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View textView) {
|
||||||
|
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||||
|
Bundle b = new Bundle();
|
||||||
|
b.putString("accountId", mention.getId());
|
||||||
|
intent.putExtras(b);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDrawState(TextPaint ds) {
|
||||||
|
super.updateDrawState(ds);
|
||||||
|
ds.setUnderlineText(false);
|
||||||
|
if (theme == THEME_DARK)
|
||||||
|
ds.setColor(ContextCompat.getColor(context, R.color.dark_link_toot));
|
||||||
|
else if (theme == THEME_BLACK)
|
||||||
|
ds.setColor(ContextCompat.getColor(context, R.color.black_link_toot));
|
||||||
|
else if (theme == THEME_LIGHT)
|
||||||
|
ds.setColor(ContextCompat.getColor(context, R.color.mastodonC4));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
startPosition, endPosition,
|
||||||
|
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else if (spannableStringT.toString().toLowerCase().contains(targetedAccount.toLowerCase())) {
|
||||||
//Accounts can be mentioned several times so we have to loop
|
//Accounts can be mentioned several times so we have to loop
|
||||||
for(int startPosition = -1 ; (startPosition = spannableStringT.toString().toLowerCase().indexOf(targetedAccount.toLowerCase(), startPosition + 1)) != -1 ; startPosition++){
|
for(int startPosition = -1 ; (startPosition = spannableStringT.toString().toLowerCase().indexOf(targetedAccount.toLowerCase(), startPosition + 1)) != -1 ; startPosition++){
|
||||||
|
|
||||||
int endPosition = startPosition + targetedAccount.length();
|
int endPosition = startPosition + targetedAccount.length();
|
||||||
if( endPosition <= spannableStringT.toString().length() && endPosition >= startPosition)
|
if( endPosition <= spannableStringT.toString().length() && endPosition >= startPosition)
|
||||||
spannableStringT.setSpan(new ClickableSpan() {
|
spannableStringT.setSpan(new ClickableSpan() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View textView) {
|
public void onClick(View textView) {
|
||||||
Intent intent = new Intent(context, ShowAccountActivity.class);
|
Intent intent = new Intent(context, ShowAccountActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putString("accountId", mention.getId());
|
b.putString("accountId", mention.getId());
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void updateDrawState(TextPaint ds) {
|
public void updateDrawState(TextPaint ds) {
|
||||||
super.updateDrawState(ds);
|
super.updateDrawState(ds);
|
||||||
ds.setUnderlineText(false);
|
ds.setUnderlineText(false);
|
||||||
if (theme == THEME_DARK)
|
if (theme == THEME_DARK)
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.dark_link_toot));
|
ds.setColor(ContextCompat.getColor(context, R.color.dark_link_toot));
|
||||||
else if (theme == THEME_BLACK)
|
else if (theme == THEME_BLACK)
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.black_link_toot));
|
ds.setColor(ContextCompat.getColor(context, R.color.black_link_toot));
|
||||||
else if (theme == THEME_LIGHT)
|
else if (theme == THEME_LIGHT)
|
||||||
ds.setColor(ContextCompat.getColor(context, R.color.mastodonC4));
|
ds.setColor(ContextCompat.getColor(context, R.color.mastodonC4));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
startPosition, endPosition,
|
startPosition, endPosition,
|
||||||
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
matcher = Helper.hashtagPattern.matcher(spannableStringT);
|
matcher = Helper.hashtagPattern.matcher(spannableStringT);
|
||||||
|
|
Loading…
Reference in New Issue