From d5ff61f02146a7e37fb6384e3578e4084778e3dc Mon Sep 17 00:00:00 2001
From: Fanchao Liu <273191+simophin@users.noreply.github.com>
Date: Wed, 21 Aug 2024 15:40:42 +1000
Subject: [PATCH 1/5] [SES-2574] Fix crash on gallery screen (#1632)
---
.../thoughtcrime/securesms/media/MediaPage.kt | 24 ++++++++++++++++---
app/src/main/res/values/themes.xml | 8 +++----
2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/app/src/main/java/org/thoughtcrime/securesms/media/MediaPage.kt b/app/src/main/java/org/thoughtcrime/securesms/media/MediaPage.kt
index c94b08b68b..49b44b5055 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/media/MediaPage.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/media/MediaPage.kt
@@ -152,12 +152,30 @@ private fun ThumbnailRow(
) {
it.diskCacheStrategy(DiskCacheStrategy.NONE)
}
- } else if (item.hasPlaceholder) {
+ } else {
+ // The resource given by the placeholder needs tinting according to our theme.
+ // But the missing thumbnail picture does not.
+ var (placeholder, shouldTint) = if (item.hasPlaceholder) {
+ item.placeholder(LocalContext.current) to true
+ } else {
+ R.drawable.ic_missing_thumbnail_picture to false
+ }
+
+ if (placeholder == 0) {
+ placeholder = R.drawable.ic_missing_thumbnail_picture
+ shouldTint = false
+ }
+
Image(
- painter = painterResource(item.placeholder(LocalContext.current)),
+ painter = painterResource(placeholder),
contentDescription = null,
modifier = Modifier.fillMaxSize(),
- contentScale = ContentScale.Inside
+ contentScale = ContentScale.Inside,
+ colorFilter = if (shouldTint) {
+ ColorFilter.tint(LocalColors.current.textSecondary)
+ } else {
+ null
+ }
)
}
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index 37f0e517ac..9f81cd153e 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -58,7 +58,10 @@
- @drawable/ic_document_small_dark
- @drawable/ic_document_large_dark
- ?danger
-
+
+ - @drawable/ic_audio_dark
+ - @drawable/ic_video_dark
+