Merge branch 'develop' into renovate/net.zetetic-sqlcipher-android-4.x

This commit is contained in:
ganfra 2026-05-06 10:10:57 +02:00 committed by GitHub
commit 1fd02be0f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 65 additions and 6 deletions

View file

@ -58,6 +58,7 @@ import io.element.android.libraries.ui.utils.a11y.isTalkbackActive
import io.element.android.wysiwyg.compose.EditorStyledText
import io.element.android.wysiwyg.link.Link
private const val TALL_IMAGE_RATIO_DIVISOR = 3
@Composable
fun TimelineItemImageView(
content: TimelineItemImageContent,
@ -79,7 +80,7 @@ fun TimelineItemImageView(
Modifier
}
TimelineItemAspectRatioBox(
modifier = containerModifier.blurHashBackground(content.blurhash, alpha = 0.9f),
modifier = containerModifier.blurHashBackground(content.blurhash, alpha = 0.9f).align(Alignment.CenterHorizontally),
aspectRatio = coerceRatioWhenHidingContent(content.aspectRatio, hideMediaContent),
) {
ProtectedView(
@ -123,7 +124,14 @@ fun TimelineItemImageView(
LocalContentColor provides ElementTheme.colors.textPrimary,
LocalTextStyle provides ElementTheme.typography.fontBodyLgRegular
) {
val aspectRatio = content.aspectRatio ?: DEFAULT_ASPECT_RATIO
val width = content.width ?: 0
val height = content.height ?: 0
// if image is narrow and tall use DEFAULT_ASPECT_RATIO
val aspectRatio = if (width < height / TALL_IMAGE_RATIO_DIVISOR) {
DEFAULT_ASPECT_RATIO
} else {
content.aspectRatio ?: DEFAULT_ASPECT_RATIO
}
EditorStyledText(
modifier = Modifier
.padding(horizontal = 4.dp) // This is (12.dp - 8.dp) contentPadding from CommonLayout
@ -200,3 +208,38 @@ internal fun TimelineImageWithCaptionRowPreview() = ElementPreview {
)
}
}
@PreviewsDayNight
@Composable
internal fun ATimelineItemEventRowPreview() = ElementPreview {
Column {
sequenceOf(false, true).forEach { isMine ->
ATimelineItemEventRow(
event = aTimelineItemEvent(
isMine = isMine,
content = aTimelineItemImageContent(
filename = "image.jpg",
caption = "A long caption that may wrap into several lines",
width = 80,
height = 300,
aspectRatio = 80f / 300f,
),
groupPosition = TimelineItemGroupPosition.Last,
),
)
}
ATimelineItemEventRow(
event = aTimelineItemEvent(
isMine = false,
content = aTimelineItemImageContent(
filename = "image.jpg",
caption = "Narrow image with null aspectRatio",
width = 80,
height = 300,
aspectRatio = null,
),
groupPosition = TimelineItemGroupPosition.Last,
),
)
}
}

View file

@ -28,6 +28,8 @@ fun aTimelineItemImageContent(
blurhash: String? = A_BLUR_HASH,
filename: String = "A picture.jpg",
caption: String? = null,
width: Int? = null,
height: Int? = 300,
) = TimelineItemImageContent(
filename = filename,
fileSize = 4 * 1024 * 1024L,
@ -38,8 +40,8 @@ fun aTimelineItemImageContent(
thumbnailSource = null,
mimeType = MimeTypes.IMAGE_JPEG,
blurhash = blurhash,
width = null,
height = 300,
width = width,
height = height,
thumbnailWidth = null,
thumbnailHeight = 150,
aspectRatio = aspectRatio,

View file

@ -23,6 +23,13 @@ fun interface JsonProvider {
@ContributesBinding(AppScope::class)
@SingleIn(AppScope::class)
class DefaultJsonProvider : JsonProvider {
private val json: Json by lazy { Json { ignoreUnknownKeys = true } }
private val json: Json by lazy {
Json {
ignoreUnknownKeys = true
allowComments = true
allowTrailingComma = true
}
}
override fun invoke() = json
}

View file

@ -80,7 +80,8 @@ class DefaultSessionWellknownRetrieverTest {
"registration_helper_url": "a_registration_url",
"enforce_element_pro": true,
"rageshake_url": "a_rageshake_url",
"other": true
// Note the trailing comma, and the comment!
"other": true,
}""".trimIndent().toByteArray()
)
},

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:86eac241e9084cc830ff13d231908da2eb0dff246aa5cac64dddaac68a5d5f13
size 295298

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:578a3707102c7754f607c3a14f94f32cafa30ee570db174386533c484cb4773c
size 295031