diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageActivity.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageActivity.kt index b2cd0326..198d0f50 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageActivity.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageActivity.kt @@ -35,7 +35,9 @@ class StorageActivity : BackupActivity() { val authority = uri.authority ?: throw AssertionError("No authority in $uri") val storageRoot = StorageRootResolver.getStorageRoots(this, authority).getOrNull(0) if (storageRoot == null) { - viewModel.onUriPermissionResultReceived(null) + viewModel.onSafOptionChosen( + StorageRootResolver.getFakeStorageRootForUri(this, uri)) + viewModel.onUriPermissionResultReceived(uri) } else { viewModel.onSafOptionChosen(storageRoot) viewModel.onUriPermissionResultReceived(uri) diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageRootResolver.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageRootResolver.kt index 4d615e6a..57cfdf6a 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageRootResolver.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageRootResolver.kt @@ -3,6 +3,7 @@ package com.stevesoltys.seedvault.ui.storage import android.content.Context import android.database.Cursor import android.graphics.drawable.Drawable +import android.net.Uri import android.os.UserHandle import android.provider.DocumentsContract import android.provider.DocumentsContract.Root.COLUMN_AVAILABLE_BYTES @@ -57,6 +58,21 @@ internal object StorageRootResolver { return roots } + fun getFakeStorageRootForUri(context: Context, uri: Uri): SafOption { + return SafOption( + authority = AUTHORITY_STORAGE, + rootId = "fake", + documentId = "fake", + // TODO: Use something other than the USB icon? + icon = getIcon(context, AUTHORITY_STORAGE, "usb", 0), + title = context.getString(R.string.storage_user_selected_location_title), + summary = context.getString(R.string.storage_user_selected_location_summary), + availableBytes = null, + isUsb = false, // TODO: Check this if possible instead of forcing false + requiresNetwork = false, // TODO: Check this if possible instead of forcing false + ) + } + private fun getStorageRoot(context: Context, authority: String, cursor: Cursor): SafOption? { val flags = cursor.getInt(COLUMN_FLAGS) val supportsCreate = flags and FLAG_SUPPORTS_CREATE != 0 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9b936b2d..fa1b5618 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -58,6 +58,8 @@ Where to find your backups? People with access to your storage location can learn which apps you use, but do not get access to the apps\' data. Existing backups in this location will be deleted. + User-chosen location + Chosen using the folder browser USB flash drive Needs to be plugged in %1$s free