summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authort895 <clombardo169@gmail.com>2024-01-24 18:38:12 +0100
committert895 <clombardo169@gmail.com>2024-01-25 18:53:49 +0100
commitbc317a9807dec79cbbfe4d0affa215a0b69bec8c (patch)
treeaada9cb1f90951ab6d76f321bd59f89e960cca33 /src
parentfrontend_common: Consistently use references (diff)
downloadyuzu-bc317a9807dec79cbbfe4d0affa215a0b69bec8c.tar
yuzu-bc317a9807dec79cbbfe4d0affa215a0b69bec8c.tar.gz
yuzu-bc317a9807dec79cbbfe4d0affa215a0b69bec8c.tar.bz2
yuzu-bc317a9807dec79cbbfe4d0affa215a0b69bec8c.tar.lz
yuzu-bc317a9807dec79cbbfe4d0affa215a0b69bec8c.tar.xz
yuzu-bc317a9807dec79cbbfe4d0affa215a0b69bec8c.tar.zst
yuzu-bc317a9807dec79cbbfe4d0affa215a0b69bec8c.zip
Diffstat (limited to '')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/MessageDialogFragment.kt32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/MessageDialogFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/MessageDialogFragment.kt
index 620d8db7c..22b084b9a 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/MessageDialogFragment.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/MessageDialogFragment.kt
@@ -26,9 +26,15 @@ class MessageDialogFragment : DialogFragment() {
val descriptionId = requireArguments().getInt(DESCRIPTION_ID)
val descriptionString = requireArguments().getString(DESCRIPTION_STRING)!!
val helpLinkId = requireArguments().getInt(HELP_LINK)
+ val dismissible = requireArguments().getBoolean(DISMISSIBLE)
+ val clearPositiveAction = requireArguments().getBoolean(CLEAR_POSITIVE_ACTION)
val builder = MaterialAlertDialogBuilder(requireContext())
+ if (clearPositiveAction) {
+ messageDialogViewModel.positiveAction = null
+ }
+
if (messageDialogViewModel.positiveAction == null) {
builder.setPositiveButton(R.string.close, null)
} else {
@@ -51,6 +57,8 @@ class MessageDialogFragment : DialogFragment() {
}
}
+ isCancelable = dismissible
+
return builder.show()
}
@@ -67,6 +75,8 @@ class MessageDialogFragment : DialogFragment() {
private const val DESCRIPTION_ID = "DescriptionId"
private const val DESCRIPTION_STRING = "DescriptionString"
private const val HELP_LINK = "Link"
+ private const val DISMISSIBLE = "Dismissible"
+ private const val CLEAR_POSITIVE_ACTION = "ClearPositiveAction"
fun newInstance(
activity: FragmentActivity? = null,
@@ -75,22 +85,28 @@ class MessageDialogFragment : DialogFragment() {
descriptionId: Int = 0,
descriptionString: String = "",
helpLinkId: Int = 0,
+ dismissible: Boolean = true,
positiveAction: (() -> Unit)? = null
): MessageDialogFragment {
+ var clearPositiveAction = false
+ if (activity != null) {
+ ViewModelProvider(activity)[MessageDialogViewModel::class.java].apply {
+ clear()
+ this.positiveAction = positiveAction
+ }
+ } else {
+ clearPositiveAction = true
+ }
+
val dialog = MessageDialogFragment()
- val bundle = Bundle()
- bundle.apply {
+ val bundle = Bundle().apply {
putInt(TITLE_ID, titleId)
putString(TITLE_STRING, titleString)
putInt(DESCRIPTION_ID, descriptionId)
putString(DESCRIPTION_STRING, descriptionString)
putInt(HELP_LINK, helpLinkId)
- }
- if (activity != null) {
- ViewModelProvider(activity)[MessageDialogViewModel::class.java].apply {
- clear()
- this.positiveAction = positiveAction
- }
+ putBoolean(DISMISSIBLE, dismissible)
+ putBoolean(CLEAR_POSITIVE_ACTION, clearPositiveAction)
}
dialog.arguments = bundle
return dialog