mirror of
https://github.com/mastodon/mastodon-android.git
synced 2025-01-30 18:34:47 +01:00
Fix colors for quotes and code blocks
This commit is contained in:
parent
c139f85b99
commit
b211789847
@ -13,7 +13,7 @@ android {
|
||||
applicationId "org.joinmastodon.android"
|
||||
minSdk 23
|
||||
targetSdk 34
|
||||
versionCode 122
|
||||
versionCode 123
|
||||
versionName "2.7.3"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public abstract class BaseMonospaceSpan extends TypefaceSpan{
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint paint){
|
||||
super.updateDrawState(paint);
|
||||
paint.setColor(UiUtils.getThemeColor(context, R.attr.colorM3Tertiary));
|
||||
paint.setColor(UiUtils.getThemeColor(context, R.attr.colorRichTextText));
|
||||
paint.setTextSize(paint.getTextSize()*0.9375f);
|
||||
paint.baselineShift=V.dp(-1);
|
||||
}
|
||||
|
@ -3,7 +3,9 @@ package org.joinmastodon.android.ui.text;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.text.Layout;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextPaint;
|
||||
@ -24,10 +26,8 @@ public class BlockQuoteSpan extends CharacterStyle implements LeadingMarginSpan{
|
||||
|
||||
public BlockQuoteSpan(Context context, boolean firstLevel){
|
||||
this.context=context;
|
||||
icon=context.getResources().getDrawable(R.drawable.quote, context.getTheme());
|
||||
icon=context.getResources().getDrawable(R.drawable.quote, context.getTheme()).mutate();
|
||||
this.firstLevel=firstLevel;
|
||||
paint.setColor(UiUtils.getThemeColor(context, R.attr.colorM3TertiaryContainer));
|
||||
paint.setAlpha(51);
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
paint.setStrokeWidth(V.dp(3));
|
||||
}
|
||||
@ -41,21 +41,34 @@ public class BlockQuoteSpan extends CharacterStyle implements LeadingMarginSpan{
|
||||
@Override
|
||||
public void drawLeadingMargin(@NonNull Canvas c, @NonNull Paint p, int x, int dir, int top, int baseline, int bottom, @NonNull CharSequence text, int start, int end, boolean first, @NonNull Layout layout){
|
||||
if(text instanceof Spanned s && s.getSpanStart(this)==start){
|
||||
int color;
|
||||
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.S && UiUtils.isDarkTheme()){
|
||||
color=UiUtils.alphaBlendColors(
|
||||
context.getColor(android.R.color.system_accent3_700),
|
||||
context.getColor(android.R.color.system_accent3_800),
|
||||
0.5f
|
||||
);
|
||||
}else{
|
||||
color=UiUtils.getThemeColor(context, R.attr.colorRichTextDecorations);
|
||||
}
|
||||
int level=s.getSpans(start, end, LeadingMarginSpan.class).length-1;
|
||||
if(dir<0){ // RTL
|
||||
// c.drawText(this.text, layout.getWidth()-V.dp(32*level)-p.measureText(this.text), baseline, p);
|
||||
if(level==0){
|
||||
icon.setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
icon.setBounds(layout.getWidth()-icon.getIntrinsicWidth(), top, layout.getWidth(), top+icon.getIntrinsicHeight());
|
||||
icon.draw(c);
|
||||
}else{
|
||||
paint.setColor(color);
|
||||
float xOffset=layout.getWidth()-V.dp(32+18*(level-1)+1.5f);
|
||||
c.drawLine(xOffset, top, xOffset, layout.getLineBottom(layout.getLineForOffset(s.getSpanEnd(this))), paint);
|
||||
}
|
||||
}else{
|
||||
if(level==0){
|
||||
icon.setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
icon.setBounds(x, top, x+icon.getIntrinsicWidth(), top+icon.getIntrinsicHeight());
|
||||
icon.draw(c);
|
||||
}else{
|
||||
paint.setColor(color);
|
||||
float xOffset=x+V.dp(32+18*(level-1)+1.5f);
|
||||
c.drawLine(xOffset, top, xOffset, layout.getLineBottom(layout.getLineForOffset(s.getSpanEnd(this))), paint);
|
||||
}
|
||||
@ -65,6 +78,6 @@ public class BlockQuoteSpan extends CharacterStyle implements LeadingMarginSpan{
|
||||
|
||||
@Override
|
||||
public void updateDrawState(TextPaint tp){
|
||||
tp.setColor(UiUtils.getThemeColor(context, R.attr.colorM3Tertiary));
|
||||
tp.setColor(UiUtils.getThemeColor(context, R.attr.colorRichTextText));
|
||||
}
|
||||
}
|
||||
|
@ -68,8 +68,7 @@ public class LinkedTextView extends TextView{
|
||||
currentActionMode=null;
|
||||
}
|
||||
});
|
||||
bgPaint.setColor(UiUtils.getThemeColor(context, R.attr.colorM3TertiaryContainer));
|
||||
bgPaint.setAlpha(20);
|
||||
bgPaint.setColor(UiUtils.getThemeColor(context, R.attr.colorRichTextContainer));
|
||||
bgPaint.setPathEffect(new CornerPathEffect(V.dp(2)));
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="20">
|
||||
<path
|
||||
android:fillColor="?colorM3TertiaryContainer"
|
||||
android:fillAlpha="0.2"
|
||||
android:fillColor="#000"
|
||||
android:pathData="M23.933,2.824C22.324,4.079 21.073,5.357 20.179,6.657C19.33,7.912 18.905,9.1 18.905,10.221C19.084,10.131 19.307,10.086 19.575,10.086C19.888,10.041 20.156,10.019 20.38,10.019C21.408,10.019 22.257,10.445 22.927,11.297C23.642,12.103 24,13.112 24,14.322C24,15.802 23.508,17.035 22.525,18.021C21.542,19.007 20.313,19.5 18.838,19.5C17.274,19.5 16.045,18.94 15.151,17.819C14.257,16.653 13.81,15.107 13.81,13.179C13.81,10.893 14.503,8.629 15.888,6.388C17.274,4.147 19.307,2.017 21.989,0L23.933,2.824ZM10.123,2.824C8.514,4.079 7.263,5.357 6.369,6.657C5.52,7.912 5.095,9.1 5.095,10.221C5.274,10.131 5.497,10.086 5.765,10.086C6.078,10.041 6.346,10.019 6.57,10.019C7.598,10.019 8.447,10.445 9.117,11.297C9.832,12.103 10.19,13.112 10.19,14.322C10.19,15.802 9.698,17.035 8.715,18.021C7.732,19.007 6.503,19.5 5.028,19.5C3.464,19.5 2.235,18.94 1.341,17.819C0.447,16.653 0,15.107 0,13.179C0,10.893 0.693,8.629 2.078,6.388C3.464,4.147 5.497,2.017 8.179,0L10.123,2.824Z"/>
|
||||
</vector>
|
||||
|
@ -45,4 +45,11 @@
|
||||
<color name="m3_sys_dark_on_surface_variant">@android:color/system_neutral2_200</color>
|
||||
<color name="m3_sys_dark_outline">@android:color/system_neutral2_400</color>
|
||||
<color name="m3_sys_dark_outline_variant">@android:color/system_neutral2_700</color>
|
||||
|
||||
<color name="ext_rich_text_text_light">@android:color/system_accent3_700</color>
|
||||
<color name="ext_rich_text_container_light">@android:color/system_accent3_100</color>
|
||||
<color name="ext_rich_text_decoration_light">@android:color/system_accent3_200</color>
|
||||
<color name="ext_rich_text_text_dark">@android:color/system_accent3_200</color>
|
||||
<color name="ext_rich_text_container_dark">@android:color/system_accent3_800</color>
|
||||
<color name="ext_rich_text_decoration_dark">#0f0</color> <!-- it's "tertiary 35" but oh well -->
|
||||
</resources>
|
||||
|
@ -33,6 +33,9 @@
|
||||
<attr name="colorWhite" format="color"/>
|
||||
<attr name="colorFavorite" format="color" />
|
||||
<attr name="colorBoost" format="color" />
|
||||
<attr name="colorRichTextText" format="color"/>
|
||||
<attr name="colorRichTextContainer" format="color"/>
|
||||
<attr name="colorRichTextDecorations" format="color"/>
|
||||
|
||||
<declare-styleable name="MaxWidthFrameLayout">
|
||||
<attr name="android:maxWidth" format="dimension"/>
|
||||
|
@ -104,5 +104,12 @@
|
||||
<color name="ext_on_bookmark_container_light_medium_contrast">#FFFFFF</color>
|
||||
<color name="ext_on_bookmark_container_dark">#FFFFFF</color>
|
||||
|
||||
<color name="ext_rich_text_text_light">#6C3646</color>
|
||||
<color name="ext_rich_text_container_light">#FFD9E1</color>
|
||||
<color name="ext_rich_text_decoration_light">#FDB2C5</color>
|
||||
<color name="ext_rich_text_text_dark">#FDB2C5</color>
|
||||
<color name="ext_rich_text_container_dark">#512030</color>
|
||||
<color name="ext_rich_text_decoration_dark">#7A4152</color>
|
||||
|
||||
<item name="overlay_ripple_alpha" format="float" type="dimen">0.12</item>
|
||||
</resources>
|
@ -58,6 +58,9 @@
|
||||
<item name="colorWhite">#FFF</item>
|
||||
<item name="colorFavorite">@color/ext_favorite_light</item>
|
||||
<item name="colorBoost">@color/ext_boost_light</item>
|
||||
<item name="colorRichTextText">@color/ext_rich_text_text_light</item>
|
||||
<item name="colorRichTextContainer">@color/ext_rich_text_container_light</item>
|
||||
<item name="colorRichTextDecorations">@color/ext_rich_text_decoration_light</item>
|
||||
|
||||
<item name="android:statusBarColor">?colorM3Background</item>
|
||||
<item name="android:navigationBarColor">@color/navigation_bar_bg_light</item>
|
||||
@ -126,6 +129,9 @@
|
||||
<item name="colorWhite">#000</item>
|
||||
<item name="colorFavorite">@color/ext_favorite_dark</item>
|
||||
<item name="colorBoost">@color/ext_boost_dark</item>
|
||||
<item name="colorRichTextText">@color/ext_rich_text_text_dark</item>
|
||||
<item name="colorRichTextContainer">@color/ext_rich_text_container_dark</item>
|
||||
<item name="colorRichTextDecorations">@color/ext_rich_text_decoration_dark</item>
|
||||
|
||||
<item name="android:statusBarColor">?colorM3Background</item>
|
||||
<item name="android:navigationBarColor">?colorM3Background</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user