From 056032cb674874e8c637d6cb4cf4b687448e87a4 Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Wed, 25 Sep 2024 23:10:51 +0530 Subject: [PATCH] Use black placeholder for thumbnails Using a black placeholder leads to clearer thumbnail and background separation on most themes. --- .../org/fossify/gallery/adapters/DirectoryAdapter.kt | 8 ++++++++ .../kotlin/org/fossify/gallery/adapters/MediaAdapter.kt | 8 ++++++++ .../main/kotlin/org/fossify/gallery/extensions/Context.kt | 8 +++++--- app/src/main/res/drawable/placeholder_rounded_big.xml | 5 +++++ app/src/main/res/drawable/placeholder_rounded_small.xml | 5 +++++ app/src/main/res/drawable/placeholder_square.xml | 4 ++++ 6 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/drawable/placeholder_rounded_big.xml create mode 100644 app/src/main/res/drawable/placeholder_rounded_small.xml create mode 100644 app/src/main/res/drawable/placeholder_square.xml diff --git a/app/src/main/kotlin/org/fossify/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/org/fossify/gallery/adapters/DirectoryAdapter.kt index b21841f9a..4feca5b69 100644 --- a/app/src/main/kotlin/org/fossify/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/org/fossify/gallery/adapters/DirectoryAdapter.kt @@ -821,6 +821,14 @@ class DirectoryAdapter( else -> ROUNDED_CORNERS_BIG } + dirThumbnail.setBackgroundResource( + when (roundedCorners) { + ROUNDED_CORNERS_SMALL -> R.drawable.placeholder_rounded_small + ROUNDED_CORNERS_BIG -> R.drawable.placeholder_rounded_big + else -> R.drawable.placeholder_square + } + ) + activity.loadImage( type = thumbnailType, path = directory.tmb, diff --git a/app/src/main/kotlin/org/fossify/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/org/fossify/gallery/adapters/MediaAdapter.kt index 7362870bb..068fca05f 100644 --- a/app/src/main/kotlin/org/fossify/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/org/fossify/gallery/adapters/MediaAdapter.kt @@ -656,6 +656,14 @@ class MediaAdapter( else -> ROUNDED_CORNERS_NONE } + mediumThumbnail.setBackgroundResource( + when (roundedCorners) { + ROUNDED_CORNERS_SMALL -> R.drawable.placeholder_rounded_small + ROUNDED_CORNERS_BIG -> R.drawable.placeholder_rounded_big + else -> R.drawable.placeholder_square + } + ) + activity.loadImage( type = medium.type, path = path, diff --git a/app/src/main/kotlin/org/fossify/gallery/extensions/Context.kt b/app/src/main/kotlin/org/fossify/gallery/extensions/Context.kt index 09e1daa35..a03a4f138 100644 --- a/app/src/main/kotlin/org/fossify/gallery/extensions/Context.kt +++ b/app/src/main/kotlin/org/fossify/gallery/extensions/Context.kt @@ -558,7 +558,6 @@ fun Context.loadImageBase( // animation is only supported without rounded corners and the file must be a GIF or WEBP. // Glide doesn't support animated AVIF: https://bumptech.github.io/glide/int/avif.html - // TODO: animate JXL if (animate && roundCorners == ROUNDED_CORNERS_NONE && (path.isGif() || path.isWebP())) { // this is required to make glide cache aware of changes options.decode(Drawable::class.java) @@ -629,8 +628,11 @@ fun Context.loadSVG( .transition(getOptionalCrossFadeTransition(crossFadeDuration)) if (roundCorners != ROUNDED_CORNERS_NONE) { - val cornerSize = - if (roundCorners == ROUNDED_CORNERS_SMALL) org.fossify.commons.R.dimen.rounded_corner_radius_small else org.fossify.commons.R.dimen.rounded_corner_radius_big + val cornerSize = when (roundCorners) { + ROUNDED_CORNERS_SMALL -> org.fossify.commons.R.dimen.rounded_corner_radius_small + else -> org.fossify.commons.R.dimen.rounded_corner_radius_big + } + val cornerRadius = resources.getDimension(cornerSize).toInt() builder = builder.transform(CenterCrop(), RoundedCorners(cornerRadius)) } diff --git a/app/src/main/res/drawable/placeholder_rounded_big.xml b/app/src/main/res/drawable/placeholder_rounded_big.xml new file mode 100644 index 000000000..62ecb9d05 --- /dev/null +++ b/app/src/main/res/drawable/placeholder_rounded_big.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/placeholder_rounded_small.xml b/app/src/main/res/drawable/placeholder_rounded_small.xml new file mode 100644 index 000000000..21f826cc7 --- /dev/null +++ b/app/src/main/res/drawable/placeholder_rounded_small.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/placeholder_square.xml b/app/src/main/res/drawable/placeholder_square.xml new file mode 100644 index 000000000..47152e43a --- /dev/null +++ b/app/src/main/res/drawable/placeholder_square.xml @@ -0,0 +1,4 @@ + + + +