1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-27 20:36:51 +01:00

fix: apply theme as set by the system

This commit is contained in:
vanous 2021-07-19 16:07:20 +02:00 committed by Gitea
parent 5b2ca65321
commit 67726944c4

View File

@ -22,7 +22,6 @@ import android.annotation.TargetApi;
import android.app.Application; import android.app.Application;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.app.NotificationManager.Policy; import android.app.NotificationManager.Policy;
import android.app.UiModeManager;
import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothAdapter;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -975,12 +974,14 @@ public class GBApplication extends Application {
public static boolean isDarkThemeEnabled() { public static boolean isDarkThemeEnabled() {
String selectedTheme = prefs.getString("pref_key_theme", context.getString(R.string.pref_theme_value_system)); String selectedTheme = prefs.getString("pref_key_theme", context.getString(R.string.pref_theme_value_system));
Resources resources = context.getResources();
UiModeManager umm = (UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q &&
selectedTheme.equals(context.getString(R.string.pref_theme_value_system))) {
return selectedTheme.equals(context.getString(R.string.pref_theme_value_dark)) || return (resources.getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
(selectedTheme.equals(context.getString(R.string.pref_theme_value_system)) } else {
&& (umm.getNightMode() == UiModeManager.MODE_NIGHT_YES)); return selectedTheme.equals(context.getString(R.string.pref_theme_value_dark));
}
} }
public static boolean isAmoledBlackEnabled() { public static boolean isAmoledBlackEnabled() {