From 8f1ccfccf20dec1d58cc5d4b4a3db79ec05978d1 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 10 Oct 2023 20:04:34 +0200 Subject: [PATCH] Move SignedOut classes to their own module. --- appnav/build.gradle.kts | 1 - .../io/element/android/appnav/RootFlowNode.kt | 12 +++-- features/signedout/api/build.gradle.kts | 28 ++++++++++ .../signedout/api/SignedOutEntryPoint.kt | 37 +++++++++++++ features/signedout/impl/build.gradle.kts | 52 +++++++++++++++++++ .../impl/DefaultSignedOutEntryPoint.kt | 46 ++++++++++++++++ .../signedout/impl}/SignedOutEvents.kt | 2 +- .../features/signedout/impl}/SignedOutNode.kt | 2 +- .../signedout/impl}/SignedOutPresenter.kt | 2 +- .../signedout/impl}/SignedOutState.kt | 2 +- .../signedout/impl}/SignedOutStateProvider.kt | 2 +- .../features/signedout/impl}/SignedOutView.kt | 3 +- .../signedout/impl}/SignedOutPresenterTest.kt | 2 +- 13 files changed, 179 insertions(+), 12 deletions(-) create mode 100644 features/signedout/api/build.gradle.kts create mode 100644 features/signedout/api/src/main/kotlin/io/element/android/features/signedout/api/SignedOutEntryPoint.kt create mode 100644 features/signedout/impl/build.gradle.kts create mode 100644 features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/DefaultSignedOutEntryPoint.kt rename {appnav/src/main/kotlin/io/element/android/appnav/signedout => features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl}/SignedOutEvents.kt (93%) rename {appnav/src/main/kotlin/io/element/android/appnav/signedout => features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl}/SignedOutNode.kt (97%) rename {appnav/src/main/kotlin/io/element/android/appnav/signedout => features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl}/SignedOutPresenter.kt (97%) rename {appnav/src/main/kotlin/io/element/android/appnav/signedout => features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl}/SignedOutState.kt (94%) rename {appnav/src/main/kotlin/io/element/android/appnav/signedout => features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl}/SignedOutStateProvider.kt (97%) rename {appnav/src/main/kotlin/io/element/android/appnav/signedout => features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl}/SignedOutView.kt (98%) rename {appnav/src/test/kotlin/io/element/android/appnav/signedout => features/signedout/impl/src/test/kotlin/io/element/android/features/signedout/impl}/SignedOutPresenterTest.kt (98%) diff --git a/appnav/build.gradle.kts b/appnav/build.gradle.kts index f7d8540c4e..88f0741ebe 100644 --- a/appnav/build.gradle.kts +++ b/appnav/build.gradle.kts @@ -64,7 +64,6 @@ dependencies { testImplementation(libs.test.turbine) testImplementation(projects.libraries.matrix.test) testImplementation(projects.features.networkmonitor.test) - testImplementation(projects.libraries.sessionStorage.implMemory) testImplementation(projects.tests.testutils) testImplementation(projects.features.rageshake.test) testImplementation(projects.features.rageshake.impl) diff --git a/appnav/src/main/kotlin/io/element/android/appnav/RootFlowNode.kt b/appnav/src/main/kotlin/io/element/android/appnav/RootFlowNode.kt index 7936912762..df98998ba5 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/RootFlowNode.kt +++ b/appnav/src/main/kotlin/io/element/android/appnav/RootFlowNode.kt @@ -42,10 +42,10 @@ import io.element.android.appnav.intent.ResolvedIntent import io.element.android.appnav.root.RootNavStateFlowFactory import io.element.android.appnav.root.RootPresenter import io.element.android.appnav.root.RootView -import io.element.android.appnav.signedout.SignedOutNode import io.element.android.features.login.api.oidc.OidcAction import io.element.android.features.login.api.oidc.OidcActionFlow import io.element.android.features.rageshake.api.bugreport.BugReportEntryPoint +import io.element.android.features.signedout.api.SignedOutEntryPoint import io.element.android.libraries.architecture.BackstackNode import io.element.android.libraries.architecture.animation.rememberDefaultTransitionHandler import io.element.android.libraries.architecture.createNode @@ -71,6 +71,7 @@ class RootFlowNode @AssistedInject constructor( private val matrixClientsHolder: MatrixClientsHolder, private val presenter: RootPresenter, private val bugReportEntryPoint: BugReportEntryPoint, + private val signedOutEntryPoint: SignedOutEntryPoint, private val intentResolver: IntentResolver, private val oidcActionFlow: OidcActionFlow, ) : BackstackNode( @@ -217,8 +218,13 @@ class RootFlowNode @AssistedInject constructor( } NavTarget.NotLoggedInFlow -> createNode(buildContext) is NavTarget.SignedOutFlow -> { - val inputs = SignedOutNode.Inputs(navTarget.sessionId) - createNode(buildContext, listOf(inputs)) + signedOutEntryPoint.nodeBuilder(this, buildContext) + .params( + SignedOutEntryPoint.Params( + sessionId = navTarget.sessionId + ) + ) + .build() } NavTarget.SplashScreen -> splashNode(buildContext) NavTarget.BugReport -> { diff --git a/features/signedout/api/build.gradle.kts b/features/signedout/api/build.gradle.kts new file mode 100644 index 0000000000..d2815315f3 --- /dev/null +++ b/features/signedout/api/build.gradle.kts @@ -0,0 +1,28 @@ +/* + * 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.signedout.api" +} + +dependencies { + implementation(projects.libraries.architecture) + implementation(projects.libraries.matrix.api) +} diff --git a/features/signedout/api/src/main/kotlin/io/element/android/features/signedout/api/SignedOutEntryPoint.kt b/features/signedout/api/src/main/kotlin/io/element/android/features/signedout/api/SignedOutEntryPoint.kt new file mode 100644 index 0000000000..7a156998d1 --- /dev/null +++ b/features/signedout/api/src/main/kotlin/io/element/android/features/signedout/api/SignedOutEntryPoint.kt @@ -0,0 +1,37 @@ +/* + * 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.signedout.api + +import com.bumble.appyx.core.modality.BuildContext +import com.bumble.appyx.core.node.Node +import io.element.android.libraries.architecture.FeatureEntryPoint +import io.element.android.libraries.matrix.api.core.SessionId + +interface SignedOutEntryPoint : FeatureEntryPoint { + + data class Params( + val sessionId: SessionId, + ) + + fun nodeBuilder(parentNode: Node, buildContext: BuildContext): NodeBuilder + + interface NodeBuilder { + fun params(params: Params): NodeBuilder + fun build(): Node + } +} + diff --git a/features/signedout/impl/build.gradle.kts b/features/signedout/impl/build.gradle.kts new file mode 100644 index 0000000000..399c95e254 --- /dev/null +++ b/features/signedout/impl/build.gradle.kts @@ -0,0 +1,52 @@ +/* + * 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-compose-library") + alias(libs.plugins.anvil) + alias(libs.plugins.ksp) + id("kotlin-parcelize") +} + +android { + namespace = "io.element.android.features.signedout.impl" +} + +anvil { + generateDaggerFactories.set(true) +} + +dependencies { + implementation(projects.anvilannotations) + anvil(projects.anvilcodegen) + api(projects.features.signedout.api) + implementation(projects.libraries.core) + implementation(projects.libraries.architecture) + implementation(projects.libraries.matrix.api) + implementation(projects.libraries.matrixui) + implementation(projects.libraries.designsystem) + + testImplementation(libs.test.junit) + testImplementation(libs.coroutines.test) + testImplementation(libs.molecule.runtime) + testImplementation(libs.test.truth) + testImplementation(libs.test.turbine) + testImplementation(projects.libraries.matrix.test) + testImplementation(projects.libraries.sessionStorage.implMemory) + testImplementation(projects.tests.testutils) + + ksp(libs.showkase.processor) +} diff --git a/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/DefaultSignedOutEntryPoint.kt b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/DefaultSignedOutEntryPoint.kt new file mode 100644 index 0000000000..59b19f041e --- /dev/null +++ b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/DefaultSignedOutEntryPoint.kt @@ -0,0 +1,46 @@ +/* + * 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.signedout.impl + +import com.bumble.appyx.core.modality.BuildContext +import com.bumble.appyx.core.node.Node +import com.bumble.appyx.core.plugin.Plugin +import com.squareup.anvil.annotations.ContributesBinding +import io.element.android.features.signedout.api.SignedOutEntryPoint +import io.element.android.libraries.architecture.createNode +import io.element.android.libraries.di.AppScope +import javax.inject.Inject + +@ContributesBinding(AppScope::class) +class DefaultSignedOutEntryPoint @Inject constructor() : SignedOutEntryPoint { + + override fun nodeBuilder(parentNode: Node, buildContext: BuildContext): SignedOutEntryPoint.NodeBuilder { + val plugins = ArrayList() + + return object : SignedOutEntryPoint.NodeBuilder { + + override fun params(params: SignedOutEntryPoint.Params): SignedOutEntryPoint.NodeBuilder { + plugins += SignedOutNode.Inputs(params.sessionId) + return this + } + + override fun build(): Node { + return parentNode.createNode(buildContext, plugins) + } + } + } +} diff --git a/appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutEvents.kt b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutEvents.kt similarity index 93% rename from appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutEvents.kt rename to features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutEvents.kt index 3c3c61696b..a2057226a4 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutEvents.kt +++ b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutEvents.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.appnav.signedout +package io.element.android.features.signedout.impl sealed interface SignedOutEvents { data object SignInAgain : SignedOutEvents diff --git a/appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutNode.kt b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutNode.kt similarity index 97% rename from appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutNode.kt rename to features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutNode.kt index 25917daab5..381daa7278 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutNode.kt +++ b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutNode.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.appnav.signedout +package io.element.android.features.signedout.impl import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier diff --git a/appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutPresenter.kt b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutPresenter.kt similarity index 97% rename from appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutPresenter.kt rename to features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutPresenter.kt index 1292ad0496..ee8cf2e63f 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutPresenter.kt +++ b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutPresenter.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.appnav.signedout +package io.element.android.features.signedout.impl import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState diff --git a/appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutState.kt b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutState.kt similarity index 94% rename from appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutState.kt rename to features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutState.kt index f181c537ba..2f7af29e40 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutState.kt +++ b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutState.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.appnav.signedout +package io.element.android.features.signedout.impl import io.element.android.libraries.sessionstorage.api.SessionData diff --git a/appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutStateProvider.kt b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutStateProvider.kt similarity index 97% rename from appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutStateProvider.kt rename to features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutStateProvider.kt index b7a81cf86b..1af0ef41de 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutStateProvider.kt +++ b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutStateProvider.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.appnav.signedout +package io.element.android.features.signedout.impl import androidx.compose.ui.tooling.preview.PreviewParameterProvider import io.element.android.libraries.matrix.api.core.SessionId diff --git a/appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutView.kt b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutView.kt similarity index 98% rename from appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutView.kt rename to features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutView.kt index badb2f83ee..42c38224b6 100644 --- a/appnav/src/main/kotlin/io/element/android/appnav/signedout/SignedOutView.kt +++ b/features/signedout/impl/src/main/kotlin/io/element/android/features/signedout/impl/SignedOutView.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.appnav.signedout +package io.element.android.features.signedout.impl import androidx.activity.compose.BackHandler import androidx.compose.foundation.background @@ -48,7 +48,6 @@ import io.element.android.libraries.designsystem.utils.CommonDrawables import io.element.android.libraries.theme.ElementTheme import kotlinx.collections.immutable.persistentListOf -// TODO i18n, when wording has been approved. @Composable fun SignedOutView( state: SignedOutState, diff --git a/appnav/src/test/kotlin/io/element/android/appnav/signedout/SignedOutPresenterTest.kt b/features/signedout/impl/src/test/kotlin/io/element/android/features/signedout/impl/SignedOutPresenterTest.kt similarity index 98% rename from appnav/src/test/kotlin/io/element/android/appnav/signedout/SignedOutPresenterTest.kt rename to features/signedout/impl/src/test/kotlin/io/element/android/features/signedout/impl/SignedOutPresenterTest.kt index 529123250c..aa064a7214 100644 --- a/appnav/src/test/kotlin/io/element/android/appnav/signedout/SignedOutPresenterTest.kt +++ b/features/signedout/impl/src/test/kotlin/io/element/android/features/signedout/impl/SignedOutPresenterTest.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package io.element.android.appnav.signedout +package io.element.android.features.signedout.impl import app.cash.molecule.RecompositionMode import app.cash.molecule.moleculeFlow