mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-22 17:05:37 +01:00
android: Use confirmation dialog when deleting shader cache
This commit is contained in:
parent
87a9dc9489
commit
345fb6b226
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
package org.yuzu.yuzu_emu.fragments
|
package org.yuzu.yuzu_emu.fragments
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@ -73,6 +74,8 @@ class GamePropertiesFragment : Fragment() {
|
|||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is using the correct scope, lint is just acting up
|
||||||
|
@SuppressLint("UnsafeRepeatOnLifecycleDetector")
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
homeViewModel.setNavigationVisibility(visible = false, animated = true)
|
homeViewModel.setNavigationVisibility(visible = false, animated = true)
|
||||||
@ -99,12 +102,24 @@ class GamePropertiesFragment : Fragment() {
|
|||||||
|
|
||||||
reloadList()
|
reloadList()
|
||||||
|
|
||||||
viewLifecycleOwner.lifecycleScope.launch {
|
viewLifecycleOwner.lifecycleScope.apply {
|
||||||
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
launch {
|
||||||
homeViewModel.openImportSaves.collect {
|
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||||
if (it) {
|
homeViewModel.openImportSaves.collect {
|
||||||
importSaves.launch(arrayOf("application/zip"))
|
if (it) {
|
||||||
homeViewModel.setOpenImportSaves(false)
|
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,
|
R.string.save_data_deleted_successfully,
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
reloadList()
|
homeViewModel.reloadPropertiesList(true)
|
||||||
}
|
}
|
||||||
).show(parentFragmentManager, MessageDialogFragment.TAG)
|
).show(parentFragmentManager, MessageDialogFragment.TAG)
|
||||||
}
|
}
|
||||||
@ -242,13 +257,20 @@ class GamePropertiesFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
shaderCacheDir.deleteRecursively()
|
MessageDialogFragment.newInstance(
|
||||||
Toast.makeText(
|
requireActivity(),
|
||||||
YuzuApplication.appContext,
|
titleId = R.string.clear_shader_cache,
|
||||||
R.string.cleared_shaders_successfully,
|
descriptionId = R.string.clear_shader_cache_warning_description,
|
||||||
Toast.LENGTH_SHORT
|
positiveAction = {
|
||||||
).show()
|
shaderCacheDir.deleteRecursively()
|
||||||
reloadList()
|
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),
|
getString(R.string.save_file_imported_success),
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
).show()
|
).show()
|
||||||
reloadList()
|
homeViewModel.reloadPropertiesList(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheSaveDir.deleteRecursively()
|
cacheSaveDir.deleteRecursively()
|
||||||
|
@ -28,6 +28,9 @@ class HomeViewModel : ViewModel() {
|
|||||||
private val _contentToInstall = MutableStateFlow<List<Uri>?>(null)
|
private val _contentToInstall = MutableStateFlow<List<Uri>?>(null)
|
||||||
val contentToInstall get() = _contentToInstall.asStateFlow()
|
val contentToInstall get() = _contentToInstall.asStateFlow()
|
||||||
|
|
||||||
|
private val _reloadPropertiesList = MutableStateFlow(false)
|
||||||
|
val reloadPropertiesList get() = _reloadPropertiesList.asStateFlow()
|
||||||
|
|
||||||
var navigatedToSetup = false
|
var navigatedToSetup = false
|
||||||
|
|
||||||
fun setNavigationVisibility(visible: Boolean, animated: Boolean) {
|
fun setNavigationVisibility(visible: Boolean, animated: Boolean) {
|
||||||
@ -59,4 +62,8 @@ class HomeViewModel : ViewModel() {
|
|||||||
fun setContentToInstall(documents: List<Uri>?) {
|
fun setContentToInstall(documents: List<Uri>?) {
|
||||||
_contentToInstall.value = documents
|
_contentToInstall.value = documents
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun reloadPropertiesList(reload: Boolean) {
|
||||||
|
_reloadPropertiesList.value = reload
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -314,6 +314,7 @@
|
|||||||
<string name="add_ons_description">Toggle mods, updates and DLC</string>
|
<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">Clear shader cache</string>
|
||||||
<string name="clear_shader_cache_description">Removes all shaders built while playing this game</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="cleared_shaders_successfully">Cleared shaders successfully</string>
|
||||||
<string name="addons_game">Addons: %1$s</string>
|
<string name="addons_game">Addons: %1$s</string>
|
||||||
<string name="save_data">Save data</string>
|
<string name="save_data">Save data</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user