adding more portrait filetype related improvements

This commit is contained in:
tibbi 2019-09-30 23:52:14 +02:00
parent ff79038efa
commit 7db3b82ae0
5 changed files with 30 additions and 10 deletions

View File

@ -62,7 +62,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.simplemobiletools:commons:5.17.17' implementation 'com.simplemobiletools:commons:5.17.19'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.multidex:multidex:2.0.1'
implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1'

View File

@ -149,6 +149,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
filename.isGif() -> TYPE_GIFS filename.isGif() -> TYPE_GIFS
filename.isRawFast() -> TYPE_RAWS filename.isRawFast() -> TYPE_RAWS
filename.isSvg() -> TYPE_SVGS filename.isSvg() -> TYPE_SVGS
file.isPortrait() -> TYPE_PORTRAITS
else -> TYPE_IMAGES else -> TYPE_IMAGES
} }
@ -280,7 +281,8 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
path.isVideoFast() && filter and TYPE_VIDEOS == 0 || path.isVideoFast() && filter and TYPE_VIDEOS == 0 ||
path.isGif() && filter and TYPE_GIFS == 0 || path.isGif() && filter and TYPE_GIFS == 0 ||
path.isRawFast() && filter and TYPE_RAWS == 0 || path.isRawFast() && filter and TYPE_RAWS == 0 ||
path.isSvg() && filter and TYPE_SVGS == 0) path.isSvg() && filter and TYPE_SVGS == 0 ||
path.isPortrait() && filter and TYPE_PORTRAITS == 0)
} }
private fun initBottomActions() { private fun initBottomActions() {

View File

@ -336,6 +336,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
mPath.isGif() -> TYPE_GIFS mPath.isGif() -> TYPE_GIFS
mPath.isSvg() -> TYPE_SVGS mPath.isSvg() -> TYPE_SVGS
mPath.isRawFast() -> TYPE_RAWS mPath.isRawFast() -> TYPE_RAWS
mPath.isPortrait() -> TYPE_PORTRAITS
else -> TYPE_IMAGES else -> TYPE_IMAGES
} }

View File

