X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2FDictionaryApplication.java;h=7ac45aeabfd2283ba590909a233c17dc044f86d3;hb=f8c9dec309c4934cf685d974bceeb159225acf1b;hp=92bb8b76fd462240f78c840733da27dbdf2715c7;hpb=14e5a61916416585b624a769e99e82d018706dae;p=Dictionary.git diff --git a/src/com/hughes/android/dictionary/DictionaryApplication.java b/src/com/hughes/android/dictionary/DictionaryApplication.java index 92bb8b7..7ac45ae 100644 --- a/src/com/hughes/android/dictionary/DictionaryApplication.java +++ b/src/com/hughes/android/dictionary/DictionaryApplication.java @@ -18,10 +18,11 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; +import android.content.res.Configuration; import android.net.Uri; import android.os.Build; import android.os.Environment; -import android.preference.PreferenceManager; +import android.support.v7.preference.PreferenceManager; import android.support.v4.view.MenuItemCompat; import android.util.Log; import android.util.TypedValue; @@ -310,9 +311,15 @@ public enum DictionaryApplication { public Theme getSelectedTheme() { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(appContext); - final String theme = prefs.getString(appContext.getString(R.string.themeKey), "themeLight"); + final String theme = prefs.getString(appContext.getString(R.string.themeKey), "themeSystem"); if (theme.equals("themeLight")) { return Theme.LIGHT; + } else if (theme.equals("themeSystem")) { + int mode = (appContext.getResources().getConfiguration().uiMode & + Configuration.UI_MODE_NIGHT_MASK); + return ((mode == Configuration.UI_MODE_NIGHT_NO) ? + Theme.LIGHT: + Theme.DEFAULT); } else { return Theme.DEFAULT; }