1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-01 22:43:00 +01:00

Add black background to Dark Theme

This commit is contained in:
vanous 2021-07-06 08:31:22 +02:00
parent 7c6e565367
commit c5aaaec7e3
7 changed files with 82 additions and 9 deletions

View File

@ -975,6 +975,10 @@ public class GBApplication extends Application {
&& (umm.getNightMode() == UiModeManager.MODE_NIGHT_YES)); && (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) { public static int getTextColor(Context context) {
TypedValue typedValue = new TypedValue(); TypedValue typedValue = new TypedValue();
Resources.Theme theme = context.getTheme(); Resources.Theme theme = context.getTheme();

View File

@ -71,9 +71,15 @@ public abstract class AbstractGBActivity extends AppCompatActivity implements GB
public static void init(GBActivity activity, int flags) { public static void init(GBActivity activity, int flags) {
if (GBApplication.isDarkThemeEnabled()) { if (GBApplication.isDarkThemeEnabled()) {
if ((flags & NO_ACTIONBAR) != 0) { 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 { } else {
activity.setTheme(R.style.GadgetbridgeThemeDark); if (GBApplication.isAmoledBlackEnabled())
activity.setTheme(R.style.GadgetbridgeThemeBlack);
else
activity.setTheme(R.style.GadgetbridgeThemeDark);
} }
} else { } else {
if ((flags & NO_ACTIONBAR) != 0) { if ((flags & NO_ACTIONBAR) != 0) {

View File

@ -203,6 +203,8 @@ public class SettingsActivity extends AbstractSettingsActivity {
}); });
pref = findPreference("language"); pref = findPreference("language");
pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { pref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override @Override
@ -393,6 +395,27 @@ public class SettingsActivity extends AbstractSettingsActivity {
audioPlayer.setEntries(newEntries); audioPlayer.setEntries(newEntries);
audioPlayer.setEntryValues(newValues); audioPlayer.setEntryValues(newValues);
audioPlayer.setDefaultValue(newValues[0]); 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 @Override

View File

@ -14,6 +14,7 @@
<color name="secondarytext" type="color">#ff808080</color> <color name="secondarytext" type="color">#ff808080</color>
<color name="tertiarytext_light" type="color">#ffd0d0d0</color> <color name="tertiarytext_light" type="color">#ffd0d0d0</color>
<color name="tertiarytext_dark" type="color">#ff606060</color> <color name="tertiarytext_dark" type="color">#ff606060</color>
<color name="tertiarytext_black" type="color">#000000</color>
<color name="divider" type="color">#1f000000</color> <color name="divider" type="color">#1f000000</color>

View File

@ -111,6 +111,7 @@
<string name="pref_theme_light">Light</string> <string name="pref_theme_light">Light</string>
<string name="pref_theme_dark">Dark</string> <string name="pref_theme_dark">Dark</string>
<string name="pref_theme_system">System</string> <string name="pref_theme_system">System</string>
<string name="pref_theme_black_background">Use black background in Dark Theme</string>
<string name="pref_title_language">Language</string> <string name="pref_title_language">Language</string>
<string name="pref_title_minimize_priority">Hide the Gadgetbridge notification</string> <string name="pref_title_minimize_priority">Hide the Gadgetbridge notification</string>
<string name="pref_summary_minimize_priority_off">The icon in the status bar and the notification in the lockscreen are shown</string> <string name="pref_summary_minimize_priority_off">The icon in the status bar and the notification in the lockscreen are shown</string>

View File

@ -47,6 +47,30 @@
</style> </style>
<!-- black theme -->
<style name="GadgetbridgeThemeBlack" parent="Theme.AppCompat">
<item name="textColorPrimary">@color/primarytext_dark</item>
<item name="textColorSecondary">@color/secondarytext</item>
<item name="textColorTertiary">@color/tertiarytext_dark</item>
<item name="android:windowBackground">@android:color/black</item>
<item name="colorPrimary">@color/primary_dark</item>
<item name="colorPrimaryDark">@color/primarydark_dark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:buttonStyle">@style/ButtonDark</item>
<item name="buttonStyle">@style/ButtonDark</item>
<item name="chart_deep_sleep">@color/chart_deep_sleep_dark</item>
<item name="chart_light_sleep">@color/chart_light_sleep_dark</item>
<item name="chart_activity">@color/chart_activity_dark</item>
<item name="chart_not_worn">@color/chart_not_worn_dark</item>
<item name="alternate_row_background">@color/alternate_row_background_dark</item>
<item name="sports_activity_summary_background">@color/alternate_row_background_dark</item>
</style>
<style name="ButtonDark" parent="Widget.AppCompat.Button.Colored"> <style name="ButtonDark" parent="Widget.AppCompat.Button.Colored">
<item name="android:textColor">@color/btn_dark</item> <item name="android:textColor">@color/btn_dark</item>
</style> </style>
@ -56,6 +80,12 @@
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
</style> </style>
<style name="GadgetbridgeThemeBlack.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="GadgetbridgeTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <style name="GadgetbridgeTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="GadgetbridgeTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> <style name="GadgetbridgeTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

View File

@ -31,13 +31,21 @@
android:key="audio_player" android:key="audio_player"
android:title="@string/pref_title_audio_player" android:title="@string/pref_title_audio_player"
android:summary="%s" /> android:summary="%s" />
<ListPreference
android:key="pref_key_theme" <PreferenceScreen android:title="@string/pref_title_theme">
android:title="@string/pref_title_theme" <ListPreference
android:entries="@array/pref_theme_options" android:defaultValue="@string/pref_theme_value_light"
android:entryValues="@array/pref_theme_values" android:entries="@array/pref_theme_options"
android:defaultValue="@string/pref_theme_value_light" android:entryValues="@array/pref_theme_values"
android:summary="%s" /> android:key="pref_key_theme"
android:summary="%s"
android:title="@string/pref_title_theme" />
<CheckBoxPreference
android:defaultValue="false"
android:key="pref_key_theme_amoled_black"
android:layout="@layout/preference_checkbox"
android:title="@string/pref_theme_black_background" />
</PreferenceScreen>
<PreferenceScreen <PreferenceScreen
android:key="language_category" android:key="language_category"