summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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() {
26 val descriptionId = requireArguments().getInt(DESCRIPTION_ID) 26 val descriptionId = requireArguments().getInt(DESCRIPTION_ID)
27 val descriptionString = requireArguments().getString(DESCRIPTION_STRING)!! 27 val descriptionString = requireArguments().getString(DESCRIPTION_STRING)!!
28 val helpLinkId = requireArguments().getInt(HELP_LINK) 28 val helpLinkId = requireArguments().getInt(HELP_LINK)
29 val dismissible = requireArguments().getBoolean(DISMISSIBLE)
30 val clearPositiveAction = requireArguments().getBoolean(CLEAR_POSITIVE_ACTION)
29 31
30 val builder = MaterialAlertDialogBuilder(requireContext()) 32 val builder = MaterialAlertDialogBuilder(requireContext())
31 33
34 if (clearPositiveAction) {
35 messageDialogViewModel.positiveAction = null
36 }
37
32 if (messageDialogViewModel.positiveAction == null) { 38 if (messageDialogViewModel.positiveAction == null) {
33 builder.setPositiveButton(R.string.close, null) 39 builder.setPositiveButton(R.string.close, null)
34 } else { 40 } else {
@@ -51,6 +57,8 @@ class MessageDialogFragment : DialogFragment() {
51 } 57 }
52 } 58 }
53 59
60 isCancelable = dismissible
61
54 return builder.show() 62 return builder.show()
55 } 63 }
56 64
@@ -67,6 +75,8 @@ class MessageDialogFragment : DialogFragment() {
67 private const val DESCRIPTION_ID = "DescriptionId" 75 private const val DESCRIPTION_ID = "DescriptionId"
68 private const val DESCRIPTION_STRING = "DescriptionString" 76 private const val DESCRIPTION_STRING = "DescriptionString"
69 private const val HELP_LINK = "Link" 77 private const val HELP_LINK = "Link"
78 private const val DISMISSIBLE = "Dismissible"
79 private const val CLEAR_POSITIVE_ACTION = "ClearPositiveAction"
70 80
71 fun newInstance( 81 fun newInstance(
72 activity: FragmentActivity? = null, 82 activity: FragmentActivity? = null,
@@ -75,22 +85,28 @@ class MessageDialogFragment : DialogFragment() {
75 descriptionId: Int = 0, 85 descriptionId: Int = 0,
76 descriptionString: String = "", 86 descriptionString: String = "",
77 helpLinkId: Int = 0, 87 helpLinkId: Int = 0,
88 dismissible: Boolean = true,
78 positiveAction: (() -> Unit)? = null 89 positiveAction: (() -> Unit)? = null
79 ): MessageDialogFragment { 90 ): MessageDialogFragment {
91 var clearPositiveAction = false
92 if (activity != null) {
93 ViewModelProvider(activity)[MessageDialogViewModel::class.java].apply {
94 clear()
95 this.positiveAction = positiveAction
96 }
97 } else {
98 clearPositiveAction = true
99 }
100
80 val dialog = MessageDialogFragment() 101 val dialog = MessageDialogFragment()
81 val bundle = Bundle() 102 val bundle = Bundle().apply {
82 bundle.apply {
83 putInt(TITLE_ID, titleId) 103 putInt(TITLE_ID, titleId)
84 putString(TITLE_STRING, titleString) 104 putString(TITLE_STRING, titleString)
85 putInt(DESCRIPTION_ID, descriptionId) 105 putInt(DESCRIPTION_ID, descriptionId)
86 putString(DESCRIPTION_STRING, descriptionString) 106 putString(DESCRIPTION_STRING, descriptionString)
87 putInt(HELP_LINK, helpLinkId) 107 putInt(HELP_LINK, helpLinkId)
88 } 108 putBoolean(DISMISSIBLE, dismissible)
89 if (activity != null) { 109 putBoolean(CLEAR_POSITIVE_ACTION, clearPositiveAction)
90 ViewModelProvider(activity)[MessageDialogViewModel::class.java].apply {
91 clear()
92 this.positiveAction = positiveAction
93 }
94 } 110 }
95 dialog.arguments = bundle 111 dialog.arguments = bundle
96 return dialog 112 return dialog