X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2FDictionaryApplication.java;h=7ac45aeabfd2283ba590909a233c17dc044f86d3;hb=f8c9dec309c4934cf685d974bceeb159225acf1b;hp=c17c7ef82975e407f707d4da0cf8e67963edb2da;hpb=3ce0dd16e69302365d3bc802f298a5388b293d86;p=Dictionary.git diff --git a/src/com/hughes/android/dictionary/DictionaryApplication.java b/src/com/hughes/android/dictionary/DictionaryApplication.java index c17c7ef..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; @@ -29,7 +30,6 @@ import android.view.Menu; import android.view.MenuItem; import android.view.MenuItem.OnMenuItemClickListener; -import com.hughes.android.dictionary.CollatorWrapper; import com.hughes.android.dictionary.DictionaryInfo.IndexInfo; import com.hughes.android.dictionary.engine.Dictionary; import com.hughes.android.dictionary.engine.TransliteratorManager; @@ -64,9 +64,9 @@ public enum DictionaryApplication { // Leave it enabled by default for correctness except // for my known broken development/performance test device config. //static public final boolean USE_COLLATOR = !android.os.Build.FINGERPRINT.equals("Samsung/cm_tassve/tassve:4.4.4/KTU84Q/20150211:userdebug/release-keys"); - static public final boolean USE_COLLATOR = true; + public static final boolean USE_COLLATOR = true; - static public final TransliteratorManager.ThreadSetup threadBackground = new TransliteratorManager.ThreadSetup() { + public static final TransliteratorManager.ThreadSetup threadBackground = new TransliteratorManager.ThreadSetup() { @Override public void onThreadStart() { // THREAD_PRIORITY_BACKGROUND seemed like a good idea, but it @@ -289,7 +289,7 @@ public enum DictionaryApplication { return dictDir; } - static public boolean checkFileCreate(File dir) { + public static boolean checkFileCreate(File dir) { boolean res = false; File testfile = new File(dir, "quickdic_writetest"); try { @@ -311,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; } @@ -406,7 +412,7 @@ public enum DictionaryApplication { && !name2.startsWith(defaultLangName + "-")) { return -1; } else if (name2.startsWith(defaultLangName + "-") - && !name1.startsWith(defaultLangName + "-")) { + && !name1.startsWith(defaultLangName + "-")) { return 1; } }