VERY experimental Nintendo Switch 2 emulator
C++
android: Fix cancel behavior on indeterminate progress dialog fragment
Charles Lombardoc44545c6d2cc
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/IndeterminateProgressDialogFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/IndeterminateProgressDialogFragment.ktindex 0d16a7d370..f128deda8a 100644--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/IndeterminateProgressDialogFragment.kt+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/IndeterminateProgressDialogFragment.kt@@ -4,12 +4,12 @@package org.yuzu.yuzu_emu.fragmentsimport android.app.Dialog-import android.content.DialogInterfaceimport android.os.Bundleimport android.view.LayoutInflaterimport android.view.Viewimport android.view.ViewGroupimport android.widget.Toast+import androidx.appcompat.app.AlertDialogimport androidx.appcompat.app.AppCompatActivityimport androidx.fragment.app.DialogFragmentimport androidx.fragment.app.activityViewModels@@ -39,9 +39,7 @@ class IndeterminateProgressDialogFragment : DialogFragment() {.setView(binding.root)if (cancellable) {- dialog.setNegativeButton(android.R.string.cancel) { _: DialogInterface, _: Int ->- taskViewModel.setCancelled(true)- }+ dialog.setNegativeButton(android.R.string.cancel, null)}val alertDialog = dialog.create()@@ -98,6 +96,18 @@ class IndeterminateProgressDialogFragment : DialogFragment() {}}+ // By default, the ProgressDialog will immediately dismiss itself upon a button being pressed.+ // Setting the OnClickListener again after the dialog is shown overrides this behavior.+ override fun onResume() {+ super.onResume()+ val alertDialog = dialog as AlertDialog+ val negativeButton = alertDialog.getButton(Dialog.BUTTON_NEGATIVE)+ negativeButton.setOnClickListener {+ alertDialog.setTitle(getString(R.string.cancelling))+ taskViewModel.setCancelled(true)+ }+ }+companion object {const val TAG = "IndeterminateProgressDialogFragment"