Browse Source

Merge pull request #3205 from element-hq/feature/bma/fixPinCrash

Fix crash when Pin code screen is displayed
pull/3207/head
Benoit Marty 2 months ago committed by GitHub
parent
commit
de62c12d00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/unlock/keypad/PinKeypad.kt
  2. 2
      features/roomlist/impl/src/test/kotlin/io/element/android/features/roomlist/impl/RoomListPresenterTest.kt

11
features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/unlock/keypad/PinKeypad.kt

@ -37,7 +37,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.clip
import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.coerceAtMost import androidx.compose.ui.unit.coerceIn
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.compose.ui.unit.times import androidx.compose.ui.unit.times
@ -50,6 +50,7 @@ import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentListOf
private val spaceBetweenPinKey = 16.dp private val spaceBetweenPinKey = 16.dp
private val minSizePinKey = 16.dp
private val maxSizePinKey = 80.dp private val maxSizePinKey = 80.dp
@Composable @Composable
@ -61,8 +62,8 @@ fun PinKeypad(
verticalAlignment: Alignment.Vertical = Alignment.Top, verticalAlignment: Alignment.Vertical = Alignment.Top,
horizontalAlignment: Alignment.Horizontal = Alignment.Start, horizontalAlignment: Alignment.Horizontal = Alignment.Start,
) { ) {
val pinKeyMaxWidth = ((maxWidth - 2 * spaceBetweenPinKey) / 3).coerceAtMost(maxSizePinKey) val pinKeyMaxWidth = ((maxWidth - 2 * spaceBetweenPinKey) / 3).coerceIn(minSizePinKey, maxSizePinKey)
val pinKeyMaxHeight = ((maxHeight - 3 * spaceBetweenPinKey) / 4).coerceAtMost(maxSizePinKey) val pinKeyMaxHeight = ((maxHeight - 3 * spaceBetweenPinKey) / 4).coerceIn(minSizePinKey, maxSizePinKey)
val pinKeySize = if (pinKeyMaxWidth < pinKeyMaxHeight) pinKeyMaxWidth else pinKeyMaxHeight val pinKeySize = if (pinKeyMaxWidth < pinKeyMaxHeight) pinKeyMaxWidth else pinKeyMaxHeight
val horizontalArrangement = spacedBy(spaceBetweenPinKey, Alignment.CenterHorizontally) val horizontalArrangement = spacedBy(spaceBetweenPinKey, Alignment.CenterHorizontally)
@ -129,7 +130,7 @@ private fun PinKeypadRow(
) )
} }
is PinKeypadModel.Number -> { is PinKeypadModel.Number -> {
PinKeyBadDigitButton( PinKeypadDigitButton(
size = pinKeySize, size = pinKeySize,
modifier = commonModifier, modifier = commonModifier,
digit = model.number.toString(), digit = model.number.toString(),
@ -158,7 +159,7 @@ private fun PinKeypadButton(
} }
@Composable @Composable
private fun PinKeyBadDigitButton( private fun PinKeypadDigitButton(
digit: String, digit: String,
size: Dp, size: Dp,
onClick: (String) -> Unit, onClick: (String) -> Unit,

2
features/roomlist/impl/src/test/kotlin/io/element/android/features/roomlist/impl/RoomListPresenterTest.kt

@ -545,7 +545,7 @@ class RoomListPresenterTest {
clearMessagesForRoomLambda.assertions().isCalledOnce() clearMessagesForRoomLambda.assertions().isCalledOnce()
.with(value(A_SESSION_ID), value(A_ROOM_ID)) .with(value(A_SESSION_ID), value(A_ROOM_ID))
initialState.eventSink.invoke(RoomListEvents.MarkAsUnread(A_ROOM_ID_2)) initialState.eventSink.invoke(RoomListEvents.MarkAsUnread(A_ROOM_ID_2))
assertThat(room2.markAsReadCalls).isEqualTo(emptyList<ReceiptType>()) assertThat(room2.markAsReadCalls).isEmpty()
assertThat(room2.setUnreadFlagCalls).isEqualTo(listOf(true)) assertThat(room2.setUnreadFlagCalls).isEqualTo(listOf(true))
// Test again with private read receipts // Test again with private read receipts
sessionPreferencesStore.setSendPublicReadReceipts(false) sessionPreferencesStore.setSendPublicReadReceipts(false)

Loading…
Cancel
Save