diff options
| author | 2023-05-29 01:34:09 -0400 | |
|---|---|---|
| committer | 2023-06-03 00:06:05 -0700 | |
| commit | 897b748895a555a19f79a88c02f1886d4ac44c88 (patch) | |
| tree | 57d243efae6a728911eb4baf776110a4e3d4321b /src | |
| parent | android: Upgrade AGP to 8.0.2 (diff) | |
| download | yuzu-897b748895a555a19f79a88c02f1886d4ac44c88.tar.gz yuzu-897b748895a555a19f79a88c02f1886d4ac44c88.tar.xz yuzu-897b748895a555a19f79a88c02f1886d4ac44c88.zip | |
android: Use dialog fragment for the reset settings dialog
Diffstat (limited to 'src')
2 files changed, 37 insertions, 12 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt index 14ae513e2..d9abc358a 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/ui/SettingsFragmentPresenter.kt | |||
| @@ -19,6 +19,7 @@ import org.yuzu.yuzu_emu.features.settings.model.Settings | |||
| 19 | import org.yuzu.yuzu_emu.features.settings.model.StringSetting | 19 | import org.yuzu.yuzu_emu.features.settings.model.StringSetting |
| 20 | import org.yuzu.yuzu_emu.features.settings.model.view.* | 20 | import org.yuzu.yuzu_emu.features.settings.model.view.* |
| 21 | import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile | 21 | import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile |
| 22 | import org.yuzu.yuzu_emu.fragments.ResetSettingsDialogFragment | ||
| 22 | import org.yuzu.yuzu_emu.utils.ThemeHelper | 23 | import org.yuzu.yuzu_emu.utils.ThemeHelper |
| 23 | 24 | ||
| 24 | class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) { | 25 | class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) { |
| @@ -115,7 +116,12 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) | |||
| 115 | RunnableSetting( | 116 | RunnableSetting( |
| 116 | R.string.reset_to_default, | 117 | R.string.reset_to_default, |
| 117 | 0 | 118 | 0 |
| 118 | ) { resetSettings() } | 119 | ) { |
| 120 | ResetSettingsDialogFragment().show( | ||
| 121 | settingsActivity.supportFragmentManager, | ||
| 122 | ResetSettingsDialogFragment.TAG | ||
| 123 | ) | ||
| 124 | } | ||
| 119 | ) | 125 | ) |
| 120 | } | 126 | } |
| 121 | } | 127 | } |
| @@ -444,15 +450,4 @@ class SettingsFragmentPresenter(private val fragmentView: SettingsFragmentView) | |||
| 444 | ) | 450 | ) |
| 445 | } | 451 | } |
| 446 | } | 452 | } |
| 447 | |||
| 448 | private fun resetSettings() { | ||
| 449 | MaterialAlertDialogBuilder(settingsActivity) | ||
| 450 | .setTitle(R.string.reset_all_settings) | ||
| 451 | .setMessage(R.string.reset_all_settings_description) | ||
| 452 | .setPositiveButton(android.R.string.ok) { _, _ -> | ||
| 453 | settingsActivity.onSettingsReset() | ||
| 454 | } | ||
| 455 | .setNegativeButton(android.R.string.cancel, null) | ||
| 456 | .show() | ||
| 457 | } | ||
| 458 | } | 453 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/ResetSettingsDialogFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/ResetSettingsDialogFragment.kt new file mode 100644 index 000000000..1b4b93ab8 --- /dev/null +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/ResetSettingsDialogFragment.kt | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | package org.yuzu.yuzu_emu.fragments | ||
| 5 | |||
| 6 | import android.app.Dialog | ||
| 7 | import android.os.Bundle | ||
| 8 | import androidx.fragment.app.DialogFragment | ||
| 9 | import com.google.android.material.dialog.MaterialAlertDialogBuilder | ||
| 10 | import org.yuzu.yuzu_emu.R | ||
| 11 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsActivity | ||
| 12 | |||
| 13 | class ResetSettingsDialogFragment : DialogFragment() { | ||
| 14 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
| 15 | val settingsActivity = requireActivity() as SettingsActivity | ||
| 16 | |||
| 17 | return MaterialAlertDialogBuilder(requireContext()) | ||
| 18 | .setTitle(R.string.reset_all_settings) | ||
| 19 | .setMessage(R.string.reset_all_settings_description) | ||
| 20 | .setPositiveButton(android.R.string.ok) { _, _ -> | ||
| 21 | settingsActivity.onSettingsReset() | ||
| 22 | } | ||
| 23 | .setNegativeButton(android.R.string.cancel, null) | ||
| 24 | .show() | ||
| 25 | } | ||
| 26 | |||
| 27 | companion object { | ||
| 28 | const val TAG = "ResetSettingsDialogFragment" | ||
| 29 | } | ||
| 30 | } | ||