From a34adb09a4ba06a2b1fc8368a4e0db4f12281d17 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Sun, 18 Jul 2010 07:19:57 +0000 Subject: [PATCH] added a language setting to change the language directly --- res/values/arrays.xml | 163 ++++++++++++++++++ res/values/strings.xml | 4 +- res/xml/apg_preferences.xml | 7 + .../thialfihar/android/apg/BaseActivity.java | 20 +++ src/org/thialfihar/android/apg/Constants.java | 1 + .../android/apg/MailListActivity.java | 3 + .../thialfihar/android/apg/Preferences.java | 10 ++ .../android/apg/PreferencesActivity.java | 39 ++++- 8 files changed, 244 insertions(+), 3 deletions(-) diff --git a/res/values/arrays.xml b/res/values/arrays.xml index db87d7c4a..4f0dac371 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -32,4 +32,167 @@ 600 + + @string/choice_language_system + Afrikaans + Bahasa indonesia + Bahasa melayu + Bamanankan + Català + Cymraeg + Dansk + Deutsch + Dholuo + Eesti + English + Español + Fulfulde, Pulaar, Pular + Gaeilge + Galego + Hausa + Hrvatski + Kinyarwanda + Kirundi + Kiswahili + Latviešu + Lietuviškai + Magyar + Malti + Nederlands + Norsk + Pyccĸий + Română + Slovenčina + Slovenščina + Somali + Српски + Tiếng Việt + Tϋrkçe + Wolof + Yorùbá + Azərbaycan + Euskera + Français + isiXhosa + isiZulu + Italiano + O\'zbek + Polski + Português + Shqip + Suomi + Svenska + Íslenska + Čeština + Ɛʋɛ + Ελληνικά + Беларуская + Български + Кыргыз + Македонски + Українська + аҧсуа бызшәа + Қазақ + Հայերեն + עברית + اردو + العربية + فارسی + پښتو + हिंदी + తెలుగు + ಕನ್ನಡ + ภาษาไทย + አማርኛ + 中文 + 日本語 + 한국어 + + + + + af + id + ms + bm + ca + cy + da + de + luo + et + en + es + ff + ga + gl + ha + hr + rw + rn + sw + lv + lt + hu + mt + nl + no + ru + ro + sk + sl + so + sr + vi + tr + wo + yo + az + eu + fr + xs + zu + it + uz + pl + pt + sq + fi + sv + is + cs + ee + el + be + bg + ky + mk + uk + ab + kk + hy + he + ur + ar + fa + ps + hi + te + kn + th + am + zh + ja + ko + + + + + da + de + en + it + sl + + diff --git a/res/values/strings.xml b/res/values/strings.xml index a5c9fd566..e83fd1734 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -99,6 +99,7 @@ Pass Phrase Cache Message Compression File Compression + Language Select 1 Selected @@ -114,7 +115,7 @@ expired not valid - + None Sign only Encrypt only @@ -125,6 +126,7 @@ 5 mins 10 mins until quit + System default DSA ElGamal diff --git a/res/xml/apg_preferences.xml b/res/xml/apg_preferences.xml index 7ce9b5344..07471a4b9 100644 --- a/res/xml/apg_preferences.xml +++ b/res/xml/apg_preferences.xml @@ -20,6 +20,13 @@ + + entryVector = new Vector(Arrays.asList(mLanguage.getEntries())); + Vector entryValueVector = new Vector(Arrays.asList(mLanguage.getEntryValues())); + String supportedLanguages[] = getResources().getStringArray(R.array.supported_languages); + HashSet supportedLanguageSet = new HashSet(Arrays.asList(supportedLanguages)); + for (int i = entryVector.size() - 1; i > -1; --i) + { + if (!supportedLanguageSet.contains(entryValueVector.get(i))) + { + entryVector.remove(i); + entryValueVector.remove(i); + } + } + CharSequence dummy[] = new CharSequence[0]; + mLanguage.setEntries(entryVector.toArray(dummy)); + mLanguage.setEntryValues(entryValueVector.toArray(dummy)); + mLanguage.setValue(mPreferences.getLanguage()); + mLanguage.setSummary(mLanguage.getEntry()); + mLanguage.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() + { + public boolean onPreferenceChange(Preference preference, Object newValue) + { + mLanguage.setValue(newValue.toString()); + mLanguage.setSummary(mLanguage.getEntry()); + mPreferences.setLanguage(newValue.toString()); + return false; + } + }); + mPassPhraseCacheTtl = (IntegerListPreference) findPreference(Constants.pref.pass_phrase_cache_ttl); mPassPhraseCacheTtl.setValue("" + mPreferences.getPassPhraseCacheTtl()); mPassPhraseCacheTtl.setSummary(mPassPhraseCacheTtl.getEntry());