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 d7526324..8e0e2356 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 7d79fb29..e1b9dd3c 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 00000000..3523e856 --- /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 bab15f14..e6294b1d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -352,4 +352,5 @@ Create a backup first Name can\'t be empty Start Tor again for finish the process + Confirm service deletion