feat: SDK 30+ Android[data/obb] selection with SAF

- enable app support for selection of Android[data/obb] with Storage Access Framework (SAF)
This commit is contained in:
darthpaul 2022-06-20 01:43:22 +01:00
parent 18d426306f
commit bec03cba83

View file

@ -159,7 +159,8 @@ fun Context.isPathOnOTG(path: String) = otgPath.isNotEmpty() && path.startsWith(
fun Context.isPathOnInternalStorage(path: String) = internalStoragePath.isNotEmpty() && path.startsWith(internalStoragePath)
fun Context.getSAFOnlyDirs(): List<String> {
return DIRS_ACCESSIBLE_ONLY_WITH_SAF.map { "$internalStoragePath$it" }
return DIRS_ACCESSIBLE_ONLY_WITH_SAF.map { "$internalStoragePath$it" } +
DIRS_ACCESSIBLE_ONLY_WITH_SAF.map { "$sdCardPath$it" }
}
fun Context.isSAFOnlyRoot(path: String): Boolean {
@ -213,7 +214,7 @@ fun isAndroidDataDir(path: String): Boolean {
fun Context.storeAndroidTreeUri(path: String, treeUri: String) {
return when {
isPathOnOTG(path) -> if (isAndroidDataDir(path)) baseConfig.otgAndroidDataTreeUri = treeUri else baseConfig.otgAndroidObbTreeUri = treeUri
isPathOnSD(path) -> if (isAndroidDataDir(path)) baseConfig.sdAndroidDataTreeUri = treeUri else baseConfig.otgAndroidObbTreeUri = treeUri
isPathOnSD(path) -> if (isAndroidDataDir(path)) baseConfig.sdAndroidDataTreeUri = treeUri else baseConfig.sdAndroidObbTreeUri = treeUri
else -> if (isAndroidDataDir(path)) baseConfig.primaryAndroidDataTreeUri = treeUri else baseConfig.primaryAndroidObbTreeUri = treeUri
}
}