]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/DictionaryApplication.java
System theme defaults to default theme
[Dictionary.git] / src / com / hughes / android / dictionary / DictionaryApplication.java
index 92bb8b76fd462240f78c840733da27dbdf2715c7..840f8ffa30ce7523d7c517155f835049a9edcc56 100644 (file)
@@ -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;
@@ -313,6 +314,12 @@ public enum DictionaryApplication {
         final String theme = prefs.getString(appContext.getString(R.string.themeKey), "themeLight");
         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;
         }