From 7589f6b1399c834bb94bb84af49089df252d203d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 18:37:35 +0000 Subject: [PATCH 001/158] Update core to v1.13.1 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5933c701da..73cb5c2f89 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,7 +9,7 @@ ksp = "1.9.23-1.0.20" firebaseAppDistribution = "4.2.0" # AndroidX -core = "1.13.0" +core = "1.13.1" # Warning: there is an issue with 1.1.0, that I cannot repro on unit test. # To repro with the application: # Clear the cache of the application and run the app. Nearly each time, there is an infinite loading From abc108a824f8aac5940dff2b46f7fd214b7d6762 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 00:24:52 +0000 Subject: [PATCH 002/158] Update datastore to v1.1.1 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 5933c701da..51ac1dda5a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,7 +15,7 @@ core = "1.13.0" # Clear the cache of the application and run the app. Nearly each time, there is an infinite loading # Due to the DefaultMigrationStore not bahaving as expected. # Stick to 1.0.0 for now, and ensure that this scenario cannot be reproduced when upgrading the version. -datastore = "1.0.0" +datastore = "1.1.1" constraintlayout = "2.1.4" constraintlayout_compose = "1.0.1" lifecycle = "2.7.0" From 26f8294eabcf49447c2dd26f67ec0046cac6f1d4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 14:53:51 +0000 Subject: [PATCH 003/158] Update dependency org.maplibre.gl:android-sdk to v11 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 27dfaa42f1..0e6aa375c8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -173,7 +173,7 @@ vanniktech_blurhash = "com.vanniktech:blurhash:0.3.0" telephoto_zoomableimage = { module = "me.saket.telephoto:zoomable-image-coil", version.ref = "telephoto" } telephoto_flick = { module = "me.saket.telephoto:flick-android", version.ref = "telephoto" } statemachine = "com.freeletics.flowredux:compose:1.2.1" -maplibre = "org.maplibre.gl:android-sdk:10.3.1" +maplibre = "org.maplibre.gl:android-sdk:11.0.0" maplibre_ktx = "org.maplibre.gl:android-sdk-ktx-v7:2.0.2" maplibre_annotation = "org.maplibre.gl:android-plugin-annotation-v9:2.0.2" opusencoder = "io.element.android:opusencoder:1.1.0" From cea03085c3822e1d11871a9e28d47c486c36ccac Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 12:55:39 +0000 Subject: [PATCH 004/158] Update dependency io.nlopez.compose.rules:detekt to v0.3.13 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index a0eedc8db7..0e5ec1c674 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -60,7 +60,7 @@ allprojects { config.from(files("$rootDir/tools/detekt/detekt.yml")) } dependencies { - detektPlugins("io.nlopez.compose.rules:detekt:0.3.12") + detektPlugins("io.nlopez.compose.rules:detekt:0.3.13") } // KtLint From 7b70cac7c5ddcd4554124d76b14ce7df3cfd2a88 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 3 Apr 2024 11:34:49 +0200 Subject: [PATCH 005/158] Rework Modifier.applyIf. It was using `Modifier.composed` which is not good for performance and detekt is warning about this. --- .../impl/search/RoomListSearchView.kt | 11 ++++--- .../designsystem/modifiers/ApplyIf.kt | 32 ++++++++----------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/search/RoomListSearchView.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/search/RoomListSearchView.kt index a18dd6607f..8190c8078e 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/search/RoomListSearchView.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/search/RoomListSearchView.kt @@ -87,10 +87,13 @@ internal fun RoomListSearchView( ) { Column( modifier = modifier - .applyIf(state.isSearchActive, ifTrue = { - // Disable input interaction to underlying views - pointerInput(Unit) {} - }) + .applyIf( + condition = state.isSearchActive, + ifTrue = { + // Disable input interaction to underlying views + pointerInput(Unit) {} + } + ) ) { if (state.isSearchActive) { RoomListSearchContent( diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/modifiers/ApplyIf.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/modifiers/ApplyIf.kt index a18d0ef3ed..3a4a433821 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/modifiers/ApplyIf.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/modifiers/ApplyIf.kt @@ -16,30 +16,26 @@ package io.element.android.libraries.designsystem.modifiers -import android.annotation.SuppressLint -import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier -import androidx.compose.ui.composed import androidx.compose.ui.platform.debugInspectorInfo +import androidx.compose.ui.platform.inspectable /** * Applies the [ifTrue] modifier when the [condition] is true, [ifFalse] otherwise. */ -@SuppressLint("UnnecessaryComposedModifier") // It's actually necessary due to the `@Composable` lambdas fun Modifier.applyIf( condition: Boolean, - ifTrue: @Composable Modifier.() -> Modifier, - ifFalse: @Composable (Modifier.() -> Modifier)? = null -): Modifier = - composed( - inspectorInfo = debugInspectorInfo { - name = "applyIf" - value = condition - } - ) { - when { - condition -> then(ifTrue(Modifier)) - ifFalse != null -> then(ifFalse(Modifier)) - else -> this - } + ifTrue: Modifier.() -> Modifier, + ifFalse: (Modifier.() -> Modifier)? = null +): Modifier = this then inspectable( + inspectorInfo = debugInspectorInfo { + name = "applyIf" + value = condition } +) { + this then when { + condition -> ifTrue(Modifier) + ifFalse != null -> ifFalse(Modifier) + else -> Modifier + } +} From f82ab91f6e38307e884d59250445afae44a663e3 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 3 Apr 2024 12:00:21 +0200 Subject: [PATCH 006/158] Supress warning `ModifierComposed` for autofill, there is a low risk of performance issue here. --- .../loginpassword/LoginPasswordView.kt | 28 +++++++++++-------- .../theme/components/TextField.kt | 1 + 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/loginpassword/LoginPasswordView.kt b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/loginpassword/LoginPasswordView.kt index 51ed3fcf6f..926601bcee 100644 --- a/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/loginpassword/LoginPasswordView.kt +++ b/features/login/impl/src/main/kotlin/io/element/android/features/login/impl/screens/loginpassword/LoginPasswordView.kt @@ -141,7 +141,7 @@ fun LoginPasswordView( // Submit Box( modifier = Modifier - .padding(horizontal = 16.dp) + .padding(horizontal = 16.dp) ) { ButtonColumnMolecule { Button( @@ -201,11 +201,14 @@ private fun LoginForm( .fillMaxWidth() .onTabOrEnterKeyFocusNext(focusManager) .testTag(TestTags.loginEmailUsername) - .autofill(autofillTypes = listOf(AutofillType.Username), onFill = { - val sanitized = it.sanitize() - loginFieldState = sanitized - eventSink(LoginPasswordEvents.SetLogin(sanitized)) - }), + .autofill( + autofillTypes = listOf(AutofillType.Username), + onFill = { + val sanitized = it.sanitize() + loginFieldState = sanitized + eventSink(LoginPasswordEvents.SetLogin(sanitized)) + } + ), placeholder = { Text(text = stringResource(CommonStrings.common_username)) }, @@ -247,11 +250,14 @@ private fun LoginForm( .fillMaxWidth() .onTabOrEnterKeyFocusNext(focusManager) .testTag(TestTags.loginPassword) - .autofill(autofillTypes = listOf(AutofillType.Password), onFill = { - val sanitized = it.sanitize() - passwordFieldState = sanitized - eventSink(LoginPasswordEvents.SetPassword(sanitized)) - }), + .autofill( + autofillTypes = listOf(AutofillType.Password), + onFill = { + val sanitized = it.sanitize() + passwordFieldState = sanitized + eventSink(LoginPasswordEvents.SetPassword(sanitized)) + } + ), onValueChange = { val sanitized = it.sanitize() passwordFieldState = sanitized diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/TextField.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/TextField.kt index f2c004d2ca..10fb4a2906 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/TextField.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/theme/components/TextField.kt @@ -213,6 +213,7 @@ private fun TextFieldValueContentToPreview() { } } +@Suppress("ModifierComposed") @OptIn(ExperimentalComposeUiApi::class) fun Modifier.autofill(autofillTypes: List, onFill: (String) -> Unit) = composed { val autofillNode = AutofillNode(autofillTypes, onFill = onFill) From e77f5f2bd749820e5f91d695a55add7aadea3470 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 17 May 2024 16:57:08 +0200 Subject: [PATCH 007/158] Suppress warning for ModifierComposed (detekt) --- .../element/android/libraries/designsystem/components/Bloom.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Bloom.kt b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Bloom.kt index 8558780a22..f8121ec500 100644 --- a/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Bloom.kt +++ b/libraries/designsystem/src/main/kotlin/io/element/android/libraries/designsystem/components/Bloom.kt @@ -168,6 +168,7 @@ data class BloomLayer( * @param bottomSoftEdgeAlpha The alpha value to apply to the bottom soft edge. * @param alpha The alpha value to apply to the bloom effect. */ +@SuppressWarnings("ModifierComposed") fun Modifier.bloom( hash: String?, background: Color, @@ -312,6 +313,7 @@ fun Modifier.bloom( * @param bottomSoftEdgeAlpha The alpha value to apply to the bottom soft edge. * @param alpha The alpha value to apply to the bloom effect. */ +@SuppressWarnings("ModifierComposed") fun Modifier.avatarBloom( avatarData: AvatarData, background: Color, From 526c33df1772c40cd2fd3e36ea7d8a59271bfbd1 Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 21 May 2024 16:12:19 +0200 Subject: [PATCH 008/158] maplibre : remove all mapbox references and update plugin to be compatible. --- .../location/impl/common/MapDefaults.kt | 4 ++-- .../location/impl/send/SendLocationView.kt | 6 ++--- .../location/impl/show/ShowLocationView.kt | 8 +++---- .../impl/show/ShowLocationViewTest.kt | 2 +- gradle/libs.versions.toml | 2 +- .../libraries/maplibre/compose/CameraMode.kt | 2 +- .../compose/CameraMoveStartedReason.kt | 12 +++++----- .../maplibre/compose/CameraPositionState.kt | 18 +++++++------- .../libraries/maplibre/compose/IconAnchor.kt | 2 +- .../libraries/maplibre/compose/MapApplier.kt | 8 +++---- ...Composable.kt => MapLibreMapComposable.kt} | 8 +++---- .../libraries/maplibre/compose/MapUpdater.kt | 14 +++++------ .../libraries/maplibre/compose/MapboxMap.kt | 24 +++++++++---------- .../libraries/maplibre/compose/Symbol.kt | 10 ++++---- 14 files changed, 60 insertions(+), 60 deletions(-) rename libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/{MapboxMapComposable.kt => MapLibreMapComposable.kt} (83%) diff --git a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/common/MapDefaults.kt b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/common/MapDefaults.kt index f5f0bbe078..6896172363 100644 --- a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/common/MapDefaults.kt +++ b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/common/MapDefaults.kt @@ -21,12 +21,12 @@ import android.view.Gravity import androidx.compose.runtime.Composable import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.ui.graphics.Color -import com.mapbox.mapboxsdk.camera.CameraPosition -import com.mapbox.mapboxsdk.geometry.LatLng import io.element.android.compound.theme.ElementTheme import io.element.android.libraries.maplibre.compose.MapLocationSettings import io.element.android.libraries.maplibre.compose.MapSymbolManagerSettings import io.element.android.libraries.maplibre.compose.MapUiSettings +import org.maplibre.android.camera.CameraPosition +import org.maplibre.android.geometry.LatLng /** * Common configuration values for the map. diff --git a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/send/SendLocationView.kt b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/send/SendLocationView.kt index a396cc120f..40aac154fa 100644 --- a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/send/SendLocationView.kt +++ b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/send/SendLocationView.kt @@ -37,7 +37,6 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp -import com.mapbox.mapboxsdk.camera.CameraPosition import io.element.android.compound.theme.ElementTheme import io.element.android.compound.tokens.generated.CompoundIcons import io.element.android.features.location.api.Location @@ -61,9 +60,10 @@ import io.element.android.libraries.designsystem.theme.components.bottomsheet.re import io.element.android.libraries.designsystem.utils.CommonDrawables import io.element.android.libraries.maplibre.compose.CameraMode import io.element.android.libraries.maplibre.compose.CameraMoveStartedReason -import io.element.android.libraries.maplibre.compose.MapboxMap +import io.element.android.libraries.maplibre.compose.MapLibreMap import io.element.android.libraries.maplibre.compose.rememberCameraPositionState import io.element.android.libraries.ui.strings.CommonStrings +import org.maplibre.android.camera.CameraPosition @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -189,7 +189,7 @@ fun SendLocationView( .consumeWindowInsets(it), contentAlignment = Alignment.Center ) { - MapboxMap( + MapLibreMap( styleUri = rememberTileStyleUrl(), modifier = Modifier.fillMaxSize(), cameraPositionState = cameraPositionState, diff --git a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationView.kt b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationView.kt index 2f352d50d2..3370dbc751 100644 --- a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationView.kt +++ b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/show/ShowLocationView.kt @@ -33,8 +33,6 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp -import com.mapbox.mapboxsdk.camera.CameraPosition -import com.mapbox.mapboxsdk.geometry.LatLng import io.element.android.compound.theme.ElementTheme import io.element.android.compound.tokens.generated.CompoundIcons import io.element.android.compound.tokens.generated.TypographyTokens @@ -56,12 +54,14 @@ import io.element.android.libraries.designsystem.utils.CommonDrawables import io.element.android.libraries.maplibre.compose.CameraMode import io.element.android.libraries.maplibre.compose.CameraMoveStartedReason import io.element.android.libraries.maplibre.compose.IconAnchor -import io.element.android.libraries.maplibre.compose.MapboxMap +import io.element.android.libraries.maplibre.compose.MapLibreMap import io.element.android.libraries.maplibre.compose.Symbol import io.element.android.libraries.maplibre.compose.rememberCameraPositionState import io.element.android.libraries.maplibre.compose.rememberSymbolState import io.element.android.libraries.ui.strings.CommonStrings import kotlinx.collections.immutable.toImmutableMap +import org.maplibre.android.camera.CameraPosition +import org.maplibre.android.geometry.LatLng @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -166,7 +166,7 @@ fun ShowLocationView( ) } - MapboxMap( + MapLibreMap( styleUri = rememberTileStyleUrl(), modifier = Modifier.fillMaxSize(), images = mapOf(PIN_ID to CommonDrawables.pin).toImmutableMap(), diff --git a/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/show/ShowLocationViewTest.kt b/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/show/ShowLocationViewTest.kt index 05160dca56..22377c3879 100644 --- a/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/show/ShowLocationViewTest.kt +++ b/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/show/ShowLocationViewTest.kt @@ -144,7 +144,7 @@ private fun AndroidComposeTestRule.setShowL onBackPressed: () -> Unit = EnsureNeverCalled(), ) { setContent { - // Simulate a LocalInspectionMode for MapboxMap + // Simulate a LocalInspectionMode for MapLibreMap CompositionLocalProvider(LocalInspectionMode provides true) { ShowLocationView( state = state, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0e6aa375c8..e917045d33 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -175,7 +175,7 @@ telephoto_flick = { module = "me.saket.telephoto:flick-android", version.ref = " statemachine = "com.freeletics.flowredux:compose:1.2.1" maplibre = "org.maplibre.gl:android-sdk:11.0.0" maplibre_ktx = "org.maplibre.gl:android-sdk-ktx-v7:2.0.2" -maplibre_annotation = "org.maplibre.gl:android-plugin-annotation-v9:2.0.2" +maplibre_annotation = "org.maplibre.gl:android-plugin-annotation-v9:3.0.0" opusencoder = "io.element.android:opusencoder:1.1.0" kotlinpoet = "com.squareup:kotlinpoet:1.16.0" diff --git a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/CameraMode.kt b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/CameraMode.kt index 0c85d3dfb3..a527201b31 100644 --- a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/CameraMode.kt +++ b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/CameraMode.kt @@ -19,7 +19,7 @@ package io.element.android.libraries.maplibre.compose import androidx.compose.runtime.Immutable -import com.mapbox.mapboxsdk.location.modes.CameraMode as InternalCameraMode +import org.maplibre.android.location.modes.CameraMode as InternalCameraMode @Immutable public enum class CameraMode { diff --git a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/CameraMoveStartedReason.kt b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/CameraMoveStartedReason.kt index 10c9d8b69a..697bbed8ed 100644 --- a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/CameraMoveStartedReason.kt +++ b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/CameraMoveStartedReason.kt @@ -19,14 +19,14 @@ package io.element.android.libraries.maplibre.compose import androidx.compose.runtime.Immutable -import com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener.REASON_API_ANIMATION -import com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener.REASON_API_GESTURE -import com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener.REASON_DEVELOPER_ANIMATION +import org.maplibre.android.maps.MapLibreMap.OnCameraMoveStartedListener.REASON_API_ANIMATION +import org.maplibre.android.maps.MapLibreMap.OnCameraMoveStartedListener.REASON_API_GESTURE +import org.maplibre.android.maps.MapLibreMap.OnCameraMoveStartedListener.REASON_DEVELOPER_ANIMATION /** * Enumerates the different reasons why the map camera started to move. * - * Based on enum values from https://docs.maptiler.com/maplibre-gl-native-android/com.mapbox.mapboxsdk.maps/#oncameramovestartedlistener. + * Based on enum values from https://docs.maptiler.com/maplibre-gl-native-android/org.maplibre.android.maps/#oncameramovestartedlistener. * * [NO_MOVEMENT_YET] is used as the initial state before any map movement has been observed. * @@ -44,11 +44,11 @@ public enum class CameraMoveStartedReason(public val value: Int) { public companion object { /** - * Converts from the Maps SDK [com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener] + * Converts from the Maps SDK [org.maplibre.android.maps.MapLibreMap.OnCameraMoveStartedListener] * constants to [CameraMoveStartedReason], or returns [UNKNOWN] if there is no such * [CameraMoveStartedReason] for the given [value]. * - * See https://docs.maptiler.com/maplibre-gl-native-android/com.mapbox.mapboxsdk.maps/#oncameramovestartedlistener. + * See https://docs.maptiler.com/maplibre-gl-native-android/org.maplibre.android.maps/#oncameramovestartedlistener. */ public fun fromInt(value: Int): CameraMoveStartedReason { return values().firstOrNull { it.value == value } ?: return UNKNOWN diff --git a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/CameraPositionState.kt b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/CameraPositionState.kt index 114e6acc02..a71ece9732 100644 --- a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/CameraPositionState.kt +++ b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/CameraPositionState.kt @@ -28,11 +28,11 @@ import androidx.compose.runtime.saveable.Saver import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.runtime.staticCompositionLocalOf -import com.mapbox.mapboxsdk.camera.CameraPosition -import com.mapbox.mapboxsdk.camera.CameraUpdateFactory -import com.mapbox.mapboxsdk.maps.MapboxMap -import com.mapbox.mapboxsdk.maps.Projection import kotlinx.parcelize.Parcelize +import org.maplibre.android.camera.CameraPosition +import org.maplibre.android.camera.CameraUpdateFactory +import org.maplibre.android.maps.MapLibreMap +import org.maplibre.android.maps.Projection /** * Create and [rememberSaveable] a [CameraPositionState] using [CameraPositionState.Saver]. @@ -49,7 +49,7 @@ public inline fun rememberCameraPositionState( /** * A state object that can be hoisted to control and observe the map's camera state. - * A [CameraPositionState] may only be used by a single [MapboxMap] composable at a time + * A [CameraPositionState] may only be used by a single [MapLibreMap] composable at a time * as it reflects instance state for a single view of a map. * * @param position the initial camera position @@ -143,15 +143,15 @@ public class CameraPositionState( // The map currently associated with this CameraPositionState. // Guarded by `lock`. - private var map: MapboxMap? by mutableStateOf(null) + private var map: MapLibreMap? by mutableStateOf(null) // The current map is set and cleared by side effect. // There can be only one associated at a time. - internal fun setMap(map: MapboxMap?) { + internal fun setMap(map: MapLibreMap?) { synchronized(lock) { if (this.map == null && map == null) return if (this.map != null && map != null) { - error("CameraPositionState may only be associated with one MapboxMap at a time") + error("CameraPositionState may only be associated with one MapLibreMap at a time") } this.map = map if (map == null) { @@ -179,7 +179,7 @@ internal val LocalCameraPositionState = staticCompositionLocalOf { CameraPositio /** The current [CameraPositionState] used by the map. */ public val currentCameraPositionState: CameraPositionState - @[MapboxMapComposable ReadOnlyComposable Composable] + @[MapLibreMapComposable ReadOnlyComposable Composable] get() = LocalCameraPositionState.current @Parcelize diff --git a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/IconAnchor.kt b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/IconAnchor.kt index 25f6f38c66..cb64f63a44 100644 --- a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/IconAnchor.kt +++ b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/IconAnchor.kt @@ -19,7 +19,7 @@ package io.element.android.libraries.maplibre.compose import androidx.compose.runtime.Immutable -import com.mapbox.mapboxsdk.style.layers.Property +import org.maplibre.android.style.layers.Property @Immutable public enum class IconAnchor { diff --git a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapApplier.kt b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapApplier.kt index 650e9d27ef..9b03a1e952 100644 --- a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapApplier.kt +++ b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapApplier.kt @@ -19,9 +19,9 @@ package io.element.android.libraries.maplibre.compose import androidx.compose.runtime.AbstractApplier -import com.mapbox.mapboxsdk.maps.MapboxMap -import com.mapbox.mapboxsdk.maps.Style -import com.mapbox.mapboxsdk.plugins.annotation.SymbolManager +import org.maplibre.android.maps.MapLibreMap +import org.maplibre.android.maps.Style +import org.maplibre.android.plugins.annotation.SymbolManager internal interface MapNode { fun onAttached() {} @@ -32,7 +32,7 @@ internal interface MapNode { private object MapNodeRoot : MapNode internal class MapApplier( - val map: MapboxMap, + val map: MapLibreMap, val style: Style, val symbolManager: SymbolManager, ) : AbstractApplier(MapNodeRoot) { diff --git a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapboxMapComposable.kt b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapLibreMapComposable.kt similarity index 83% rename from libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapboxMapComposable.kt rename to libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapLibreMapComposable.kt index 15876b0033..19f5864815 100644 --- a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapboxMapComposable.kt +++ b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapLibreMapComposable.kt @@ -22,10 +22,10 @@ import androidx.compose.runtime.ComposableTargetMarker /** * An annotation that can be used to mark a composable function as being expected to be use in a - * composable function that is also marked or inferred to be marked as a [MapboxMapComposable]. + * composable function that is also marked or inferred to be marked as a [MapLibreMapComposable]. * - * This will produce build warnings when [MapboxMapComposable] composable functions are used outside - * of a [MapboxMapComposable] content lambda, and vice versa. + * This will produce build warnings when [MapLibreMapComposable] composable functions are used outside + * of a [MapLibreMapComposable] content lambda, and vice versa. */ @Retention(AnnotationRetention.BINARY) @ComposableTargetMarker(description = "MapLibre Map Composable") @@ -36,4 +36,4 @@ import androidx.compose.runtime.ComposableTargetMarker AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER, ) -public annotation class MapboxMapComposable +public annotation class MapLibreMapComposable diff --git a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapUpdater.kt b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapUpdater.kt index 759061ac3d..7a41c9f7b9 100644 --- a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapUpdater.kt +++ b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapUpdater.kt @@ -26,17 +26,17 @@ import androidx.compose.runtime.ComposeNode import androidx.compose.runtime.currentComposer import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext -import com.mapbox.mapboxsdk.location.LocationComponentActivationOptions -import com.mapbox.mapboxsdk.location.LocationComponentOptions -import com.mapbox.mapboxsdk.location.OnCameraTrackingChangedListener -import com.mapbox.mapboxsdk.location.engine.LocationEngineRequest -import com.mapbox.mapboxsdk.maps.MapboxMap -import com.mapbox.mapboxsdk.maps.Style +import org.maplibre.android.location.LocationComponentActivationOptions +import org.maplibre.android.location.LocationComponentOptions +import org.maplibre.android.location.OnCameraTrackingChangedListener +import org.maplibre.android.location.engine.LocationEngineRequest +import org.maplibre.android.maps.MapLibreMap +import org.maplibre.android.maps.Style private const val LOCATION_REQUEST_INTERVAL = 750L internal class MapPropertiesNode( - val map: MapboxMap, + val map: MapLibreMap, style: Style, context: Context, cameraPositionState: CameraPositionState, diff --git a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapboxMap.kt b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapboxMap.kt index 4fab4b506f..352585cc1a 100644 --- a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapboxMap.kt +++ b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapboxMap.kt @@ -46,14 +46,14 @@ import androidx.compose.ui.platform.LocalLifecycleOwner import androidx.compose.ui.viewinterop.AndroidView import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleEventObserver -import com.mapbox.mapboxsdk.Mapbox -import com.mapbox.mapboxsdk.maps.MapView -import com.mapbox.mapboxsdk.maps.MapboxMap -import com.mapbox.mapboxsdk.maps.Style -import com.mapbox.mapboxsdk.plugins.annotation.SymbolManager import kotlinx.collections.immutable.ImmutableMap import kotlinx.collections.immutable.persistentMapOf import kotlinx.coroutines.awaitCancellation +import org.maplibre.android.MapLibre +import org.maplibre.android.maps.MapLibreMap +import org.maplibre.android.maps.MapView +import org.maplibre.android.maps.Style +import org.maplibre.android.plugins.annotation.SymbolManager import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine @@ -63,7 +63,7 @@ import kotlin.coroutines.suspendCoroutine * Heavily inspired by https://github.com/googlemaps/android-maps-compose * * @param styleUri a URI where to asynchronously fetch a style for the map - * @param modifier Modifier to be applied to the MapboxMap + * @param modifier Modifier to be applied to the MapLibreMap * @param images images added to the map's style to be later used with [Symbol] * @param cameraPositionState the [CameraPositionState] to be used to control or observe the map's * camera state @@ -73,7 +73,7 @@ import kotlin.coroutines.suspendCoroutine * @param content the content of the map */ @Composable -public fun MapboxMap( +public fun MapLibreMap( styleUri: String, modifier: Modifier = Modifier, images: ImmutableMap = persistentMapOf(), @@ -82,7 +82,7 @@ public fun MapboxMap( symbolManagerSettings: MapSymbolManagerSettings = DefaultMapSymbolManagerSettings, locationSettings: MapLocationSettings = DefaultMapLocationSettings, content: ( - @Composable @MapboxMapComposable + @Composable @MapLibreMapComposable () -> Unit )? = null, ) { @@ -99,7 +99,7 @@ public fun MapboxMap( val context = LocalContext.current val mapView = remember { - Mapbox.getInstance(context) + MapLibre.getInstance(context) MapView(context) } @@ -168,13 +168,13 @@ private suspend inline fun CompositionContext.newComposition( } } -private suspend inline fun MapView.awaitMap(): MapboxMap = suspendCoroutine { continuation -> +private suspend inline fun MapView.awaitMap(): MapLibreMap = suspendCoroutine { continuation -> getMapAsync { map -> continuation.resume(map) } } -private suspend inline fun MapboxMap.awaitStyle( +private suspend inline fun MapLibreMap.awaitStyle( context: Context, styleUri: String, images: ImmutableMap, @@ -227,7 +227,7 @@ private fun MapView.lifecycleObserver(previousState: MutableState { // Skip calling mapView.onCreate if the lifecycle did not go through onDestroy - in - // this case the MapboxMap composable also doesn't leave the composition. So, + // this case the MapLibreMap composable also doesn't leave the composition. So, // recreating the map does not restore state properly which must be avoided. if (previousState.value != Lifecycle.Event.ON_STOP) { this.onCreate(Bundle()) diff --git a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/Symbol.kt b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/Symbol.kt index bb40c7dfa9..18d942ec80 100644 --- a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/Symbol.kt +++ b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/Symbol.kt @@ -26,10 +26,10 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.Saver import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue -import com.mapbox.mapboxsdk.geometry.LatLng -import com.mapbox.mapboxsdk.plugins.annotation.Symbol -import com.mapbox.mapboxsdk.plugins.annotation.SymbolManager -import com.mapbox.mapboxsdk.plugins.annotation.SymbolOptions +import org.maplibre.android.geometry.LatLng +import org.maplibre.android.plugins.annotation.Symbol +import org.maplibre.android.plugins.annotation.SymbolManager +import org.maplibre.android.plugins.annotation.SymbolOptions internal class SymbolNode( val symbolManager: SymbolManager, @@ -85,7 +85,7 @@ public fun rememberSymbolState( * @param iconAnchor the anchor for the symbol image */ @Composable -@MapboxMapComposable +@MapLibreMapComposable public fun Symbol( iconId: String, state: SymbolState = rememberSymbolState(), From 102025f1a65693bd587e1f122a3cef5b0efc11c6 Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Tue, 7 May 2024 01:10:03 +0100 Subject: [PATCH 009/158] Ensure selected/deselected filters stay on top This looks a little more "sane", and more closely matches what iOS does with it's filter chips. This has to manually track which filters were "just-deselected" and move those even higher up the z stack to ensure they appear above even when sliding right. This is because the order is determined by the position left-to-right of the _final_ destination of the chip. In this case we want anything that's either currently selected, or was selected and is still fading out to appear on top. Signed-off-by: Joe Groocock --- changelog.d/2809.bugfix | 1 + .../impl/filters/RoomListFiltersView.kt | 21 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 changelog.d/2809.bugfix diff --git a/changelog.d/2809.bugfix b/changelog.d/2809.bugfix new file mode 100644 index 0000000000..70e3079686 --- /dev/null +++ b/changelog.d/2809.bugfix @@ -0,0 +1 @@ +Render selected/deselected room list filters on top diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/filters/RoomListFiltersView.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/filters/RoomListFiltersView.kt index fcdc260c6e..be7448c4a0 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/filters/RoomListFiltersView.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/filters/RoomListFiltersView.kt @@ -32,12 +32,15 @@ import androidx.compose.material3.FilterChip import androidx.compose.material3.FilterChipDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.mutableStateOf +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.res.stringResource import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp +import androidx.compose.ui.zIndex import io.element.android.compound.theme.ElementTheme import io.element.android.compound.tokens.generated.CompoundIcons import io.element.android.libraries.designsystem.preview.ElementPreview @@ -62,6 +65,7 @@ fun RoomListFiltersView( } val lazyListState = rememberLazyListState() + val previousFilters = remember { mutableStateOf(listOf()) } LazyRow( contentPadding = PaddingValues(start = 8.dp, end = 16.dp), modifier = modifier.fillMaxWidth(), @@ -75,17 +79,26 @@ fun RoomListFiltersView( modifier = Modifier .padding(start = 8.dp) .testTag(TestTags.homeScreenClearFilters), - onClick = ::onClearFiltersClicked + onClick = { + previousFilters.value = state.selectedFilters() + onClearFiltersClicked() + } ) } } - for (filterWithSelection in state.filterSelectionStates) { + state.filterSelectionStates.forEachIndexed { i, filterWithSelection -> item(filterWithSelection.filter) { + val zIndex = (if (previousFilters.value.contains(filterWithSelection.filter)) state.filterSelectionStates.size else 0) - i.toFloat() RoomListFilterView( - modifier = Modifier.animateItemPlacement(), + modifier = Modifier + .animateItemPlacement() + .zIndex(zIndex), roomListFilter = filterWithSelection.filter, selected = filterWithSelection.isSelected, - onClick = ::onToggleFilter, + onClick = { + previousFilters.value = state.selectedFilters() + onToggleFilter(it) + }, ) } } From 9fa8d97d5787e8994836ecfdba9d5d6f8d35edfc Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Wed, 8 May 2024 09:54:48 +0100 Subject: [PATCH 010/158] Animate room filter colours This is much closer to how iOS looks, and is much nicer on the eyes. Signed-off-by: Joe Groocock --- .../impl/filters/RoomListFiltersView.kt | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/filters/RoomListFiltersView.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/filters/RoomListFiltersView.kt index be7448c4a0..2ebad2646e 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/filters/RoomListFiltersView.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/filters/RoomListFiltersView.kt @@ -16,6 +16,9 @@ package io.element.android.features.roomlist.impl.filters +import androidx.compose.animation.animateColorAsState +import androidx.compose.animation.core.Spring +import androidx.compose.animation.core.spring import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -139,16 +142,27 @@ private fun RoomListFilterView( onClick: (RoomListFilter) -> Unit, modifier: Modifier = Modifier ) { + val background = animateColorAsState( + targetValue = if (selected) ElementTheme.colors.bgActionPrimaryRest else ElementTheme.colors.bgCanvasDefault, + animationSpec = spring(stiffness = Spring.StiffnessMediumLow), + label = "chip background colour", + ) + val textColour = animateColorAsState( + targetValue = if (selected) ElementTheme.colors.textOnSolidPrimary else ElementTheme.colors.textPrimary, + animationSpec = spring(stiffness = Spring.StiffnessMediumLow), + label = "chip text colour", + ) + FilterChip( selected = selected, onClick = { onClick(roomListFilter) }, modifier = modifier.height(36.dp), shape = CircleShape, colors = FilterChipDefaults.filterChipColors( - containerColor = ElementTheme.colors.bgCanvasDefault, - selectedContainerColor = ElementTheme.colors.bgActionPrimaryRest, - labelColor = ElementTheme.colors.textPrimary, - selectedLabelColor = ElementTheme.colors.textOnSolidPrimary, + containerColor = background.value, + selectedContainerColor = background.value, + labelColor = textColour.value, + selectedLabelColor = textColour.value ), label = { Text(text = stringResource(id = roomListFilter.stringResource)) From a5e97475bf7276ee13370e9d29957929adbeadf6 Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Tue, 21 May 2024 22:17:18 +0000 Subject: [PATCH 011/158] Animate room list filters when clearing They animate cleanly back to their original locations now, and correctly overlap each other when doing so. The only thing that is mildly jarring is the reappearing chips, but there's no way to animate appearance in the current version of jetpack compose, so that'll have to be fixed later. Signed-off-by: Joe Groocock --- .../features/roomlist/impl/filters/RoomListFiltersView.kt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/filters/RoomListFiltersView.kt b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/filters/RoomListFiltersView.kt index 2ebad2646e..7a1cb2039a 100644 --- a/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/filters/RoomListFiltersView.kt +++ b/features/roomlist/impl/src/main/kotlin/io/element/android/features/roomlist/impl/filters/RoomListFiltersView.kt @@ -34,7 +34,6 @@ import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.FilterChip import androidx.compose.material3.FilterChipDefaults import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Alignment @@ -106,13 +105,6 @@ fun RoomListFiltersView( } } } - LaunchedEffect(state.filterSelectionStates) { - // Checking for canScrollBackward is necessary for the itemPlacementAnimation to work correctly. - // We don't want the itemPlacementAnimation to be triggered when clearing the filters. - if (!state.hasAnyFilterSelected || lazyListState.canScrollBackward) { - lazyListState.animateScrollToItem(0) - } - } } @Composable From 12c6eefca0bf0d63c31198a69150fe4c004d0ede Mon Sep 17 00:00:00 2001 From: ganfra Date: Wed, 22 May 2024 11:56:06 +0200 Subject: [PATCH 012/158] MapLibre : rename file MapBoxMap to match composable. --- .../libraries/maplibre/compose/{MapboxMap.kt => MapLibreMap.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/{MapboxMap.kt => MapLibreMap.kt} (100%) diff --git a/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapboxMap.kt b/libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapLibreMap.kt similarity index 100% rename from libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapboxMap.kt rename to libraries/maplibre-compose/src/main/kotlin/io/element/android/libraries/maplibre/compose/MapLibreMap.kt From 5781d6eac6682c0fc030875b0d12dd33b23ddce3 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 23 May 2024 10:47:31 +0200 Subject: [PATCH 013/158] Add Konsist test `Fake classes must be named using Fake and the interface it fakes` --- .../android/tests/konsist/KonsistClassNameTest.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt index 9ecf90ebe6..092901e1e3 100644 --- a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt +++ b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt @@ -20,6 +20,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider import com.bumble.appyx.core.node.Node import com.lemonappdev.konsist.api.Konsist import com.lemonappdev.konsist.api.ext.list.withAllParentsOf +import com.lemonappdev.konsist.api.ext.list.withNameContaining import com.lemonappdev.konsist.api.verify.assertTrue import io.element.android.libraries.architecture.Presenter import org.junit.Test @@ -62,4 +63,16 @@ class KonsistClassNameTest { it.name.endsWith("Provider") && (it.name.contains("IconList") || it.name.contains(providedType)) } } + + @Test + fun `Fake classes must be named using Fake and the interface it fakes`() { + Konsist.scopeFromProject() + .classes() + .withNameContaining("Fake") + .assertTrue { + val interfaceName = it.name.replace("Fake", "") + it.name.startsWith("Fake") && + it.parents.any { parent -> parent.name.replace(".", "") == interfaceName } + } + } } From 1459ff0f77d262060fed0f168dc0c1911cfc5412 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 23 May 2024 10:51:48 +0200 Subject: [PATCH 014/158] Rename class (code quality) --- .../state/{FakeWelcomeState.kt => FakeWelcomeScreenState.kt} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename features/ftue/impl/src/test/kotlin/io/element/android/features/ftue/impl/welcome/state/{FakeWelcomeState.kt => FakeWelcomeScreenState.kt} (94%) diff --git a/features/ftue/impl/src/test/kotlin/io/element/android/features/ftue/impl/welcome/state/FakeWelcomeState.kt b/features/ftue/impl/src/test/kotlin/io/element/android/features/ftue/impl/welcome/state/FakeWelcomeScreenState.kt similarity index 94% rename from features/ftue/impl/src/test/kotlin/io/element/android/features/ftue/impl/welcome/state/FakeWelcomeState.kt rename to features/ftue/impl/src/test/kotlin/io/element/android/features/ftue/impl/welcome/state/FakeWelcomeScreenState.kt index 6b4d4b2287..66ffe24285 100644 --- a/features/ftue/impl/src/test/kotlin/io/element/android/features/ftue/impl/welcome/state/FakeWelcomeState.kt +++ b/features/ftue/impl/src/test/kotlin/io/element/android/features/ftue/impl/welcome/state/FakeWelcomeScreenState.kt @@ -16,7 +16,7 @@ package io.element.android.features.ftue.impl.welcome.state -class FakeWelcomeState : WelcomeScreenState { +class FakeWelcomeScreenState : WelcomeScreenState { private var isWelcomeScreenNeeded = true override fun isWelcomeScreenNeeded(): Boolean { From 9ddefc08c50e672ad64d0735ee1cb676acf8a117 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 23 May 2024 10:55:22 +0200 Subject: [PATCH 015/158] Move FakeBugReporterMode to FakeBugReporter.Mode --- .../impl/bugreport/BugReportPresenterTest.kt | 6 +++--- .../impl/bugreport/FakeBugReporter.kt | 20 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenterTest.kt b/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenterTest.kt index 69617f30f8..9b07b1c942 100644 --- a/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenterTest.kt +++ b/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/BugReportPresenterTest.kt @@ -144,7 +144,7 @@ class BugReportPresenterTest { @Test fun `present - send success`() = runTest { val presenter = createPresenter( - FakeBugReporter(mode = FakeBugReporterMode.Success), + FakeBugReporter(mode = FakeBugReporter.Mode.Success), FakeCrashDataStore(crashData = A_CRASH_DATA, appHasCrashed = true), FakeScreenshotHolder(screenshotUri = A_SCREENSHOT_URI), ) @@ -170,7 +170,7 @@ class BugReportPresenterTest { @Test fun `present - send failure`() = runTest { val presenter = createPresenter( - FakeBugReporter(mode = FakeBugReporterMode.Failure), + FakeBugReporter(mode = FakeBugReporter.Mode.Failure), FakeCrashDataStore(crashData = A_CRASH_DATA, appHasCrashed = true), FakeScreenshotHolder(screenshotUri = A_SCREENSHOT_URI), ) @@ -219,7 +219,7 @@ class BugReportPresenterTest { @Test fun `present - send cancel`() = runTest { val presenter = createPresenter( - FakeBugReporter(mode = FakeBugReporterMode.Cancel), + FakeBugReporter(mode = FakeBugReporter.Mode.Cancel), FakeCrashDataStore(crashData = A_CRASH_DATA, appHasCrashed = true), FakeScreenshotHolder(screenshotUri = A_SCREENSHOT_URI), ) diff --git a/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/FakeBugReporter.kt b/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/FakeBugReporter.kt index cce2d5d144..a4d4f83da9 100644 --- a/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/FakeBugReporter.kt +++ b/features/rageshake/impl/src/test/kotlin/io/element/android/features/rageshake/impl/bugreport/FakeBugReporter.kt @@ -22,7 +22,13 @@ import io.element.android.libraries.matrix.test.A_FAILURE_REASON import kotlinx.coroutines.delay import java.io.File -class FakeBugReporter(val mode: FakeBugReporterMode = FakeBugReporterMode.Success) : BugReporter { +class FakeBugReporter(val mode: Mode = Mode.Success) : BugReporter { + enum class Mode { + Success, + Failure, + Cancel + } + override suspend fun sendBugReport( withDevicesLogs: Boolean, withCrashLogs: Boolean, @@ -37,12 +43,12 @@ class FakeBugReporter(val mode: FakeBugReporterMode = FakeBugReporterMode.Succes listener?.onProgress(50) delay(100) when (mode) { - FakeBugReporterMode.Success -> Unit - FakeBugReporterMode.Failure -> { + Mode.Success -> Unit + Mode.Failure -> { listener?.onUploadFailed(A_FAILURE_REASON) return } - FakeBugReporterMode.Cancel -> { + Mode.Cancel -> { listener?.onUploadCancelled() return } @@ -64,9 +70,3 @@ class FakeBugReporter(val mode: FakeBugReporterMode = FakeBugReporterMode.Succes // No op } } - -enum class FakeBugReporterMode { - Success, - Failure, - Cancel -} From db21cd439e1ef67f6dc99bd3f2f09b0dc59c97c5 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 23 May 2024 10:56:35 +0200 Subject: [PATCH 016/158] Rename class (code quality) --- ...terFake.kt => FakePermissionsPresenter.kt} | 2 +- .../impl/send/SendLocationPresenterTest.kt | 30 +++++++++---------- .../impl/show/ShowLocationPresenterTest.kt | 26 ++++++++-------- 3 files changed, 29 insertions(+), 29 deletions(-) rename features/location/impl/src/test/kotlin/io/element/android/features/location/impl/common/permissions/{PermissionsPresenterFake.kt => FakePermissionsPresenter.kt} (95%) diff --git a/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/common/permissions/PermissionsPresenterFake.kt b/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/common/permissions/FakePermissionsPresenter.kt similarity index 95% rename from features/location/impl/src/test/kotlin/io/element/android/features/location/impl/common/permissions/PermissionsPresenterFake.kt rename to features/location/impl/src/test/kotlin/io/element/android/features/location/impl/common/permissions/FakePermissionsPresenter.kt index e79ac9e453..8bbaf5c428 100644 --- a/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/common/permissions/PermissionsPresenterFake.kt +++ b/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/common/permissions/FakePermissionsPresenter.kt @@ -18,7 +18,7 @@ package io.element.android.features.location.impl.common.permissions import androidx.compose.runtime.Composable -class PermissionsPresenterFake : PermissionsPresenter { +class FakePermissionsPresenter : PermissionsPresenter { val events = mutableListOf() private fun handleEvent(event: PermissionsEvents) { diff --git a/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/send/SendLocationPresenterTest.kt b/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/send/SendLocationPresenterTest.kt index b6b469c44a..af4ac6c9c7 100644 --- a/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/send/SendLocationPresenterTest.kt +++ b/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/send/SendLocationPresenterTest.kt @@ -24,9 +24,9 @@ import im.vector.app.features.analytics.plan.Composer import io.element.android.features.location.api.Location import io.element.android.features.location.impl.aPermissionsState import io.element.android.features.location.impl.common.actions.FakeLocationActions +import io.element.android.features.location.impl.common.permissions.FakePermissionsPresenter import io.element.android.features.location.impl.common.permissions.PermissionsEvents import io.element.android.features.location.impl.common.permissions.PermissionsPresenter -import io.element.android.features.location.impl.common.permissions.PermissionsPresenterFake import io.element.android.features.location.impl.common.permissions.PermissionsState import io.element.android.features.messages.test.FakeMessageComposerContext import io.element.android.libraries.matrix.api.room.location.AssetType @@ -45,7 +45,7 @@ class SendLocationPresenterTest { @get:Rule val warmUpRule = WarmUpRule() - private val permissionsPresenterFake = PermissionsPresenterFake() + private val fakePermissionsPresenter = FakePermissionsPresenter() private val fakeMatrixRoom = FakeMatrixRoom() private val fakeAnalyticsService = FakeAnalyticsService() private val fakeMessageComposerContext = FakeMessageComposerContext() @@ -53,7 +53,7 @@ class SendLocationPresenterTest { private val fakeBuildMeta = aBuildMeta(applicationName = "app name") private val sendLocationPresenter: SendLocationPresenter = SendLocationPresenter( permissionsPresenterFactory = object : PermissionsPresenter.Factory { - override fun create(permissions: List): PermissionsPresenter = permissionsPresenterFake + override fun create(permissions: List): PermissionsPresenter = fakePermissionsPresenter }, room = fakeMatrixRoom, analyticsService = fakeAnalyticsService, @@ -64,7 +64,7 @@ class SendLocationPresenterTest { @Test fun `initial state with permissions granted`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.AllGranted, shouldShowRationale = false, @@ -90,7 +90,7 @@ class SendLocationPresenterTest { @Test fun `initial state with permissions partially granted`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.SomeGranted, shouldShowRationale = false, @@ -116,7 +116,7 @@ class SendLocationPresenterTest { @Test fun `initial state with permissions denied`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.NoneGranted, shouldShowRationale = false, @@ -142,7 +142,7 @@ class SendLocationPresenterTest { @Test fun `initial state with permissions denied once`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.NoneGranted, shouldShowRationale = true, @@ -168,7 +168,7 @@ class SendLocationPresenterTest { @Test fun `rationale dialog dismiss`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.NoneGranted, shouldShowRationale = true, @@ -199,7 +199,7 @@ class SendLocationPresenterTest { @Test fun `rationale dialog continue`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.NoneGranted, shouldShowRationale = true, @@ -221,13 +221,13 @@ class SendLocationPresenterTest { // Continue the dialog sends permission request to the permissions presenter myLocationState.eventSink(SendLocationEvents.RequestPermissions) - assertThat(permissionsPresenterFake.events.last()).isEqualTo(PermissionsEvents.RequestPermissions) + assertThat(fakePermissionsPresenter.events.last()).isEqualTo(PermissionsEvents.RequestPermissions) } } @Test fun `permission denied dialog dismiss`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.NoneGranted, shouldShowRationale = false, @@ -258,7 +258,7 @@ class SendLocationPresenterTest { @Test fun `share sender location`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.AllGranted, shouldShowRationale = false, @@ -314,7 +314,7 @@ class SendLocationPresenterTest { @Test fun `share pin location`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.NoneGranted, shouldShowRationale = false, @@ -370,7 +370,7 @@ class SendLocationPresenterTest { @Test fun `composer context passes through analytics`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.NoneGranted, shouldShowRationale = false, @@ -418,7 +418,7 @@ class SendLocationPresenterTest { @Test fun `open settings activity`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.NoneGranted, shouldShowRationale = false, diff --git a/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/show/ShowLocationPresenterTest.kt b/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/show/ShowLocationPresenterTest.kt index ff80a3935d..dab964b6e1 100644 --- a/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/show/ShowLocationPresenterTest.kt +++ b/features/location/impl/src/test/kotlin/io/element/android/features/location/impl/show/ShowLocationPresenterTest.kt @@ -23,9 +23,9 @@ import com.google.common.truth.Truth.assertThat import io.element.android.features.location.api.Location import io.element.android.features.location.impl.aPermissionsState import io.element.android.features.location.impl.common.actions.FakeLocationActions +import io.element.android.features.location.impl.common.permissions.FakePermissionsPresenter import io.element.android.features.location.impl.common.permissions.PermissionsEvents import io.element.android.features.location.impl.common.permissions.PermissionsPresenter -import io.element.android.features.location.impl.common.permissions.PermissionsPresenterFake import io.element.android.features.location.impl.common.permissions.PermissionsState import io.element.android.libraries.matrix.test.core.aBuildMeta import io.element.android.tests.testutils.WarmUpRule @@ -38,13 +38,13 @@ class ShowLocationPresenterTest { @get:Rule val warmUpRule = WarmUpRule() - private val permissionsPresenterFake = PermissionsPresenterFake() + private val fakePermissionsPresenter = FakePermissionsPresenter() private val fakeLocationActions = FakeLocationActions() private val fakeBuildMeta = aBuildMeta(applicationName = "app name") private val location = Location(1.23, 4.56, 7.8f) private val presenter = ShowLocationPresenter( permissionsPresenterFactory = object : PermissionsPresenter.Factory { - override fun create(permissions: List): PermissionsPresenter = permissionsPresenterFake + override fun create(permissions: List): PermissionsPresenter = fakePermissionsPresenter }, fakeLocationActions, fakeBuildMeta, @@ -54,7 +54,7 @@ class ShowLocationPresenterTest { @Test fun `emits initial state with no location permission`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.NoneGranted, shouldShowRationale = false, @@ -74,7 +74,7 @@ class ShowLocationPresenterTest { @Test fun `emits initial state location permission denied once`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.NoneGranted, shouldShowRationale = true, @@ -94,7 +94,7 @@ class ShowLocationPresenterTest { @Test fun `emits initial state with location permission`() = runTest { - permissionsPresenterFake.givenState(aPermissionsState(permissions = PermissionsState.Permissions.AllGranted)) + fakePermissionsPresenter.givenState(aPermissionsState(permissions = PermissionsState.Permissions.AllGranted)) moleculeFlow(RecompositionMode.Immediate) { presenter.present() @@ -109,7 +109,7 @@ class ShowLocationPresenterTest { @Test fun `emits initial state with partial location permission`() = runTest { - permissionsPresenterFake.givenState(aPermissionsState(permissions = PermissionsState.Permissions.SomeGranted)) + fakePermissionsPresenter.givenState(aPermissionsState(permissions = PermissionsState.Permissions.SomeGranted)) moleculeFlow(RecompositionMode.Immediate) { presenter.present() @@ -137,7 +137,7 @@ class ShowLocationPresenterTest { @Test fun `centers on user location`() = runTest { - permissionsPresenterFake.givenState(aPermissionsState(permissions = PermissionsState.Permissions.AllGranted)) + fakePermissionsPresenter.givenState(aPermissionsState(permissions = PermissionsState.Permissions.AllGranted)) moleculeFlow(RecompositionMode.Immediate) { presenter.present() @@ -165,7 +165,7 @@ class ShowLocationPresenterTest { @Test fun `rationale dialog dismiss`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.NoneGranted, shouldShowRationale = true, @@ -196,7 +196,7 @@ class ShowLocationPresenterTest { @Test fun `rationale dialog continue`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.NoneGranted, shouldShowRationale = true, @@ -218,13 +218,13 @@ class ShowLocationPresenterTest { // Continue the dialog sends permission request to the permissions presenter trackLocationState.eventSink(ShowLocationEvents.RequestPermissions) - assertThat(permissionsPresenterFake.events.last()).isEqualTo(PermissionsEvents.RequestPermissions) + assertThat(fakePermissionsPresenter.events.last()).isEqualTo(PermissionsEvents.RequestPermissions) } } @Test fun `permission denied dialog dismiss`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.NoneGranted, shouldShowRationale = false, @@ -255,7 +255,7 @@ class ShowLocationPresenterTest { @Test fun `open settings activity`() = runTest { - permissionsPresenterFake.givenState( + fakePermissionsPresenter.givenState( aPermissionsState( permissions = PermissionsState.Permissions.NoneGranted, shouldShowRationale = false, From 55fda265d9f210d571a0368e8e02bb9d5777838d Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 23 May 2024 10:57:16 +0200 Subject: [PATCH 017/158] Rename class (code quality) --- .../features/migration/impl/MigrationPresenterTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/features/migration/impl/src/test/kotlin/io/element/android/features/migration/impl/MigrationPresenterTest.kt b/features/migration/impl/src/test/kotlin/io/element/android/features/migration/impl/MigrationPresenterTest.kt index 3ea0625f76..29be8682e3 100644 --- a/features/migration/impl/src/test/kotlin/io/element/android/features/migration/impl/MigrationPresenterTest.kt +++ b/features/migration/impl/src/test/kotlin/io/element/android/features/migration/impl/MigrationPresenterTest.kt @@ -37,7 +37,7 @@ class MigrationPresenterTest { @Test fun `present - no migration should occurs if ApplicationMigrationVersion is the last one`() = runTest { - val migrations = (1..10).map { FakeMigration(it) } + val migrations = (1..10).map { FakeAppMigration(it) } val store = InMemoryMigrationStore(migrations.maxOf { it.order }) val presenter = createPresenter( migrationStore = store, @@ -57,7 +57,7 @@ class MigrationPresenterTest { @Test fun `present - testing all migrations`() = runTest { val store = InMemoryMigrationStore(0) - val migrations = (1..10).map { FakeMigration(it) } + val migrations = (1..10).map { FakeAppMigration(it) } val presenter = createPresenter( migrationStore = store, migrations = migrations.toSet(), @@ -81,13 +81,13 @@ class MigrationPresenterTest { private fun createPresenter( migrationStore: MigrationStore = InMemoryMigrationStore(0), - migrations: Set = setOf(FakeMigration(1)), + migrations: Set = setOf(FakeAppMigration(1)), ) = MigrationPresenter( migrationStore = migrationStore, migrations = migrations, ) -private class FakeMigration( +private class FakeAppMigration( override val order: Int, var migrateLambda: LambdaNoParamRecorder = lambdaRecorder { -> }, ) : AppMigration { From ab2e620e3911ef86520e6e7b9bece2543f3212df Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 23 May 2024 10:57:53 +0200 Subject: [PATCH 018/158] Rename class (code quality) --- .../features/migration/impl/migrations/AppMigration02Test.kt | 4 ++-- ...eStoreFactory.kt => FakeSessionPreferencesStoreFactory.kt} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename libraries/preferences/test/src/main/kotlin/io/element/android/libraries/preferences/test/{FakeSessionPreferenceStoreFactory.kt => FakeSessionPreferencesStoreFactory.kt} (97%) diff --git a/features/migration/impl/src/test/kotlin/io/element/android/features/migration/impl/migrations/AppMigration02Test.kt b/features/migration/impl/src/test/kotlin/io/element/android/features/migration/impl/migrations/AppMigration02Test.kt index 1a077fda2e..6bb2f5babd 100644 --- a/features/migration/impl/src/test/kotlin/io/element/android/features/migration/impl/migrations/AppMigration02Test.kt +++ b/features/migration/impl/src/test/kotlin/io/element/android/features/migration/impl/migrations/AppMigration02Test.kt @@ -17,7 +17,7 @@ package io.element.android.features.migration.impl.migrations import com.google.common.truth.Truth.assertThat -import io.element.android.libraries.preferences.test.FakeSessionPreferenceStoreFactory +import io.element.android.libraries.preferences.test.FakeSessionPreferencesStoreFactory import io.element.android.libraries.preferences.test.InMemorySessionPreferencesStore import io.element.android.libraries.sessionstorage.impl.memory.InMemorySessionStore import io.element.android.libraries.sessionstorage.test.aSessionData @@ -33,7 +33,7 @@ class AppMigration02Test { updateData(aSessionData()) } val sessionPreferencesStore = InMemorySessionPreferencesStore(isSessionVerificationSkipped = false) - val sessionPreferencesStoreFactory = FakeSessionPreferenceStoreFactory( + val sessionPreferencesStoreFactory = FakeSessionPreferencesStoreFactory( getLambda = lambdaRecorder { _, _, -> sessionPreferencesStore }, ) val migration = AppMigration02(sessionStore = sessionStore, sessionPreferenceStoreFactory = sessionPreferencesStoreFactory) diff --git a/libraries/preferences/test/src/main/kotlin/io/element/android/libraries/preferences/test/FakeSessionPreferenceStoreFactory.kt b/libraries/preferences/test/src/main/kotlin/io/element/android/libraries/preferences/test/FakeSessionPreferencesStoreFactory.kt similarity index 97% rename from libraries/preferences/test/src/main/kotlin/io/element/android/libraries/preferences/test/FakeSessionPreferenceStoreFactory.kt rename to libraries/preferences/test/src/main/kotlin/io/element/android/libraries/preferences/test/FakeSessionPreferencesStoreFactory.kt index 264ac4ec3a..96761a9712 100644 --- a/libraries/preferences/test/src/main/kotlin/io/element/android/libraries/preferences/test/FakeSessionPreferenceStoreFactory.kt +++ b/libraries/preferences/test/src/main/kotlin/io/element/android/libraries/preferences/test/FakeSessionPreferencesStoreFactory.kt @@ -24,7 +24,7 @@ import io.element.android.tests.testutils.lambda.LambdaTwoParamsRecorder import io.element.android.tests.testutils.lambda.lambdaRecorder import kotlinx.coroutines.CoroutineScope -class FakeSessionPreferenceStoreFactory( +class FakeSessionPreferencesStoreFactory( var getLambda: LambdaTwoParamsRecorder = lambdaRecorder { _, _ -> throw NotImplementedError() }, var removeLambda: LambdaOneParamRecorder = lambdaRecorder { _ -> }, ) : SessionPreferencesStoreFactory { From 909794f256e7475fe08b4f9b4e209b72ae9f0243 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 23 May 2024 10:59:54 +0200 Subject: [PATCH 019/158] Exclude FakeImageLoader from this test. --- .../io/element/android/tests/konsist/KonsistClassNameTest.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt index 092901e1e3..af7eb44618 100644 --- a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt +++ b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistClassNameTest.kt @@ -21,6 +21,7 @@ import com.bumble.appyx.core.node.Node import com.lemonappdev.konsist.api.Konsist import com.lemonappdev.konsist.api.ext.list.withAllParentsOf import com.lemonappdev.konsist.api.ext.list.withNameContaining +import com.lemonappdev.konsist.api.ext.list.withoutName import com.lemonappdev.konsist.api.verify.assertTrue import io.element.android.libraries.architecture.Presenter import org.junit.Test @@ -69,6 +70,9 @@ class KonsistClassNameTest { Konsist.scopeFromProject() .classes() .withNameContaining("Fake") + .withoutName( + "FakeImageLoader", + ) .assertTrue { val interfaceName = it.name.replace("Fake", "") it.name.startsWith("Fake") && From e3f18f41d6d10486978bf6a995ec9bdb56db2ff5 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 23 May 2024 11:00:54 +0200 Subject: [PATCH 020/158] Rename class (code quality) --- .../libraries/voicerecorder/impl/VoiceRecorderImplTest.kt | 4 ++-- ...{FakeAudioRecorderFactory.kt => FakeAudioReaderFactory.kt} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename libraries/voicerecorder/impl/src/test/kotlin/io/element/android/libraries/voicerecorder/test/{FakeAudioRecorderFactory.kt => FakeAudioReaderFactory.kt} (97%) diff --git a/libraries/voicerecorder/impl/src/test/kotlin/io/element/android/libraries/voicerecorder/impl/VoiceRecorderImplTest.kt b/libraries/voicerecorder/impl/src/test/kotlin/io/element/android/libraries/voicerecorder/impl/VoiceRecorderImplTest.kt index 9bb1ace7b1..022661bc11 100644 --- a/libraries/voicerecorder/impl/src/test/kotlin/io/element/android/libraries/voicerecorder/impl/VoiceRecorderImplTest.kt +++ b/libraries/voicerecorder/impl/src/test/kotlin/io/element/android/libraries/voicerecorder/impl/VoiceRecorderImplTest.kt @@ -28,7 +28,7 @@ import io.element.android.libraries.voicerecorder.impl.audio.AudioConfig import io.element.android.libraries.voicerecorder.impl.audio.SampleRate import io.element.android.libraries.voicerecorder.impl.di.VoiceRecorderModule import io.element.android.libraries.voicerecorder.test.FakeAudioLevelCalculator -import io.element.android.libraries.voicerecorder.test.FakeAudioRecorderFactory +import io.element.android.libraries.voicerecorder.test.FakeAudioReaderFactory import io.element.android.libraries.voicerecorder.test.FakeEncoder import io.element.android.libraries.voicerecorder.test.FakeFileSystem import io.element.android.libraries.voicerecorder.test.FakeVoiceFileManager @@ -136,7 +136,7 @@ class VoiceRecorderImplTest { return VoiceRecorderImpl( dispatchers = testCoroutineDispatchers(), timeSource = timeSource, - audioReaderFactory = FakeAudioRecorderFactory( + audioReaderFactory = FakeAudioReaderFactory( audio = AUDIO, ), encoder = FakeEncoder(fakeFileSystem), diff --git a/libraries/voicerecorder/impl/src/test/kotlin/io/element/android/libraries/voicerecorder/test/FakeAudioRecorderFactory.kt b/libraries/voicerecorder/impl/src/test/kotlin/io/element/android/libraries/voicerecorder/test/FakeAudioReaderFactory.kt similarity index 97% rename from libraries/voicerecorder/impl/src/test/kotlin/io/element/android/libraries/voicerecorder/test/FakeAudioRecorderFactory.kt rename to libraries/voicerecorder/impl/src/test/kotlin/io/element/android/libraries/voicerecorder/test/FakeAudioReaderFactory.kt index 02d8b4742c..657b8d6ee9 100644 --- a/libraries/voicerecorder/impl/src/test/kotlin/io/element/android/libraries/voicerecorder/test/FakeAudioRecorderFactory.kt +++ b/libraries/voicerecorder/impl/src/test/kotlin/io/element/android/libraries/voicerecorder/test/FakeAudioReaderFactory.kt @@ -21,7 +21,7 @@ import io.element.android.libraries.voicerecorder.impl.audio.Audio import io.element.android.libraries.voicerecorder.impl.audio.AudioConfig import io.element.android.libraries.voicerecorder.impl.audio.AudioReader -class FakeAudioRecorderFactory( +class FakeAudioReaderFactory( private val audio: List