From 25177e6d3d8f988baf55fc44029e12258e4603fd Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 24 Apr 2020 17:55:10 +0200 Subject: [PATCH] show Portrait photos by default only on Android 9+ --- .../gallery/pro/activities/MainActivity.kt | 2 +- .../gallery/pro/dialogs/FilterMediaDialog.kt | 2 +- .../simplemobiletools/gallery/pro/helpers/Config.kt | 2 +- .../simplemobiletools/gallery/pro/helpers/Constants.kt | 10 +++++++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 086f853a0..c53acb145 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -1065,7 +1065,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { if (mIsSearchOpen) { directories_empty_placeholder.text = getString(R.string.no_items_found) directories_empty_placeholder_2.beGone() - } else if (dirs.isEmpty() && config.filterMedia == TYPE_DEFAULT_FILTER) { + } else if (dirs.isEmpty() && config.filterMedia == getDefaultFileFilter()) { directories_empty_placeholder.text = getString(R.string.no_media_add_included) directories_empty_placeholder_2.text = getString(R.string.add_folder) 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 dc8a06293..5bcd1d09c 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 @@ -46,7 +46,7 @@ class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result: result += TYPE_PORTRAITS if (result == 0) { - result = TYPE_DEFAULT_FILTER + result = getDefaultFileFilter() } activity.config.filterMedia = result diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt index 06663d8f1..ca35ccda2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Config.kt @@ -191,7 +191,7 @@ class Config(context: Context) : BaseConfig(context) { set(blackBackground) = prefs.edit().putBoolean(BLACK_BACKGROUND, blackBackground).apply() var filterMedia: Int - get() = prefs.getInt(FILTER_MEDIA, TYPE_DEFAULT_FILTER) + get() = prefs.getInt(FILTER_MEDIA, getDefaultFileFilter()) set(filterMedia) = prefs.edit().putInt(FILTER_MEDIA, filterMedia).apply() var dirColumnCnt: Int 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 683fbf25e..9e4c19f12 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 @@ -1,6 +1,7 @@ package com.simplemobiletools.gallery.pro.helpers import com.simplemobiletools.commons.helpers.MONTH_SECONDS +import com.simplemobiletools.commons.helpers.isPiePlus // shared preferences const val DIRECTORY_SORT_ORDER = "directory_sort_order" @@ -169,7 +170,14 @@ const val TYPE_GIFS = 4 const val TYPE_RAWS = 8 const val TYPE_SVGS = 16 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 + +fun getDefaultFileFilter(): Int { + var types = TYPE_IMAGES or TYPE_VIDEOS or TYPE_GIFS or TYPE_RAWS or TYPE_SVGS + if (isPiePlus()) { + types += TYPE_PORTRAITS + } + return types +} const val LOCATION_INTERNAL = 1 const val LOCATION_SD = 2