diff --git a/app/src/main/java/net/nullsum/audinaut/activity/SubsonicActivity.java b/app/src/main/java/net/nullsum/audinaut/activity/SubsonicActivity.java index 33fe394..f687a68 100644 --- a/app/src/main/java/net/nullsum/audinaut/activity/SubsonicActivity.java +++ b/app/src/main/java/net/nullsum/audinaut/activity/SubsonicActivity.java @@ -24,6 +24,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.media.AudioManager; +import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.Handler; @@ -85,7 +86,13 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte private static ImageLoader IMAGE_LOADER; static { - AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO); + // If Android Pie or older, set night mode by system clock + if (Build.VERSION.SDK_INT<29) { + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO); + } else { + // Else, for Android 10+, follow system dark mode setting + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM); + } } final List backStack = new ArrayList<>(); diff --git a/app/src/main/java/net/nullsum/audinaut/util/ThemeUtil.java b/app/src/main/java/net/nullsum/audinaut/util/ThemeUtil.java index 27efe6d..7df24d7 100644 --- a/app/src/main/java/net/nullsum/audinaut/util/ThemeUtil.java +++ b/app/src/main/java/net/nullsum/audinaut/util/ThemeUtil.java @@ -18,6 +18,7 @@ package net.nullsum.audinaut.util; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; +import android.os.Build; import android.util.Log; import net.nullsum.audinaut.R; @@ -33,7 +34,15 @@ public final class ThemeUtil { public static String getTheme(Context 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)) { int currentNightMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index de4dfa7..25ca90c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -162,8 +162,8 @@ Light Dark Black - Day/Night - Day/Black Night + Dynamic (Light/Dark) + Dynamic (Light/Black) Fullscreen Hide as many UI elements as Android will allow Display Track # diff --git a/app/src/main/res/xml/settings_appearance.xml b/app/src/main/res/xml/settings_appearance.xml index 548cf25..597fc5d 100644 --- a/app/src/main/res/xml/settings_appearance.xml +++ b/app/src/main/res/xml/settings_appearance.xml @@ -3,7 +3,6 @@ android:title="@string/settings.appearance_title">