This commit is contained in:
LagradOst 2022-03-11 16:18:59 +01:00
parent 3bad9cad5e
commit 8bbb20557f

View file

@ -29,7 +29,7 @@ import java.text.SimpleDateFormat
import java.util.* import java.util.*
object BackupUtils { object BackupUtils {
var restoreFileSelector: ActivityResultLauncher<String>? = null var restoreFileSelector: ActivityResultLauncher<Array<String>>? = null
// Kinda hack, but I couldn't think of a better way // Kinda hack, but I couldn't think of a better way
data class BackupVars( data class BackupVars(
@ -143,7 +143,7 @@ object BackupUtils {
fun FragmentActivity.setUpBackup() { fun FragmentActivity.setUpBackup() {
try { try {
restoreFileSelector = restoreFileSelector =
registerForActivityResult(ActivityResultContracts.GetContent()) { uri: Uri? -> registerForActivityResult(ActivityResultContracts.OpenDocument()) { uri: Uri? ->
this.let { activity -> this.let { activity ->
uri?.let { uri?.let {
try { try {
@ -180,7 +180,14 @@ object BackupUtils {
fun FragmentActivity.restorePrompt() { fun FragmentActivity.restorePrompt() {
runOnUiThread { runOnUiThread {
restoreFileSelector?.launch("application/json") restoreFileSelector?.launch(
arrayOf(
"text/plain",
"text/str",
"text/x-unknown",
"application/json"
)
)
} }
} }