Remove default "light" value for theme in settings_appearance.xml. Change getTheme logic to give a default of day/night on Android 10+.
This commit is contained in:
parent
f506bfb14a
commit
d37a72b2a0
|
@ -18,8 +18,11 @@ package net.nullsum.audinaut.util;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
|
|
||||||
import net.nullsum.audinaut.R;
|
import net.nullsum.audinaut.R;
|
||||||
import net.nullsum.audinaut.activity.SettingsActivity;
|
import net.nullsum.audinaut.activity.SettingsActivity;
|
||||||
import net.nullsum.audinaut.activity.SubsonicFragmentActivity;
|
import net.nullsum.audinaut.activity.SubsonicFragmentActivity;
|
||||||
|
@ -33,7 +36,15 @@ public final class ThemeUtil {
|
||||||
|
|
||||||
public static String getTheme(Context context) {
|
public static String getTheme(Context context) {
|
||||||
SharedPreferences prefs = Util.getPreferences(context);
|
SharedPreferences prefs = Util.getPreferences(context);
|
||||||
String theme = prefs.getString(Constants.PREFERENCES_KEY_THEME, null);
|
String theme;
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT<29) {
|
||||||
|
// If Android Pie or older, default to null (handled below as light)
|
||||||
|
theme = prefs.getString(Constants.PREFERENCES_KEY_THEME, null);
|
||||||
|
} else {
|
||||||
|
// Else, for Android 10+, default to follow system dark mode setting
|
||||||
|
theme = prefs.getString(Constants.PREFERENCES_KEY_THEME, THEME_DAY_NIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
if (THEME_DAY_NIGHT.equals(theme)) {
|
if (THEME_DAY_NIGHT.equals(theme)) {
|
||||||
int currentNightMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
int currentNightMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
android:title="@string/settings.appearance_title">
|
android:title="@string/settings.appearance_title">
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:defaultValue="light"
|
|
||||||
android:entries="@array/themeNames"
|
android:entries="@array/themeNames"
|
||||||
android:entryValues="@array/themeValues"
|
android:entryValues="@array/themeValues"
|
||||||
android:key="theme"
|
android:key="theme"
|
||||||
|
|
Loading…
Reference in New Issue