From e186e62a0ea2d652d3dfaf313f9948ecdf0f0479 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 14 Oct 2026 17:41:07 +0200 Subject: [PATCH] Move RoomListBanner to its own file The test source set also has a RoomListState.kt file in the same package, so its RoomListStateKt class was shadowing the one of the main source set, and the toRoomListBanner() functions were not found when running the tests (NoSuchMethodError). Co-Authored-By: Claude Opus 5.5 (1M context) --- .../home/impl/roomlist/RoomListBanner.kt | 40 +++++++++++++++++++ .../home/impl/roomlist/RoomListState.kt | 33 --------------- 2 files changed, 40 insertions(+), 33 deletions(-) create mode 100644 features/home/impl/src/main/kotlin/io/element/android/features/home/impl/roomlist/RoomListBanner.kt diff --git a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/roomlist/RoomListBanner.kt b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/roomlist/RoomListBanner.kt new file mode 100644 index 0000000000..c273cc9ce4 --- /dev/null +++ b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/roomlist/RoomListBanner.kt @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2026 Element Creations Ltd. + * + * SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial. + * Please see LICENSE files in the repository root for full details. + */ + +package io.element.android.features.home.impl.roomlist + +/** + * The banners which can be displayed at the top of the room list. At most one banner is displayed at a time. + */ +internal enum class RoomListBanner { + SetUpRecovery, + RecoveryKeyConfirmation, + FullScreenIntentPermission, + BatteryOptimization, + NewNotificationSound, + SwipeAvatar, +} + +internal fun SecurityBannerState.toRoomListBanner(): RoomListBanner? = when (this) { + SecurityBannerState.SetUpRecovery -> RoomListBanner.SetUpRecovery + SecurityBannerState.RecoveryKeyConfirmation -> RoomListBanner.RecoveryKeyConfirmation + SecurityBannerState.None -> null +} + +/** + * Banner precedence (top-to-bottom): security > full-screen-intent > battery-optimization > + * new-notification-sound > swipe-avatar. At most one renders at a time. + */ +internal fun RoomListContentState.Rooms.toRoomListBanner(): RoomListBanner? { + return securityBannerState.toRoomListBanner() ?: when { + fullScreenIntentPermissionsState.shouldDisplayBanner -> RoomListBanner.FullScreenIntentPermission + batteryOptimizationState.shouldDisplayBanner -> RoomListBanner.BatteryOptimization + showNewNotificationSoundBanner -> RoomListBanner.NewNotificationSound + showSwipeAvatarBanner -> RoomListBanner.SwipeAvatar + else -> null + } +} diff --git a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/roomlist/RoomListState.kt b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/roomlist/RoomListState.kt index f77695399b..6d3d85ab56 100644 --- a/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/roomlist/RoomListState.kt +++ b/features/home/impl/src/main/kotlin/io/element/android/features/home/impl/roomlist/RoomListState.kt @@ -61,18 +61,6 @@ enum class SecurityBannerState { RecoveryKeyConfirmation, } -/** - * The banners which can be displayed at the top of the room list. At most one banner is displayed at a time. - */ -internal enum class RoomListBanner { - SetUpRecovery, - RecoveryKeyConfirmation, - FullScreenIntentPermission, - BatteryOptimization, - NewNotificationSound, - SwipeAvatar, -} - @Immutable sealed interface RoomListContentState { data class Skeleton(val count: Int) : RoomListContentState @@ -92,24 +80,3 @@ sealed interface RoomListContentState { val showAllActivity: Boolean, ) : RoomListContentState } - -internal fun SecurityBannerState.toRoomListBanner(): RoomListBanner? = when (this) { - SecurityBannerState.SetUpRecovery -> RoomListBanner.SetUpRecovery - SecurityBannerState.RecoveryKeyConfirmation -> RoomListBanner.RecoveryKeyConfirmation - SecurityBannerState.None -> null -} - -/** - * Banner precedence (top-to-bottom): security > full-screen-intent > battery-optimization > - * new-notification-sound > swipe-avatar. At most one renders at a time. - */ -internal fun RoomListContentState.Rooms.toRoomListBanner(): RoomListBanner? { - return securityBannerState.toRoomListBanner() ?: when { - fullScreenIntentPermissionsState.shouldDisplayBanner -> RoomListBanner.FullScreenIntentPermission - batteryOptimizationState.shouldDisplayBanner -> RoomListBanner.BatteryOptimization - showNewNotificationSoundBanner -> RoomListBanner.NewNotificationSound - showSwipeAvatarBanner -> RoomListBanner.SwipeAvatar - else -> null - } -} -