diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/FilterMediaDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/FilterMediaDialog.kt index 0802d5c67..b4c072021 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/FilterMediaDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/FilterMediaDialog.kt @@ -19,6 +19,7 @@ class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result: filter_media_gifs.isChecked = filterMedia and TYPE_GIFS != 0 filter_media_raws.isChecked = filterMedia and TYPE_RAWS != 0 filter_media_svgs.isChecked = filterMedia and TYPE_SVGS != 0 + filter_media_portraits.isChecked = filterMedia and TYPE_PORTRAITS != 0 } AlertDialog.Builder(activity) @@ -41,6 +42,8 @@ class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result: result += TYPE_RAWS if (view.filter_media_svgs.isChecked) result += TYPE_SVGS + if (view.filter_media_portraits.isChecked) + result += TYPE_PORTRAITS activity.config.filterMedia = result callback(result) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt index 134df275c..7f91dc21b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt @@ -162,7 +162,8 @@ const val TYPE_VIDEOS = 2 const val TYPE_GIFS = 4 const val TYPE_RAWS = 8 const val TYPE_SVGS = 16 -const val TYPE_DEFAULT_FILTER = TYPE_IMAGES or TYPE_VIDEOS or TYPE_GIFS or TYPE_RAWS or TYPE_SVGS +const val TYPE_PORTRAITS = 32 +const val TYPE_DEFAULT_FILTER = TYPE_IMAGES or TYPE_VIDEOS or TYPE_GIFS or TYPE_RAWS or TYPE_SVGS or TYPE_PORTRAITS const val LOCATION_INTERNAL = 1 const val LOCATION_SD = 2 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 57a354fb5..ba762eb3a 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 @@ -206,6 +206,7 @@ class MediaFetcher(val context: Context) { val checkProperFileSize = getProperFileSize || config.fileLoadingPriority == PRIORITY_COMPROMISE val checkFileExistence = config.fileLoadingPriority == PRIORITY_VALIDITY val showHidden = config.shouldShowHidden + val showPortraits = config.filterMedia and TYPE_PORTRAITS != 0 val dateTakens = if (getProperDateTaken && folder != FAVORITES && !isRecycleBin) getFolderDateTakens(folder) else HashMap() val subdirs = ArrayList() // used only for Portrait photos starting with "IMG_" for now @@ -217,7 +218,7 @@ class MediaFetcher(val context: Context) { val notDirs = ArrayList() allFiles.forEach { if (it.isDirectory) { - if (it.name.startsWith("img_", true)) { + if (showPortraits && it.name.startsWith("img_", true)) { subdirs.add(it) } } else { @@ -229,6 +230,12 @@ class MediaFetcher(val context: Context) { } } + for (subdir in subdirs) { + val portraitFiles = subdir.listFiles() ?: continue + val cover = portraitFiles.firstOrNull { it.name.contains("cover", true) } ?: portraitFiles.first() + files.add(cover) + } + for (file in files) { if (shouldStop) { break @@ -298,6 +305,7 @@ class MediaFetcher(val context: Context) { media.add(medium) } } + return media } diff --git a/app/src/main/res/layout/dialog_filter_media.xml b/app/src/main/res/layout/dialog_filter_media.xml index b90fc9aeb..f707967a2 100644 --- a/app/src/main/res/layout/dialog_filter_media.xml +++ b/app/src/main/res/layout/dialog_filter_media.xml @@ -49,4 +49,12 @@ android:paddingBottom="@dimen/activity_margin" android:text="@string/svgs"/> + +