Android: Remove hardcoded strings from system update dialogs

This commit is contained in:
Charles Lombardo 2023-01-26 13:02:53 -05:00
parent 410aaef56e
commit 917ca2273e
5 changed files with 24 additions and 6 deletions

View File

@ -27,10 +27,14 @@ class OnlineUpdateRegionSelectDialogFragment : DialogFragment() {
viewModel.region = which viewModel.region = which
SystemUpdateProgressBarDialogFragment().show( SystemUpdateProgressBarDialogFragment().show(
parentFragmentManager, parentFragmentManager,
"OnlineUpdateProgressBarDialogFragment" SystemUpdateProgressBarDialogFragment.TAG
) )
dismiss() dismiss()
} }
.create() .create()
} }
companion object {
const val TAG = "OnlineUpdateRegionSelectDialogFragment"
}
} }

View File

@ -17,11 +17,15 @@ class SystemMenuNotInstalledDialogFragment : DialogFragment() {
.setPositiveButton(R.string.yes) { _: DialogInterface?, _: Int -> .setPositiveButton(R.string.yes) { _: DialogInterface?, _: Int ->
OnlineUpdateRegionSelectDialogFragment().show( OnlineUpdateRegionSelectDialogFragment().show(
parentFragmentManager, parentFragmentManager,
"OnlineUpdateRegionSelectDialogFragment" OnlineUpdateRegionSelectDialogFragment.TAG
) )
dismiss() dismiss()
} }
.setNegativeButton(R.string.no) { _: DialogInterface?, _: Int -> dismiss() } .setNegativeButton(R.string.no) { _: DialogInterface?, _: Int -> dismiss() }
.create() .create()
} }
companion object {
const val TAG = "SystemMenuNotInstalledDialogFragment"
}
} }

View File

@ -76,7 +76,7 @@ class SystemUpdateProgressBarDialogFragment : DialogFragment() {
} }
val progressBarFragment = SystemUpdateResultFragment() val progressBarFragment = SystemUpdateResultFragment()
progressBarFragment.show(parentFragmentManager, "OnlineUpdateResultFragment") progressBarFragment.show(parentFragmentManager, SystemUpdateResultFragment.TAG)
dismiss() dismiss()
} }
@ -100,4 +100,8 @@ class SystemUpdateProgressBarDialogFragment : DialogFragment() {
viewModel.setCanceled() viewModel.setCanceled()
} }
} }
companion object {
const val TAG = "SystemUpdateProgressBarDialogFragment"
}
} }

View File

@ -12,6 +12,8 @@ import org.dolphinemu.dolphinemu.R
import org.dolphinemu.dolphinemu.utils.WiiUtils import org.dolphinemu.dolphinemu.utils.WiiUtils
class SystemUpdateResultFragment : DialogFragment() { class SystemUpdateResultFragment : DialogFragment() {
private val resultKey = "result"
private var mResult = 0 private var mResult = 0
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
@ -20,7 +22,7 @@ class SystemUpdateResultFragment : DialogFragment() {
mResult = viewModel.resultData.value!!.toInt() mResult = viewModel.resultData.value!!.toInt()
viewModel.clear() viewModel.clear()
} else { } else {
mResult = savedInstanceState.getInt("result") mResult = savedInstanceState.getInt(resultKey)
} }
val message: String = when (mResult) { val message: String = when (mResult) {
WiiUtils.UPDATE_RESULT_SUCCESS -> getString(R.string.update_success) WiiUtils.UPDATE_RESULT_SUCCESS -> getString(R.string.update_success)
@ -56,6 +58,10 @@ class SystemUpdateResultFragment : DialogFragment() {
override fun onSaveInstanceState(outState: Bundle) { override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState) super.onSaveInstanceState(outState)
outState.putInt("result", mResult) outState.putInt(resultKey, mResult)
}
companion object {
const val TAG = "SystemUpdateResultFragment"
} }
} }

View File

@ -319,7 +319,7 @@ public final class MainPresenter
SystemUpdateProgressBarDialogFragment progressBarFragment = SystemUpdateProgressBarDialogFragment progressBarFragment =
new SystemUpdateProgressBarDialogFragment(); new SystemUpdateProgressBarDialogFragment();
progressBarFragment progressBarFragment
.show(activity.getSupportFragmentManager(), "SystemUpdateProgressBarDialogFragment"); .show(activity.getSupportFragmentManager(), SystemUpdateProgressBarDialogFragment.TAG);
progressBarFragment.setCancelable(false); progressBarFragment.setCancelable(false);
} }