From b9322d3dd6de5a92920229adf4a05b9d659e2f78 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 7 Jul 2019 21:40:20 +0200 Subject: [PATCH] prioritize some folders at getFoldersToScan --- .../gallery/pro/helpers/MediaFetcher.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 a67a88468..67bc52291 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 @@ -2,6 +2,7 @@ package com.simplemobiletools.gallery.pro.helpers import android.content.Context import android.database.Cursor +import android.os.Environment import android.provider.MediaStore import android.text.format.DateFormat import com.simplemobiletools.commons.extensions.* @@ -45,7 +46,20 @@ class MediaFetcher(val context: Context) { return try { val cursor = context.contentResolver.query(uri, projection, selection, selectionArgs, null) - parseCursor(cursor) + val folders = parseCursor(cursor) + + val priorityFolders = arrayListOf( + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).toString(), + "${Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM)}/Camera", + Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString() + ).filter { File(it).exists() } + + folders.sortBy { + val folder = it + !priorityFolders.any { it.equals(folder, true) } + } + + folders } catch (e: Exception) { ArrayList() }