Add boldListItemNumber theme property

It controls whether we show the number part of ordered lists in bold.
This commit is contained in:
Bastien Léonard 2020-11-26 09:21:45 +01:00
parent 82cb42813a
commit 6e129e80ce

View File

@ -139,6 +139,9 @@ public class MarkwonTheme {
// width of bullet, by default min(blockMargin, height) / 2 // width of bullet, by default min(blockMargin, height) / 2
protected final int bulletWidth; protected final int bulletWidth;
// whether ordered lists show the number part in bold
protected final boolean boldListItemNumber;
// by default - main text color // by default - main text color
protected final int codeTextColor; protected final int codeTextColor;
@ -196,6 +199,7 @@ public class MarkwonTheme {
this.listItemColor = builder.listItemColor; this.listItemColor = builder.listItemColor;
this.bulletListItemStrokeWidth = builder.bulletListItemStrokeWidth; this.bulletListItemStrokeWidth = builder.bulletListItemStrokeWidth;
this.bulletWidth = builder.bulletWidth; this.bulletWidth = builder.bulletWidth;
this.boldListItemNumber = builder.boldListItemNumber;
this.codeTextColor = builder.codeTextColor; this.codeTextColor = builder.codeTextColor;
this.codeBlockTextColor = builder.codeBlockTextColor; this.codeBlockTextColor = builder.codeBlockTextColor;
this.codeBackgroundColor = builder.codeBackgroundColor; this.codeBackgroundColor = builder.codeBackgroundColor;
@ -278,6 +282,10 @@ public class MarkwonTheme {
if (bulletListItemStrokeWidth != 0) { if (bulletListItemStrokeWidth != 0) {
paint.setStrokeWidth(bulletListItemStrokeWidth); paint.setStrokeWidth(bulletListItemStrokeWidth);
} }
if (boldListItemNumber) {
paint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
}
} }
public int getBulletWidth(int height) { public int getBulletWidth(int height) {
@ -469,6 +477,7 @@ public class MarkwonTheme {
private int listItemColor; private int listItemColor;
private int bulletListItemStrokeWidth; private int bulletListItemStrokeWidth;
private int bulletWidth; private int bulletWidth;
private boolean boldListItemNumber;
private int codeTextColor; private int codeTextColor;
private int codeBlockTextColor; // @since 1.0.5 private int codeBlockTextColor; // @since 1.0.5
private int codeBackgroundColor; private int codeBackgroundColor;
@ -497,6 +506,7 @@ public class MarkwonTheme {
this.listItemColor = theme.listItemColor; this.listItemColor = theme.listItemColor;
this.bulletListItemStrokeWidth = theme.bulletListItemStrokeWidth; this.bulletListItemStrokeWidth = theme.bulletListItemStrokeWidth;
this.bulletWidth = theme.bulletWidth; this.bulletWidth = theme.bulletWidth;
this.boldListItemNumber = theme.boldListItemNumber;
this.codeTextColor = theme.codeTextColor; this.codeTextColor = theme.codeTextColor;
this.codeBlockTextColor = theme.codeBlockTextColor; this.codeBlockTextColor = theme.codeBlockTextColor;
this.codeBackgroundColor = theme.codeBackgroundColor; this.codeBackgroundColor = theme.codeBackgroundColor;
@ -561,6 +571,12 @@ public class MarkwonTheme {
return this; return this;
} }
@NonNull
public Builder boldListItemNumber(boolean boldListItemNumber) {
this.boldListItemNumber = boldListItemNumber;
return this;
}
@NonNull @NonNull
public Builder codeTextColor(@ColorInt int codeTextColor) { public Builder codeTextColor(@ColorInt int codeTextColor) {
this.codeTextColor = codeTextColor; this.codeTextColor = codeTextColor;