From c5aaaec7e376bfd4d52fdad24bb356b0dc1cef77 Mon Sep 17 00:00:00 2001 From: vanous Date: Tue, 6 Jul 2021 08:31:22 +0200 Subject: [PATCH] Add black background to Dark Theme --- .../gadgetbridge/GBApplication.java | 4 +++ .../activities/AbstractGBActivity.java | 10 +++++-- .../activities/SettingsActivity.java | 23 ++++++++++++++ app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/values/styles.xml | 30 +++++++++++++++++++ app/src/main/res/xml/preferences.xml | 22 +++++++++----- 7 files changed, 82 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java index fb5d59db0..93d147dd8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/GBApplication.java @@ -975,6 +975,10 @@ public class GBApplication extends Application { && (umm.getNightMode() == UiModeManager.MODE_NIGHT_YES)); } + public static boolean isAmoledBlackEnabled() { + return prefs.getBoolean("pref_key_theme_amoled_black", false); + } + public static int getTextColor(Context context) { TypedValue typedValue = new TypedValue(); Resources.Theme theme = context.getTheme(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractGBActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractGBActivity.java index 5ae22a227..8d0ea2d51 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractGBActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AbstractGBActivity.java @@ -71,9 +71,15 @@ public abstract class AbstractGBActivity extends AppCompatActivity implements GB public static void init(GBActivity activity, int flags) { if (GBApplication.isDarkThemeEnabled()) { if ((flags & NO_ACTIONBAR) != 0) { - activity.setTheme(R.style.GadgetbridgeThemeDark_NoActionBar); + if (GBApplication.isAmoledBlackEnabled()) + activity.setTheme(R.style.GadgetbridgeThemeBlack_NoActionBar); + else + activity.setTheme(R.style.GadgetbridgeThemeDark_NoActionBar); } else { - activity.setTheme(R.style.GadgetbridgeThemeDark); + if (GBApplication.isAmoledBlackEnabled()) + activity.setTheme(R.style.GadgetbridgeThemeBlack); + else + activity.setTheme(R.style.GadgetbridgeThemeDark); } } else { if ((flags & NO_ACTIONBAR) != 0) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java index 6094e5974..73c47e10f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/SettingsActivity.java @@ -203,6 +203,8 @@ public class SettingsActivity extends AbstractSettingsActivity { }); + + pref = findPreference("language"); pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override @@ -393,6 +395,27 @@ public class SettingsActivity extends AbstractSettingsActivity { audioPlayer.setEntries(newEntries); audioPlayer.setEntryValues(newValues); audioPlayer.setDefaultValue(newValues[0]); + + final Preference theme = (ListPreference) findPreference("pref_key_theme"); + final Preference amoled_black = findPreference("pref_key_theme_amoled_black"); + + String selectedTheme = prefs.getString("pref_key_theme", SettingsActivity.this.getString(R.string.pref_theme_value_system)); + if (selectedTheme.equals("light")) + amoled_black.setEnabled(false); + else + amoled_black.setEnabled(true); + + theme.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newVal) { + final String val = newVal.toString(); + if (val.equals("light")) + amoled_black.setEnabled(false); + else + amoled_black.setEnabled(true); + return true; + } + }); } @Override diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 674cbae79..1fb55ceec 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -14,6 +14,7 @@ #ff808080 #ffd0d0d0 #ff606060 + #000000 #1f000000 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d5e7f0a0a..29c58cb0d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -111,6 +111,7 @@ Light Dark System + Use black background in Dark Theme Language Hide the Gadgetbridge notification The icon in the status bar and the notification in the lockscreen are shown diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 8260c24ce..14c9c4db0 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -47,6 +47,30 @@ + + + + @@ -56,6 +80,12 @@ true + + +