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

[tor-commits] [orbot/master] tweak default bridge behavior based on locale



commit 7e9890e8c5ee59969641fcb661ff15d56e9ef560
Author: n8fr8 <nathan@xxxxxxxxxxx>
Date:   Thu Jan 4 22:59:39 2018 -0500

    tweak default bridge behavior based on locale
---
 .../org/torproject/android/OrbotMainActivity.java  |  1 +
 .../ui/onboarding/BridgeWizardActivity.java        | 24 ++++++++++++++++++----
 .../org/torproject/android/service/util/Prefs.java |  9 ++++++--
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
index 059e4273..c9882b76 100644
--- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java
+++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
@@ -969,6 +969,7 @@ public class OrbotMainActivity extends AppCompatActivity
 
         if (mBtnBridges.isChecked())
         {
+            Prefs.putBridgesEnabled(true);
             startActivity(new Intent(this, BridgeWizardActivity.class));
         }
         else
diff --git a/app/src/main/java/org/torproject/android/ui/onboarding/BridgeWizardActivity.java b/app/src/main/java/org/torproject/android/ui/onboarding/BridgeWizardActivity.java
index 82ff5fea..1a0f20ca 100644
--- a/app/src/main/java/org/torproject/android/ui/onboarding/BridgeWizardActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/onboarding/BridgeWizardActivity.java
@@ -18,6 +18,7 @@ import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.view.MenuItem;
 import android.view.View;
+import android.widget.RadioButton;
 import android.widget.TextView;
 import android.widget.Toast;
 
@@ -49,7 +50,9 @@ public class BridgeWizardActivity extends AppCompatActivity {
 
         setTitle(getString(R.string.bridges));
 
-        findViewById(R.id.btnBridgesDirect).setOnClickListener(new View.OnClickListener() {
+        RadioButton btnDirect = (RadioButton)
+                findViewById(R.id.btnBridgesDirect);
+        btnDirect.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 Prefs.setBridgesList("");
@@ -59,7 +62,8 @@ public class BridgeWizardActivity extends AppCompatActivity {
             }
         });
 
-        findViewById(R.id.btnBridgesObfs4).setOnClickListener(new View.OnClickListener() {
+        RadioButton btnObfs4 = (RadioButton)findViewById(R.id.btnBridgesObfs4);
+        btnObfs4.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 Prefs.setBridgesList("obfs4");
@@ -70,7 +74,9 @@ public class BridgeWizardActivity extends AppCompatActivity {
         });
 
 
-        findViewById(R.id.btnBridgesMeek).setOnClickListener(new View.OnClickListener() {
+        RadioButton btnMeek = (RadioButton)findViewById(R.id.btnBridgesMeek);
+
+        btnMeek.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 Prefs.setBridgesList("meek");
@@ -81,12 +87,22 @@ public class BridgeWizardActivity extends AppCompatActivity {
         });
 
 
-        findViewById(R.id.btnBridgesNew).setOnClickListener(new View.OnClickListener() {
+        RadioButton btnNew = (RadioButton)findViewById(R.id.btnBridgesNew);
+        btnNew.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 showGetBridgePrompt("");
             }
         });
+
+        if (!Prefs.bridgesEnabled())
+            btnDirect.setChecked(true);
+        else if (Prefs.getBridgesList().equals("meek"))
+            btnMeek.setChecked(true);
+        else if (Prefs.getBridgesList().equals("obfs4"))
+            btnObfs4.setChecked(true);
+
+
     }
 
     @Override
diff --git a/orbotservice/src/main/java/org/torproject/android/service/util/Prefs.java b/orbotservice/src/main/java/org/torproject/android/service/util/Prefs.java
index 806516d7..0a2bf45e 100644
--- a/orbotservice/src/main/java/org/torproject/android/service/util/Prefs.java
+++ b/orbotservice/src/main/java/org/torproject/android/service/util/Prefs.java
@@ -42,7 +42,9 @@ public class Prefs {
     }
 
     public static boolean bridgesEnabled() {
-        return prefs.getBoolean(PREF_BRIDGES_ENABLED, false);
+        //if phone is in Farsi, enable bridges by default
+        boolean bridgesEnabledDefault = Locale.getDefault().getLanguage().equals("fa");
+        return prefs.getBoolean(PREF_BRIDGES_ENABLED, bridgesEnabledDefault);
     }
 
     public static void putBridgesEnabled(boolean value) {
@@ -50,7 +52,10 @@ public class Prefs {
     }
 
     public static String getBridgesList() {
-        return prefs.getString(PREF_BRIDGES_LIST, "");
+        String defaultBridgeType = "obfs4";
+        if (Locale.getDefault().getLanguage().equals("fa"))
+            defaultBridgeType = "meek"; //if Farsi, use meek as the default bridge type
+        return prefs.getString(PREF_BRIDGES_LIST, defaultBridgeType);
     }
 
     public static void setBridgesList(String value) {



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