From: Reimar Döffinger Date: Mon, 24 Aug 2015 19:25:02 +0000 (+0200) Subject: Move Theme class into DictionaryApplication. X-Git-Url: http://gitweb.fperrin.net/?p=Dictionary.git;a=commitdiff_plain;h=801dc82cfeb5c41d4ff93c3dbe94e68f71c36867 Move Theme class into DictionaryApplication. That is where it is mostly used, and it simplifies compiling the DictionaryPC part. --- diff --git a/src/com/hughes/android/dictionary/C.java b/src/com/hughes/android/dictionary/C.java index 76ce541..904618d 100644 --- a/src/com/hughes/android/dictionary/C.java +++ b/src/com/hughes/android/dictionary/C.java @@ -26,39 +26,4 @@ public class C { public static final String THANKS_FOR_UPDATING_VERSION = "thanksForUpdatingVersion"; - enum Theme { - DEFAULT(R.style.Theme_Default, - R.style.Theme_Default_TokenRow_Fg, - R.color.theme_default_token_row_fg, - R.drawable.theme_default_token_row_main_bg, - R.drawable.theme_default_token_row_other_bg, - R.drawable.theme_default_normal_row_bg), - - LIGHT(R.style.Theme_Light, - R.style.Theme_Light_TokenRow_Fg, - R.color.theme_light_token_row_fg, - R.drawable.theme_light_token_row_main_bg, - R.drawable.theme_light_token_row_other_bg, - R.drawable.theme_light_normal_row_bg); - - Theme(final int themeId, final int tokenRowFg, - final int tokenRowFgColor, - final int tokenRowMainBg, final int tokenRowOtherBg, - final int normalRowBg) { - this.themeId = themeId; - this.tokenRowFg = tokenRowFg; - this.tokenRowFgColor = tokenRowFgColor; - this.tokenRowMainBg = tokenRowMainBg; - this.tokenRowOtherBg = tokenRowOtherBg; - this.normalRowBg = normalRowBg; - } - - final int themeId; - final int tokenRowFg; - final int tokenRowFgColor; - final int tokenRowMainBg; - final int tokenRowOtherBg; - final int normalRowBg; - } - } diff --git a/src/com/hughes/android/dictionary/DictionaryActivity.java b/src/com/hughes/android/dictionary/DictionaryActivity.java index cd238f3..769ce95 100644 --- a/src/com/hughes/android/dictionary/DictionaryActivity.java +++ b/src/com/hughes/android/dictionary/DictionaryActivity.java @@ -143,7 +143,7 @@ public class DictionaryActivity extends ActionBarActivity { volatile boolean ttsReady; Typeface typeface; - C.Theme theme = C.Theme.LIGHT; + DictionaryApplication.Theme theme = DictionaryApplication.Theme.LIGHT; int textColorFg = Color.BLACK; int fontSizeSp; diff --git a/src/com/hughes/android/dictionary/DictionaryApplication.java b/src/com/hughes/android/dictionary/DictionaryApplication.java index 5d6bab8..9897183 100644 --- a/src/com/hughes/android/dictionary/DictionaryApplication.java +++ b/src/com/hughes/android/dictionary/DictionaryApplication.java @@ -63,6 +63,41 @@ public class DictionaryApplication extends Application { // Unordered. static Map DOWNLOADABLE_UNCOMPRESSED_FILENAME_NAME_TO_DICTIONARY_INFO = null; + enum Theme { + DEFAULT(R.style.Theme_Default, + R.style.Theme_Default_TokenRow_Fg, + R.color.theme_default_token_row_fg, + R.drawable.theme_default_token_row_main_bg, + R.drawable.theme_default_token_row_other_bg, + R.drawable.theme_default_normal_row_bg), + + LIGHT(R.style.Theme_Light, + R.style.Theme_Light_TokenRow_Fg, + R.color.theme_light_token_row_fg, + R.drawable.theme_light_token_row_main_bg, + R.drawable.theme_light_token_row_other_bg, + R.drawable.theme_light_normal_row_bg); + + Theme(final int themeId, final int tokenRowFg, + final int tokenRowFgColor, + final int tokenRowMainBg, final int tokenRowOtherBg, + final int normalRowBg) { + this.themeId = themeId; + this.tokenRowFg = tokenRowFg; + this.tokenRowFgColor = tokenRowFgColor; + this.tokenRowMainBg = tokenRowMainBg; + this.tokenRowOtherBg = tokenRowOtherBg; + this.normalRowBg = normalRowBg; + } + + final int themeId; + final int tokenRowFg; + final int tokenRowFgColor; + final int tokenRowMainBg; + final int tokenRowOtherBg; + final int normalRowBg; + } + // Useful: // http://www.loc.gov/standards/iso639-2/php/code_list.php public static final Map isoCodeToResources = new LinkedHashMap(); @@ -379,13 +414,13 @@ public class DictionaryApplication extends Application { return new File(file); } - public C.Theme getSelectedTheme() { + public Theme getSelectedTheme() { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); final String theme = prefs.getString(getString(R.string.themeKey), "themeLight"); if (theme.equals("themeLight")) { - return C.Theme.LIGHT; + return Theme.LIGHT; } else { - return C.Theme.DEFAULT; + return Theme.DEFAULT; } }