1
0
Fork 0
forked from suyu/suyu

android: Allow importing saves even if no saves are found

Exporting still won't be allowed on an empty save directory.
This commit is contained in:
Charles Lombardo 2023-09-20 15:00:34 -04:00
parent 1fae4a01a8
commit bdb4fd208f

View file

@ -65,27 +65,22 @@ class ImportExportSavesFragment : DialogFragment() {
} }
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return if (savesFolderRoot == "") { val builder = MaterialAlertDialogBuilder(requireContext())
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.manage_save_data) .setTitle(R.string.manage_save_data)
.setMessage(R.string.import_export_saves_no_profile)
.setPositiveButton(android.R.string.ok, null)
.show()
} else {
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.manage_save_data)
.setMessage(R.string.manage_save_data_description)
.setNegativeButton(R.string.export_saves) { _, _ ->
exportSave()
}
.setPositiveButton(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) .setNeutralButton(android.R.string.cancel, null)
.show()
if (savesFolderRoot != "") {
builder.setNegativeButton(R.string.export_saves) { _, _ ->
exportSave()
} }
} }
return builder.show()
}
/** /**
* Zips the save files located in the given folder path and creates a new zip file with the current date and time. * Zips the save files located in the given folder path and creates a new zip file with the current date and time.
* @return true if the zip file is successfully created, false otherwise. * @return true if the zip file is successfully created, false otherwise.