aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/values/arrays.xml163
-rw-r--r--res/values/strings.xml4
-rw-r--r--res/xml/apg_preferences.xml7
-rw-r--r--src/org/thialfihar/android/apg/BaseActivity.java20
-rw-r--r--src/org/thialfihar/android/apg/Constants.java1
-rw-r--r--src/org/thialfihar/android/apg/MailListActivity.java3
-rw-r--r--src/org/thialfihar/android/apg/Preferences.java10
-rw-r--r--src/org/thialfihar/android/apg/PreferencesActivity.java39
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 @@
<item>600</item>
</string-array>
+ <string-array name="language_entries">
+ <item>@string/choice_language_system</item>
+ <item>Afrikaans</item>
+ <item>Bahasa indonesia</item>
+ <item>Bahasa melayu</item>
+ <item>Bamanankan</item>
+ <item>Català</item>
+ <item>Cymraeg</item>
+ <item>Dansk</item>
+ <item>Deutsch</item>
+ <item>Dholuo</item>
+ <item>Eesti</item>
+ <item>English</item>
+ <item>Español</item>
+ <item>Fulfulde, Pulaar, Pular</item>
+ <item>Gaeilge</item>
+ <item>Galego</item>
+ <item>Hausa</item>
+ <item>Hrvatski</item>
+ <item>Kinyarwanda</item>
+ <item>Kirundi</item>
+ <item>Kiswahili</item>
+ <item>Latviešu</item>
+ <item>Lietuviškai</item>
+ <item>Magyar</item>
+ <item>Malti</item>
+ <item>Nederlands</item>
+ <item>Norsk</item>
+ <item>Pyccĸий</item>
+ <item>Română</item>
+ <item>Slovenčina</item>
+ <item>Slovenščina</item>
+ <item>Somali</item>
+ <item>Српски</item>
+ <item>Tiếng Việt</item>
+ <item>Tϋrkçe</item>
+ <item>Wolof</item>
+ <item>Yorùbá</item>
+ <item>Azərbaycan</item>
+ <item>Euskera</item>
+ <item>Français</item>
+ <item>isiXhosa</item>
+ <item>isiZulu</item>
+ <item>Italiano</item>
+ <item>O\'zbek</item>
+ <item>Polski</item>
+ <item>Português</item>
+ <item>Shqip</item>
+ <item>Suomi</item>
+ <item>Svenska</item>
+ <item>Íslenska</item>
+ <item>Čeština</item>
+ <item>Ɛʋɛ</item>
+ <item>Ελληνικά</item>
+ <item>Беларуская</item>
+ <item>Български</item>
+ <item>Кыргыз</item>
+ <item>Македонски</item>
+ <item>Українська</item>
+ <item>аҧсуа бызшәа</item>
+ <item>Қазақ</item>
+ <item>Հայերեն</item>
+ <item>עברית</item>
+ <item>اردو</item>
+ <item>العربية</item>
+ <item>فارسی</item>
+ <item>پښتو</item>
+ <item>हिंदी</item>
+ <item>తెలుగు</item>
+ <item>ಕನ್ನಡ</item>
+ <item>ภาษาไทย</item>
+ <item>አማርኛ</item>
+ <item>中文</item>
+ <item>日本語</item>
+ <item>한국어</item>
+ </string-array>
+
+ <string-array name="language_values">
+ <item></item>
+ <item>af</item>
+ <item>id</item>
+ <item>ms</item>
+ <item>bm</item>
+ <item>ca</item>
+ <item>cy</item>
+ <item>da</item>
+ <item>de</item>
+ <item>luo</item>
+ <item>et</item>
+ <item>en</item>
+ <item>es</item>
+ <item>ff</item>
+ <item>ga</item>
+ <item>gl</item>
+ <item>ha</item>
+ <item>hr</item>
+ <item>rw</item>
+ <item>rn</item>
+ <item>sw</item>
+ <item>lv</item>
+ <item>lt</item>
+ <item>hu</item>
+ <item>mt</item>
+ <item>nl</item>
+ <item>no</item>
+ <item>ru</item>
+ <item>ro</item>
+ <item>sk</item>
+ <item>sl</item>
+ <item>so</item>
+ <item>sr</item>
+ <item>vi</item>
+ <item>tr</item>
+ <item>wo</item>
+ <item>yo</item>
+ <item>az</item>
+ <item>eu</item>
+ <item>fr</item>
+ <item>xs</item>
+ <item>zu</item>
+ <item>it</item>
+ <item>uz</item>
+ <item>pl</item>
+ <item>pt</item>
+ <item>sq</item>
+ <item>fi</item>
+ <item>sv</item>
+ <item>is</item>
+ <item>cs</item>
+ <item>ee</item>
+ <item>el</item>
+ <item>be</item>
+ <item>bg</item>
+ <item>ky</item>
+ <item>mk</item>
+ <item>uk</item>
+ <item>ab</item>
+ <item>kk</item>
+ <item>hy</item>
+ <item>he</item>
+ <item>ur</item>
+ <item>ar</item>
+ <item>fa</item>
+ <item>ps</item>
+ <item>hi</item>
+ <item>te</item>
+ <item>kn</item>
+ <item>th</item>
+ <item>am</item>
+ <item>zh</item>
+ <item>ja</item>
+ <item>ko</item>
+ </string-array>
+
+ <string-array name="supported_languages">
+ <item></item>
+ <item>da</item>
+ <item>de</item>
+ <item>en</item>
+ <item>it</item>
+ <item>sl</item>
+ </string-array>
+
</resources>
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 @@
<string name="label_passPhraseCacheTtl">Pass Phrase Cache</string>
<string name="label_messageCompression">Message Compression</string>
<string name="label_fileCompression">File Compression</string>
+ <string name="label_language">Language</string>
<string name="noKeysSelected">Select</string>
<string name="oneKeySelected">1 Selected</string>
@@ -114,7 +115,7 @@
<string name="expired">expired</string>
<string name="notValid">not valid</string>
- <!-- choice_lowerCase: capitalized firwst word, no punctuation -->
+ <!-- choice_lowerCase: capitalized first word, no punctuation -->
<string name="choice_none">None</string>
<string name="choice_signOnly">Sign only</string>
<string name="choice_encryptOnly">Encrypt only</string>
@@ -125,6 +126,7 @@
<string name="choice_5mins">5 mins</string>
<string name="choice_10mins">10 mins</string>
<string name="choice_untilQuit">until quit</string>
+ <string name="choice_language_system">System default</string>
<string name="dsa">DSA</string>
<string name="elgamal">ElGamal</string>
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 @@
<PreferenceCategory
android:title="@string/section_general">
+ <ListPreference
+ android:key="language"
+ android:title="@string/label_language"
+ android:entries="@array/language_entries"
+ android:entryValues="@array/language_values"
+ android:dialogTitle="@string/label_language" />
+
<org.thialfihar.android.apg.IntegerListPreference
android:persistent="false"
android:key="passPhraseCacheTtl"
diff --git a/src/org/thialfihar/android/apg/BaseActivity.java b/src/org/thialfihar/android/apg/BaseActivity.java
index 17fe3b0c8..4a0360b25 100644
--- a/src/org/thialfihar/android/apg/BaseActivity.java
+++ b/src/org/thialfihar/android/apg/BaseActivity.java
@@ -17,6 +17,7 @@
package org.thialfihar.android.apg;
import java.io.File;
+import java.util.Locale;
import android.app.Activity;
import android.app.AlertDialog;
@@ -25,6 +26,7 @@ import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
@@ -60,6 +62,7 @@ public class BaseActivity extends Activity
super.onCreate(savedInstanceState);
mPreferences = Preferences.getPreferences(this);
+ setLanguage(this, mPreferences.getLanguage());
Apg.initialize(this);
@@ -378,4 +381,21 @@ public class BaseActivity extends Activity
protected String getDeleteFile() {
return mDeleteFile;
}
+
+ public static void setLanguage(Context context, String language)
+ {
+ Locale locale;
+ if (language == null || language.equals(""))
+ {
+ locale = Locale.getDefault();
+ }
+ else
+ {
+ locale = new Locale(language);
+ }
+ Configuration config = new Configuration();
+ config.locale = locale;
+ context.getResources().updateConfiguration(config,
+ context.getResources().getDisplayMetrics());
+ }
}
diff --git a/src/org/thialfihar/android/apg/Constants.java b/src/org/thialfihar/android/apg/Constants.java
index 4e818b0b9..0a819a509 100644
--- a/src/org/thialfihar/android/apg/Constants.java
+++ b/src/org/thialfihar/android/apg/Constants.java
@@ -31,5 +31,6 @@ public final class Constants {
public static final String default_message_compression = "defaultMessageCompression";
public static final String default_file_compression = "defaultFileCompression";
public static final String pass_phrase_cache_ttl = "passPhraseCacheTtl";
+ public static final String language = "language";
}
}
diff --git a/src/org/thialfihar/android/apg/MailListActivity.java b/src/org/thialfihar/android/apg/MailListActivity.java
index c4de68e91..2becaad3c 100644
--- a/src/org/thialfihar/android/apg/MailListActivity.java
+++ b/src/org/thialfihar/android/apg/MailListActivity.java
@@ -80,6 +80,9 @@ public class MailListActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
+ Preferences prefs = Preferences.getPreferences(this);
+ BaseActivity.setLanguage(this, prefs.getLanguage());
+
super.onCreate(savedInstanceState);
mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
diff --git a/src/org/thialfihar/android/apg/Preferences.java b/src/org/thialfihar/android/apg/Preferences.java
index 50489dc89..cf5470f2a 100644
--- a/src/org/thialfihar/android/apg/Preferences.java
+++ b/src/org/thialfihar/android/apg/Preferences.java
@@ -23,6 +23,16 @@ public class Preferences {
mSharedPreferences = context.getSharedPreferences("APG.main", Context.MODE_PRIVATE);
}
+ public String getLanguage() {
+ return mSharedPreferences.getString(Constants.pref.language, "");
+ }
+
+ public void setLanguage(String value) {
+ SharedPreferences.Editor editor = mSharedPreferences.edit();
+ editor.putString(Constants.pref.language, value);
+ editor.commit();
+ }
+
public int getPassPhraseCacheTtl() {
int ttl = mSharedPreferences.getInt(Constants.pref.pass_phrase_cache_ttl, 180);
// fix the value if it was set to "never" in previous versions, which currently is not
diff --git a/src/org/thialfihar/android/apg/PreferencesActivity.java b/src/org/thialfihar/android/apg/PreferencesActivity.java
index c8778c780..6e7e6f657 100644
--- a/src/org/thialfihar/android/apg/PreferencesActivity.java
+++ b/src/org/thialfihar/android/apg/PreferencesActivity.java
@@ -16,15 +16,21 @@
package org.thialfihar.android.apg;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Vector;
+
import org.bouncycastle2.bcpg.HashAlgorithmTags;
import org.bouncycastle2.openpgp.PGPEncryptedData;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
+import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
public class PreferencesActivity extends PreferenceActivity {
+ private ListPreference mLanguage = null;
private IntegerListPreference mPassPhraseCacheTtl = null;
private IntegerListPreference mEncryptionAlgorithm = null;
private IntegerListPreference mHashAlgorithm = null;
@@ -35,12 +41,41 @@ public class PreferencesActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
mPreferences = Preferences.getPreferences(this);
+ BaseActivity.setLanguage(this, mPreferences.getLanguage());
+ super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.apg_preferences);
+ mLanguage = (ListPreference) findPreference(Constants.pref.language);
+ Vector<CharSequence> entryVector = new Vector<CharSequence>(Arrays.asList(mLanguage.getEntries()));
+ Vector<CharSequence> entryValueVector = new Vector<CharSequence>(Arrays.asList(mLanguage.getEntryValues()));
+ String supportedLanguages[] = getResources().getStringArray(R.array.supported_languages);
+ HashSet<String> supportedLanguageSet = new HashSet<String>(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());