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

[tor-commits] [orbot/master] Fixes #358



commit 76a52f7f88c0e9d1a35ba96f108263aee28b1aea
Author: bim <dsnake@xxxxxxxxxxxxxx>
Date:   Sun Jul 19 15:12:07 2020 -0400

    Fixes #358
    ~ BridgeWizard bridge options are selected correctly when the wizard is opened/closed.
    ~ Custom Bridges option is behind a button now that is only visible when the radio button is set
    ~ Some String updates to make it clear a given connection test is for bridges or not
---
 .../ui/onboarding/BridgeWizardActivity.java        | 45 +++++++++++++++-------
 .../main/res/layout/activity_custom_bridges.xml    |  2 +-
 app/src/main/res/layout/content_bridge_wizard.xml  |  8 ++++
 app/src/main/res/values/strings.xml                |  6 ++-
 4 files changed, 45 insertions(+), 16 deletions(-)

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 27f24164..f641c81d 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
@@ -28,7 +28,8 @@ import java.net.SocketAddress;
 
 public class BridgeWizardActivity extends AppCompatActivity {
 
-    private static int MOAT_REQUEST_CODE = 666;
+    private static final int MOAT_REQUEST_CODE = 666;
+    private static final int CUSTOM_BRIDGES_REQUEST_CODE = 1312;
 
     private static TextView mTvStatus;
     private static HostTester runningHostTest;
@@ -38,6 +39,8 @@ public class BridgeWizardActivity extends AppCompatActivity {
     private RadioButton mBtMeek;
     private RadioButton mBtCustom;
 
+    private View mBtnConfgiureCustomBridges;
+
     private static final String BUNDLE_KEY_TV_STATUS_VISIBILITY = "visibility";
     private static final String BUNDLE_KEY_TV_STATUS_TEXT = "text";
 
@@ -63,14 +66,18 @@ public class BridgeWizardActivity extends AppCompatActivity {
 
         setTitle(getString(R.string.bridges));
 
-        findViewById(R.id.btnMoat).setOnClickListener(v -> startActivityForResult(new Intent(BridgeWizardActivity.this, MoatActivity.class),
-                MOAT_REQUEST_CODE));
+        findViewById(R.id.btnMoat).setOnClickListener(v -> {
+            cancelHostTestIfRunning();
+            startActivityForResult(new Intent(BridgeWizardActivity.this, MoatActivity.class), MOAT_REQUEST_CODE);
+        });
 
         mBtDirect = findViewById(R.id.btnBridgesDirect);
-        mBtDirect.setOnClickListener(v -> {
+        mBtDirect.setOnCheckedChangeListener((buttonView, isChecked) -> {
+            if (!isChecked) return;
             Prefs.setBridgesList("");
             Prefs.putBridgesEnabled(false);
             testBridgeConnection();
+
         });
 
         mBtObfs4 = findViewById(R.id.btnBridgesObfs4);
@@ -91,10 +98,18 @@ public class BridgeWizardActivity extends AppCompatActivity {
 
         mBtCustom = findViewById(R.id.btnCustomBridges);
         mBtCustom.setOnCheckedChangeListener((buttonView, isChecked) -> {
-            if (isChecked) return;
-            cancelHostTestIfRunning();
-            startActivity(new Intent(BridgeWizardActivity.this, CustomBridgesActivity.class));
+            if (isChecked) {
+                cancelHostTestIfRunning();
+                mTvStatus.setVisibility(View.GONE);
+                mBtnConfgiureCustomBridges.setVisibility(View.VISIBLE);
+            } else {
+                mBtnConfgiureCustomBridges.setVisibility(View.GONE);
+            }
         });
+
+        mBtnConfgiureCustomBridges = findViewById(R.id.btnConfigureCustomBridges);
+        mBtnConfgiureCustomBridges.setOnClickListener(v ->
+                startActivityForResult(new Intent(BridgeWizardActivity.this, CustomBridgesActivity.class), CUSTOM_BRIDGES_REQUEST_CODE));
     }
 
     @Override
@@ -130,12 +145,13 @@ public class BridgeWizardActivity extends AppCompatActivity {
             else {
                 evaluateBridgeListState();
             }
+        } else if (requestCode == CUSTOM_BRIDGES_REQUEST_CODE) {
+            if (noBridgesSet()) mBtDirect.setChecked(true);
         } else {
             super.onActivityResult(requestCode, resultCode, data);
         }
     }
 
-
     private void testBridgeConnection() {
         cancelHostTestIfRunning();
         HostTester hostTester = new HostTester();
@@ -157,7 +173,7 @@ public class BridgeWizardActivity extends AppCompatActivity {
         protected void onPreExecute() {
             // Pre Code
             mTvStatus.setVisibility(View.VISIBLE);
-            mTvStatus.setText(R.string.testing_bridges);
+            mTvStatus.setText(mBtDirect.isChecked() ? R.string.testing_tor_direct : R.string.testing_bridges);
         }
 
         @Override
@@ -181,14 +197,14 @@ public class BridgeWizardActivity extends AppCompatActivity {
             // Post Code
             runningHostTest = null;
             if (result) {
-                mTvStatus.setText(R.string.testing_bridges_success);
+                int stringRes = mBtDirect.isChecked() ? R.string.testing_tor_direct_success : R.string.testing_bridges_success;
+                mTvStatus.setText(stringRes);
             } else {
                 mTvStatus.setText(R.string.testing_bridges_fail);
             }
         }
     }
 
-
     @Override
     public void onSaveInstanceState(Bundle savedInstanceState) {
         savedInstanceState.putInt(BUNDLE_KEY_TV_STATUS_VISIBILITY, mTvStatus.getVisibility());
@@ -224,8 +240,7 @@ public class BridgeWizardActivity extends AppCompatActivity {
 
     private void evaluateBridgeListState() {
         Log.d(getClass().getSimpleName(), String.format("bridgesEnabled=%b, bridgesList=%s", Prefs.bridgesEnabled(), Prefs.getBridgesList()));
-
-        if (!Prefs.bridgesEnabled()) {
+        if (noBridgesSet()) {
             mBtDirect.setChecked(true);
         } else if (Prefs.getBridgesList().equals("meek")) {
             mBtMeek.setChecked(true);
@@ -243,5 +258,7 @@ public class BridgeWizardActivity extends AppCompatActivity {
         }
     }
 
-
+    private static boolean noBridgesSet() {
+        return !Prefs.bridgesEnabled() || Prefs.getBridgesList().trim().equals("");
+    }
 }
diff --git a/app/src/main/res/layout/activity_custom_bridges.xml b/app/src/main/res/layout/activity_custom_bridges.xml
index 8a7b2998..add6a6fc 100644
--- a/app/src/main/res/layout/activity_custom_bridges.xml
+++ b/app/src/main/res/layout/activity_custom_bridges.xml
@@ -91,7 +91,7 @@
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_margin="12dp"
-                android:text="@string/get_bridges_email" />
+                android:text="@string/get_bridges_email_request" />
 
         </LinearLayout>
 
diff --git a/app/src/main/res/layout/content_bridge_wizard.xml b/app/src/main/res/layout/content_bridge_wizard.xml
index 5c3d990e..0b75ffa4 100644
--- a/app/src/main/res/layout/content_bridge_wizard.xml
+++ b/app/src/main/res/layout/content_bridge_wizard.xml
@@ -67,6 +67,14 @@
 
         </RadioGroup>
 
+        <Button
+            android:id="@+id/btnConfigureCustomBridges"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_margin="12dp"
+            android:text="@string/configure_custom_bridges"
+            android:visibility="gone" />
+
         <TextView
             android:id="@+id/lbl_bridge_test_status"
             android:layout_width="match_parent"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 308174e7..bbf55492 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -172,6 +172,7 @@
     <string name="bridge_mode">Request New Bridge</string>
 
     <string name="get_bridges_email">Email</string>
+    <string name="get_bridges_email_request">Request Bridges via Email</string>
     <string name="get_bridges_web">Web</string>
 
     <string name="activate">Activate</string>
@@ -242,7 +243,9 @@
     <string name="pref_disable_ipv4_summary">Tells exits not to connect to IPv4 addresses</string>
     <string name="app_shortcuts">Tor-Enabled Apps</string>
     <string name="testing_bridges">Testing bridge connection to Tor....</string>
+    <string name="testing_tor_direct">Testing connection to Tor...</string>
     <string name="testing_bridges_success">Success. Bridge configuration is good!</string>
+    <string name="testing_tor_direct_success">Success. Tor connection is good!</string>
     <string name="testing_bridges_fail">FAILED. Try another option</string>
     <string name="bridge_direct_connect">Connect directly to Tor (Best)</string>
     <string name="bridge_community">Connect through community servers</string>
@@ -270,7 +273,8 @@
     <!-- BridgeWizardActivity -->
     <string name="request_bridges_from_torproject">Request Bridges from torproject.org</string>
     <string name="custom_bridges">Custom Bridges</string>
-    
+    <string name="configure_custom_bridges">Configure Custom Bridges</string>
+
     <!-- CustomBridgesActivity -->
     <string name="use_custom_bridges">Use Custom Bridges</string>
     <string name="in_a_browser">In a browser, visit %s and tap "Get Bridges" > "Just Give Me Bridges!"</string>



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