[SES-2574] Fix crash on gallery screen (#1632)

This commit is contained in:
Fanchao Liu 2024-08-21 15:40:42 +10:00 committed by GitHub
parent eea54d1a17
commit d5ff61f021
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 7 deletions

View File

@ -152,12 +152,30 @@ private fun ThumbnailRow(
) { ) {
it.diskCacheStrategy(DiskCacheStrategy.NONE) 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( Image(
painter = painterResource(item.placeholder(LocalContext.current)), painter = painterResource(placeholder),
contentDescription = null, contentDescription = null,
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Inside contentScale = ContentScale.Inside,
colorFilter = if (shouldTint) {
ColorFilter.tint(LocalColors.current.textSecondary)
} else {
null
}
) )
} }

View File

@ -58,7 +58,10 @@
<item name="attachment_document_icon_small">@drawable/ic_document_small_dark</item> <item name="attachment_document_icon_small">@drawable/ic_document_small_dark</item>
<item name="attachment_document_icon_large">@drawable/ic_document_large_dark</item> <item name="attachment_document_icon_large">@drawable/ic_document_large_dark</item>
<item name="colorError">?danger</item> <item name="colorError">?danger</item>
</style>
<item name="conversation_icon_attach_audio">@drawable/ic_audio_dark</item>
<item name="conversation_icon_attach_video">@drawable/ic_video_dark</item>
</style>
<!-- This should be the default theme for the application. --> <!-- This should be the default theme for the application. -->
<style name="Theme.Session.DayNight" parent="Base.Theme.Session"> <style name="Theme.Session.DayNight" parent="Base.Theme.Session">
@ -206,9 +209,6 @@
<item name="linkpreview_secondary_text_color">?android:textColorPrimary</item> <item name="linkpreview_secondary_text_color">?android:textColorPrimary</item>
<item name="linkpreview_divider_color">@color/transparent</item> <item name="linkpreview_divider_color">@color/transparent</item>
<item name="conversation_icon_attach_audio">@drawable/ic_audio_dark</item>
<item name="conversation_icon_attach_video">@drawable/ic_video_dark</item>
<item name="sticker_management_icon">@drawable/sticker_button_dark</item> <item name="sticker_management_icon">@drawable/sticker_button_dark</item>
<item name="sticker_management_divider_color">@color/core_grey_75</item> <item name="sticker_management_divider_color">@color/core_grey_75</item>
<item name="sticker_management_empty_background_color">@color/core_grey_85</item> <item name="sticker_management_empty_background_color">@color/core_grey_85</item>