diff options
author | t895 <clombardo169@gmail.com> | 2023-12-12 19:58:25 +0100 |
---|---|---|
committer | t895 <clombardo169@gmail.com> | 2023-12-12 23:25:37 +0100 |
commit | 345fb6b22636d2677f9bcb6113d81a4833aadd5c (patch) | |
tree | 7d0855a3f71d0c82fb4a30d5b02a2aea226697a5 | |
parent | android: Always use custom settings when launched from intent (diff) | |
download | yuzu-345fb6b22636d2677f9bcb6113d81a4833aadd5c.tar yuzu-345fb6b22636d2677f9bcb6113d81a4833aadd5c.tar.gz yuzu-345fb6b22636d2677f9bcb6113d81a4833aadd5c.tar.bz2 yuzu-345fb6b22636d2677f9bcb6113d81a4833aadd5c.tar.lz yuzu-345fb6b22636d2677f9bcb6113d81a4833aadd5c.tar.xz yuzu-345fb6b22636d2677f9bcb6113d81a4833aadd5c.tar.zst yuzu-345fb6b22636d2677f9bcb6113d81a4833aadd5c.zip |
3 files changed, 45 insertions, 15 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt index e062425a1..6ede3f85c 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/GamePropertiesFragment.kt @@ -3,6 +3,7 @@ package org.yuzu.yuzu_emu.fragments +import android.annotation.SuppressLint import android.os.Bundle import android.text.TextUtils import android.view.LayoutInflater @@ -73,6 +74,8 @@ class GamePropertiesFragment : Fragment() { return binding.root } + // This is using the correct scope, lint is just acting up + @SuppressLint("UnsafeRepeatOnLifecycleDetector") override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) homeViewModel.setNavigationVisibility(visible = false, animated = true) @@ -99,12 +102,24 @@ class GamePropertiesFragment : Fragment() { reloadList() - viewLifecycleOwner.lifecycleScope.launch { - repeatOnLifecycle(Lifecycle.State.STARTED) { - homeViewModel.openImportSaves.collect { - if (it) { - importSaves.launch(arrayOf("application/zip")) - homeViewModel.setOpenImportSaves(false) + viewLifecycleOwner.lifecycleScope.apply { + launch { + repeatOnLifecycle(Lifecycle.State.STARTED) { + homeViewModel.openImportSaves.collect { + if (it) { + importSaves.launch(arrayOf("application/zip")) + homeViewModel.setOpenImportSaves(false) + } + } + } + } + launch { + repeatOnLifecycle(Lifecycle.State.STARTED) { + homeViewModel.reloadPropertiesList.collect { + if (it) { + reloadList() + homeViewModel.reloadPropertiesList(false) + } } } } @@ -214,7 +229,7 @@ class GamePropertiesFragment : Fragment() { R.string.save_data_deleted_successfully, Toast.LENGTH_SHORT ).show() - reloadList() + homeViewModel.reloadPropertiesList(true) } ).show(parentFragmentManager, MessageDialogFragment.TAG) } @@ -242,13 +257,20 @@ class GamePropertiesFragment : Fragment() { } } ) { - shaderCacheDir.deleteRecursively() - Toast.makeText( - YuzuApplication.appContext, - R.string.cleared_shaders_successfully, - Toast.LENGTH_SHORT - ).show() - reloadList() + MessageDialogFragment.newInstance( + requireActivity(), + titleId = R.string.clear_shader_cache, + descriptionId = R.string.clear_shader_cache_warning_description, + positiveAction = { + shaderCacheDir.deleteRecursively() + Toast.makeText( + YuzuApplication.appContext, + R.string.cleared_shaders_successfully, + Toast.LENGTH_SHORT + ).show() + homeViewModel.reloadPropertiesList(true) + } + ).show(parentFragmentManager, MessageDialogFragment.TAG) } ) } @@ -388,7 +410,7 @@ class GamePropertiesFragment : Fragment() { getString(R.string.save_file_imported_success), Toast.LENGTH_LONG ).show() - reloadList() + homeViewModel.reloadPropertiesList(true) } cacheSaveDir.deleteRecursively() diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt index d801db105..513ac2fc5 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/model/HomeViewModel.kt @@ -28,6 +28,9 @@ class HomeViewModel : ViewModel() { private val _contentToInstall = MutableStateFlow<List<Uri>?>(null) val contentToInstall get() = _contentToInstall.asStateFlow() + private val _reloadPropertiesList = MutableStateFlow(false) + val reloadPropertiesList get() = _reloadPropertiesList.asStateFlow() + var navigatedToSetup = false fun setNavigationVisibility(visible: Boolean, animated: Boolean) { @@ -59,4 +62,8 @@ class HomeViewModel : ViewModel() { fun setContentToInstall(documents: List<Uri>?) { _contentToInstall.value = documents } + + fun reloadPropertiesList(reload: Boolean) { + _reloadPropertiesList.value = reload + } } diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index 50879b3a3..c86c43df2 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml @@ -314,6 +314,7 @@ <string name="add_ons_description">Toggle mods, updates and DLC</string> <string name="clear_shader_cache">Clear shader cache</string> <string name="clear_shader_cache_description">Removes all shaders built while playing this game</string> + <string name="clear_shader_cache_warning_description">You will experience more stuttering as the shader cache regenerates</string> <string name="cleared_shaders_successfully">Cleared shaders successfully</string> <string name="addons_game">Addons: %1$s</string> <string name="save_data">Save data</string> |