[tor-commits] [orbot/master] confirm_service_deletion

n8fr8 at torproject.org n8fr8 at torproject.org
Thu Mar 2 04:10:21 UTC 2017


commit 07044f774833f448ab401458edd76a7477712bf7
Author: arrase <arrase at gmail.com>
Date:   Mon Nov 28 23:25:19 2016 +0100

    confirm_service_deletion
---
 .../ui/hiddenservices/HiddenServicesActivity.java  |  3 +-
 .../ui/hiddenservices/dialogs/HSActionsDialog.java |  7 ++--
 .../ui/hiddenservices/dialogs/HSDeleteDialog.java  | 44 ++++++++++++++++++++++
 app/src/main/res/values/strings.xml                |  1 +
 4 files changed, 49 insertions(+), 6 deletions(-)

diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java
index d752632..8e0e235 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/HiddenServicesActivity.java
@@ -15,7 +15,6 @@ import android.view.MenuItem;
 import android.view.View;
 import android.widget.AdapterView;
 import android.widget.ListView;
-import android.widget.TextView;
 
 import org.torproject.android.R;
 import org.torproject.android.ui.hiddenservices.adapters.OnionListAdapter;
@@ -79,7 +78,7 @@ public class HiddenServicesActivity extends AppCompatActivity {
                 );
 
                 arguments.putString(
-                        "onion",item.getString(item.getColumnIndex(HSContentProvider.HiddenService.DOMAIN))
+                        "onion", item.getString(item.getColumnIndex(HSContentProvider.HiddenService.DOMAIN))
                 );
 
                 HSActionsDialog dialog = new HSActionsDialog();
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSActionsDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSActionsDialog.java
index 7d79fb2..e1b9dd3 100644
--- a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSActionsDialog.java
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSActionsDialog.java
@@ -17,7 +17,6 @@ import android.widget.Toast;
 
 import org.torproject.android.R;
 import org.torproject.android.ui.hiddenservices.backup.BackupUtils;
-import org.torproject.android.ui.hiddenservices.providers.HSContentProvider;
 import org.torproject.android.ui.hiddenservices.storage.PermissionManager;
 
 public class HSActionsDialog extends DialogFragment {
@@ -87,9 +86,9 @@ public class HSActionsDialog extends DialogFragment {
         Button delete = (Button) dialog_view.findViewById(R.id.btn_hs_delete);
         delete.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
-                v.getContext().getContentResolver().delete(
-                        HSContentProvider.CONTENT_URI, "port=" + arguments.getString("port"), null
-                );
+                HSDeleteDialog dialog = new HSDeleteDialog();
+                dialog.setArguments(arguments);
+                dialog.show(getFragmentManager(), "HSDeleteDialog");
                 actionDialog.dismiss();
             }
         });
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDeleteDialog.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDeleteDialog.java
new file mode 100644
index 0000000..3523e85
--- /dev/null
+++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/dialogs/HSDeleteDialog.java
@@ -0,0 +1,44 @@
+package org.torproject.android.ui.hiddenservices.dialogs;
+
+
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v4.app.DialogFragment;
+import android.support.v7.app.AlertDialog;
+
+import org.torproject.android.R;
+import org.torproject.android.ui.hiddenservices.providers.HSContentProvider;
+
+public class HSDeleteDialog extends DialogFragment {
+
+    @NonNull
+    @Override
+    public Dialog onCreateDialog(Bundle savedInstanceState) {
+        final Bundle arguments = getArguments();
+
+        DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
+            @Override
+            public void onClick(DialogInterface dialog, int which) {
+                switch (which) {
+                    case DialogInterface.BUTTON_POSITIVE:
+                        getActivity().getContentResolver().delete(
+                                HSContentProvider.CONTENT_URI, "port=" + arguments.getString("port"), null
+                        );
+                        break;
+
+                    case DialogInterface.BUTTON_NEGATIVE:
+                        // Do nothing
+                        break;
+                }
+            }
+        };
+
+        return new AlertDialog.Builder(getActivity())
+                .setMessage(R.string.confirm_service_deletion)
+                .setPositiveButton(R.string.btn_okay, dialogClickListener)
+                .setNegativeButton(R.string.btn_cancel, dialogClickListener)
+                .create();
+    }
+}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index bab15f1..e6294b1 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -352,4 +352,5 @@
     <string name="create_a_backup_first">Create a backup first</string>
     <string name="name_can_t_be_empty">Name can\'t be empty</string>
     <string name="start_tor_again_for_finish_the_process">Start Tor again for finish the process</string>
+    <string name="confirm_service_deletion">Confirm service deletion</string>
 </resources>





More information about the tor-commits mailing list