Reduce cross fade duration to 150ms

This commit is contained in:
Naveen 2024-04-16 16:11:52 +05:30
parent 140af47c0d
commit 86b22f828a
No known key found for this signature in database
GPG key ID: 0E155DAD31671DA3
2 changed files with 33 additions and 9 deletions

View file

@ -1,5 +1,6 @@
package org.fossify.gallery.extensions package org.fossify.gallery.extensions
import android.annotation.SuppressLint
import android.appwidget.AppWidgetManager import android.appwidget.AppWidgetManager
import android.content.ComponentName import android.content.ComponentName
import android.content.Context import android.content.Context
@ -472,8 +473,15 @@ fun Context.getFolderNameFromPath(path: String): String {
} }
fun Context.loadImage( fun Context.loadImage(
type: Int, path: String, target: MySquareImageView, horizontalScroll: Boolean, animateGifs: Boolean, cropThumbnails: Boolean, type: Int,
roundCorners: Int, signature: ObjectKey, skipMemoryCacheAtPaths: ArrayList<String>? = null path: String,
target: MySquareImageView,
horizontalScroll: Boolean,
animateGifs: Boolean,
cropThumbnails: Boolean,
roundCorners: Int,
signature: ObjectKey,
skipMemoryCacheAtPaths: ArrayList<String>? = null,
) { ) {
target.isHorizontalScrolling = horizontalScroll target.isHorizontalScrolling = horizontalScroll
if (type == TYPE_SVGS) { if (type == TYPE_SVGS) {
@ -505,6 +513,7 @@ fun Context.getPathLocation(path: String): Int {
} }
} }
@SuppressLint("CheckResult")
fun Context.loadImageBase( fun Context.loadImageBase(
path: String, path: String,
target: MySquareImageView, target: MySquareImageView,
@ -514,7 +523,7 @@ fun Context.loadImageBase(
skipMemoryCacheAtPaths: ArrayList<String>? = null, skipMemoryCacheAtPaths: ArrayList<String>? = null,
animate: Boolean = false, animate: Boolean = false,
tryLoadingWithPicasso: Boolean = false, tryLoadingWithPicasso: Boolean = false,
crossFadeDuration: Int = 300 crossFadeDuration: Int = THUMBNAIL_FADE_DURATION_MS,
) { ) {
val options = RequestOptions() val options = RequestOptions()
.signature(signature) .signature(signature)
@ -572,7 +581,7 @@ fun Context.loadImageBase(
model: Any, model: Any,
targetBitmap: Target<Drawable>, targetBitmap: Target<Drawable>,
dataSource: DataSource, dataSource: DataSource,
isFirstResource: Boolean isFirstResource: Boolean,
): Boolean { ): Boolean {
return false return false
} }
@ -582,7 +591,14 @@ fun Context.loadImageBase(
builder.into(target) builder.into(target)
} }
fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boolean, roundCorners: Int, signature: ObjectKey) { fun Context.loadSVG(
path: String,
target: MySquareImageView,
cropThumbnails: Boolean,
roundCorners: Int,
signature: ObjectKey,
crossFadeDuration: Int = THUMBNAIL_FADE_DURATION_MS,
) {
target.scaleType = if (cropThumbnails) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER target.scaleType = if (cropThumbnails) ImageView.ScaleType.CENTER_CROP else ImageView.ScaleType.FIT_CENTER
val options = RequestOptions().signature(signature) val options = RequestOptions().signature(signature)
@ -591,7 +607,7 @@ fun Context.loadSVG(path: String, target: MySquareImageView, cropThumbnails: Boo
.listener(SvgSoftwareLayerSetter()) .listener(SvgSoftwareLayerSetter())
.load(path) .load(path)
.apply(options) .apply(options)
.transition(DrawableTransitionOptions.withCrossFade()) .transition(DrawableTransitionOptions.withCrossFade(crossFadeDuration))
if (roundCorners != ROUNDED_CORNERS_NONE) { if (roundCorners != ROUNDED_CORNERS_NONE) {
val cornerSize = val cornerSize =
@ -636,7 +652,7 @@ fun Context.getCachedDirectories(
getImagesOnly: Boolean = false, getImagesOnly: Boolean = false,
forceShowHidden: Boolean = false, forceShowHidden: Boolean = false,
forceShowExcluded: Boolean = false, forceShowExcluded: Boolean = false,
callback: (ArrayList<Directory>) -> Unit callback: (ArrayList<Directory>) -> Unit,
) { ) {
ensureBackgroundThread { ensureBackgroundThread {
try { try {
@ -988,8 +1004,13 @@ fun Context.addPathToDB(path: String) {
} }
fun Context.createDirectoryFromMedia( fun Context.createDirectoryFromMedia(
path: String, curMedia: ArrayList<Medium>, albumCovers: ArrayList<AlbumCover>, hiddenString: String, path: String,
includedFolders: MutableSet<String>, getProperFileSize: Boolean, noMediaFolders: ArrayList<String> curMedia: ArrayList<Medium>,
albumCovers: ArrayList<AlbumCover>,
hiddenString: String,
includedFolders: MutableSet<String>,
getProperFileSize: Boolean,
noMediaFolders: ArrayList<String>,
): Directory { ): Directory {
val OTGPath = config.OTGPath val OTGPath = config.OTGPath
val grouped = MediaFetcher(this).groupMedia(curMedia, path) val grouped = MediaFetcher(this).groupMedia(curMedia, path)

View file

@ -245,6 +245,9 @@ const val FOLDER_MEDIA_CNT_NONE = 3
const val FOLDER_STYLE_SQUARE = 1 const val FOLDER_STYLE_SQUARE = 1
const val FOLDER_STYLE_ROUNDED_CORNERS = 2 const val FOLDER_STYLE_ROUNDED_CORNERS = 2
// animations
const val THUMBNAIL_FADE_DURATION_MS = 150
fun getPermissionToRequest() = if (isTiramisuPlus()) PERMISSION_READ_MEDIA_IMAGES else PERMISSION_WRITE_STORAGE fun getPermissionToRequest() = if (isTiramisuPlus()) PERMISSION_READ_MEDIA_IMAGES else PERMISSION_WRITE_STORAGE
fun getRequiredPermission() = if (isUpsideDownCakePlus()) PERMISSION_READ_MEDIA_VISUAL_USER_SELECTED else getPermissionToRequest() fun getRequiredPermission() = if (isUpsideDownCakePlus()) PERMISSION_READ_MEDIA_VISUAL_USER_SELECTED else getPermissionToRequest()