fix #656, separate Images and Raws at filtering
This commit is contained in:
parent
d2bac07abb
commit
5062d3f087
11 changed files with 61 additions and 18 deletions
|
@ -87,7 +87,8 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
|||
val type = when {
|
||||
file.isImageFast() -> TYPE_IMAGES
|
||||
file.isVideoFast() -> TYPE_VIDEOS
|
||||
else -> TYPE_GIFS
|
||||
file.isGif() -> TYPE_GIFS
|
||||
else -> TYPE_RAWS
|
||||
}
|
||||
|
||||
mMedium = Medium(null, getFilenameFromUri(mUri!!), mUri.toString(), mUri!!.path.getParentPath(), 0, 0, file.length(), type)
|
||||
|
|
|
@ -444,7 +444,8 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
val thumbnailType = when {
|
||||
directory.tmb.isImageFast() -> TYPE_IMAGES
|
||||
directory.tmb.isVideoFast() -> TYPE_VIDEOS
|
||||
else -> TYPE_GIFS
|
||||
directory.tmb.isGif() -> TYPE_GIFS
|
||||
else -> TYPE_RAWS
|
||||
}
|
||||
|
||||
activity.loadImage(thumbnailType, directory.tmb, dir_thumbnail, scrollHorizontally, animateGifs, cropThumbnails)
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.simplemobiletools.gallery.R
|
|||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_GIFS
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_IMAGES
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_RAWS
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_VIDEOS
|
||||
import kotlinx.android.synthetic.main.dialog_filter_media.view.*
|
||||
|
||||
|
@ -19,10 +20,11 @@ class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result:
|
|||
filter_media_images.isChecked = filterMedia and TYPE_IMAGES != 0
|
||||
filter_media_videos.isChecked = filterMedia and TYPE_VIDEOS != 0
|
||||
filter_media_gifs.isChecked = filterMedia and TYPE_GIFS != 0
|
||||
filter_media_raws.isChecked = filterMedia and TYPE_RAWS != 0
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
.setPositiveButton(R.string.ok, { dialog, which -> dialogConfirmed() })
|
||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, R.string.filter_media)
|
||||
|
@ -37,6 +39,8 @@ class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result:
|
|||
result += TYPE_VIDEOS
|
||||
if (view.filter_media_gifs.isChecked)
|
||||
result += TYPE_GIFS
|
||||
if (view.filter_media_raws.isChecked)
|
||||
result += TYPE_RAWS
|
||||
|
||||
activity.config.filterMedia = result
|
||||
callback(result)
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simplemobiletools.gallery.extensions
|
|||
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_GIFS
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_IMAGES
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_RAWS
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_VIDEOS
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
|
||||
|
@ -19,5 +20,9 @@ fun ArrayList<Medium>.getDirMediaTypes(): Int {
|
|||
types += TYPE_GIFS
|
||||
}
|
||||
|
||||
if (any { it.isRaw() }) {
|
||||
types += TYPE_RAWS
|
||||
}
|
||||
|
||||
return types
|
||||
}
|
||||
|
|
|
@ -203,7 +203,7 @@ fun Context.checkAppendingHidden(path: String, hidden: String, includedFolders:
|
|||
|
||||
fun Context.loadImage(type: Int, path: String, target: MySquareImageView, horizontalScroll: Boolean, animateGifs: Boolean, cropThumbnails: Boolean) {
|
||||
target.isHorizontalScrolling = horizontalScroll
|
||||
if (type == TYPE_IMAGES || type == TYPE_VIDEOS) {
|
||||
if (type == TYPE_IMAGES || type == TYPE_VIDEOS || type == TYPE_RAWS) {
|
||||
if (type == TYPE_IMAGES && path.isPng()) {
|
||||
loadPng(path, target, cropThumbnails)
|
||||
} else {
|
||||
|
@ -289,7 +289,8 @@ fun Context.getCachedDirectories(getVideosOnly: Boolean = false, getImagesOnly:
|
|||
else -> filteredDirectories.filter {
|
||||
(filterMedia and TYPE_IMAGES != 0 && it.types and TYPE_IMAGES != 0) ||
|
||||
(filterMedia and TYPE_VIDEOS != 0 && it.types and TYPE_VIDEOS != 0) ||
|
||||
(filterMedia and TYPE_GIFS != 0 && it.types and TYPE_GIFS != 0)
|
||||
(filterMedia and TYPE_GIFS != 0 && it.types and TYPE_GIFS != 0) ||
|
||||
(filterMedia and TYPE_RAWS != 0 && it.types and TYPE_RAWS != 0)
|
||||
}
|
||||
}) as ArrayList<Directory>
|
||||
|
||||
|
@ -331,7 +332,8 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag
|
|||
else -> media.filter {
|
||||
(filterMedia and TYPE_IMAGES != 0 && it.type == TYPE_IMAGES) ||
|
||||
(filterMedia and TYPE_VIDEOS != 0 && it.type == TYPE_VIDEOS) ||
|
||||
(filterMedia and TYPE_GIFS != 0 && it.type == TYPE_GIFS)
|
||||
(filterMedia and TYPE_GIFS != 0 && it.type == TYPE_GIFS) ||
|
||||
(filterMedia and TYPE_RAWS != 0 && it.type == TYPE_RAWS)
|
||||
}
|
||||
}) as ArrayList<Medium>
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ class Config(context: Context) : BaseConfig(context) {
|
|||
set(darkBackground) = prefs.edit().putBoolean(DARK_BACKGROUND, darkBackground).apply()
|
||||
|
||||
var filterMedia: Int
|
||||
get() = prefs.getInt(FILTER_MEDIA, TYPE_IMAGES or TYPE_VIDEOS or TYPE_GIFS)
|
||||
get() = prefs.getInt(FILTER_MEDIA, TYPE_IMAGES or TYPE_VIDEOS or TYPE_GIFS or TYPE_RAWS)
|
||||
set(filterMedia) = prefs.edit().putInt(FILTER_MEDIA, filterMedia).apply()
|
||||
|
||||
var dirColumnCnt: Int
|
||||
|
|
|
@ -104,6 +104,7 @@ const val EXT_ALBUM = 1024
|
|||
const val TYPE_IMAGES = 1
|
||||
const val TYPE_VIDEOS = 2
|
||||
const val TYPE_GIFS = 4
|
||||
const val TYPE_RAWS = 8
|
||||
|
||||
const val LOCAITON_INTERNAL = 1
|
||||
const val LOCATION_SD = 2
|
||||
|
|
|
@ -70,6 +70,12 @@ class MediaFetcher(val context: Context) {
|
|||
query.append("${MediaStore.Images.Media.DATA} LIKE ?")
|
||||
}
|
||||
|
||||
if (filterMedia and TYPE_RAWS != 0) {
|
||||
rawExtensions.forEach {
|
||||
query.append("${MediaStore.Images.Media.DATA} LIKE ? OR ")
|
||||
}
|
||||
}
|
||||
|
||||
var selectionQuery = query.toString().trim().removeSuffix("OR")
|
||||
selectionQuery += ") AND "
|
||||
return selectionQuery
|
||||
|
@ -93,6 +99,12 @@ class MediaFetcher(val context: Context) {
|
|||
args.add("%.gif")
|
||||
}
|
||||
|
||||
if (filterMedia and TYPE_RAWS != 0) {
|
||||
rawExtensions.forEach {
|
||||
args.add("%$it")
|
||||
}
|
||||
}
|
||||
|
||||
return args
|
||||
}
|
||||
|
||||
|
@ -160,8 +172,9 @@ class MediaFetcher(val context: Context) {
|
|||
val isImage = filename.isImageFast()
|
||||
val isVideo = if (isImage) false else filename.isVideoFast()
|
||||
val isGif = if (isImage || isVideo) false else filename.isGif()
|
||||
val isRaw = if (isImage || isVideo || isGif) false else filename.isRaw()
|
||||
|
||||
if (!isImage && !isVideo && !isGif)
|
||||
if (!isImage && !isVideo && !isGif && !isRaw)
|
||||
continue
|
||||
|
||||
if (isVideo && (isPickImage || filterMedia and TYPE_VIDEOS == 0))
|
||||
|
@ -173,6 +186,9 @@ class MediaFetcher(val context: Context) {
|
|||
if (isGif && filterMedia and TYPE_GIFS == 0)
|
||||
continue
|
||||
|
||||
if (isRaw && filterMedia and TYPE_RAWS == 0)
|
||||
continue
|
||||
|
||||
if (!showHidden && filename.startsWith('.'))
|
||||
continue
|
||||
|
||||
|
@ -190,7 +206,8 @@ class MediaFetcher(val context: Context) {
|
|||
val type = when {
|
||||
isImage -> TYPE_IMAGES
|
||||
isVideo -> TYPE_VIDEOS
|
||||
else -> TYPE_GIFS
|
||||
isGif -> TYPE_GIFS
|
||||
else -> TYPE_RAWS
|
||||
}
|
||||
|
||||
val medium = Medium(null, filename, file.absolutePath, folder, lastModified, dateTaken, size, type)
|
||||
|
@ -214,8 +231,9 @@ class MediaFetcher(val context: Context) {
|
|||
val isImage = filename.isImageFast()
|
||||
val isVideo = if (isImage) false else filename.isVideoFast()
|
||||
val isGif = if (isImage || isVideo) false else filename.isGif()
|
||||
val isRaw = if (isImage || isVideo || isGif) false else filename.isRaw()
|
||||
|
||||
if (!isImage && !isVideo && !isGif)
|
||||
if (!isImage && !isVideo && !isGif || !isRaw)
|
||||
continue
|
||||
|
||||
if (isVideo && (isPickImage || filterMedia and TYPE_VIDEOS == 0))
|
||||
|
@ -227,6 +245,9 @@ class MediaFetcher(val context: Context) {
|
|||
if (isGif && filterMedia and TYPE_GIFS == 0)
|
||||
continue
|
||||
|
||||
if (isRaw && filterMedia and TYPE_RAWS == 0)
|
||||
continue
|
||||
|
||||
if (!showHidden && filename.startsWith('.'))
|
||||
continue
|
||||
|
||||
|
@ -240,7 +261,8 @@ class MediaFetcher(val context: Context) {
|
|||
val type = when {
|
||||
isImage -> TYPE_IMAGES
|
||||
isVideo -> TYPE_VIDEOS
|
||||
else -> TYPE_GIFS
|
||||
isGif -> TYPE_GIFS
|
||||
else -> TYPE_RAWS
|
||||
}
|
||||
|
||||
val path = Uri.decode(file.uri.toString().replaceFirst("${context.config.OTGTreeUri}/document/${context.config.OTGPartition}%3A", OTG_PATH))
|
||||
|
|
|
@ -6,13 +6,13 @@ import android.arch.persistence.room.Index
|
|||
import android.arch.persistence.room.PrimaryKey
|
||||
import com.simplemobiletools.commons.extensions.formatDate
|
||||
import com.simplemobiletools.commons.extensions.formatSize
|
||||
import com.simplemobiletools.commons.extensions.isRaw
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_DATE_MODIFIED
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_NAME
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_PATH
|
||||
import com.simplemobiletools.commons.helpers.SORT_BY_SIZE
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_GIFS
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_IMAGES
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_RAWS
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_VIDEOS
|
||||
import java.io.Serializable
|
||||
|
||||
|
@ -37,7 +37,7 @@ data class Medium(
|
|||
|
||||
fun isVideo() = type == TYPE_VIDEOS
|
||||
|
||||
fun isRaw() = path.isRaw()
|
||||
fun isRaw() = type == TYPE_RAWS
|
||||
|
||||
fun getBubbleText(sorting: Int) = when {
|
||||
sorting and SORT_BY_NAME != 0 -> name
|
||||
|
|
|
@ -3,14 +3,12 @@ package com.simplemobiletools.gallery.receivers
|
|||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.simplemobiletools.commons.extensions.getFilenameFromPath
|
||||
import com.simplemobiletools.commons.extensions.getParentPath
|
||||
import com.simplemobiletools.commons.extensions.isImageFast
|
||||
import com.simplemobiletools.commons.extensions.isVideoFast
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.REFRESH_PATH
|
||||
import com.simplemobiletools.gallery.extensions.galleryDB
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_GIFS
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_IMAGES
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_RAWS
|
||||
import com.simplemobiletools.gallery.helpers.TYPE_VIDEOS
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
import java.io.File
|
||||
|
@ -29,6 +27,7 @@ class RefreshMediaReceiver : BroadcastReceiver() {
|
|||
private fun getFileType(path: String) = when {
|
||||
path.isImageFast() -> TYPE_IMAGES
|
||||
path.isVideoFast() -> TYPE_VIDEOS
|
||||
else -> TYPE_GIFS
|
||||
path.isGif() -> TYPE_GIFS
|
||||
else -> TYPE_RAWS
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,4 +33,12 @@
|
|||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/gifs"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||
android:id="@+id/filter_media_raws"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingTop="@dimen/activity_margin"
|
||||
android:text="@string/raw_images"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in a new issue