[tor-commits] [orbot/master] Finish BridgeWizardActivity on successful MOAT.

n8fr8 at torproject.org n8fr8 at torproject.org
Tue Apr 28 21:05:02 UTC 2020


commit 5c99859e0398830f9e8f28eda553d987e56d83ab
Author: Benjamin Erhart <berhart at netzarchitekten.com>
Date:   Wed Apr 22 11:47:11 2020 +0200

    Finish BridgeWizardActivity on successful MOAT.
---
 .../android/ui/onboarding/BridgeWizardActivity.java    | 18 ++++++++++++++++--
 .../torproject/android/ui/onboarding/MoatActivity.java |  1 +
 2 files changed, 17 insertions(+), 2 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 5ffe79e5..21b4f4e5 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
@@ -14,6 +14,7 @@ import android.view.View;
 import android.widget.RadioButton;
 import android.widget.TextView;
 
+import androidx.annotation.Nullable;
 import androidx.appcompat.app.ActionBar;
 import androidx.appcompat.app.AppCompatActivity;
 import androidx.appcompat.widget.Toolbar;
@@ -31,6 +32,8 @@ import static org.torproject.android.MainConstants.URL_TOR_BRIDGES;
 
 public class BridgeWizardActivity extends AppCompatActivity {
 
+    private static int MOAT_REQUEST_CODE = 666;
+
     private TextView tvStatus;
 
     @Override
@@ -94,7 +97,8 @@ public class BridgeWizardActivity extends AppCompatActivity {
         btnMoat.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                startActivity(new Intent(BridgeWizardActivity.this, MoatActivity.class));
+                startActivityForResult(new Intent(BridgeWizardActivity.this, MoatActivity.class),
+                        MOAT_REQUEST_CODE);
             }
         });
 
@@ -104,7 +108,6 @@ public class BridgeWizardActivity extends AppCompatActivity {
             btnMeek.setChecked(true);
         else if (Prefs.getBridgesList().equals("obfs4"))
             btnObfs4.setChecked(true);
-
     }
 
     @Override
@@ -122,6 +125,17 @@ public class BridgeWizardActivity extends AppCompatActivity {
         return super.onOptionsItemSelected(item);
     }
 
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+        // If the MoatActivity could successfully gather OBFS4 bridges,
+        // the job is done and we can return immediately.
+        if (requestCode == MOAT_REQUEST_CODE && resultCode == RESULT_OK) {
+            finish();
+        }
+        else {
+            super.onActivityResult(requestCode, resultCode, data);
+        }
+    }
 
     private void showGetBridgePrompt() {
         new AlertDialog.Builder(this)
diff --git a/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java b/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java
index 0b99477f..464b3bd4 100644
--- a/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/onboarding/MoatActivity.java
@@ -259,6 +259,7 @@ public class MoatActivity extends AppCompatActivity implements View.OnClickListe
 
                             mProgressBar.setVisibility(View.GONE);
 
+                            MoatActivity.this.setResult(RESULT_OK);
                             MoatActivity.this.finish();
                         }
                         catch (JSONException e) {





More information about the tor-commits mailing list