mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-24 00:27:33 +01:00
Add a new "system" theme option and rig isDarkThemeEnabled to return if system currently sports a dark theme.
This commit is contained in:
parent
80fb05e44a
commit
1221827560
@ -22,6 +22,7 @@ import android.app.Application;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.NotificationManager.Policy;
|
||||
import android.app.UiModeManager;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -81,13 +82,9 @@ import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.AMAZFITBIP;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.AMAZFITCOR;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.AMAZFITCOR2;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.HPLUS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.ID115;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.MIBAND;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.MIBAND2;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.MIBAND3;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.MIBAND4;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.ZETIME;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.fromKey;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.util.GB.NOTIFICATION_CHANNEL_ID;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.util.GB.NOTIFICATION_CHANNEL_HIGH_PRIORITY_ID;
|
||||
@ -937,7 +934,13 @@ public class GBApplication extends Application {
|
||||
}
|
||||
|
||||
public static boolean isDarkThemeEnabled() {
|
||||
return prefs.getString("pref_key_theme", context.getString(R.string.pref_theme_value_light)).equals(context.getString(R.string.pref_theme_value_dark));
|
||||
String selectedTheme = prefs.getString("pref_key_theme", context.getString(R.string.pref_theme_value_light));
|
||||
|
||||
UiModeManager umm = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
|
||||
|
||||
return selectedTheme.equals(context.getString(R.string.pref_theme_value_dark)) ||
|
||||
(selectedTheme.equals(context.getString(R.string.pref_theme_value_system))
|
||||
&& (umm.getNightMode() == UiModeManager.MODE_NIGHT_YES));
|
||||
}
|
||||
|
||||
public static int getTextColor(Context context) {
|
||||
|
@ -1,13 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="pref_theme_options">
|
||||
<item>@string/pref_theme_system</item>
|
||||
<item>@string/pref_theme_light</item>
|
||||
<item>@string/pref_theme_dark</item>
|
||||
</string-array>
|
||||
<string-array name="pref_theme_values">
|
||||
<item>@string/pref_theme_value_system</item>
|
||||
<item>@string/pref_theme_value_light</item>
|
||||
<item>@string/pref_theme_value_dark</item>
|
||||
</string-array>
|
||||
<string name="pref_theme_value_system" translatable="false">system</string>
|
||||
<string name="pref_theme_value_light" translatable="false">light</string>
|
||||
<string name="pref_theme_value_dark" translatable="false">dark</string>
|
||||
|
||||
@ -762,6 +765,7 @@
|
||||
<string name="pref_media_forward_value" translatable="false">FORWARD</string>
|
||||
<string name="pref_media_rewind_value" translatable="false">REWIND</string>
|
||||
|
||||
|
||||
<string-array name="pref_hybridhr_buttonfunctions">
|
||||
<item name="notificationsPanelApp">@string/menuitem_notifications</item>
|
||||
<item name="weatherApp">@string/menuitem_weather</item>
|
||||
|
@ -88,6 +88,7 @@
|
||||
<string name="pref_title_theme">Theme</string>
|
||||
<string name="pref_theme_light">Light</string>
|
||||
<string name="pref_theme_dark">Dark</string>
|
||||
<string name="pref_theme_system">System</string>
|
||||
<string name="pref_title_language">Language</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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user