From 6e75e0bfc5c58954734e7aca8ee390f869470709 Mon Sep 17 00:00:00 2001 From: Prat Date: Mon, 1 Oct 2018 02:50:48 -0400 Subject: [PATCH] Add deletion confirmation (#865) --- .../keylesspalace/tusky/fragment/SFragment.java | 16 ++++++++++++---- app/src/main/res/values/strings.xml | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java index 417765b3..c6ec2ceb 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java @@ -23,6 +23,7 @@ import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.ActivityOptionsCompat; import android.support.v4.view.ViewCompat; +import android.support.v7.app.AlertDialog; import android.support.v7.widget.PopupMenu; import android.text.Spanned; import android.view.Menu; @@ -32,7 +33,6 @@ import com.keylesspalace.tusky.BottomSheetActivity; import com.keylesspalace.tusky.ComposeActivity; import com.keylesspalace.tusky.R; import com.keylesspalace.tusky.ReportActivity; -import com.keylesspalace.tusky.TuskyApplication; import com.keylesspalace.tusky.ViewMediaActivity; import com.keylesspalace.tusky.ViewTagActivity; import com.keylesspalace.tusky.ViewVideoActivity; @@ -210,8 +210,7 @@ public abstract class SFragment extends BaseFragment { return true; } case R.id.status_delete: { - timelineCases().delete(id); - removeItem(position); + showConfirmDeleteDialog(id, position); return true; } } @@ -273,5 +272,14 @@ public abstract class SFragment extends BaseFragment { startActivity(intent); } - + protected void showConfirmDeleteDialog(final String id, final int position) { + new AlertDialog.Builder(getActivity()) + .setMessage(R.string.dialog_delete_toot_warning) + .setPositiveButton(android.R.string.ok, (dialogInterface, i) -> { + timelineCases().delete(id); + removeItem(position); + }) + .setNegativeButton(android.R.string.cancel, null) + .show(); + } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b5ee921c..1643bae5 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -153,6 +153,7 @@ Download Revoke the follow request? Unfollow this account? + Delete this toot? Public: Post to public timelines Unlisted: Do not show in public timelines