mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
rename some media type related constants
This commit is contained in:
parent
2eaff8568f
commit
d0f4f0d403
9 changed files with 63 additions and 68 deletions
|
@ -85,9 +85,9 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
|
||||||
val bundle = Bundle()
|
val bundle = Bundle()
|
||||||
val file = File(mUri.toString())
|
val file = File(mUri.toString())
|
||||||
val type = when {
|
val type = when {
|
||||||
file.isImageFast() -> TYPE_IMAGE
|
file.isImageFast() -> TYPE_IMAGES
|
||||||
file.isVideoFast() -> TYPE_VIDEO
|
file.isVideoFast() -> TYPE_VIDEOS
|
||||||
else -> TYPE_GIF
|
else -> TYPE_GIFS
|
||||||
}
|
}
|
||||||
|
|
||||||
mMedium = Medium(null, getFilenameFromUri(mUri!!), mUri.toString(), mUri!!.path.getParentPath(), 0, 0, file.length(), type)
|
mMedium = Medium(null, getFilenameFromUri(mUri!!), mUri.toString(), mUri!!.path.getParentPath(), 0, 0, file.length(), type)
|
||||||
|
|
|
@ -19,9 +19,9 @@ import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.dialogs.ExcludeFolderDialog
|
import com.simplemobiletools.gallery.dialogs.ExcludeFolderDialog
|
||||||
import com.simplemobiletools.gallery.dialogs.PickMediumDialog
|
import com.simplemobiletools.gallery.dialogs.PickMediumDialog
|
||||||
import com.simplemobiletools.gallery.extensions.*
|
import com.simplemobiletools.gallery.extensions.*
|
||||||
import com.simplemobiletools.gallery.helpers.TYPE_GIF
|
import com.simplemobiletools.gallery.helpers.TYPE_GIFS
|
||||||
import com.simplemobiletools.gallery.helpers.TYPE_IMAGE
|
import com.simplemobiletools.gallery.helpers.TYPE_IMAGES
|
||||||
import com.simplemobiletools.gallery.helpers.TYPE_VIDEO
|
import com.simplemobiletools.gallery.helpers.TYPE_VIDEOS
|
||||||
import com.simplemobiletools.gallery.helpers.VIEW_TYPE_LIST
|
import com.simplemobiletools.gallery.helpers.VIEW_TYPE_LIST
|
||||||
import com.simplemobiletools.gallery.models.AlbumCover
|
import com.simplemobiletools.gallery.models.AlbumCover
|
||||||
import com.simplemobiletools.gallery.models.Directory
|
import com.simplemobiletools.gallery.models.Directory
|
||||||
|
@ -413,9 +413,9 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
dir_path?.text = "${directory.path.substringBeforeLast("/")}/"
|
dir_path?.text = "${directory.path.substringBeforeLast("/")}/"
|
||||||
photo_cnt.text = directory.mediaCnt.toString()
|
photo_cnt.text = directory.mediaCnt.toString()
|
||||||
val thumbnailType = when {
|
val thumbnailType = when {
|
||||||
directory.tmb.isImageFast() -> TYPE_IMAGE
|
directory.tmb.isImageFast() -> TYPE_IMAGES
|
||||||
directory.tmb.isVideoFast() -> TYPE_VIDEO
|
directory.tmb.isVideoFast() -> TYPE_VIDEOS
|
||||||
else -> TYPE_GIF
|
else -> TYPE_GIFS
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.loadImage(thumbnailType, directory.tmb, dir_thumbnail, scrollHorizontally, animateGifs, cropThumbnails)
|
activity.loadImage(thumbnailType, directory.tmb, dir_thumbnail, scrollHorizontally, animateGifs, cropThumbnails)
|
||||||
|
|
|
@ -10,10 +10,10 @@ import com.simplemobiletools.commons.helpers.sumByLong
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.extensions.checkAppendingHidden
|
import com.simplemobiletools.gallery.extensions.checkAppendingHidden
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
import com.simplemobiletools.gallery.helpers.GIFS
|
|
||||||
import com.simplemobiletools.gallery.helpers.IMAGES
|
|
||||||
import com.simplemobiletools.gallery.helpers.MediaFetcher
|
import com.simplemobiletools.gallery.helpers.MediaFetcher
|
||||||
import com.simplemobiletools.gallery.helpers.VIDEOS
|
import com.simplemobiletools.gallery.helpers.TYPE_GIFS
|
||||||
|
import com.simplemobiletools.gallery.helpers.TYPE_IMAGES
|
||||||
|
import com.simplemobiletools.gallery.helpers.TYPE_VIDEOS
|
||||||
import com.simplemobiletools.gallery.models.Directory
|
import com.simplemobiletools.gallery.models.Directory
|
||||||
import com.simplemobiletools.gallery.models.Medium
|
import com.simplemobiletools.gallery.models.Medium
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -74,15 +74,15 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va
|
||||||
private fun getDirMediaTypes(media: ArrayList<Medium>): Int {
|
private fun getDirMediaTypes(media: ArrayList<Medium>): Int {
|
||||||
var types = 0
|
var types = 0
|
||||||
if (media.any { it.isImage() }) {
|
if (media.any { it.isImage() }) {
|
||||||
types += IMAGES
|
types += TYPE_IMAGES
|
||||||
}
|
}
|
||||||
|
|
||||||
if (media.any { it.isVideo() }) {
|
if (media.any { it.isVideo() }) {
|
||||||
types += VIDEOS
|
types += TYPE_VIDEOS
|
||||||
}
|
}
|
||||||
|
|
||||||
if (media.any { it.isGif() }) {
|
if (media.any { it.isGif() }) {
|
||||||
types += GIFS
|
types += TYPE_GIFS
|
||||||
}
|
}
|
||||||
|
|
||||||
return types
|
return types
|
||||||
|
|
|
@ -5,9 +5,9 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.gallery.R
|
import com.simplemobiletools.gallery.R
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
import com.simplemobiletools.gallery.helpers.GIFS
|
import com.simplemobiletools.gallery.helpers.TYPE_GIFS
|
||||||
import com.simplemobiletools.gallery.helpers.IMAGES
|
import com.simplemobiletools.gallery.helpers.TYPE_IMAGES
|
||||||
import com.simplemobiletools.gallery.helpers.VIDEOS
|
import com.simplemobiletools.gallery.helpers.TYPE_VIDEOS
|
||||||
import kotlinx.android.synthetic.main.dialog_filter_media.view.*
|
import kotlinx.android.synthetic.main.dialog_filter_media.view.*
|
||||||
|
|
||||||
class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result: Int) -> Unit) {
|
class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result: Int) -> Unit) {
|
||||||
|
@ -16,9 +16,9 @@ class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result:
|
||||||
init {
|
init {
|
||||||
val filterMedia = activity.config.filterMedia
|
val filterMedia = activity.config.filterMedia
|
||||||
view.apply {
|
view.apply {
|
||||||
filter_media_images.isChecked = filterMedia and IMAGES != 0
|
filter_media_images.isChecked = filterMedia and TYPE_IMAGES != 0
|
||||||
filter_media_videos.isChecked = filterMedia and VIDEOS != 0
|
filter_media_videos.isChecked = filterMedia and TYPE_VIDEOS != 0
|
||||||
filter_media_gifs.isChecked = filterMedia and GIFS != 0
|
filter_media_gifs.isChecked = filterMedia and TYPE_GIFS != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder(activity)
|
AlertDialog.Builder(activity)
|
||||||
|
@ -32,11 +32,11 @@ class FilterMediaDialog(val activity: BaseSimpleActivity, val callback: (result:
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
var result = 0
|
var result = 0
|
||||||
if (view.filter_media_images.isChecked)
|
if (view.filter_media_images.isChecked)
|
||||||
result += IMAGES
|
result += TYPE_IMAGES
|
||||||
if (view.filter_media_videos.isChecked)
|
if (view.filter_media_videos.isChecked)
|
||||||
result += VIDEOS
|
result += TYPE_VIDEOS
|
||||||
if (view.filter_media_gifs.isChecked)
|
if (view.filter_media_gifs.isChecked)
|
||||||
result += GIFS
|
result += TYPE_GIFS
|
||||||
|
|
||||||
activity.config.filterMedia = result
|
activity.config.filterMedia = result
|
||||||
callback(result)
|
callback(result)
|
||||||
|
|
|
@ -183,13 +183,13 @@ fun Context.checkAppendingHidden(path: String, hidden: String, includedFolders:
|
||||||
|
|
||||||
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) {
|
||||||
target.isHorizontalScrolling = horizontalScroll
|
target.isHorizontalScrolling = horizontalScroll
|
||||||
if (type == TYPE_IMAGE || type == TYPE_VIDEO) {
|
if (type == TYPE_IMAGES || type == TYPE_VIDEOS) {
|
||||||
if (type == TYPE_IMAGE && path.isPng()) {
|
if (type == TYPE_IMAGES && path.isPng()) {
|
||||||
loadPng(path, target, cropThumbnails)
|
loadPng(path, target, cropThumbnails)
|
||||||
} else {
|
} else {
|
||||||
loadJpg(path, target, cropThumbnails)
|
loadJpg(path, target, cropThumbnails)
|
||||||
}
|
}
|
||||||
} else if (type == TYPE_GIF) {
|
} else if (type == TYPE_GIFS) {
|
||||||
try {
|
try {
|
||||||
val gifDrawable = GifDrawable(path)
|
val gifDrawable = GifDrawable(path)
|
||||||
target.setImageDrawable(gifDrawable)
|
target.setImageDrawable(gifDrawable)
|
||||||
|
@ -255,9 +255,9 @@ fun Context.getCachedDirectories(callback: (ArrayList<Directory>) -> Unit) {
|
||||||
var filteredDirectories = directories.filter { it.path.shouldFolderBeVisible(excludedPaths, includedPaths, shouldShowHidden) } as ArrayList<Directory>
|
var filteredDirectories = directories.filter { it.path.shouldFolderBeVisible(excludedPaths, includedPaths, shouldShowHidden) } as ArrayList<Directory>
|
||||||
val filterMedia = config.filterMedia
|
val filterMedia = config.filterMedia
|
||||||
filteredDirectories = filteredDirectories.filter {
|
filteredDirectories = filteredDirectories.filter {
|
||||||
(filterMedia and IMAGES != 0 && it.types == TYPE_IMAGE) ||
|
(filterMedia and TYPE_IMAGES != 0 && it.types and TYPE_IMAGES != 0) ||
|
||||||
(filterMedia and VIDEOS != 0 && it.types == TYPE_VIDEO) ||
|
(filterMedia and TYPE_VIDEOS != 0 && it.types and TYPE_VIDEOS != 0) ||
|
||||||
(filterMedia and GIFS != 0 && it.types == TYPE_GIF)
|
(filterMedia and TYPE_GIFS != 0 && it.types and TYPE_GIFS != 0)
|
||||||
} as ArrayList<Directory>
|
} as ArrayList<Directory>
|
||||||
|
|
||||||
callback(filteredDirectories)
|
callback(filteredDirectories)
|
||||||
|
@ -278,9 +278,9 @@ fun Context.getCachedMedia(path: String, callback: (ArrayList<Medium>) -> Unit)
|
||||||
|
|
||||||
val filterMedia = config.filterMedia
|
val filterMedia = config.filterMedia
|
||||||
filteredMedia = filteredMedia.filter {
|
filteredMedia = filteredMedia.filter {
|
||||||
(filterMedia and IMAGES != 0 && it.type == TYPE_IMAGE) ||
|
(filterMedia and TYPE_IMAGES != 0 && it.type == TYPE_IMAGES) ||
|
||||||
(filterMedia and VIDEOS != 0 && it.type == TYPE_VIDEO) ||
|
(filterMedia and TYPE_VIDEOS != 0 && it.type == TYPE_VIDEOS) ||
|
||||||
(filterMedia and GIFS != 0 && it.type == TYPE_GIF)
|
(filterMedia and TYPE_GIFS != 0 && it.type == TYPE_GIFS)
|
||||||
} as ArrayList<Medium>
|
} as ArrayList<Medium>
|
||||||
|
|
||||||
callback(filteredMedia)
|
callback(filteredMedia)
|
||||||
|
|
|
@ -164,7 +164,7 @@ class Config(context: Context) : BaseConfig(context) {
|
||||||
set(darkBackground) = prefs.edit().putBoolean(DARK_BACKGROUND, darkBackground).apply()
|
set(darkBackground) = prefs.edit().putBoolean(DARK_BACKGROUND, darkBackground).apply()
|
||||||
|
|
||||||
var filterMedia: Int
|
var filterMedia: Int
|
||||||
get() = prefs.getInt(FILTER_MEDIA, IMAGES or VIDEOS or GIFS)
|
get() = prefs.getInt(FILTER_MEDIA, TYPE_IMAGES or TYPE_VIDEOS or TYPE_GIFS)
|
||||||
set(filterMedia) = prefs.edit().putInt(FILTER_MEDIA, filterMedia).apply()
|
set(filterMedia) = prefs.edit().putInt(FILTER_MEDIA, filterMedia).apply()
|
||||||
|
|
||||||
var dirColumnCnt: Int
|
var dirColumnCnt: Int
|
||||||
|
|
|
@ -81,11 +81,6 @@ const val ROTATE_BY_SYSTEM_SETTING = 0
|
||||||
const val ROTATE_BY_DEVICE_ROTATION = 1
|
const val ROTATE_BY_DEVICE_ROTATION = 1
|
||||||
const val ROTATE_BY_ASPECT_RATIO = 2
|
const val ROTATE_BY_ASPECT_RATIO = 2
|
||||||
|
|
||||||
// filter media
|
|
||||||
const val IMAGES = 1
|
|
||||||
const val VIDEOS = 2
|
|
||||||
const val GIFS = 4
|
|
||||||
|
|
||||||
// view types
|
// view types
|
||||||
const val VIEW_TYPE_GRID = 1
|
const val VIEW_TYPE_GRID = 1
|
||||||
const val VIEW_TYPE_LIST = 2
|
const val VIEW_TYPE_LIST = 2
|
||||||
|
@ -104,6 +99,6 @@ const val EXT_ARTIST = 512
|
||||||
const val EXT_ALBUM = 1024
|
const val EXT_ALBUM = 1024
|
||||||
|
|
||||||
// media types
|
// media types
|
||||||
const val TYPE_IMAGE = 1
|
const val TYPE_IMAGES = 1
|
||||||
const val TYPE_VIDEO = 2
|
const val TYPE_VIDEOS = 2
|
||||||
const val TYPE_GIF = 3
|
const val TYPE_GIFS = 4
|
||||||
|
|
|
@ -58,19 +58,19 @@ class MediaFetcher(val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
query.append("(")
|
query.append("(")
|
||||||
if (filterMedia and IMAGES != 0) {
|
if (filterMedia and TYPE_IMAGES != 0) {
|
||||||
photoExtensions.forEach {
|
photoExtensions.forEach {
|
||||||
query.append("${MediaStore.Images.Media.DATA} LIKE ? OR ")
|
query.append("${MediaStore.Images.Media.DATA} LIKE ? OR ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterMedia and 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 ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterMedia and GIFS != 0) {
|
if (filterMedia and TYPE_GIFS != 0) {
|
||||||
query.append("${MediaStore.Images.Media.DATA} LIKE ?")
|
query.append("${MediaStore.Images.Media.DATA} LIKE ?")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,19 +86,19 @@ class MediaFetcher(val context: Context) {
|
||||||
args.add("$path/%/%")
|
args.add("$path/%/%")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterMedia and IMAGES != 0) {
|
if (filterMedia and TYPE_IMAGES != 0) {
|
||||||
photoExtensions.forEach {
|
photoExtensions.forEach {
|
||||||
args.add("%$it")
|
args.add("%$it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterMedia and VIDEOS != 0) {
|
if (filterMedia and TYPE_VIDEOS != 0) {
|
||||||
videoExtensions.forEach {
|
videoExtensions.forEach {
|
||||||
args.add("%$it")
|
args.add("%$it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterMedia and GIFS != 0) {
|
if (filterMedia and TYPE_GIFS != 0) {
|
||||||
args.add("%.gif")
|
args.add("%.gif")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,13 +200,13 @@ class MediaFetcher(val context: Context) {
|
||||||
if (!isImage && !isVideo && !isGif)
|
if (!isImage && !isVideo && !isGif)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (isVideo && (isPickImage || filterMedia and VIDEOS == 0))
|
if (isVideo && (isPickImage || filterMedia and TYPE_VIDEOS == 0))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (isImage && (isPickVideo || filterMedia and IMAGES == 0))
|
if (isImage && (isPickVideo || filterMedia and TYPE_IMAGES == 0))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (isGif && filterMedia and GIFS == 0)
|
if (isGif && filterMedia and TYPE_GIFS == 0)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (!showHidden && filename.startsWith('.'))
|
if (!showHidden && filename.startsWith('.'))
|
||||||
|
@ -220,9 +220,9 @@ class MediaFetcher(val context: Context) {
|
||||||
val dateModified = file.lastModified()
|
val dateModified = file.lastModified()
|
||||||
|
|
||||||
val type = when {
|
val type = when {
|
||||||
isImage -> TYPE_IMAGE
|
isImage -> TYPE_IMAGES
|
||||||
isVideo -> TYPE_VIDEO
|
isVideo -> TYPE_VIDEOS
|
||||||
else -> TYPE_GIF
|
else -> TYPE_GIFS
|
||||||
}
|
}
|
||||||
|
|
||||||
val medium = Medium(null, filename, file.absolutePath, folder, dateModified, dateTaken, size, type)
|
val medium = Medium(null, filename, file.absolutePath, folder, dateModified, dateTaken, size, type)
|
||||||
|
@ -248,13 +248,13 @@ class MediaFetcher(val context: Context) {
|
||||||
if (!isImage && !isVideo && !isGif)
|
if (!isImage && !isVideo && !isGif)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (isVideo && (isPickImage || filterMedia and VIDEOS == 0))
|
if (isVideo && (isPickImage || filterMedia and TYPE_VIDEOS == 0))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (isImage && (isPickVideo || filterMedia and IMAGES == 0))
|
if (isImage && (isPickVideo || filterMedia and TYPE_IMAGES == 0))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (isGif && filterMedia and GIFS == 0)
|
if (isGif && filterMedia and TYPE_GIFS == 0)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (!showHidden && filename.startsWith('.'))
|
if (!showHidden && filename.startsWith('.'))
|
||||||
|
@ -268,9 +268,9 @@ class MediaFetcher(val context: Context) {
|
||||||
val dateModified = file.lastModified()
|
val dateModified = file.lastModified()
|
||||||
|
|
||||||
val type = when {
|
val type = when {
|
||||||
isImage -> TYPE_IMAGE
|
isImage -> TYPE_IMAGES
|
||||||
isVideo -> TYPE_VIDEO
|
isVideo -> TYPE_VIDEOS
|
||||||
else -> TYPE_GIF
|
else -> TYPE_GIFS
|
||||||
}
|
}
|
||||||
|
|
||||||
val path = Uri.decode(file.uri.toString().replaceFirst("${context.config.OTGBasePath}%3A", OTG_PATH))
|
val path = Uri.decode(file.uri.toString().replaceFirst("${context.config.OTGBasePath}%3A", OTG_PATH))
|
||||||
|
|
|
@ -8,9 +8,9 @@ import com.simplemobiletools.commons.extensions.formatDate
|
||||||
import com.simplemobiletools.commons.extensions.formatSize
|
import com.simplemobiletools.commons.extensions.formatSize
|
||||||
import com.simplemobiletools.commons.extensions.isDng
|
import com.simplemobiletools.commons.extensions.isDng
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.gallery.helpers.TYPE_GIF
|
import com.simplemobiletools.gallery.helpers.TYPE_GIFS
|
||||||
import com.simplemobiletools.gallery.helpers.TYPE_IMAGE
|
import com.simplemobiletools.gallery.helpers.TYPE_IMAGES
|
||||||
import com.simplemobiletools.gallery.helpers.TYPE_VIDEO
|
import com.simplemobiletools.gallery.helpers.TYPE_VIDEOS
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
|
||||||
@Entity(tableName = "media", indices = [(Index(value = "full_path", unique = true))])
|
@Entity(tableName = "media", indices = [(Index(value = "full_path", unique = true))])
|
||||||
|
@ -29,11 +29,11 @@ data class Medium(
|
||||||
var sorting: Int = 0
|
var sorting: Int = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isGif() = type == TYPE_GIF
|
fun isGif() = type == TYPE_GIFS
|
||||||
|
|
||||||
fun isImage() = type == TYPE_IMAGE
|
fun isImage() = type == TYPE_IMAGES
|
||||||
|
|
||||||
fun isVideo() = type == TYPE_VIDEO
|
fun isVideo() = type == TYPE_VIDEOS
|
||||||
|
|
||||||
fun isDng() = path.isDng()
|
fun isDng() = path.isDng()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue