From c57d57293624b0a0a4eb2540e1f090839d86adea Mon Sep 17 00:00:00 2001 From: PabloG02 Date: Fri, 7 Apr 2023 23:00:07 +0200 Subject: [PATCH] Show dialog before deleting save --- app/src/main/java/emu/skyline/AppDialog.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/emu/skyline/AppDialog.kt b/app/src/main/java/emu/skyline/AppDialog.kt index 4453cef7..144a8377 100644 --- a/app/src/main/java/emu/skyline/AppDialog.kt +++ b/app/src/main/java/emu/skyline/AppDialog.kt @@ -17,6 +17,7 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.activity.result.contract.ActivityResultContracts +import androidx.appcompat.app.AlertDialog import androidx.documentfile.provider.DocumentFile import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialogFragment @@ -132,9 +133,17 @@ class AppDialog : BottomSheetDialogFragment() { binding.deleteSave.isEnabled = saveExists binding.deleteSave.setOnClickListener { - File(saveFolderPath).deleteRecursively() - binding.deleteSave.isEnabled = false - binding.exportSave.isEnabled = false + AlertDialog.Builder(requireContext()) + .setTitle("Are you sure you want to delete this save?") + .setMessage("This action is irreversible.") + .setPositiveButton("Yes") { dialogInterface, _ -> + File(saveFolderPath).deleteRecursively() + binding.deleteSave.isEnabled = false + binding.exportSave.isEnabled = false + dialogInterface.dismiss() + }.setNegativeButton("No") { dialogInterface, _ -> + dialogInterface.cancel() + }.show() } binding.importSave.setOnClickListener {