start showing portrait photos better, if appropriate
This commit is contained in:
parent
9308353862
commit
ad85ec5a63
4 changed files with 22 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<File>() // used only for Portrait photos starting with "IMG_" for now
|
||||
|
||||
|
@ -217,7 +218,7 @@ class MediaFetcher(val context: Context) {
|
|||
val notDirs = ArrayList<File>()
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -49,4 +49,12 @@
|
|||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:text="@string/svgs"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
android:id="@+id/filter_media_portraits"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:text="@string/portraits"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in a new issue