[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [orbot/master] reimplement custom language support for Aymara



commit fcff7eadefc94f94995861be6d32e2c7e7df75ea
Author: n8fr8 <nathan@xxxxxxxxxxxxxxxxxxxx>
Date:   Tue Oct 30 07:39:12 2018 -0400

    reimplement custom language support for Aymara
---
 app/src/main/java/org/torproject/android/OrbotApp.java      |  4 ++--
 .../main/java/org/torproject/android/OrbotMainActivity.java |  8 +++++++-
 .../java/org/torproject/android/settings/Languages.java     |  2 +-
 .../torproject/android/settings/SettingsPreferences.java    | 13 ++++++++-----
 app/src/main/res/values/strings.xml                         |  2 ++
 app/src/main/res/xml/preferences.xml                        |  2 +-
 6 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/app/src/main/java/org/torproject/android/OrbotApp.java b/app/src/main/java/org/torproject/android/OrbotApp.java
index 0e8e1375..a61f0937 100644
--- a/app/src/main/java/org/torproject/android/OrbotApp.java
+++ b/app/src/main/java/org/torproject/android/OrbotApp.java
@@ -44,10 +44,10 @@ public class OrbotApp extends Application implements OrbotConstants
     public void onCreate() {
         super.onCreate();
 
-        /**
+
         Languages.setup(OrbotMainActivity.class, R.string.menu_settings);
         Languages.setLanguage(this, Prefs.getDefaultLocale(), true);
-         **/
+
         Language.setFromPreference(this, "pref_default_locale");
 
         //check for updates via github, since it is unlikely to be blocked; notify the user of places where upgrades can be found
diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
index 4e50dd53..f19bbc06 100644
--- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java
+++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
@@ -22,6 +22,7 @@ import org.torproject.android.service.util.Prefs;
 import org.torproject.android.service.TorService;
 import org.torproject.android.service.TorServiceConstants;
 import org.torproject.android.service.util.TorServiceUtils;
+import org.torproject.android.settings.Languages;
 import org.torproject.android.settings.LocaleHelper;
 import org.torproject.android.settings.SettingsPreferences;
 import org.torproject.android.ui.AppManagerActivity;
@@ -91,6 +92,7 @@ import android.widget.Toast;
 import com.google.zxing.integration.android.IntentIntegrator;
 import com.google.zxing.integration.android.IntentResult;
 
+import im.delight.android.languages.Language;
 import pl.bclogic.pulsator4droid.library.PulsatorLayout;
 
 import static android.support.v4.content.FileProvider.getUriForFile;
@@ -935,7 +937,11 @@ public class OrbotMainActivity extends AppCompatActivity
         if (request == REQUEST_SETTINGS && response == RESULT_OK)
         {
             if (data != null && (!TextUtils.isEmpty(data.getStringExtra("locale")))) {
-                LocaleHelper.setLocale(getApplicationContext(), Prefs.getDefaultLocale());
+
+                Prefs.setDefaultLocale(data.getStringExtra("locale"));
+                Languages.setLanguage(this, Prefs.getDefaultLocale(), true);
+                Language.setFromPreference(this, "pref_default_locale");
+
                 finish();
                 startActivity(new Intent(this,OrbotMainActivity.class));
             }
diff --git a/app/src/main/java/org/torproject/android/settings/Languages.java b/app/src/main/java/org/torproject/android/settings/Languages.java
index abed8838..fcdfa344 100644
--- a/app/src/main/java/org/torproject/android/settings/Languages.java
+++ b/app/src/main/java/org/torproject/android/settings/Languages.java
@@ -28,7 +28,7 @@ public class Languages {
             Locale.ITALIAN, Locale.JAPANESE, Locale.KOREAN,
             Locale.TRADITIONAL_CHINESE, Locale.SIMPLIFIED_CHINESE,
             TIBETAN, new Locale("af"), new Locale("am"),
-            new Locale("ar"), new Locale("az"), new Locale("bg"),
+            new Locale("ar"), new Locale("ay"), new Locale("az"), new Locale("bg"),
             new Locale("bn"), new Locale("ca"), new Locale("cs"),
             new Locale("da"), new Locale("el"), new Locale("es"),
             new Locale("et"), new Locale("eu"), new Locale("fa"),
diff --git a/app/src/main/java/org/torproject/android/settings/SettingsPreferences.java b/app/src/main/java/org/torproject/android/settings/SettingsPreferences.java
index 513432a1..827eb940 100644
--- a/app/src/main/java/org/torproject/android/settings/SettingsPreferences.java
+++ b/app/src/main/java/org/torproject/android/settings/SettingsPreferences.java
@@ -28,19 +28,22 @@ public class SettingsPreferences
         addPreferencesFromResource(R.xml.preferences);
         getPreferenceManager().setSharedPreferencesMode(Context.MODE_MULTI_PROCESS);
 
-
         prefLocale = (ListPreference) findPreference("pref_default_locale");
-        /**
+
         Languages languages = Languages.get(this);
         prefLocale.setEntries(languages.getAllNames());
-        prefLocale.setEntryValues(languages.getSupportedLocales());**/
+        prefLocale.setEntryValues(languages.getSupportedLocales());
         prefLocale.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
 
             @Override
             public boolean onPreferenceChange(Preference preference, Object newValue) {
                 String language = (String) newValue;
+
+
                 Prefs.setDefaultLocale(language);
-                LocaleHelper.setLocale(getApplicationContext(), language);
+                Languages.setLanguage(SettingsPreferences.this, Prefs.getDefaultLocale(), true);
+                Language.setFromPreference(SettingsPreferences.this, "pref_default_locale");
+
                 Intent intentResult = new Intent();
                 intentResult.putExtra("locale", language);
                 setResult(RESULT_OK, intentResult);
@@ -57,7 +60,7 @@ public class SettingsPreferences
 
     @Override
     protected void onPause() {
-        Language.setFromPreference(this, "pref_default_locale", true);
+        //Language.setFromPreference(this, "pref_default_locale", true);
 
         super.onPause();
     }
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b9ccc2d0..f14b51b5 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -405,4 +405,6 @@
 
     <string name="menu_new_identity">New Identity</string>
 
+    <string name="use_system_default">Use System Default</string>
+
 </resources>
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index 194d6f1a..0e5a70be 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -1,7 +1,7 @@
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android";>
 
     <PreferenceCategory android:title="@string/pref_general_group">
-        <im.delight.android.languages.LanguagePreference
+        <ListPreference
             android:key="pref_default_locale"
             android:title="@string/set_locale_title"
             android:enabled="true"



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits