Theme block quote color

This commit is contained in:
M66B 2021-07-05 06:53:21 +02:00
parent 79c0c8fffe
commit 6e07657557
6 changed files with 19 additions and 9 deletions

View File

@ -151,6 +151,7 @@ public class EditTextCompose extends FixedEditText {
html = h;
final int colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary);
final int colorBlockquote = Helper.resolveColor(context, R.attr.colorBlockquote, colorPrimary);
final int quoteGap = context.getResources().getDimensionPixelSize(R.dimen.quote_gap_size);
final int quoteStripe = context.getResources().getDimensionPixelSize(R.dimen.quote_stripe_width);
@ -176,9 +177,9 @@ public class EditTextCompose extends FixedEditText {
for (QuoteSpan span : spans) {
QuoteSpan q;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P)
q = new QuoteSpan(colorPrimary);
q = new QuoteSpan(colorBlockquote);
else
q = new QuoteSpan(colorPrimary, quoteStripe, quoteGap);
q = new QuoteSpan(colorBlockquote, quoteStripe, quoteGap);
ssb.setSpan(q,
ssb.getSpanStart(span),
ssb.getSpanEnd(span),

View File

@ -5702,6 +5702,7 @@ public class FragmentCompose extends FragmentBase {
final boolean show_images = args.getBoolean("show_images", false);
int colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary);
final int colorBlockquote = Helper.resolveColor(context, R.attr.colorBlockquote, colorPrimary);
int quoteGap = context.getResources().getDimensionPixelSize(R.dimen.quote_gap_size);
int quoteStripe = context.getResources().getDimensionPixelSize(R.dimen.quote_stripe_width);
@ -5727,9 +5728,9 @@ public class FragmentCompose extends FragmentBase {
for (QuoteSpan quoteSpan : bodySpans) {
QuoteSpan q;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P)
q = new QuoteSpan(colorPrimary);
q = new QuoteSpan(colorBlockquote);
else
q = new QuoteSpan(colorPrimary, quoteStripe, quoteGap);
q = new QuoteSpan(colorBlockquote, quoteStripe, quoteGap);
bodyBuilder.setSpan(q,
bodyBuilder.getSpanStart(quoteSpan),
bodyBuilder.getSpanEnd(quoteSpan),

View File

@ -1035,9 +1035,13 @@ public class Helper {
}
static int resolveColor(Context context, int attr) {
return resolveColor(context, attr, 0xFF0000);
}
static int resolveColor(Context context, int attr, int def) {
int[] attrs = new int[]{attr};
TypedArray a = context.getTheme().obtainStyledAttributes(attrs);
int color = a.getColor(0, 0xFF0000);
int color = a.getColor(0, def);
a.recycle();
return color;
}

View File

@ -2173,6 +2173,7 @@ public class HtmlHelper {
final int colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary);
final int colorAccent = Helper.resolveColor(context, R.attr.colorAccent);
final int colorBlockquote = Helper.resolveColor(context, R.attr.colorBlockquote, colorPrimary);
final int colorSeparator = Helper.resolveColor(context, R.attr.colorSeparator);
int bulletGap = context.getResources().getDimensionPixelSize(R.dimen.bullet_gap_size);
int bulletRadius = context.getResources().getDimensionPixelSize(R.dimen.bullet_radius_size);
@ -2460,9 +2461,9 @@ public class HtmlHelper {
ssb.append("\n");
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P)
setSpan(ssb, new QuoteSpan(colorPrimary), start, ssb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
setSpan(ssb, new QuoteSpan(colorBlockquote), start, ssb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
else
setSpan(ssb, new QuoteSpan(colorPrimary, quoteStripe, quoteGap), start, ssb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
setSpan(ssb, new QuoteSpan(colorBlockquote, quoteStripe, quoteGap), start, ssb.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
break;
case "br":
ssb.append('\n');

View File

@ -489,6 +489,7 @@ public class StyleHelper {
Context context = etBody.getContext();
int colorPrimary = Helper.resolveColor(context, R.attr.colorPrimary);
final int colorBlockquote = Helper.resolveColor(context, R.attr.colorBlockquote, colorPrimary);
int quoteGap = context.getResources().getDimensionPixelSize(R.dimen.quote_gap_size);
int quoteStripe = context.getResources().getDimensionPixelSize(R.dimen.quote_stripe_width);
@ -521,9 +522,9 @@ public class StyleHelper {
if (!has) {
QuoteSpan q;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P)
q = new QuoteSpan(colorPrimary);
q = new QuoteSpan(colorBlockquote);
else
q = new QuoteSpan(colorPrimary, quoteStripe, quoteGap);
q = new QuoteSpan(colorBlockquote, quoteStripe, quoteGap);
edit.setSpan(q, paragraph.first, paragraph.second, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}

View File

@ -3,6 +3,7 @@
<attr name="colorRead" format="reference" />
<attr name="colorUnread" format="reference" />
<attr name="colorUnreadHighlight" format="reference" />
<attr name="colorBlockquote" format="reference" />
<attr name="colorHighlight" format="reference" />
<attr name="colorEncrypt" format="reference" />
<attr name="colorSeparator" format="reference" />
@ -437,6 +438,7 @@
<item name="colorAccent">@color/darkSolarizedAccent</item>
<item name="colorUnreadHighlight">@color/darkSolarizedAccent</item>
<item name="colorBlockquote">@color/darkSolarizedAccent</item>
<item name="colorActionBackground">@color/darkSolarizedActionBackground</item>