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

[tor-commits] [orbot/master] MOAT Errors won't disappear on device rotation



commit 33276a9f5104abf76cff54b2b737b739046bc269
Author: bim <dsnake@xxxxxxxxxxxxxx>
Date:   Sun May 10 18:51:37 2020 -0400

    MOAT Errors won't disappear on device rotation
---
 .../org/torproject/android/OrbotMainActivity.java  |  4 +--
 .../android/ui/dialog/AboutDialogFragment.java     |  2 +-
 .../android/ui/dialog/MoatErrorDialogFragment.java | 32 ++++++++++++++++++++++
 .../android/ui/onboarding/MoatActivity.java        |  9 ++----
 app/src/main/res/layout/layout_about.xml           |  6 ++--
 5 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/app/src/main/java/org/torproject/android/OrbotMainActivity.java b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
index 837d7e60..c1359457 100644
--- a/app/src/main/java/org/torproject/android/OrbotMainActivity.java
+++ b/app/src/main/java/org/torproject/android/OrbotMainActivity.java
@@ -459,9 +459,7 @@ public class OrbotMainActivity extends AppCompatActivity
             Intent intent = new Intent(OrbotMainActivity.this, SettingsPreferences.class);
             startActivityForResult(intent, REQUEST_SETTINGS);
         } else if (item.getItemId() == R.id.menu_exit) {
-            //exit app
-            doExit();
-
+            doExit(); // exit appp
         } else if (item.getItemId() == R.id.menu_about) {
             new AboutDialogFragment().show(getSupportFragmentManager(), AboutDialogFragment.TAG);
         } else if (item.getItemId() == R.id.menu_scan) {
diff --git a/app/src/main/java/org/torproject/android/ui/dialog/AboutDialogFragment.java b/app/src/main/java/org/torproject/android/ui/dialog/AboutDialogFragment.java
index 38b9821a..10ad06b6 100644
--- a/app/src/main/java/org/torproject/android/ui/dialog/AboutDialogFragment.java
+++ b/app/src/main/java/org/torproject/android/ui/dialog/AboutDialogFragment.java
@@ -46,7 +46,7 @@ public class AboutDialogFragment extends DialogFragment {
         boolean buildAboutText = true;
 
         if (savedInstanceState != null) {
-            String tvAboutText = savedInstanceState.getParcelable(BUNDLE_KEY_TV_ABOUT_TEXT);
+            String tvAboutText = savedInstanceState.getString(BUNDLE_KEY_TV_ABOUT_TEXT);
             if (tvAboutText != null) {
                 buildAboutText = false;
                 tvAbout.setText(tvAboutText);
diff --git a/app/src/main/java/org/torproject/android/ui/dialog/MoatErrorDialogFragment.java b/app/src/main/java/org/torproject/android/ui/dialog/MoatErrorDialogFragment.java
new file mode 100644
index 00000000..ad8f9477
--- /dev/null
+++ b/app/src/main/java/org/torproject/android/ui/dialog/MoatErrorDialogFragment.java
@@ -0,0 +1,32 @@
+package org.torproject.android.ui.dialog;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.os.Bundle;
+
+import androidx.fragment.app.DialogFragment;
+
+import org.torproject.android.R;
+
+public class MoatErrorDialogFragment extends DialogFragment {
+
+    public static final String TAG = MoatErrorDialogFragment.class.getSimpleName();
+    private static final String BUNDLE_KEY_MSG = "msg";
+
+    public static MoatErrorDialogFragment newInstance(String message) {
+        MoatErrorDialogFragment fragment = new MoatErrorDialogFragment();
+        Bundle args = new Bundle();
+        args.putString(BUNDLE_KEY_MSG, message);
+        fragment.setArguments(args);
+        return fragment;
+    }
+
+    @Override
+    public Dialog onCreateDialog(Bundle savedInstanceState) {
+        return new AlertDialog.Builder(getContext())
+                .setTitle(R.string.error)
+                .setMessage(getArguments().getString(BUNDLE_KEY_MSG))
+                .setNegativeButton(R.string.btn_okay, null)
+                .create();
+    }
+}
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 df390a2f..83235e92 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
@@ -26,7 +26,6 @@ import android.widget.TextView;
 
 import androidx.annotation.NonNull;
 import androidx.appcompat.app.ActionBar;
-import androidx.appcompat.app.AlertDialog;
 import androidx.appcompat.app.AppCompatActivity;
 import androidx.appcompat.widget.Toolbar;
 import androidx.localbroadcastmanager.content.LocalBroadcastManager;
@@ -46,6 +45,7 @@ import org.torproject.android.R;
 import org.torproject.android.service.OrbotService;
 import org.torproject.android.service.TorServiceConstants;
 import org.torproject.android.service.util.Prefs;
+import org.torproject.android.ui.dialog.MoatErrorDialogFragment;
 
 /**
  Implements the MOAT protocol: Fetches OBFS4 bridges via Meek Azure.
@@ -435,11 +435,8 @@ public class MoatActivity extends AppCompatActivity implements View.OnClickListe
         mBtRequest.setEnabled(mIvCaptcha.getVisibility() == View.VISIBLE);
 
         if (!isFinishing()) {
-            new AlertDialog.Builder(this)
-                    .setTitle(R.string.error)
-                    .setMessage(TextUtils.isEmpty(detail) ? exception.getLocalizedMessage() : detail)
-                    .setNegativeButton(R.string.btn_okay, null)
-                    .show();
+            String message = TextUtils.isEmpty(detail) ? exception.getLocalizedMessage() : detail;
+            MoatErrorDialogFragment.newInstance(message).show(getSupportFragmentManager(), MoatErrorDialogFragment.TAG);
         }
     }
 }
diff --git a/app/src/main/res/layout/layout_about.xml b/app/src/main/res/layout/layout_about.xml
index ce1792b3..dca409c9 100644
--- a/app/src/main/res/layout/layout_about.xml
+++ b/app/src/main/res/layout/layout_about.xml
@@ -1,5 +1,7 @@
-<?xml version="1.0" encoding="utf-8"?>)
-            archivesBaseName = "Orbot-$versionName"
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
     android:orientation="vertical">
 
     <ScrollView



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