use verified/error text colors for diff
This commit is contained in:
parent
8a5b36db96
commit
aa42873274
|
@ -1601,7 +1601,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
|
|||
title.setText(item.parsedName);
|
||||
value.setText(item.parsedValue);
|
||||
if(item.verifiedAt!=null){
|
||||
int textColor=UiUtils.isDarkTheme() ? 0xFF89bb9c : 0xFF5b8e63;
|
||||
int textColor=UiUtils.getThemeColor(getContext(), R.attr.colorM3Success);
|
||||
value.setTextColor(textColor);
|
||||
value.setLinkTextColor(textColor);
|
||||
Drawable check=getResources().getDrawable(R.drawable.ic_fluent_checkmark_starburst_20_regular, getActivity().getTheme()).mutate();
|
||||
|
|
|
@ -250,9 +250,9 @@ public abstract class StatusDisplayItem{
|
|||
|
||||
boolean hasSpoiler=!TextUtils.isEmpty(statusForContent.spoilerText);
|
||||
if(!TextUtils.isEmpty(statusForContent.content)){
|
||||
SpannableStringBuilder parsedText=HtmlParser.parse(statusForContent.content, statusForContent.emojis, statusForContent.mentions, statusForContent.tags, accountID);
|
||||
SpannableStringBuilder parsedText=HtmlParser.parse(statusForContent.content, statusForContent.emojis, statusForContent.mentions, statusForContent.tags, accountID, fragment.getContext());
|
||||
HtmlParser.applyFilterHighlights(fragment.getActivity(), parsedText, status.filtered);
|
||||
TextStatusDisplayItem text=new TextStatusDisplayItem(parentID, HtmlParser.parse(statusForContent.content, statusForContent.emojis, statusForContent.mentions, statusForContent.tags, accountID), fragment, statusForContent, (flags & FLAG_NO_TRANSLATE) != 0);
|
||||
TextStatusDisplayItem text=new TextStatusDisplayItem(parentID, HtmlParser.parse(statusForContent.content, statusForContent.emojis, statusForContent.mentions, statusForContent.tags, accountID, fragment.getContext()), fragment, statusForContent, (flags & FLAG_NO_TRANSLATE) != 0);
|
||||
contentItems.add(text);
|
||||
}else if(!hasSpoiler && header!=null){
|
||||
header.needBottomPadding=true;
|
||||
|
|
|
@ -3,21 +3,21 @@ package org.joinmastodon.android.ui.text;
|
|||
import android.text.TextPaint;
|
||||
import android.text.style.CharacterStyle;
|
||||
|
||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||
|
||||
public class DiffRemovedSpan extends CharacterStyle {
|
||||
|
||||
private final String text;
|
||||
private final int color;
|
||||
|
||||
public DiffRemovedSpan(String text){
|
||||
public DiffRemovedSpan(String text, int color){
|
||||
this.text=text;
|
||||
this.color=color;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint tp) {
|
||||
tp.setStrikeThruText(true);
|
||||
tp.setColor(0xFFCA5B63);
|
||||
tp.setColor(color);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
|
|
|
@ -70,6 +70,10 @@ public class HtmlParser{
|
|||
|
||||
private HtmlParser(){}
|
||||
|
||||
public static SpannableStringBuilder parse(String source, List<Emoji> emojis, List<Mention> mentions, List<Hashtag> tags, String accountID){
|
||||
return parse(source, emojis, mentions, tags, accountID, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse HTML and custom emoji into a spanned string for display.
|
||||
* Supported tags: <ul>
|
||||
|
@ -82,7 +86,7 @@ public class HtmlParser{
|
|||
* @param emojis Custom emojis that are present in source as <code>:code:</code>
|
||||
* @return a spanned string
|
||||
*/
|
||||
public static SpannableStringBuilder parse(String source, List<Emoji> emojis, List<Mention> mentions, List<Hashtag> tags, String accountID){
|
||||
public static SpannableStringBuilder parse(String source, List<Emoji> emojis, List<Mention> mentions, List<Hashtag> tags, String accountID, Context context){
|
||||
class SpanInfo{
|
||||
public Object span;
|
||||
public int start;
|
||||
|
@ -107,6 +111,9 @@ public class HtmlParser{
|
|||
Map<String, Hashtag> tagsByTag=tags.stream().distinct().collect(Collectors.toMap(t->t.name.toLowerCase(), Function.identity()));
|
||||
|
||||
final SpannableStringBuilder ssb=new SpannableStringBuilder();
|
||||
int colorInsert=UiUtils.getThemeColor(context, R.attr.colorM3Success);
|
||||
int colorDelete=UiUtils.getThemeColor(context, R.attr.colorM3Error);
|
||||
|
||||
Jsoup.parseBodyFragment(source).body().traverse(new NodeVisitor(){
|
||||
private final ArrayList<SpanInfo> openSpans=new ArrayList<>();
|
||||
|
||||
|
@ -173,8 +180,8 @@ public class HtmlParser{
|
|||
case "code", "pre" -> openSpans.add(new SpanInfo(new TypefaceSpan("monospace"), ssb.length(), el));
|
||||
case "blockquote" -> openSpans.add(new SpanInfo(new LeadingMarginSpan.Standard(V.dp(10)), ssb.length(), el));
|
||||
// fake elements for the edit history diff view
|
||||
case "edit-diff-insert" -> openSpans.add(new SpanInfo(new ForegroundColorSpan(UiUtils.isDarkTheme() ? 0xFF89bb9c : 0xFF5b8e63), ssb.length(), el));
|
||||
case "edit-diff-delete" -> openSpans.add(new SpanInfo(new DiffRemovedSpan(el.text()), ssb.length(), el));
|
||||
case "edit-diff-insert" -> openSpans.add(new SpanInfo(new ForegroundColorSpan(colorInsert), ssb.length(), el));
|
||||
case "edit-diff-delete" -> openSpans.add(new SpanInfo(new DiffRemovedSpan(el.text(), colorDelete), ssb.length(), el));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
<attr name="colorM3DarkOnSurface" format="color" />
|
||||
<attr name="colorTabBarAlpha" format="color" />
|
||||
<attr name="colorFilledCardAlpha" format="color" />
|
||||
<attr name="colorM3Success" format="color" />
|
||||
<attr name="toolbarActionButtonStyle" format="reference" />
|
||||
|
||||
<attr name="colorPrimary25" format="color" />
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
<item name="colorPoll">@color/bookmark_selected</item>
|
||||
<item name="colorTabBarAlpha">#14000000</item>
|
||||
<item name="colorFilledCardAlpha">#22000000</item>
|
||||
<item name="colorM3Success">#FF5b8e63</item>
|
||||
|
||||
<item name="colorM3DisabledBackground">#1F1F1F1F</item>
|
||||
<item name="colorM3Error">#B3261E</item>
|
||||
|
@ -143,6 +144,7 @@
|
|||
<item name="colorM3OnErrorContainer">#F9DEDC</item>
|
||||
<item name="colorWhite">#000</item>
|
||||
<item name="colorSensitiveOverlay">#80000000</item>
|
||||
<item name="colorM3Success">#FF89bb9c</item>
|
||||
</style>
|
||||
|
||||
<style name="ColorPalette.Dark.TrueBlack">
|
||||
|
|
Loading…
Reference in New Issue