From b5f8a6c443ec96cd54f7a1b56b75944dfc7b4776 Mon Sep 17 00:00:00 2001 From: Alec Su Date: Thu, 31 Aug 2023 22:02:24 +0800 Subject: [PATCH] Support storage ID formats for NTFS and ChromeOS --- .../src/main/java/com/anggrayudi/storage/extension/TextExt.kt | 2 +- .../main/java/com/anggrayudi/storage/file/DocumentFileCompat.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/src/main/java/com/anggrayudi/storage/extension/TextExt.kt b/storage/src/main/java/com/anggrayudi/storage/extension/TextExt.kt index c74c06c..cef5b34 100644 --- a/storage/src/main/java/com/anggrayudi/storage/extension/TextExt.kt +++ b/storage/src/main/java/com/anggrayudi/storage/extension/TextExt.kt @@ -72,7 +72,7 @@ fun String.parent(): String { } val parentPath = folderTree.take(folderTree.size - 1).joinToString("/", "/") return if (parentPath.startsWith(SimpleStorage.externalStoragePath) - || parentPath.matches(Regex("/storage/[A-Z0-9]{4}-[A-Z0-9]{4}(.*?)")) + || parentPath.matches(Regex("/storage/[A-Z0-9-]+(.*?)")) || Build.VERSION.SDK_INT < 21 && parentPath.startsWith(SimpleStorage.KITKAT_SD_CARD_PATH) ) { parentPath diff --git a/storage/src/main/java/com/anggrayudi/storage/file/DocumentFileCompat.kt b/storage/src/main/java/com/anggrayudi/storage/file/DocumentFileCompat.kt index 6abf04f..8f510e4 100644 --- a/storage/src/main/java/com/anggrayudi/storage/file/DocumentFileCompat.kt +++ b/storage/src/main/java/com/anggrayudi/storage/file/DocumentFileCompat.kt @@ -62,7 +62,7 @@ object DocumentFileCompat { val FILE_NAME_DUPLICATION_REGEX_WITHOUT_EXTENSION = Regex("(.*?) \\(\\d+\\)") @RestrictTo(RestrictTo.Scope.LIBRARY) - val SD_CARD_STORAGE_ID_REGEX = Regex("[A-Z0-9]{4}-[A-Z0-9]{4}") + val SD_CARD_STORAGE_ID_REGEX = Regex("[A-Z0-9-]+") @RestrictTo(RestrictTo.Scope.LIBRARY) val SD_CARD_STORAGE_PATH_REGEX = Regex("/storage/$SD_CARD_STORAGE_ID_REGEX(.*?)")