Theming support for about screen

This commit is contained in:
ByteHamster 2018-07-26 10:26:00 +02:00
parent aa2ec1687f
commit 7e05ff2a4e
4 changed files with 39 additions and 8 deletions

View File

@ -73,9 +73,12 @@ public class AboutActivity extends AppCompatActivity {
InputStream input = null;
try {
TypedArray res = AboutActivity.this.getTheme().obtainStyledAttributes(
new int[] { android.R.attr.textColorPrimary });
int colorResource = res.getColor(0, 0);
String colorString = String.format("#%06X", 0xFFFFFF & colorResource);
new int[] { R.attr.about_screen_font_color, R.attr.about_screen_background,
R.attr.about_screen_card_background, R.attr.about_screen_card_border});
String fontColor = String.format("#%06X", 0xFFFFFF & res.getColor(0, 0));
String backgroundColor = String.format("#%06X", 0xFFFFFF & res.getColor(1, 0));
String cardBackground = String.format("#%06X", 0xFFFFFF & res.getColor(2, 0));
String cardBorder = String.format("#%06X", 0xFFFFFF & res.getColor(3, 0));
res.recycle();
input = getAssets().open(filename);
String webViewData = IOUtils.toString(input, Charset.defaultCharset());
@ -100,7 +103,10 @@ public class AboutActivity extends AppCompatActivity {
"</head><body><p>" + webViewData + "</p></body></html>";
webViewData = webViewData.replace("\n", "<br/>");
}
webViewData = webViewData.replace("@fontcolor@", colorString);
webViewData = webViewData.replace("@fontcolor@", fontColor);
webViewData = webViewData.replace("@background@", backgroundColor);
webViewData = webViewData.replace("@card_background@", cardBackground);
webViewData = webViewData.replace("@card_border@", cardBorder);
subscriber.onSuccess(webViewData);
} catch (IOException e) {
Log.e(TAG, Log.getStackTraceString(e));

View File

@ -10,13 +10,13 @@
}
html, body {
background: #e5e5e5;
background: @background@;
margin: 0;
padding: 0;
}
* {
color: #000;
color: @fontcolor@;
font-family: roboto-Light;
font-size: 12pt;
}
@ -38,10 +38,10 @@
}
.card {
background: #fff;
background: @card_background@;
margin: 10px;
padding: 10px;
border: 1px solid #d2d2d2;
border: 1px solid @card_border@;
border-top-width: 0;
border-bottom-width: 2px;
}

View File

@ -63,4 +63,9 @@
<attr name="overlay_background" format="color"/>
<attr name="nav_drawer_background" format="color"/>
<attr name="about_screen_background" format="color"/>
<attr name="about_screen_card_background" format="color"/>
<attr name="about_screen_card_border" format="color"/>
<attr name="about_screen_font_color" format="color"/>
</resources>

View File

@ -69,6 +69,11 @@
<item type="attr" name="master_switch_background">@color/master_switch_background_light</item>
<item type="attr" name="currently_playing_background">@color/highlight_light</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
<item type="attr" name="about_screen_background">#e5e5e5</item>
<item type="attr" name="about_screen_card_background">#ffffff</item>
<item type="attr" name="about_screen_card_border">#d2d2d2</item>
<item type="attr" name="about_screen_font_color">#000000</item>
</style>
<style name="Theme.AntennaPod.Dark" parent="Theme.Base.AntennaPod.Dark">
@ -139,6 +144,11 @@
<item type="attr" name="master_switch_background">@color/master_switch_background_dark</item>
<item type="attr" name="currently_playing_background">@color/highlight_dark</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
<item type="attr" name="about_screen_background">#303030</item>
<item type="attr" name="about_screen_card_background">#424242</item>
<item type="attr" name="about_screen_card_border">#262626</item>
<item type="attr" name="about_screen_font_color">#ffffff</item>
</style>
<style name="Theme.AntennaPod.TrueBlack" parent="Theme.Base.AntennaPod.TrueBlack">
@ -231,6 +241,11 @@
<item type="attr" name="master_switch_background">@color/master_switch_background_light</item>
<item type="attr" name="currently_playing_background">@color/highlight_light</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
<item type="attr" name="about_screen_background">#e5e5e5</item>
<item type="attr" name="about_screen_card_background">#ffffff</item>
<item type="attr" name="about_screen_card_border">#d2d2d2</item>
<item type="attr" name="about_screen_font_color">#000000</item>
</style>
<style name="Theme.AntennaPod.Dark.NoTitle" parent="Theme.Base.AntennaPod.Dark.NoTitle">
@ -302,6 +317,11 @@
<item type="attr" name="master_switch_background">@color/master_switch_background_dark</item>
<item type="attr" name="currently_playing_background">@color/highlight_dark</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
<item type="attr" name="about_screen_background">#303030</item>
<item type="attr" name="about_screen_card_background">#424242</item>
<item type="attr" name="about_screen_card_border">#262626</item>
<item type="attr" name="about_screen_font_color">#ffffff</item>
</style>
<style name="Theme.AntennaPod.TrueBlack.NoTitle" parent="Theme.Base.AntennaPod.TrueBlack.NoTitle">