From f6a1ba1c74f06467a55b81b3307af0c5b0bbbc58 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 8 Oct 2021 22:16:30 +0200 Subject: [PATCH] moving file deletion handling into Commons --- app/build.gradle | 2 +- .../gallery/pro/extensions/Context.kt | 15 ----------- .../gallery/pro/helpers/MediaFetcher.kt | 26 ------------------- 3 files changed, 1 insertion(+), 42 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f81e5b2d9..c9035b9fe 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -78,7 +78,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:8663595392' + implementation 'com.github.SimpleMobileTools:Simple-Commons:9da550ecf3' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.22' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index d95fb11a4..0ba186d14 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -1098,18 +1098,3 @@ fun Context.getFileDateTaken(path: String): Long { return 0L } - -fun Context.getFileUrisFromFileDirItems(fileDirItems: ArrayList): ArrayList { - val fileUris = ArrayList() - val allIds = MediaFetcher(this).getMediaStoreIds() - val filePaths = fileDirItems.map { it.path.lowercase(Locale.getDefault()) } - for ((filePath, mediaStoreId) in allIds) { - if (filePaths.contains(filePath.lowercase(Locale.getDefault()))) { - val baseUri = getFileUri(filePath) - val uri = ContentUris.withAppendedId(baseUri, mediaStoreId) - fileUris.add(uri) - } - } - - return fileUris -} diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt index 05838c375..3574f46c0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/MediaFetcher.kt @@ -616,32 +616,6 @@ class MediaFetcher(val context: Context) { return sizes } - fun getMediaStoreIds(): HashMap { - val ids = HashMap() - val projection = arrayOf( - Images.Media.DATA, - Images.Media._ID - ) - - val uri = Files.getContentUri("external") - - try { - context.queryCursor(uri, projection) { cursor -> - try { - val id = cursor.getLongValue(Images.Media._ID) - if (id != 0L) { - val path = cursor.getStringValue(Images.Media.DATA) - ids[path] = id - } - } catch (e: Exception) { - } - } - } catch (e: Exception) { - } - - return ids - } - fun sortMedia(media: ArrayList, sorting: Int) { if (sorting and SORT_BY_RANDOM != 0) { media.shuffle()