summaryrefslogtreecommitdiff
path: root/core/src/main
diff options
context:
space:
mode:
authorH. Lehmann <ByteHamster@users.noreply.github.com>2019-09-20 23:47:31 +0200
committerGitHub <noreply@github.com>2019-09-20 23:47:31 +0200
commitc5dba814d27ae37bb3b53dd011c5b80b6b654f5b (patch)
tree7671bf921a4bae52fedcbd81f5f31a02b1bfc140 /core/src/main
parentfa3437960b705b443a1df996e228ec6713879916 (diff)
parent46c8679fe254ad23f0d055b3227a1fb2610086ef (diff)
downloadAntennaPod-c5dba814d27ae37bb3b53dd011c5b80b6b654f5b.zip
Merge pull request #3403 from ByteHamster/follow-system-theme
Add option to follow system theme
Diffstat (limited to 'core/src/main')
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java15
-rw-r--r--core/src/main/res/values/arrays.xml3
-rw-r--r--core/src/main/res/values/strings.xml1
3 files changed, 14 insertions, 5 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
index 6d614f039..a06047229 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
@@ -2,6 +2,7 @@ package de.danoeh.antennapod.core.preferences;
import android.content.Context;
import android.content.SharedPreferences;
+import android.content.res.Configuration;
import android.preference.PreferenceManager;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
@@ -164,7 +165,7 @@ public class UserPreferences {
* @return R.style.Theme_AntennaPod_Light or R.style.Theme_AntennaPod_Dark
*/
public static int getTheme() {
- return readThemeValue(prefs.getString(PREF_THEME, "0"));
+ return readThemeValue(prefs.getString(PREF_THEME, "system"));
}
public static int getNoTitleTheme() {
@@ -672,14 +673,18 @@ public class UserPreferences {
}
private static int readThemeValue(String valueFromPrefs) {
- switch (Integer.parseInt(valueFromPrefs)) {
- case 0:
+ switch (valueFromPrefs) {
+ case "0":
return R.style.Theme_AntennaPod_Light;
- case 1:
+ case "1":
return R.style.Theme_AntennaPod_Dark;
- case 2:
+ case "2":
return R.style.Theme_AntennaPod_TrueBlack;
default:
+ int nightMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
+ if (nightMode == Configuration.UI_MODE_NIGHT_YES) {
+ return R.style.Theme_AntennaPod_Dark;
+ }
return R.style.Theme_AntennaPod_Light;
}
}
diff --git a/core/src/main/res/values/arrays.xml b/core/src/main/res/values/arrays.xml
index 7c9811bc7..5e7eab1ea 100644
--- a/core/src/main/res/values/arrays.xml
+++ b/core/src/main/res/values/arrays.xml
@@ -157,11 +157,14 @@
</string-array>
<string-array name="theme_options">
+ <item>@string/pref_theme_title_use_system</item>
<item>@string/pref_theme_title_light</item>
<item>@string/pref_theme_title_dark</item>
<item>@string/pref_theme_title_trueblack</item>
</string-array>
+
<string-array name="theme_values">
+ <item>system</item>
<item>0</item>
<item>1</item>
<item>2</item>
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index bf805a19e..b7bbce0ce 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -398,6 +398,7 @@
<string name="pref_parallel_downloads_title">Parallel Downloads</string>
<string name="pref_episode_cache_title">Episode Cache</string>
<string name="pref_episode_cache_summary">Total number of downloaded episodes cached on the device. Automatic download will be suspended if this number is reached.</string>
+ <string name="pref_theme_title_use_system">Use system theme</string>
<string name="pref_theme_title_light">Light</string>
<string name="pref_theme_title_dark">Dark</string>
<string name="pref_theme_title_trueblack">Black (AMOLED ready)</string>