android: Adjust import/export saves dialog

This commit is contained in:
Charles Lombardo 2023-06-01 23:56:14 -04:00 committed by bunnei
parent 20abd49a21
commit c927a30d09
3 changed files with 21 additions and 15 deletions

View file

@ -99,7 +99,7 @@ class HomeSettingsFragment : Fragment() {
R.drawable.ic_add R.drawable.ic_add
) { mainActivity.getGamesDirectory.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).data) }, ) { mainActivity.getGamesDirectory.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).data) },
HomeSetting( HomeSetting(
R.string.import_export_saves, R.string.manage_save_data,
R.string.import_export_saves_description, R.string.import_export_saves_description,
R.drawable.ic_save R.drawable.ic_save
) { ImportExportSavesFragment().show(parentFragmentManager, ImportExportSavesFragment.TAG) }, ) { ImportExportSavesFragment().show(parentFragmentManager, ImportExportSavesFragment.TAG) },

View file

@ -68,19 +68,21 @@ class ImportExportSavesFragment : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return if (savesFolderRoot == "") { return if (savesFolderRoot == "") {
MaterialAlertDialogBuilder(requireContext()) MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.import_export_saves) .setTitle(R.string.manage_save_data)
.setMessage(R.string.import_export_saves_no_profile) .setMessage(R.string.import_export_saves_no_profile)
.setPositiveButton(android.R.string.ok, null) .setPositiveButton(android.R.string.ok, null)
.show() .show()
} else { } else {
MaterialAlertDialogBuilder(requireContext()) MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.import_export_saves) .setTitle(R.string.manage_save_data)
.setPositiveButton(R.string.export_saves) { _, _ -> .setMessage(R.string.manage_save_data_description)
.setNegativeButton(R.string.export_saves) { _, _ ->
exportSave() exportSave()
} }
.setNeutralButton(R.string.import_saves) { _, _ -> .setPositiveButton(R.string.import_saves) { _, _ ->
documentPicker.launch(arrayOf("application/zip")) documentPicker.launch(arrayOf("application/zip"))
} }
.setNeutralButton(android.R.string.cancel, null)
.show() .show()
} }
} }
@ -95,7 +97,10 @@ class ImportExportSavesFragment : DialogFragment() {
tempFolder.mkdirs() tempFolder.mkdirs()
val saveFolder = File(savesFolderRoot) val saveFolder = File(savesFolderRoot)
val outputZipFile = File( val outputZipFile = File(
tempFolder, "yuzu saves - ${LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))}.zip" tempFolder,
"yuzu saves - ${
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))
}.zip"
) )
outputZipFile.createNewFile() outputZipFile.createNewFile()
ZipOutputStream(BufferedOutputStream(FileOutputStream(outputZipFile))).use { zos -> ZipOutputStream(BufferedOutputStream(FileOutputStream(outputZipFile))).use { zos ->
@ -206,11 +211,10 @@ class ImportExportSavesFragment : DialogFragment() {
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
if (!validZip) { if (!validZip) {
Toast.makeText( MessageDialogFragment.newInstance(
context, R.string.save_file_invalid_zip_structure,
context.getString(R.string.save_file_invalid_zip_structure), R.string.save_file_invalid_zip_structure_description
Toast.LENGTH_LONG ).show(childFragmentManager, MessageDialogFragment.TAG)
).show()
return@withContext return@withContext
} }
Toast.makeText( Toast.makeText(

View file

@ -87,11 +87,13 @@
<string name="no_file_manager">No file manager found</string> <string name="no_file_manager">No file manager found</string>
<string name="notification_no_directory_link">Could not open yuzu directory</string> <string name="notification_no_directory_link">Could not open yuzu directory</string>
<string name="notification_no_directory_link_description">Please locate the user folder with the file manager\'s side panel manually.</string> <string name="notification_no_directory_link_description">Please locate the user folder with the file manager\'s side panel manually.</string>
<string name="import_export_saves">Import/export saves</string> <string name="manage_save_data">Manage save data</string>
<string name="manage_save_data_description">Save data found. Please select an option below.</string>
<string name="import_export_saves_description">Import or export save files</string> <string name="import_export_saves_description">Import or export save files</string>
<string name="import_export_saves_no_profile">No user profile found. Please launch a game first and retry.</string> <string name="import_export_saves_no_profile">No save data found. Please launch a game and retry.</string>
<string name="save_file_imported_success">Save files were imported successfully</string> <string name="save_file_imported_success">Imported successfully</string>
<string name="save_file_invalid_zip_structure">Invalid save directory structure: The first subfolder name must be the title ID of the game.</string> <string name="save_file_invalid_zip_structure">Invalid save directory structure</string>
<string name="save_file_invalid_zip_structure_description">The first subfolder name must be the title ID of the game.</string>
<string name="import_saves">Import</string> <string name="import_saves">Import</string>
<string name="export_saves">Export</string> <string name="export_saves">Export</string>