From fa262bbceb96d4813ab6daa5db5fa2f93782a6e8 Mon Sep 17 00:00:00 2001 From: Mauricio Colli Date: Sat, 27 Jan 2018 02:41:11 -0200 Subject: [PATCH] Improve settings theme color - Closes #863 --- .../schabi/newpipe/settings/SettingsActivity.java | 3 ++- .../java/org/schabi/newpipe/util/ThemeHelper.java | 15 +++++++++++++++ app/src/main/res/values/colors.xml | 3 +++ app/src/main/res/values/styles.xml | 14 ++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/settings/SettingsActivity.java b/app/src/main/java/org/schabi/newpipe/settings/SettingsActivity.java index 7f91a7ca1..7d6f8d633 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SettingsActivity.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SettingsActivity.java @@ -43,7 +43,8 @@ public class SettingsActivity extends AppCompatActivity implements BasePreferenc @Override protected void onCreate(Bundle savedInstanceBundle) { - ThemeHelper.setTheme(this); + setTheme(ThemeHelper.getSettingsThemeStyle(this)); + super.onCreate(savedInstanceBundle); setContentView(R.layout.settings_layout); diff --git a/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java b/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java index b078ac0c8..b2a20c491 100644 --- a/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/ThemeHelper.java @@ -49,6 +49,21 @@ public class ThemeHelper { return PreferenceManager.getDefaultSharedPreferences(context).getString(themeKey, defaultTheme); } + @StyleRes + public static int getSettingsThemeStyle(Context context) { + String lightTheme = context.getResources().getString(R.string.light_theme_key); + String darkTheme = context.getResources().getString(R.string.dark_theme_key); + String blackTheme = context.getResources().getString(R.string.black_theme_key); + + String selectedTheme = getSelectedTheme(context); + + if (selectedTheme.equals(lightTheme)) return R.style.LightSettingsTheme; + else if (selectedTheme.equals(blackTheme)) return R.style.BlackSettingsTheme; + else if (selectedTheme.equals(darkTheme)) return R.style.DarkSettingsTheme; + // Fallback + else return R.style.DarkSettingsTheme; + } + /** * Get a resource id from a resource styled according to the the context's theme. */ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 694e4900f..1b9d102bf 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -6,6 +6,7 @@ #e53935 #d32f2f #000000 + #e53935 #32000000 #48868686 #2a868686 @@ -20,6 +21,7 @@ #CD322E #BC211D #FFFFFF + #ff5252 #0affffff #48ffffff #2affffff @@ -31,6 +33,7 @@ #000 + @color/dark_settings_accent_color #1effffff #23454545 diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index b9c1d9f9c..a71e01743 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -90,6 +90,20 @@ @color/black_contrast_background_color + + + + + + + +