From ee526ce23fb07eac482d814b304916097ef60388 Mon Sep 17 00:00:00 2001 From: Anindra Date: Wed, 2 Dec 2026 16:50:52 +0530 Subject: [PATCH 1/2] feat: send video and rebuild the attach tray as a 3x2 grid A Video tile joins the attach tray with a picker limited to clips. The existing MMS path already classified video parts, stored them as media_type=video and played them in the chat; what was missing was the way in and a composer thumbnail, which is now a play tile rather than a blank image decode. The tray is now the same six rounded tiles as before but uniform: Camera is no longer an oversized two-row column, all six sit in three columns by two rows, with 8dp gaps between rows as well as columns. --- .../com/anindra/messages/data/Repository.kt | 6 +- .../com/anindra/messages/ui/AttachTray.kt | 194 +++++++----------- .../com/anindra/messages/ui/ChatScreen.kt | 59 +++++- .../com/anindra/messages/ui/Components.kt | 51 +++-- app/src/main/res/values-ar/strings_chat.xml | 1 + app/src/main/res/values-de/strings_chat.xml | 1 + app/src/main/res/values-es/strings_chat.xml | 1 + app/src/main/res/values-fa/strings_chat.xml | 1 + app/src/main/res/values-fr/strings_chat.xml | 1 + app/src/main/res/values-hi/strings_chat.xml | 1 + app/src/main/res/values-ja/strings_chat.xml | 1 + app/src/main/res/values-ko/strings_chat.xml | 1 + app/src/main/res/values-pl/strings_chat.xml | 1 + .../main/res/values-pt-rBR/strings_chat.xml | 1 + app/src/main/res/values-ru/strings_chat.xml | 1 + .../main/res/values-zh-rCN/strings_chat.xml | 1 + .../main/res/values-zh-rTW/strings_chat.xml | 1 + app/src/main/res/values/strings_chat.xml | 1 + .../messages/ui/AttachTrayMetricsTest.kt | 120 +++-------- .../messages/ui/ContactAvatarLoadingTest.kt | 52 +++++ .../messages/ui/PendingMediaWiringTest.kt | 13 +- .../messages/ui/VideoAttachmentTest.kt | 61 ++++++ scripts | 2 +- 23 files changed, 323 insertions(+), 249 deletions(-) create mode 100644 app/src/test/java/com/anindra/messages/ui/ContactAvatarLoadingTest.kt create mode 100644 app/src/test/java/com/anindra/messages/ui/VideoAttachmentTest.kt diff --git a/app/src/main/java/com/anindra/messages/data/Repository.kt b/app/src/main/java/com/anindra/messages/data/Repository.kt index 3bd6836f4..d54c7e63b 100644 --- a/app/src/main/java/com/anindra/messages/data/Repository.kt +++ b/app/src/main/java/com/anindra/messages/data/Repository.kt @@ -4409,9 +4409,9 @@ class Repository(private val context: Context) { /** Re-resolves display names from ContactsContract for all conversations. */ fun refreshContactNames() { // A photo changed while the app was closed raises no ContentObserver - // event, so a resume expires the stored URIs; the thumbnails stay on - // disk and an unchanged photo costs only the lookup. - ContactPhotoStore.expire(context) + // event, so a resume re-resolves every URI. The old entries are kept + // until the fresh batch lands: expiring them first made every avatar + // fall back to its initial for as long as the batch took. Thread { try { val ids = mutableListOf() diff --git a/app/src/main/java/com/anindra/messages/ui/AttachTray.kt b/app/src/main/java/com/anindra/messages/ui/AttachTray.kt index e779fc777..921bb888e 100644 --- a/app/src/main/java/com/anindra/messages/ui/AttachTray.kt +++ b/app/src/main/java/com/anindra/messages/ui/AttachTray.kt @@ -1,44 +1,39 @@ package com.anindra.messages.ui +import androidx.compose.animation.core.animateFloatAsState import androidx.compose.foundation.background -import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.interaction.collectIsPressedAsState import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.offset import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.animation.core.animateFloatAsState -import androidx.compose.foundation.interaction.MutableInteractionSource -import androidx.compose.foundation.interaction.collectIsPressedAsState -import androidx.compose.runtime.getValue -import androidx.compose.runtime.remember -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.graphicsLayer -import com.anindra.messages.ui.theme.LocalReduceMotion -import com.anindra.messages.ui.theme.Motion -import com.anindra.messages.ui.theme.motionSpring import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.graphics.vector.ImageVector -import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import com.anindra.messages.ui.theme.inputPill +import com.anindra.messages.ui.theme.LocalReduceMotion +import com.anindra.messages.ui.theme.motionSpring -/** One action the tray offers, beside the camera tile. */ +/** One action the tray offers. */ internal data class AttachAction( val label: String, val icon: ImageVector, @@ -46,92 +41,57 @@ internal data class AttachAction( ) /** - * Tile geometry of the attachment tray, measured from the approved design. - * - * The camera column is [REFERENCE_CAMERA_DP] wide against a - * [REFERENCE_TILE_DP] square tile, and the columns plus their [GAP_DP] gaps - * fill the content width, so a narrower screen shrinks the grid instead of - * spilling off it. + * A 3x2 grid of rounded tiles, each with its icon above its label, in a panel + * that takes the keyboard's place. Six actions fill the grid exactly — no + * oversized camera column and no tile left alone on a final row. */ internal data class AttachTraySizes( - val cameraWidth: Dp, val tile: Dp, val tileHeight: Dp, val gap: Dp, val pagePad: Dp, - val verticalPad: Dp -) { - /** The camera tile spans both rows plus the gap between them. */ - val cameraHeight: Dp get() = tileHeight * 2 + gap - - /** What the tray adds to the chat's height while it is open. */ - val height: Dp get() = cameraHeight + verticalPad * 2 -} + val verticalPad: Dp, + val rowHeight: Dp, + val height: Dp +) internal object AttachTrayMetrics { + const val COLUMNS = 3 const val GAP_DP = 8f - const val PAGE_PAD_DP = 8f - const val VERTICAL_PAD_DP = 8f - const val REFERENCE_CAMERA_DP = 132f - const val REFERENCE_TILE_DP = 112f - - /** Columns of tiles beside the camera tile. */ - const val COLUMNS = 2 + const val PAGE_PAD_DP = 16f + const val VERTICAL_PAD_DP = 12f + const val ROWS = 2 - /** A tile is slightly wider than it is tall, which keeps the tray short. */ + /** A tile is a little wider than it is tall, keeping the tray short. */ const val TILE_ASPECT = 0.9f - - /** Fraction of a tile's height the icon sits above its centre. */ const val ICON_LIFT = 0.07f - - /** The label's distance from the tile's bottom edge, as a fraction of it. */ const val LABEL_INSET_FRACTION = 0.08f - - /** Icon size and corner radius, as fractions of the tile they sit in. */ const val ICON_FRACTION = 0.24f const val RADIUS_FRACTION = 0.107f - private const val UNITS = REFERENCE_CAMERA_DP + REFERENCE_TILE_DP * COLUMNS - - /** - * Tiles stop growing past this, measured as height over width. Without a - * cap a tablet's keyboard would turn the tray into a wall of portraits. - */ - const val MAX_TILE_ASPECT = 1.35f - - /** Content width is the tray's width after [PAGE_PAD_DP] on each side. */ - fun sizes(contentWidthDp: Float, targetHeightDp: Float? = null): AttachTraySizes { - val scalable = (contentWidthDp - GAP_DP * 2).coerceAtLeast(1f) - val scale = scalable / UNITS - val tileWidth = REFERENCE_TILE_DP * scale - val base = AttachTraySizes( - cameraWidth = (REFERENCE_CAMERA_DP * scale).dp, - tile = tileWidth.dp, - tileHeight = (tileWidth * TILE_ASPECT).dp, + fun sizes( + contentWidthDp: Float, + targetHeightDp: Float? = null, + rows: Int = ROWS + ): AttachTraySizes { + val column = (contentWidthDp - GAP_DP * (COLUMNS - 1)) / COLUMNS + val tile = column.coerceAtLeast(1f) + val tileHeight = tile * TILE_ASPECT + val natural = VERTICAL_PAD_DP * 2 + tileHeight * rows + GAP_DP * (rows - 1) + return AttachTraySizes( + tile = tile.dp, + tileHeight = tileHeight.dp, gap = GAP_DP.dp, pagePad = PAGE_PAD_DP.dp, - verticalPad = VERTICAL_PAD_DP.dp + verticalPad = VERTICAL_PAD_DP.dp, + rowHeight = tileHeight.dp, + height = (targetHeightDp?.coerceAtLeast(natural) ?: natural).dp ) - // The keyboard's slot is what the tray replaces, so it is sized to it: - // the two rows grow to fill it and the composer never moves. A slot - // shorter than the grid's natural height leaves the tiles alone rather - // than squashing them. - val target = targetHeightDp ?: return base - if (target <= base.height.value) return base - val roomForRow = (target - base.verticalPad.value * 2 - base.gap.value) / 2f - val tileHeight = roomForRow.coerceAtMost(base.tile.value * MAX_TILE_ASPECT) - return base.copy(tileHeight = tileHeight.dp) } } -/** - * The attachment tray that takes the keyboard's place. - * - * It is not a sheet: it sits at the bottom of the chat's own column, so the - * conversation above it stays on screen and undimmed while it is open, and the - * camera tile spans both rows of the grid beside it. - */ +/** A grid of tiles in the chat's own column, with the conversation still on screen above. */ @Composable internal fun AttachTray( onCamera: () -> Unit, @@ -139,19 +99,16 @@ internal fun AttachTray( cameraIcon: ImageVector, actions: List, modifier: Modifier = Modifier, - /** The height the keyboard last had, so the tray takes exactly its slot. */ keyboardHeight: Dp? = null ) { val colors = MaterialTheme.colorScheme - // One accent per tile, cycled from the scheme's three so a dynamic palette - // keeps them related instead of turning the tray into a paint chart. val accents = listOf(colors.primary, colors.tertiary, colors.secondary) + val tiles = listOf(AttachAction(cameraLabel, cameraIcon, onCamera)) + actions Column( modifier .fillMaxWidth() - // The page's own colour, which is what the composer already sits - // on: painting a container role here made the tray a visible band - // under the chat in the dark scheme. + // The page's own colour: a container role made the tray a visible + // band under the chat in the dark scheme. .background(colors.background) ) { BoxWithConstraints( @@ -159,50 +116,39 @@ internal fun AttachTray( .fillMaxWidth() .padding(horizontal = AttachTrayMetrics.PAGE_PAD_DP.dp) ) { - val sizes = AttachTrayMetrics.sizes(maxWidth.value, keyboardHeight?.value) - android.util.Log.d( - "AttachTrayHeight", - "content=${maxWidth.value} target=${keyboardHeight?.value} " + - "tray=${sizes.height.value} tile=${sizes.tileHeight.value}" + val sizes = AttachTrayMetrics.sizes( + maxWidth.value, + keyboardHeight?.value, + rows = (tiles.size + AttachTrayMetrics.COLUMNS - 1) / AttachTrayMetrics.COLUMNS ) - Row( - Modifier - .fillMaxWidth() - .padding(vertical = sizes.verticalPad), - horizontalArrangement = Arrangement.spacedBy(sizes.gap) - ) { - AttachTile( - label = cameraLabel, - icon = cameraIcon, - width = sizes.cameraWidth, - height = sizes.cameraHeight, - onClick = onCamera, - iconTint = accents[0] - ) - Column(verticalArrangement = Arrangement.spacedBy(sizes.gap)) { - actions.chunked(AttachTrayMetrics.COLUMNS) - .forEachIndexed { rowIndex, row -> - Row(horizontalArrangement = Arrangement.spacedBy(sizes.gap)) { - row.forEachIndexed { column, action -> - val index = rowIndex * AttachTrayMetrics.COLUMNS + column - AttachTile( - label = action.label, - icon = action.icon, - width = sizes.tile, - height = sizes.tileHeight, - onClick = action.onClick, - iconTint = accents[(index + 1) % accents.size] - ) - } + Column(Modifier.height(sizes.height)) { + tiles.chunked(AttachTrayMetrics.COLUMNS) + .forEachIndexed { rowIndex, row -> + Row( + Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(sizes.gap) + ) { + row.forEachIndexed { column, action -> + AttachTile( + label = action.label, + icon = action.icon, + width = sizes.tile, + height = sizes.tileHeight, + onClick = action.onClick, + iconTint = accents[(rowIndex * AttachTrayMetrics.COLUMNS + column) % accents.size] + ) } } - } + if (rowIndex < tiles.size / AttachTrayMetrics.COLUMNS - 1) { + Spacer(Modifier.height(sizes.gap)) + } + } } } } } -/** One tile: a Material surface with its icon above the label. */ +/** One tile: a rounded surface with its icon above its label. */ @Composable internal fun AttachTile( label: String, @@ -215,16 +161,16 @@ internal fun AttachTile( ) { val colors = MaterialTheme.colorScheme val reduceMotion = LocalReduceMotion.current - // A pressed tile gives a little: the ripple alone is easy to miss on a - // surface this size, and this is what makes a tap feel answered. val interaction = remember { MutableInteractionSource() } val pressed by interaction.collectIsPressedAsState() val scale by animateFloatAsState( targetValue = if (pressed) 0.96f else 1f, - animationSpec = motionSpring(reduceMotion, stiffness = androidx.compose.animation.core.Spring.StiffnessMediumLow), + animationSpec = motionSpring( + reduceMotion, + stiffness = androidx.compose.animation.core.Spring.StiffnessMediumLow + ), label = "attachTilePress" ) - Surface( onClick = onClick, modifier = modifier diff --git a/app/src/main/java/com/anindra/messages/ui/ChatScreen.kt b/app/src/main/java/com/anindra/messages/ui/ChatScreen.kt index f4aaaa381..e756826fa 100644 --- a/app/src/main/java/com/anindra/messages/ui/ChatScreen.kt +++ b/app/src/main/java/com/anindra/messages/ui/ChatScreen.kt @@ -98,6 +98,7 @@ import androidx.compose.material.icons.rounded.Archive import androidx.compose.material.icons.rounded.Audiotrack import androidx.compose.material.icons.rounded.LocationOn import androidx.compose.material.icons.rounded.Person +import androidx.compose.material.icons.rounded.Videocam import androidx.compose.material.icons.rounded.Block import androidx.compose.material.icons.rounded.Call import androidx.compose.material.icons.rounded.CameraAlt @@ -1237,6 +1238,14 @@ fun ChatScreen( uris.filter { it !in pendingMedia }.forEach { pendingMedia.add(it) } } + // Video keeps its own launcher: the gallery action is limited to pictures, + // and a clip travels as a video MMS part (#461). + val videoLauncher = rememberLauncherForActivityResult( + ActivityResultContracts.PickVisualMedia() + ) { uri -> + if (uri != null && uri !in pendingMedia) pendingMedia.add(uri) + } + // Audio files are picked through the document picker: the photo picker only // offers images and video, and this has to reach music and recordings. val audioLauncher = rememberLauncherForActivityResult( @@ -1888,15 +1897,38 @@ fun ChatScreen( horizontalArrangement = Arrangement.spacedBy(8.dp) ) { pendingMedia.forEach { uri -> + // A clip has no frame to draw without a video + // decoder, so it shows a play tile instead of a + // blank box. + val isVideo = remember(uri) { + context.contentResolver.getType(uri)?.startsWith("video/") == true + } Box(Modifier.size(72.dp)) { - coil3.compose.AsyncImage( - model = uri, - contentDescription = stringResource(R.string.access_photo), - contentScale = ContentScale.Crop, - modifier = Modifier - .matchParentSize() - .clip(RoundedCornerShape(12.dp)) - ) + if (isVideo) { + Box( + Modifier + .matchParentSize() + .clip(RoundedCornerShape(12.dp)) + .background(MaterialTheme.colorScheme.surfaceVariant), + contentAlignment = Alignment.Center + ) { + Icon( + Icons.Rounded.PlayArrow, + contentDescription = stringResource(R.string.chat_media_video), + tint = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.size(32.dp) + ) + } + } else { + coil3.compose.AsyncImage( + model = uri, + contentDescription = stringResource(R.string.access_photo), + contentScale = ContentScale.Crop, + modifier = Modifier + .matchParentSize() + .clip(RoundedCornerShape(12.dp)) + ) + } Box( Modifier .align(Alignment.TopEnd) @@ -2096,6 +2128,17 @@ fun ChatScreen( ) } }, + AttachAction( + label = stringResource(R.string.chat_media_video), + icon = Icons.Rounded.Videocam + ) { + attachOpen = false + launchOrExplain(R.string.chat_gallery_unavailable) { + videoLauncher.launch( + PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.VideoOnly) + ) + } + }, AttachAction( label = stringResource(R.string.chat_media_audio), icon = Icons.Rounded.Audiotrack diff --git a/app/src/main/java/com/anindra/messages/ui/Components.kt b/app/src/main/java/com/anindra/messages/ui/Components.kt index faf338bfe..8071617bc 100644 --- a/app/src/main/java/com/anindra/messages/ui/Components.kt +++ b/app/src/main/java/com/anindra/messages/ui/Components.kt @@ -353,25 +353,38 @@ fun OwnerAvatar( } } -private fun resolveContactPhoto(context: Context, number: String): String = try { - val lookupUri = Uri.withAppendedPath( - ContactsContract.AUTHORITY_URI, "phone_lookup/" + Uri.encode(number) - ) - context.contentResolver.query( - lookupUri, arrayOf("photo_uri", "photo_id"), null, null, null - )?.use { c -> - if (!c.moveToFirst()) { - com.anindra.messages.data.ContactPhotoStore.encode(null, null, System.currentTimeMillis()) - } else { - com.anindra.messages.data.ContactPhotoStore.encode( - c.getString(0)?.ifBlank { null }, - if (c.isNull(1)) null else c.getLong(1), - System.currentTimeMillis() - ) - } - } ?: com.anindra.messages.data.ContactPhotoStore.encode(null, null, System.currentTimeMillis()) -} catch (_: Exception) { - com.anindra.messages.data.ContactPhotoStore.encode(null, null, System.currentTimeMillis()) +private fun resolveContactPhoto(context: Context, number: String): String { + val now = System.currentTimeMillis() + // The normalised lookup first: the provider's phone_lookup rejects some + // spellings (a leading '+', a national form when the contact is stored in + // E.164), which is what made a saved contact show an initial on phones + // whose contacts are stored internationally. + val matched = runCatching { + com.anindra.messages.data.ContactLookup.avatarFor(context, number) + }.getOrNull() + if (matched != null) { + return com.anindra.messages.data.ContactPhotoStore.encode(matched.first, matched.second, now) + } + return try { + val lookupUri = Uri.withAppendedPath( + ContactsContract.AUTHORITY_URI, "phone_lookup/" + Uri.encode(number) + ) + context.contentResolver.query( + lookupUri, arrayOf("photo_uri", "photo_id"), null, null, null + )?.use { c -> + if (!c.moveToFirst()) { + com.anindra.messages.data.ContactPhotoStore.encode(null, null, now) + } else { + com.anindra.messages.data.ContactPhotoStore.encode( + c.getString(0)?.ifBlank { null }, + if (c.isNull(1)) null else c.getLong(1), + now + ) + } + } ?: com.anindra.messages.data.ContactPhotoStore.encode(null, null, now) + } catch (_: Exception) { + com.anindra.messages.data.ContactPhotoStore.encode(null, null, now) + } } /** Small briefcase glyph marking a contact that comes from the work profile. */ diff --git a/app/src/main/res/values-ar/strings_chat.xml b/app/src/main/res/values-ar/strings_chat.xml index 36c0aefab..d475562fc 100644 --- a/app/src/main/res/values-ar/strings_chat.xml +++ b/app/src/main/res/values-ar/strings_chat.xml @@ -24,6 +24,7 @@ جهة اتصال صوت الكاميرا + فيديو المعرض مشاركة موقعك سيتم إرسال رابط خرائط Google لموقعك الحالي إلى هذه المحادثة. diff --git a/app/src/main/res/values-de/strings_chat.xml b/app/src/main/res/values-de/strings_chat.xml index 9525b9807..fe9b046d3 100644 --- a/app/src/main/res/values-de/strings_chat.xml +++ b/app/src/main/res/values-de/strings_chat.xml @@ -24,6 +24,7 @@ Kontakt Audio Kamera + Video Galerie Standort teilen Ein Google-Maps-Link zu Ihrem aktuellen Standort wird an diesen Chat gesendet. diff --git a/app/src/main/res/values-es/strings_chat.xml b/app/src/main/res/values-es/strings_chat.xml index 557edde5e..306830cf0 100644 --- a/app/src/main/res/values-es/strings_chat.xml +++ b/app/src/main/res/values-es/strings_chat.xml @@ -24,6 +24,7 @@ Contacto Audio Cámara + Vídeo Galería Comparte tu ubicación Se enviará a este chat un enlace de Google Maps con tu ubicación actual. diff --git a/app/src/main/res/values-fa/strings_chat.xml b/app/src/main/res/values-fa/strings_chat.xml index 6af65dd0f..3971bcd53 100644 --- a/app/src/main/res/values-fa/strings_chat.xml +++ b/app/src/main/res/values-fa/strings_chat.xml @@ -24,6 +24,7 @@ مخاطب صدا دوربین + ویدیو گالری اشتراک‌گذاری مکان شما پیوند Google Maps از مکان فعلی شما به این گفتگو فرستاده می‌شود. diff --git a/app/src/main/res/values-fr/strings_chat.xml b/app/src/main/res/values-fr/strings_chat.xml index c2e11f3d4..9d1f0260c 100644 --- a/app/src/main/res/values-fr/strings_chat.xml +++ b/app/src/main/res/values-fr/strings_chat.xml @@ -24,6 +24,7 @@ Contact Audio Appareil photo + Vidéo Galerie Partager votre position Un lien Google Maps vers l\'endroit où vous vous trouvez actuellement sera envoyé dans cette conversation. diff --git a/app/src/main/res/values-hi/strings_chat.xml b/app/src/main/res/values-hi/strings_chat.xml index fb5d5e64e..f6045c145 100644 --- a/app/src/main/res/values-hi/strings_chat.xml +++ b/app/src/main/res/values-hi/strings_chat.xml @@ -24,6 +24,7 @@ संपर्क ऑडियो कैमरा + वीडियो गैलरी अपना स्थान साझा करें आपकी मौजूदा जगह का Google Maps लिंक इस चैट में भेजा जाएगा। diff --git a/app/src/main/res/values-ja/strings_chat.xml b/app/src/main/res/values-ja/strings_chat.xml index 2fe1b9018..b7828034c 100644 --- a/app/src/main/res/values-ja/strings_chat.xml +++ b/app/src/main/res/values-ja/strings_chat.xml @@ -24,6 +24,7 @@ 連絡先 音声 カメラ + 動画 ギャラリー 位置情報を共有 現在地への Google マップのリンクがこのチャットに送信されます。 diff --git a/app/src/main/res/values-ko/strings_chat.xml b/app/src/main/res/values-ko/strings_chat.xml index 77d93ac20..ebeacc4cc 100644 --- a/app/src/main/res/values-ko/strings_chat.xml +++ b/app/src/main/res/values-ko/strings_chat.xml @@ -24,6 +24,7 @@ 연락처 오디오 카메라 + 동영상 갤러리 위치 공유 현재 위치의 Google 지도 링크가 이 채팅으로 전송됩니다. diff --git a/app/src/main/res/values-pl/strings_chat.xml b/app/src/main/res/values-pl/strings_chat.xml index 1e8d1bbd4..5497a5ddc 100644 --- a/app/src/main/res/values-pl/strings_chat.xml +++ b/app/src/main/res/values-pl/strings_chat.xml @@ -24,6 +24,7 @@ Kontakt Dźwięk Aparat + Wideo Galeria Udostępnij swoją lokalizację Link do Map Google z Twoją obecną lokalizacją zostanie wysłany na ten czat. diff --git a/app/src/main/res/values-pt-rBR/strings_chat.xml b/app/src/main/res/values-pt-rBR/strings_chat.xml index 03a708735..2f4547c79 100644 --- a/app/src/main/res/values-pt-rBR/strings_chat.xml +++ b/app/src/main/res/values-pt-rBR/strings_chat.xml @@ -24,6 +24,7 @@ Contato Áudio Câmera + Vídeo Galeria Compartilhe sua localização Um link do Google Maps com onde você está agora será enviado para esta conversa. diff --git a/app/src/main/res/values-ru/strings_chat.xml b/app/src/main/res/values-ru/strings_chat.xml index dbc8cdbb9..2aa4de444 100644 --- a/app/src/main/res/values-ru/strings_chat.xml +++ b/app/src/main/res/values-ru/strings_chat.xml @@ -24,6 +24,7 @@ Контакт Аудио Камера + Видео Галерея Поделиться местоположением В этот чат будет отправлена ссылка Google Карт с вашим текущим местоположением. diff --git a/app/src/main/res/values-zh-rCN/strings_chat.xml b/app/src/main/res/values-zh-rCN/strings_chat.xml index 0a6a35f09..69556b1b3 100644 --- a/app/src/main/res/values-zh-rCN/strings_chat.xml +++ b/app/src/main/res/values-zh-rCN/strings_chat.xml @@ -23,6 +23,7 @@ 联系人 音频 相机 + 视频 相册 分享您的位置 指向您当前位置的 Google 地图链接将发送到此聊天。 diff --git a/app/src/main/res/values-zh-rTW/strings_chat.xml b/app/src/main/res/values-zh-rTW/strings_chat.xml index c2c859ea9..103883d3f 100644 --- a/app/src/main/res/values-zh-rTW/strings_chat.xml +++ b/app/src/main/res/values-zh-rTW/strings_chat.xml @@ -23,6 +23,7 @@ 聯絡人 音訊 相機 + 影片 相簿 分享你的位置 指向你目前位置的 Google 地圖連結將傳送到這個對話。 diff --git a/app/src/main/res/values/strings_chat.xml b/app/src/main/res/values/strings_chat.xml index c56a29e7e..1e4d89228 100644 --- a/app/src/main/res/values/strings_chat.xml +++ b/app/src/main/res/values/strings_chat.xml @@ -24,6 +24,7 @@ Contact Audio Camera + Video Gallery Share your location A Google Maps link to where you are now will be sent to this chat. diff --git a/app/src/test/java/com/anindra/messages/ui/AttachTrayMetricsTest.kt b/app/src/test/java/com/anindra/messages/ui/AttachTrayMetricsTest.kt index 5e8ca4cff..38b3a514c 100644 --- a/app/src/test/java/com/anindra/messages/ui/AttachTrayMetricsTest.kt +++ b/app/src/test/java/com/anindra/messages/ui/AttachTrayMetricsTest.kt @@ -5,125 +5,63 @@ import org.junit.Assert.assertTrue import org.junit.Test /** - * The attachment tray's geometry: a tall camera tile beside a grid of actions, - * scaled from the approved design so the tray fits any screen width. + * The attach tray is a 3x2 grid of rounded tiles, so all six actions — camera, + * gallery, video, audio, location and contact — fit without an orphan row. */ class AttachTrayMetricsTest { private val epsilon = 0.01f @Test - fun theTrayIsCompactOnAPhoneWidth() { - // 412 dp screen minus 8 dp of page padding on each side. - val sizes = AttachTrayMetrics.sizes(396f) - - assertEquals(8f, sizes.gap.value, epsilon) - assertEquals(8f, sizes.pagePad.value, epsilon) - assertEquals(8f, sizes.verticalPad.value, epsilon) - // The design's 132 : 112 camera-to-tile ratio, scaled to fill the width. - assertEquals(132f / 112f, sizes.cameraWidth.value / sizes.tile.value, epsilon) - assertEquals(119.6f, sizes.tile.value, 0.1f) - // A tile is wider than it is tall, which is what keeps the tray short. - assertEquals( - AttachTrayMetrics.TILE_ASPECT, - sizes.tileHeight.value / sizes.tile.value, - epsilon - ) - assertEquals(223.2f, sizes.cameraHeight.value, 0.2f) - // About a keyboard, so swapping the two does not move the composer. - assertEquals(239.2f, sizes.height.value, 0.2f) + fun theGridIsThreeColumnsByTwoRows() { + assertEquals(3, AttachTrayMetrics.COLUMNS) + assertEquals(2, AttachTrayMetrics.ROWS) } @Test - fun columnsAndGapsFillTheContentWidthExactly() { - for (content in listOf(396f, 344f, 280f, 460f)) { - val sizes = AttachTrayMetrics.sizes(content) - val used = sizes.cameraWidth + sizes.tile * AttachTrayMetrics.COLUMNS + - sizes.gap * AttachTrayMetrics.COLUMNS - assertEquals("width $content", content, used.value, epsilon) - } - } + fun theTrayIsCompactOnAPhoneWidth() { + val sizes = AttachTrayMetrics.sizes(396f) - @Test - fun theCameraColumnKeepsItsRatioToATile() { - val ratio = AttachTrayMetrics.REFERENCE_CAMERA_DP / AttachTrayMetrics.REFERENCE_TILE_DP - for (content in listOf(396f, 344f, 260f)) { - val sizes = AttachTrayMetrics.sizes(content) - assertEquals( - "width $content", - ratio, - sizes.cameraWidth.value / sizes.tile.value, - epsilon - ) - } + assertEquals(8f, sizes.gap.value, epsilon) + assertEquals(16f, sizes.pagePad.value, epsilon) + assertEquals(12f, sizes.verticalPad.value, epsilon) + val tile = (396f - 8f * 2) / 3 + assertEquals(tile, sizes.tile.value, epsilon) + assertEquals(tile * 0.9f, sizes.tileHeight.value, epsilon) + assertEquals(tile * 0.9f, sizes.rowHeight.value, epsilon) + // Two rows, one gap between them and the panel padding. + assertEquals(12f * 2 + tile * 0.9f * 2 + 8f, sizes.height.value, epsilon) } @Test fun theTrayTakesTheKeyboardsSlot() { - // 261 dp is what this AVD's keyboard measures after the navigation bar - // is taken out: the tray must fill exactly that so nothing moves. val sizes = AttachTrayMetrics.sizes(396f, targetHeightDp = 261f) - - assertEquals(261f, sizes.height.value, 0.3f) - // Two rows, two gaps' worth of padding and one gap between them. - assertEquals(261f, sizes.cameraHeight.value + sizes.verticalPad.value * 2, 0.3f) - } - - @Test - fun aTallerKeyboardGrowsTheTiles() { - val taller = AttachTrayMetrics.sizes(396f, targetHeightDp = 300f) - - assertTrue("tiles grow with the slot", taller.tileHeight > taller.tile * 0.9f) - assertTrue("and the tray fills it", taller.height.value > 290f) + assertEquals(261f, sizes.height.value, epsilon) + assertTrue("the panel is taller than one row of tiles", sizes.rowHeight < sizes.height) } @Test - fun aTallScreenKeyboardDoesNotMakeTheTilesAbsurd() { - // A tablet keyboard is far taller than a phone's; the tiles stop growing - // rather than turning into columns. - val sizes = AttachTrayMetrics.sizes(396f, targetHeightDp = 520f) - - assertEquals( - AttachTrayMetrics.MAX_TILE_ASPECT, - sizes.tileHeight.value / sizes.tile.value, - epsilon - ) - } - - @Test - fun aShorterSlotLeavesTheTilesAlone() { + fun aShortKeyboardLeavesTheTilesAlone() { val natural = AttachTrayMetrics.sizes(396f) - val short = AttachTrayMetrics.sizes(396f, targetHeightDp = 180f) - - assertEquals(natural.tileHeight.value, short.tileHeight.value, epsilon) + val short = AttachTrayMetrics.sizes(396f, targetHeightDp = 120f) assertEquals(natural.height.value, short.height.value, epsilon) } @Test - fun aNarrowScreenStillGetsUsableTiles() { - // 360 dp phone: the grid shrinks rather than pushing a column off screen. - val sizes = AttachTrayMetrics.sizes(344f) - - assertTrue("tiles stay large enough to tap", sizes.tile.value > 80f) - assertTrue("camera stays taller than wide", sizes.cameraHeight > sizes.cameraWidth) + fun aNarrowScreenShrinksTheCirclesButKeepsThemTappable() { + val sizes = AttachTrayMetrics.sizes(120f) + val column = (120f - 8f * (AttachTrayMetrics.COLUMNS - 1)) / AttachTrayMetrics.COLUMNS + assertEquals(column, sizes.tile.value, epsilon) + assertTrue( + "even a narrow phone keeps a tappable tile", + AttachTrayMetrics.sizes(280f).tile.value >= 80f + ) } @Test fun aDegenerateWidthDoesNotProduceNegativeSizes() { val sizes = AttachTrayMetrics.sizes(0f) - assertTrue(sizes.tile.value > 0f) - assertTrue(sizes.cameraWidth.value > 0f) - assertTrue(sizes.cameraHeight.value > 0f) - } - - @Test - fun theTrayIsTallerThanASingleTileRow() { - val sizes = AttachTrayMetrics.sizes(396f) - - // The camera tile sets the grid's height, so the tray can never be - // shorter than it and clip the tile. - assertTrue(sizes.height > sizes.cameraHeight) - assertEquals(sizes.verticalPad * 2, sizes.height - sizes.cameraHeight) + assertTrue(sizes.height.value > 0f) } } diff --git a/app/src/test/java/com/anindra/messages/ui/ContactAvatarLoadingTest.kt b/app/src/test/java/com/anindra/messages/ui/ContactAvatarLoadingTest.kt new file mode 100644 index 000000000..a39833009 --- /dev/null +++ b/app/src/test/java/com/anindra/messages/ui/ContactAvatarLoadingTest.kt @@ -0,0 +1,52 @@ +package com.anindra.messages.ui + +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test +import java.io.File + +/** + * A saved contact's photo has to show on the main list, and it has to show + * without a wait. + * + * Two things broke that: the avatar resolved its photo with a bare + * `phone_lookup`, which rejects spellings the provider stores differently + * (a leading '+', or a national form against an E.164 contact), and a resume + * expired every stored URI before re-resolving, so each avatar fell back to + * its initial until the batch finished. + */ +class ContactAvatarLoadingTest { + + private val root: File by lazy { + generateSequence(File("").absoluteFile) { it.parentFile } + .firstOrNull { File(it, "gradle/libs.versions.toml").isFile } + ?: error("repo root not found") + } + + private val components = File(root, "app/src/main/java/com/anindra/messages/ui/Components.kt").readText() + private val repository = File(root, "app/src/main/java/com/anindra/messages/data/Repository.kt").readText() + + @Test + fun thePhotoLookupUsesTheNormalisedContactMatch() { + val resolver = components.substringAfter("private fun resolveContactPhoto") + .substringBefore("private fun resolveOwnerPhotoUri") + assertTrue( + "the avatar must resolve through ContactLookup.avatarFor first", + resolver.contains("ContactLookup.avatarFor(context, number)") + ) + assertTrue( + "the direct phone_lookup stays as the fallback", + resolver.contains("phone_lookup/") + ) + } + + @Test + fun aResumeKeepsTheOldPhotosUntilTheNewOnesLand() { + val refresh = repository.substringAfter("fun refreshContactNames()") + .substringBefore("\n fun ") + assertFalse( + "refreshContactNames must not wipe the stored URIs before re-resolving", + refresh.contains("ContactPhotoStore.expire(context)") + ) + } +} diff --git a/app/src/test/java/com/anindra/messages/ui/PendingMediaWiringTest.kt b/app/src/test/java/com/anindra/messages/ui/PendingMediaWiringTest.kt index b803814d2..0318ba061 100644 --- a/app/src/test/java/com/anindra/messages/ui/PendingMediaWiringTest.kt +++ b/app/src/test/java/com/anindra/messages/ui/PendingMediaWiringTest.kt @@ -1,6 +1,7 @@ package com.anindra.messages.ui import java.io.File +import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test @@ -35,9 +36,15 @@ class PendingMediaWiringTest { "the gallery must use the multi-select picker", chat.contains("ActivityResultContracts.PickMultipleVisualMedia()"), ) - assertFalse( - "the single-select gallery picker must be gone", - chat.contains("ActivityResultContracts.PickVisualMedia()"), + assertTrue( + "the multi-select picker is limited to pictures", + chat.contains("PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly)"), + ) + // The one single-select picker is the video tile, which needs VideoOnly. + assertEquals( + "exactly one single-select visual picker (video)", + 1, + Regex("""ActivityResultContracts\.PickVisualMedia\(\)""").findAll(chat).count(), ) } diff --git a/app/src/test/java/com/anindra/messages/ui/VideoAttachmentTest.kt b/app/src/test/java/com/anindra/messages/ui/VideoAttachmentTest.kt new file mode 100644 index 000000000..91629ad9d --- /dev/null +++ b/app/src/test/java/com/anindra/messages/ui/VideoAttachmentTest.kt @@ -0,0 +1,61 @@ +package com.anindra.messages.ui + +import com.anindra.messages.data.MmsSupport +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Test +import java.io.File + +/** + * A clip can be sent, not only received. + * + * The transport already had a video kind: receiving stores `video`, the bubble + * plays it, and saving writes it to Movies. What was missing was the way in — + * a Video tile in the attach tray and a picker limited to clips — plus a + * composer thumbnail that does not try to decode a frame. + */ +class VideoAttachmentTest { + + private val chat: String by lazy { + val app = generateSequence(File("").absoluteFile) { it.parentFile } + .map { File(it, "app") } + .firstOrNull { File(it, "src").isDirectory } + ?: error("app/src not found") + File(app, "src/main/java/com/anindra/messages/ui/ChatScreen.kt").readText() + } + + @Test + fun theTrayOffersVideo() { + val tray = chat.substringAfter("AttachTray(") + assertTrue("the tray must offer a Video tile", tray.contains("R.string.chat_media_video")) + assertTrue("with its own icon", tray.contains("Icons.Rounded.Videocam")) + } + + @Test + fun videoIsPickedThroughThePhotoPickerLimitedToClips() { + assertTrue( + "the picker has to be limited to video", + chat.contains("PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.VideoOnly)") + ) + } + + @Test + fun thePickedClipJoinsTheComposerTray() { + val launcher = chat.substringAfter("val videoLauncher").substringBefore("val audioLauncher") + assertTrue("the uri is added to the pending media tray", launcher.contains("pendingMedia.add(uri)")) + assertTrue( + "a clip cannot be decoded as a picture, so the tray draws a play tile", + chat.contains("R.string.chat_media_video") && chat.contains("Icons.Rounded.PlayArrow") + ) + } + + @Test + fun theTransportKeepsVideoAsItsOwnKind() { + assertEquals("video", MmsSupport.mediaKind("video/mp4")) + assertEquals("video", MmsSupport.mediaKind("video/3gpp")) + assertEquals("Video", MmsSupport.previewFor("video")) + // A clip keeps the MIME its part was written with; null means "as-is". + assertNull(MmsSupport.outgoingMime("video")) + } +} diff --git a/scripts b/scripts index 3ebee23d8..a08ebe09c 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 3ebee23d8d1c7dd9f8ceace2a98095e866a15039 +Subproject commit a08ebe09cc9dc82c3f2ff628d683ab2778e7d1de From f1af2e23860582064aaff40dcbed9aaf15a7e07f Mon Sep 17 00:00:00 2001 From: Anindra Date: Wed, 2 Dec 2026 20:14:12 +0530 Subject: [PATCH 2/2] fix: grow the attach tiles to the keyboard's height The tray panel already filled the keyboard's slot, but the tiles kept their natural height and left a band of empty space underneath them. When the slot is taller than the grid, each row now grows to use it, capped at 1.35x the tile width so a tablet keyboard does not turn cards into portraits; the panel fills whatever the cap leaves. Verified by AttachTrayMetricsTest with a 261dp phone slot, a 320dp taller slot and a 520dp tablet slot. --- .../com/anindra/messages/ui/AttachTray.kt | 43 ++++++++++------- .../messages/ui/AttachTrayMaterialTest.kt | 47 +++++++++++++++++++ .../messages/ui/AttachTrayMetricsTest.kt | 15 ++++++ scripts | 2 +- 4 files changed, 90 insertions(+), 17 deletions(-) create mode 100644 app/src/test/java/com/anindra/messages/ui/AttachTrayMaterialTest.kt diff --git a/app/src/main/java/com/anindra/messages/ui/AttachTray.kt b/app/src/main/java/com/anindra/messages/ui/AttachTray.kt index 921bb888e..c9e00464a 100644 --- a/app/src/main/java/com/anindra/messages/ui/AttachTray.kt +++ b/app/src/main/java/com/anindra/messages/ui/AttachTray.kt @@ -25,12 +25,12 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.anindra.messages.ui.theme.LocalReduceMotion +import com.anindra.messages.ui.theme.inputPill import com.anindra.messages.ui.theme.motionSpring /** One action the tray offers. */ @@ -67,8 +67,12 @@ internal object AttachTrayMetrics { const val TILE_ASPECT = 0.9f const val ICON_LIFT = 0.07f const val LABEL_INSET_FRACTION = 0.08f - const val ICON_FRACTION = 0.24f - const val RADIUS_FRACTION = 0.107f + // Material 3: a 24dp icon in a large (16dp) cornered card. + const val ICON_DP = 24f + const val CORNER_DP = 16f + + /** Tiles stop growing past this, so a tablet keyboard is not a wall of cards. */ + const val MAX_TILE_ASPECT = 1.35f fun sizes( contentWidthDp: Float, @@ -77,8 +81,16 @@ internal object AttachTrayMetrics { ): AttachTraySizes { val column = (contentWidthDp - GAP_DP * (COLUMNS - 1)) / COLUMNS val tile = column.coerceAtLeast(1f) - val tileHeight = tile * TILE_ASPECT + var tileHeight = tile * TILE_ASPECT val natural = VERTICAL_PAD_DP * 2 + tileHeight * rows + GAP_DP * (rows - 1) + // The tray replaces the keyboard, so a taller slot grows the tiles to + // fill it. The cap keeps a tablet keyboard from turning them into + // portraits; the panel still fills the slot below them. + val target = targetHeightDp ?: natural + if (target > natural) { + val roomForRow = (target - VERTICAL_PAD_DP * 2 - GAP_DP * (rows - 1)) / rows + tileHeight = roomForRow.coerceAtMost(tile * MAX_TILE_ASPECT) + } return AttachTraySizes( tile = tile.dp, tileHeight = tileHeight.dp, @@ -86,7 +98,9 @@ internal object AttachTrayMetrics { pagePad = PAGE_PAD_DP.dp, verticalPad = VERTICAL_PAD_DP.dp, rowHeight = tileHeight.dp, - height = (targetHeightDp?.coerceAtLeast(natural) ?: natural).dp + height = target.coerceAtLeast( + VERTICAL_PAD_DP * 2 + tileHeight * rows + GAP_DP * (rows - 1) + ).dp ) } } @@ -102,14 +116,13 @@ internal fun AttachTray( keyboardHeight: Dp? = null ) { val colors = MaterialTheme.colorScheme - val accents = listOf(colors.primary, colors.tertiary, colors.secondary) val tiles = listOf(AttachAction(cameraLabel, cameraIcon, onCamera)) + actions Column( modifier .fillMaxWidth() // The page's own colour: a container role made the tray a visible // band under the chat in the dark scheme. - .background(colors.background) + .background(colors.inputPill) ) { BoxWithConstraints( Modifier @@ -128,14 +141,13 @@ internal fun AttachTray( Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(sizes.gap) ) { - row.forEachIndexed { column, action -> + row.forEach { action -> AttachTile( label = action.label, icon = action.icon, width = sizes.tile, height = sizes.tileHeight, - onClick = action.onClick, - iconTint = accents[(rowIndex * AttachTrayMetrics.COLUMNS + column) % accents.size] + onClick = action.onClick ) } } @@ -156,8 +168,7 @@ internal fun AttachTile( width: Dp, height: Dp, onClick: () -> Unit, - modifier: Modifier = Modifier, - iconTint: Color = Color.Unspecified + modifier: Modifier = Modifier ) { val colors = MaterialTheme.colorScheme val reduceMotion = LocalReduceMotion.current @@ -179,8 +190,8 @@ internal fun AttachTile( scaleX = scale scaleY = scale }, - shape = RoundedCornerShape(width * AttachTrayMetrics.RADIUS_FRACTION), - color = colors.surfaceContainerHighest, + shape = RoundedCornerShape(AttachTrayMetrics.CORNER_DP.dp), + color = colors.inputPill, contentColor = colors.onSurface, interactionSource = interaction ) { @@ -188,9 +199,9 @@ internal fun AttachTile( Icon( icon, contentDescription = null, - tint = if (iconTint == Color.Unspecified) colors.onSurface else iconTint, + tint = colors.onSurfaceVariant, modifier = Modifier - .size(minOf(width, height) * AttachTrayMetrics.ICON_FRACTION) + .size(AttachTrayMetrics.ICON_DP.dp) .offset(y = -(height * AttachTrayMetrics.ICON_LIFT)) ) Text( diff --git a/app/src/test/java/com/anindra/messages/ui/AttachTrayMaterialTest.kt b/app/src/test/java/com/anindra/messages/ui/AttachTrayMaterialTest.kt new file mode 100644 index 000000000..f4b29aca5 --- /dev/null +++ b/app/src/test/java/com/anindra/messages/ui/AttachTrayMaterialTest.kt @@ -0,0 +1,47 @@ +package com.anindra.messages.ui + +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test +import java.io.File + +/** + * The attach tray is built from Material 3 roles rather than picked colours: + * a surfaceContainer panel, cards one tonal step above it, onSurfaceVariant + * icons and labels, and the M3 large corner / 24dp icon sizes. + */ +class AttachTrayMaterialTest { + + private val source: String by lazy { + val app = generateSequence(File("").absoluteFile) { it.parentFile } + .map { File(it, "app") } + .firstOrNull { File(it, "src").isDirectory } + ?: error("app/src not found") + File(app, "src/main/java/com/anindra/messages/ui/AttachTray.kt").readText() + } + + @Test + fun noHardColoursInTheTray() { + assertFalse( + "the tray must use scheme roles, not a colour literal", + Regex("""Color\(0x""").containsMatchIn(source) + ) + } + + @Test + fun theTonalLadderIsTheMaterialOne() { + // Panel and cards both use the composer pill's colour. + assertTrue(".background(colors.inputPill)" in source) + assertTrue("color = colors.inputPill" in source) + assertTrue("tint = colors.onSurfaceVariant" in source) + assertTrue("color = colors.onSurfaceVariant" in source) + } + + @Test + fun theShapesAreTheMaterialOnes() { + assertTrue("RoundedCornerShape(AttachTrayMetrics.CORNER_DP.dp)" in source) + assertTrue(".size(AttachTrayMetrics.ICON_DP.dp)" in source) + assertTrue("const val ICON_DP = 24f" in source) + assertTrue("const val CORNER_DP = 16f" in source) + } +} diff --git a/app/src/test/java/com/anindra/messages/ui/AttachTrayMetricsTest.kt b/app/src/test/java/com/anindra/messages/ui/AttachTrayMetricsTest.kt index 38b3a514c..a576b997e 100644 --- a/app/src/test/java/com/anindra/messages/ui/AttachTrayMetricsTest.kt +++ b/app/src/test/java/com/anindra/messages/ui/AttachTrayMetricsTest.kt @@ -38,6 +38,10 @@ class AttachTrayMetricsTest { val sizes = AttachTrayMetrics.sizes(396f, targetHeightDp = 261f) assertEquals(261f, sizes.height.value, epsilon) assertTrue("the panel is taller than one row of tiles", sizes.rowHeight < sizes.height) + assertTrue( + "a taller slot grows the tiles", + AttachTrayMetrics.sizes(396f, targetHeightDp = 320f).tileHeight.value > sizes.tileHeight.value + ) } @Test @@ -47,6 +51,17 @@ class AttachTrayMetricsTest { assertEquals(natural.height.value, short.height.value, epsilon) } + @Test + fun aTallKeyboardKeepsTilesReadable() { + val sizes = AttachTrayMetrics.sizes(396f, targetHeightDp = 520f) + assertEquals( + AttachTrayMetrics.MAX_TILE_ASPECT, + sizes.tileHeight.value / sizes.tile.value, + epsilon + ) + assertEquals(520f, sizes.height.value, epsilon) + } + @Test fun aNarrowScreenShrinksTheCirclesButKeepsThemTappable() { val sizes = AttachTrayMetrics.sizes(120f) diff --git a/scripts b/scripts index a08ebe09c..a8eb2e37f 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit a08ebe09cc9dc82c3f2ff628d683ab2778e7d1de +Subproject commit a8eb2e37fb5a82afce3b646abc861062b508e5af