From 184a68b637bece117a72674475bea28b837fd8c8 Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 9 Mar 2023 12:31:30 +0100 Subject: [PATCH] [Architecture] split createroom feature module --- appnav/build.gradle.kts | 2 +- .../android/appnav/LoggedInFlowNode.kt | 5 +-- features/createroom/.gitignore | 1 - features/createroom/api/build.gradle.kts | 27 ++++++++++++++++ .../createroom/api/CreateRoomEntryPoint.kt | 21 ++++++++++++ features/createroom/consumer-rules.pro | 0 .../createroom/{ => impl}/build.gradle.kts | 13 ++++++-- .../createroom/impl}/CreateRoomFlowNode.kt | 25 +++++++++------ .../impl/DefaultCreateRoomEntryPoint.kt | 32 +++++++++++++++++++ .../impl}/root/CreateRoomRootEvents.kt | 2 +- .../impl}/root/CreateRoomRootNode.kt | 2 +- .../impl}/root/CreateRoomRootPresenter.kt | 2 +- .../impl}/root/CreateRoomRootScreen.kt | 2 +- .../impl}/root/CreateRoomRootState.kt | 2 +- .../impl}/root/CreateRoomRootStateProvider.kt | 2 +- .../root/CreateRoomRootPresenterTests.kt | 4 ++- features/createroom/proguard-rules.pro | 21 ------------ .../createroom/src/main/AndroidManifest.xml | 20 ------------ .../kotlin/extension/DependencyHandleScope.kt | 2 +- settings.gradle.kts | 3 +- 20 files changed, 122 insertions(+), 66 deletions(-) delete mode 100644 features/createroom/.gitignore create mode 100644 features/createroom/api/build.gradle.kts create mode 100644 features/createroom/api/src/main/kotlin/io/element/android/features/createroom/api/CreateRoomEntryPoint.kt delete mode 100644 features/createroom/consumer-rules.pro rename features/createroom/{ => impl}/build.gradle.kts (87%) rename features/createroom/{src/main/kotlin/io/element/android/features/createroom => impl/src/main/kotlin/io/element/android/features/createroom/impl}/CreateRoomFlowNode.kt (70%) create mode 100644 features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/DefaultCreateRoomEntryPoint.kt rename features/createroom/{src/main/kotlin/io/element/android/features/createroom => impl/src/main/kotlin/io/element/android/features/createroom/impl}/root/CreateRoomRootEvents.kt (92%) rename features/createroom/{src/main/kotlin/io/element/android/features/createroom => impl/src/main/kotlin/io/element/android/features/createroom/impl}/root/CreateRoomRootNode.kt (96%) rename features/createroom/{src/main/kotlin/io/element/android/features/createroom => impl/src/main/kotlin/io/element/android/features/createroom/impl}/root/CreateRoomRootPresenter.kt (95%) rename features/createroom/{src/main/kotlin/io/element/android/features/createroom => impl/src/main/kotlin/io/element/android/features/createroom/impl}/root/CreateRoomRootScreen.kt (99%) rename features/createroom/{src/main/kotlin/io/element/android/features/createroom => impl/src/main/kotlin/io/element/android/features/createroom/impl}/root/CreateRoomRootState.kt (93%) rename features/createroom/{src/main/kotlin/io/element/android/features/createroom => impl/src/main/kotlin/io/element/android/features/createroom/impl}/root/CreateRoomRootStateProvider.kt (94%) rename features/createroom/{src/test/kotlin/io/element/android/features/createroom => impl/src/test/kotlin/io/element/android/features/createroom/impl}/root/CreateRoomRootPresenterTests.kt (88%) delete mode 100644 features/createroom/proguard-rules.pro delete mode 100644 features/createroom/src/main/AndroidManifest.xml diff --git a/appnav/build.gradle.kts b/appnav/build.gradle.kts index e201d0817b..77f4690793 100644 --- a/appnav/build.gradle.kts +++ b/appnav/build.gradle.kts @@ -43,7 +43,7 @@ dependencies { implementation(projects.features.preferences.api) implementation(projects.features.logout.api) implementation(projects.features.onboarding.api) - implementation(projects.features.createroom) + implementation(projects.features.createroom.api) implementation(projects.libraries.core) implementation(projects.libraries.architecture) diff --git a/appnav/src/main/kotlin/io/element/android/appnav/LoggedInFlowNode.kt b/appnav/src/main/kotlin/io/element/android/appnav/LoggedInFlowNode.kt index 74f39105ad..d86d302ac7 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/LoggedInFlowNode.kt +++ b/appnav/src/main/kotlin/io/element/android/appnav/LoggedInFlowNode.kt @@ -35,7 +35,7 @@ import com.bumble.appyx.navmodel.backstack.operation.push import dagger.assisted.Assisted import dagger.assisted.AssistedInject import io.element.android.anvilannotations.ContributesNode -import io.element.android.features.createroom.CreateRoomFlowNode +import io.element.android.features.createroom.api.CreateRoomEntryPoint import io.element.android.features.preferences.api.PreferencesEntryPoint import io.element.android.features.roomlist.api.RoomListEntryPoint import io.element.android.libraries.architecture.BackstackNode @@ -57,6 +57,7 @@ class LoggedInFlowNode @AssistedInject constructor( @Assisted plugins: List, private val roomListEntryPoint: RoomListEntryPoint, private val preferencesEntryPoint: PreferencesEntryPoint, + private val createRoomEntryPoint: CreateRoomEntryPoint, ) : BackstackNode( backstack = BackStack( initialElement = NavTarget.RoomList, @@ -160,7 +161,7 @@ class LoggedInFlowNode @AssistedInject constructor( .build() } NavTarget.CreateRoom -> { - CreateRoomFlowNode(buildContext) + createRoomEntryPoint.createNode(this, buildContext) } } } diff --git a/features/createroom/.gitignore b/features/createroom/.gitignore deleted file mode 100644 index 42afabfd2a..0000000000 --- a/features/createroom/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build \ No newline at end of file diff --git a/features/createroom/api/build.gradle.kts b/features/createroom/api/build.gradle.kts new file mode 100644 index 0000000000..b3fceedc27 --- /dev/null +++ b/features/createroom/api/build.gradle.kts @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id("io.element.android-library") +} + +android { + namespace = "io.element.android.features.createroom.api" +} + +dependencies { + implementation(projects.libraries.architecture) +} diff --git a/features/createroom/api/src/main/kotlin/io/element/android/features/createroom/api/CreateRoomEntryPoint.kt b/features/createroom/api/src/main/kotlin/io/element/android/features/createroom/api/CreateRoomEntryPoint.kt new file mode 100644 index 0000000000..049c101806 --- /dev/null +++ b/features/createroom/api/src/main/kotlin/io/element/android/features/createroom/api/CreateRoomEntryPoint.kt @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2023 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.element.android.features.createroom.api + +import io.element.android.libraries.architecture.SimpleFeatureEntryPoint + +interface CreateRoomEntryPoint : SimpleFeatureEntryPoint diff --git a/features/createroom/consumer-rules.pro b/features/createroom/consumer-rules.pro deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/features/createroom/build.gradle.kts b/features/createroom/impl/build.gradle.kts similarity index 87% rename from features/createroom/build.gradle.kts rename to features/createroom/impl/build.gradle.kts index 0450de2c3d..dc7eaded75 100644 --- a/features/createroom/build.gradle.kts +++ b/features/createroom/impl/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 New Vector Ltd + * Copyright (c) 2022 New Vector Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,13 +18,19 @@ @Suppress("DSL_SCOPE_VIOLATION") plugins { id("io.element.android-compose-library") - alias(libs.plugins.ksp) alias(libs.plugins.anvil) + alias(libs.plugins.ksp) id("kotlin-parcelize") } android { - namespace = "io.element.android.features.createroom" + namespace = "io.element.android.features.createroom.impl" + + testOptions { + unitTests { + isIncludeAndroidResources = true + } + } } anvil { @@ -42,6 +48,7 @@ dependencies { implementation(projects.libraries.designsystem) implementation(projects.libraries.elementresources) implementation(projects.libraries.uiStrings) + api(projects.features.createroom.api) testImplementation(libs.test.junit) testImplementation(libs.coroutines.test) diff --git a/features/createroom/src/main/kotlin/io/element/android/features/createroom/CreateRoomFlowNode.kt b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/CreateRoomFlowNode.kt similarity index 70% rename from features/createroom/src/main/kotlin/io/element/android/features/createroom/CreateRoomFlowNode.kt rename to features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/CreateRoomFlowNode.kt index 408fe0cb44..618eda0166 100644 --- a/features/createroom/src/main/kotlin/io/element/android/features/createroom/CreateRoomFlowNode.kt +++ b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/CreateRoomFlowNode.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.features.createroom +package io.element.android.features.createroom.impl import android.os.Parcelable import androidx.compose.runtime.Composable @@ -22,22 +22,29 @@ import androidx.compose.ui.Modifier import com.bumble.appyx.core.composable.Children import com.bumble.appyx.core.modality.BuildContext import com.bumble.appyx.core.node.Node -import com.bumble.appyx.core.node.ParentNode +import com.bumble.appyx.core.plugin.Plugin import com.bumble.appyx.navmodel.backstack.BackStack -import io.element.android.features.createroom.root.CreateRoomRootNode +import dagger.assisted.Assisted +import dagger.assisted.AssistedInject +import io.element.android.anvilannotations.ContributesNode +import io.element.android.features.createroom.impl.root.CreateRoomRootNode +import io.element.android.libraries.architecture.BackstackNode import io.element.android.libraries.architecture.animation.rememberDefaultTransitionHandler import io.element.android.libraries.architecture.createNode +import io.element.android.libraries.di.SessionScope import kotlinx.parcelize.Parcelize -class CreateRoomFlowNode( - buildContext: BuildContext, - private val backstack: BackStack = BackStack( +@ContributesNode(SessionScope::class) +class CreateRoomFlowNode @AssistedInject constructor( + @Assisted buildContext: BuildContext, + @Assisted plugins: List, +) : BackstackNode( + backstack = BackStack( initialElement = NavTarget.Root, savedStateMap = buildContext.savedStateMap, ), -) : ParentNode( - navModel = backstack, - buildContext = buildContext + buildContext = buildContext, + plugins = plugins ) { sealed interface NavTarget : Parcelable { diff --git a/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/DefaultCreateRoomEntryPoint.kt b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/DefaultCreateRoomEntryPoint.kt new file mode 100644 index 0000000000..214ed3a9ec --- /dev/null +++ b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/DefaultCreateRoomEntryPoint.kt @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.element.android.features.createroom.impl + +import com.bumble.appyx.core.modality.BuildContext +import com.bumble.appyx.core.node.Node +import com.squareup.anvil.annotations.ContributesBinding +import io.element.android.features.createroom.api.CreateRoomEntryPoint +import io.element.android.libraries.architecture.createNode +import io.element.android.libraries.di.AppScope +import javax.inject.Inject + +@ContributesBinding(AppScope::class) +class DefaultCreateRoomEntryPoint @Inject constructor() : CreateRoomEntryPoint { + override fun createNode(parentNode: Node, buildContext: BuildContext): Node { + return parentNode.createNode(buildContext) + } +} diff --git a/features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootEvents.kt b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootEvents.kt similarity index 92% rename from features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootEvents.kt rename to features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootEvents.kt index 820d071866..2159caf0aa 100644 --- a/features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootEvents.kt +++ b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootEvents.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.features.createroom.root +package io.element.android.features.createroom.impl.root sealed interface CreateRoomRootEvents { object CreateRoom : CreateRoomRootEvents diff --git a/features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootNode.kt b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootNode.kt similarity index 96% rename from features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootNode.kt rename to features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootNode.kt index 8d3d41b434..de7893e2e3 100644 --- a/features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootNode.kt +++ b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootNode.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.features.createroom.root +package io.element.android.features.createroom.impl.root import android.os.Parcelable import androidx.compose.runtime.Composable diff --git a/features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootPresenter.kt b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootPresenter.kt similarity index 95% rename from features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootPresenter.kt rename to features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootPresenter.kt index ad93d9143d..6ff99f421c 100644 --- a/features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootPresenter.kt +++ b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootPresenter.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.features.createroom.root +package io.element.android.features.createroom.impl.root import androidx.compose.runtime.Composable import io.element.android.libraries.architecture.Presenter diff --git a/features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootScreen.kt b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootScreen.kt similarity index 99% rename from features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootScreen.kt rename to features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootScreen.kt index 889207265e..33e6d2b711 100644 --- a/features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootScreen.kt +++ b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootScreen.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.features.createroom.root +package io.element.android.features.createroom.impl.root import androidx.annotation.DrawableRes import androidx.compose.foundation.clickable diff --git a/features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootState.kt b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootState.kt similarity index 93% rename from features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootState.kt rename to features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootState.kt index 9793cd950e..3e47b322b7 100644 --- a/features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootState.kt +++ b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootState.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.features.createroom.root +package io.element.android.features.createroom.impl.root // TODO add your ui models. Remove the eventSink if you don't have events. // Do not use default value, so no member get forgotten in the presenters. diff --git a/features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootStateProvider.kt b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootStateProvider.kt similarity index 94% rename from features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootStateProvider.kt rename to features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootStateProvider.kt index b5ff38bcec..4c3049d32f 100644 --- a/features/createroom/src/main/kotlin/io/element/android/features/createroom/root/CreateRoomRootStateProvider.kt +++ b/features/createroom/impl/src/main/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootStateProvider.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.features.createroom.root +package io.element.android.features.createroom.impl.root import androidx.compose.ui.tooling.preview.PreviewParameterProvider diff --git a/features/createroom/src/test/kotlin/io/element/android/features/createroom/root/CreateRoomRootPresenterTests.kt b/features/createroom/impl/src/test/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootPresenterTests.kt similarity index 88% rename from features/createroom/src/test/kotlin/io/element/android/features/createroom/root/CreateRoomRootPresenterTests.kt rename to features/createroom/impl/src/test/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootPresenterTests.kt index c03b48efa8..e6c9155d88 100644 --- a/features/createroom/src/test/kotlin/io/element/android/features/createroom/root/CreateRoomRootPresenterTests.kt +++ b/features/createroom/impl/src/test/kotlin/io/element/android/features/createroom/impl/root/CreateRoomRootPresenterTests.kt @@ -16,12 +16,14 @@ @file:OptIn(ExperimentalCoroutinesApi::class) -package io.element.android.features.createroom.root +package io.element.android.features.createroom.impl.root import app.cash.molecule.RecompositionClock import app.cash.molecule.moleculeFlow import app.cash.turbine.test import com.google.common.truth.Truth.assertThat +import io.element.android.features.createroom.impl.root.CreateRoomRootEvents +import io.element.android.features.createroom.impl.root.CreateRoomRootPresenter import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Test diff --git a/features/createroom/proguard-rules.pro b/features/createroom/proguard-rules.pro deleted file mode 100644 index 481bb43481..0000000000 --- a/features/createroom/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/features/createroom/src/main/AndroidManifest.xml b/features/createroom/src/main/AndroidManifest.xml deleted file mode 100644 index 86d497f107..0000000000 --- a/features/createroom/src/main/AndroidManifest.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - diff --git a/plugins/src/main/kotlin/extension/DependencyHandleScope.kt b/plugins/src/main/kotlin/extension/DependencyHandleScope.kt index 565df12d80..812b281ffd 100644 --- a/plugins/src/main/kotlin/extension/DependencyHandleScope.kt +++ b/plugins/src/main/kotlin/extension/DependencyHandleScope.kt @@ -69,5 +69,5 @@ fun DependencyHandlerScope.allFeatures() { implementation(project(":features:messages:impl")) implementation(project(":features:rageshake:impl")) implementation(project(":features:preferences:impl")) - implementation(project(":features:createroom")) + implementation(project(":features:createroom:impl")) } diff --git a/settings.gradle.kts b/settings.gradle.kts index 709e491e56..c975591405 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -80,4 +80,5 @@ include(":features:messages:api") include(":features:messages:impl") include(":features:login:api") include(":features:login:impl") -include(":features:createroom") +include(":features:createroom:api") +include(":features:createroom:impl")