@ -448,7 +448,7 @@ fun Context.getFolderNameFromPath(path: String): String {
fun Context.loadImage(type: Int, path: String, target: MySquareImageView, horizontalScroll: Boolean, animateGifs: Boolean, cropThumbnails: Boolean, fun Context.loadImage(type: Int, path: String, target: MySquareImageView, horizontalScroll: Boolean, animateGifs: Boolean, cropThumbnails: Boolean,
skipMemoryCacheAtPaths: ArrayList<String>? = null) { skipMemoryCacheAtPaths: ArrayList<String>? = null) {
target.isHorizontalScrolling = horizontalScroll target.isHorizontalScrolling = horizontalScroll
if (type == TYPE_IMAGES || type == TYPE_VIDEOS || type == TYPE_RAWS) { if (type == TYPE_IMAGES || type == TYPE_VIDEOS || type == TYPE_RAWS || type == TYPE_PORTRAITS) {
if (type == TYPE_IMAGES && path.isPng()) { if (type == TYPE_IMAGES && path.isPng()) {
loadPng(path, target, cropThumbnails, skipMemoryCacheAtPaths) loadPng(path, target, cropThumbnails, skipMemoryCacheAtPaths)
} else { } else {
@ -814,6 +814,7 @@ fun Context.addPathToDB(path: String) {
path.isGif() -> TYPE_GIFS path.isGif() -> TYPE_GIFS
path.isRawFast() -> TYPE_RAWS path.isRawFast() -> TYPE_RAWS
path.isSvg() -> TYPE_SVGS path.isSvg() -> TYPE_SVGS
path.isPortrait() -> TYPE_PORTRAITS
else -> TYPE_IMAGES else -> TYPE_IMAGES
} }

View File

@ -97,6 +97,11 @@ class MediaFetcher(val context: Context) {
} }
} }
if (filterMedia and TYPE_PORTRAITS != 0) {
query.append("${MediaStore.Images.Media.DATA} LIKE ? OR ")
query.append("${MediaStore.Images.Media.DATA} LIKE ? OR ")
}
if (filterMedia and TYPE_VIDEOS != 0) { if (filterMedia and TYPE_VIDEOS != 0) {
videoExtensions.forEach { videoExtensions.forEach {
query.append("${MediaStore.Images.Media.DATA} LIKE ? OR ") query.append("${MediaStore.Images.Media.DATA} LIKE ? OR ")
@ -130,6 +135,11 @@ class MediaFetcher(val context: Context) {
} }
} }
if (filterMedia and TYPE_PORTRAITS != 0) {
args.add("%.jpg")
args.add("%.jpeg")
}
if (filterMedia and TYPE_VIDEOS != 0) { if (filterMedia and TYPE_VIDEOS != 0) {
videoExtensions.forEach { videoExtensions.forEach {
args.add("%$it") args.add("%$it")
@ -208,7 +218,10 @@ class MediaFetcher(val context: Context) {
val showHidden = config.shouldShowHidden val showHidden = config.shouldShowHidden
val showPortraits = filterMedia and TYPE_PORTRAITS != 0 val showPortraits = filterMedia and TYPE_PORTRAITS != 0
val dateTakens = if (getProperDateTaken && folder != FAVORITES && !isRecycleBin) getFolderDateTakens(folder) else HashMap() 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
// used only for Portrait photos starting with "IMG_" for now
val subdirs = ArrayList<File>()
val covers = ArrayList<String>()
val files = when (folder) { val files = when (folder) {
FAVORITES -> favoritePaths.filter { showHidden || !it.contains("/.") }.map { File(it) }.toMutableList() as ArrayList<File> FAVORITES -> favoritePaths.filter { showHidden || !it.contains("/.") }.map { File(it) }.toMutableList() as ArrayList<File>
@ -234,6 +247,7 @@ class MediaFetcher(val context: Context) {
val portraitFiles = subdir.listFiles() ?: continue val portraitFiles = subdir.listFiles() ?: continue
val cover = portraitFiles.firstOrNull { it.name.contains("cover", true) } ?: portraitFiles.first() val cover = portraitFiles.firstOrNull { it.name.contains("cover", true) } ?: portraitFiles.first()
files.add(cover) files.add(cover)
covers.add(cover.absolutePath)
} }
for (file in files) { for (file in files) {
@ -242,13 +256,14 @@ class MediaFetcher(val context: Context) {
} }
val path = file.absolutePath val path = file.absolutePath
val isImage = path.isImageFast() val isPortrait = covers.contains(path)
val isVideo = if (isImage) false else path.isVideoFast() val isImage = if (isPortrait) false else path.isImageFast()
val isGif = if (isImage || isVideo) false else path.isGif() val isVideo = if (isPortrait || isImage) false else path.isVideoFast()
val isRaw = if (isImage || isVideo || isGif) false else path.isRawFast() val isGif = if (isPortrait || isImage || isVideo) false else path.isGif()
val isSvg = if (isImage || isVideo || isGif || isRaw) false else path.isSvg() val isRaw = if (isPortrait || isImage || isVideo || isGif) false else path.isRawFast()
val isSvg = if (isPortrait || isImage || isVideo || isGif || isRaw) false else path.isSvg()
if (!isImage && !isVideo && !isGif && !isRaw && !isSvg) if (!isPortrait && !isImage && !isVideo && !isGif && !isRaw && !isSvg)
continue continue
if (isVideo && (isPickImage || filterMedia and TYPE_VIDEOS == 0)) if (isVideo && (isPickImage || filterMedia and TYPE_VIDEOS == 0))
@ -297,6 +312,7 @@ class MediaFetcher(val context: Context) {
isGif -> TYPE_GIFS isGif -> TYPE_GIFS
isRaw -> TYPE_RAWS isRaw -> TYPE_RAWS
isSvg -> TYPE_SVGS isSvg -> TYPE_SVGS
isPortrait -> TYPE_PORTRAITS
else -> TYPE_IMAGES else -> TYPE_IMAGES
} }