diff options
Diffstat (limited to 'mobile/android')
5 files changed, 62 insertions, 6 deletions
diff --git a/mobile/android/android-components/plugins/dependencies/src/main/java/DependenciesPlugin.kt b/mobile/android/android-components/plugins/dependencies/src/main/java/DependenciesPlugin.kt index a58ac29588..0dbc6cf837 100644 --- a/mobile/android/android-components/plugins/dependencies/src/main/java/DependenciesPlugin.kt +++ b/mobile/android/android-components/plugins/dependencies/src/main/java/DependenciesPlugin.kt @@ -61,7 +61,7 @@ object Versions { const val browser = "1.8.0" const val biometric = "1.1.0" const val cardview = "1.0.0" - const val compose_bom = "2024.03.00" + const val compose_bom = "2024.04.01" const val constraintlayout = "2.1.4" const val coordinatorlayout = "1.2.0" const val core = "1.12.0" diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/compose/SwipeToDismissBox.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/compose/SwipeToDismissBox.kt index 9992cf75d3..8c5159baec 100644 --- a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/compose/SwipeToDismissBox.kt +++ b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/compose/SwipeToDismissBox.kt @@ -124,6 +124,20 @@ class SwipeToDismissState( */ val isSwipingToStart: Boolean get() = swipeDestination == SwipeToDismissAnchor.Start + + /** + * The current [IntOffset] of the swipe. If the X-offset is currently [Float.NaN], it will return 0. + */ + val safeSwipeOffset: IntOffset + get() { + val xOffset = if (anchoredDraggableState.offset.isNaN()) { + 0 + } else { + anchoredDraggableState.offset.roundToInt() + } + + return IntOffset(x = xOffset, y = 0) + } } /** @@ -186,7 +200,7 @@ fun SwipeToDismissBox( ) Box( - modifier = Modifier.offset { IntOffset(state.anchoredDraggableState.offset.roundToInt(), 0) }, + modifier = Modifier.offset { state.safeSwipeOffset }, content = dismissContent, ) } diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/messaging/state/MessagingMiddleware.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/messaging/state/MessagingMiddleware.kt index 46ac69595c..2122e1efee 100644 --- a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/messaging/state/MessagingMiddleware.kt +++ b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/messaging/state/MessagingMiddleware.kt @@ -135,8 +135,15 @@ class MessagingMiddleware( context.store.dispatch(UpdateMessageToShow(updatedMessage)) } val oldMessageIndex = context.state.messaging.messages.indexOfFirst { it.id == updatedMessage.id } - val newList = context.state.messaging.messages.toMutableList() - newList[oldMessageIndex] = updatedMessage - return newList + + return if (oldMessageIndex != -1) { + val newList = context.state.messaging.messages.toMutableList() + newList[oldMessageIndex] = updatedMessage + newList + } else { + // No need to update the message, it was removed. This is due to a race condition, see: + // https://bugzilla.mozilla.org/show_bug.cgi?id=1897485 + context.state.messaging.messages + } } } diff --git a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/messaging/state/MessagingMiddlewareTest.kt b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/messaging/state/MessagingMiddlewareTest.kt index 88b9161583..05e20c1163 100644 --- a/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/messaging/state/MessagingMiddlewareTest.kt +++ b/mobile/android/fenix/app/src/test/java/org/mozilla/fenix/messaging/state/MessagingMiddlewareTest.kt @@ -347,6 +347,41 @@ class MessagingMiddlewareTest { assertEquals(0, store.state.messaging.messages.size) assertEquals(0, store.state.messaging.messageToShow.size) } + + @Test + fun `GIVEN message is not found WHEN updateMessage THEN do not update the message list`() = runTestOnMain { + val message = createMessage(messageId = "1") + val message2 = createMessage(messageId = "2") + val store = AppStore( + AppState( + messaging = MessagingState( + messages = listOf( + message, + ), + ), + ), + listOf( + MessagingMiddleware(controller, coroutineScope), + ), + ) + + every { + controller.getNextMessage( + FenixMessageSurfaceId.HOMESCREEN, + any(), + ) + } returns message + + coEvery { + controller.onMessageDisplayed(eq(message), any()) + } returns message2 + + store.dispatch(Evaluate(FenixMessageSurfaceId.HOMESCREEN)).joinBlocking() + store.waitUntilIdle() + + assertEquals(1, store.state.messaging.messages.count()) + assertEquals(message, store.state.messaging.messages.first()) + } } private fun createMessage( metadata: Message.Metadata = createMetadata(), diff --git a/mobile/android/version.txt b/mobile/android/version.txt index ab2a50c778..9931f67c71 100644 --- a/mobile/android/version.txt +++ b/mobile/android/version.txt @@ -1 +1 @@ -126.0 +126.0.1 |