Working with syntax rendering

This commit is contained in:
Dimitry Ivanov 2018-07-17 11:37:53 +03:00
parent 2ac6090a3d
commit f7d58bccc8
7 changed files with 32 additions and 5 deletions

View File

@ -74,6 +74,7 @@ public class MarkdownRenderer {
.syntaxHighlight(Prism4jSyntaxHighlight.create(prism4j, prism4jTheme)) .syntaxHighlight(Prism4jSyntaxHighlight.create(prism4j, prism4jTheme))
.theme(SpannableTheme.builderWithDefaults(context) .theme(SpannableTheme.builderWithDefaults(context)
.codeBackgroundColor(prism4jTheme.background()) .codeBackgroundColor(prism4jTheme.background())
.codeTextColor(prism4jTheme.textColor())
.build()) .build())
.build(); .build();

View File

@ -25,9 +25,9 @@ public class Themes {
// we have only 2 themes and Light one is default // we have only 2 themes and Light one is default
final int theme; final int theme;
if (dark) { if (dark) {
theme = R.style.AppThemeBaseDark; theme = R.style.AppThemeDark;
} else { } else {
theme = R.style.AppThemeBaseLight; theme = R.style.AppThemeLight;
} }
final Context appContext = context.getApplicationContext(); final Context appContext = context.getApplicationContext();

View File

@ -1,6 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="colorPrimary">#424242</color> <color name="colorPrimary">#424242</color>
<color name="colorPrimaryDark">#212121</color> <color name="colorPrimaryDark">#212121</color>
<color name="colorAccent">#4caf50</color> <color name="colorAccent">#4caf50</color>
<color name="white">#FFF</color>
<color name="black">#dd000000</color>
<color name="theme_light_window_background">#FFF</color>
<color name="theme_light_text_color">#dd000000</color>
<color name="theme_dark_window_background">#303030</color>
<color name="theme_dark_text_color">#ddffffff</color>
</resources> </resources>

View File

@ -10,7 +10,14 @@
<item name="ic_app_bar_theme">@drawable/ic_app_bar_theme_dark</item> <item name="ic_app_bar_theme">@drawable/ic_app_bar_theme_dark</item>
</style> </style>
<style name="AppThemeLight" parent="AppThemeBaseLight" /> <style name="AppThemeLight" parent="AppThemeBaseLight">
<style name="AppThemeDark" parent="AppThemeBaseDark" /> <item name="android:windowBackground">@color/theme_light_window_background</item>
<item name="android:textColor">@color/theme_light_text_color</item>
</style>
<style name="AppThemeDark" parent="AppThemeBaseDark">
<item name="android:windowBackground">@color/theme_dark_window_background</item>
<item name="android:textColor">@color/theme_dark_text_color</item>
</style>
</resources> </resources>

View File

@ -51,5 +51,5 @@ ext {
OK_HTTP = 'com.squareup.okhttp3:okhttp:3.9.0' OK_HTTP = 'com.squareup.okhttp3:okhttp:3.9.0'
PRISM_4J = 'ru.noties:prism4j:1.0.0' PRISM_4J = 'ru.noties:prism4j:1.0.0'
PRISM_4J_BUNDLER = 'ru.noties:prism4j-bundler:1.0.0' PRISM_4J_BUNDLER = 'ru.noties:prism4j-bundler:1.0.1'
} }

View File

@ -11,6 +11,9 @@ public interface Prism4jTheme {
@ColorInt @ColorInt
int background(); int background();
@ColorInt
int textColor();
void apply( void apply(
@NonNull String language, @NonNull String language,
@NonNull Prism4j.Syntax syntax, @NonNull Prism4j.Syntax syntax,

View File

@ -67,4 +67,9 @@ public class Prism4jThemeDefault extends Prism4jThemeBase {
public int background() { public int background() {
return 0xFFf5f2f0; return 0xFFf5f2f0;
} }
@Override
public int textColor() {
return 0xFF000000;
}
} }