From 4cd261dcc78c49bd7ac2626cabf5197e7b612f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montwe=CC=81?= Date: Thu, 29 Jun 2023 11:26:07 +0200 Subject: [PATCH 1/6] Add feature launcher module to add host activity for composable views --- feature/launcher/build.gradle.kts | 25 ++++++++++ feature/launcher/src/main/AndroidManifest.xml | 13 +++++ .../launcher/FeatureLauncherActivity.kt | 49 +++++++++++++++++++ .../launcher/di/FeatureLauncherModule.kt | 10 ++++ .../navigation/FeatureLauncherNavHost.kt | 43 ++++++++++++++++ .../feature/launcher/ui/FeatureLauncherApp.kt | 32 ++++++++++++ settings.gradle.kts | 1 + 7 files changed, 173 insertions(+) create mode 100644 feature/launcher/build.gradle.kts create mode 100644 feature/launcher/src/main/AndroidManifest.xml create mode 100644 feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/FeatureLauncherActivity.kt create mode 100644 feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/di/FeatureLauncherModule.kt create mode 100644 feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt create mode 100644 feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/ui/FeatureLauncherApp.kt diff --git a/feature/launcher/build.gradle.kts b/feature/launcher/build.gradle.kts new file mode 100644 index 000000000..ed6f16361 --- /dev/null +++ b/feature/launcher/build.gradle.kts @@ -0,0 +1,25 @@ +plugins { + id(ThunderbirdPlugins.Library.androidCompose) +} + +android { + namespace = "app.k9mail.feature.launcher" + resourcePrefix = "launcher_" + + buildTypes { + debug { + manifestPlaceholders["appAuthRedirectScheme"] = "FIXME: override this in your app project" + } + release { + manifestPlaceholders["appAuthRedirectScheme"] = "FIXME: override this in your app project" + } + } +} + +dependencies { + implementation(projects.core.ui.compose.designsystem) + implementation(projects.feature.onboarding) + implementation(projects.feature.account.setup) + + testImplementation(projects.core.ui.compose.testing) +} diff --git a/feature/launcher/src/main/AndroidManifest.xml b/feature/launcher/src/main/AndroidManifest.xml new file mode 100644 index 000000000..f3051e0d1 --- /dev/null +++ b/feature/launcher/src/main/AndroidManifest.xml @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/FeatureLauncherActivity.kt b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/FeatureLauncherActivity.kt new file mode 100644 index 000000000..93049c832 --- /dev/null +++ b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/FeatureLauncherActivity.kt @@ -0,0 +1,49 @@ +package app.k9mail.feature.launcher + +import android.app.Activity +import android.content.Intent +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.core.view.WindowCompat +import app.k9mail.feature.account.setup.navigation.NAVIGATION_ROUTE_ACCOUNT_SETUP +import app.k9mail.feature.launcher.ui.FeatureLauncherApp +import app.k9mail.feature.onboarding.navigation.NAVIGATION_ROUTE_ONBOARDING + +class FeatureLauncherActivity : ComponentActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + WindowCompat.setDecorFitsSystemWindows(window, false) + + val destination = intent.getStringExtra(EXTRA_DESTINATION) + + setContent { + FeatureLauncherApp(startDestination = destination) + } + } + + companion object { + private const val EXTRA_DESTINATION = "destination" + private const val DESTINATION_ONBOARDING = NAVIGATION_ROUTE_ONBOARDING + private const val DESTINATION_SETUP_ACCOUNT = NAVIGATION_ROUTE_ACCOUNT_SETUP + + @JvmStatic + fun launchOnboarding(context: Activity) { + val intent = Intent(context, FeatureLauncherActivity::class.java).apply { + putExtra(EXTRA_DESTINATION, DESTINATION_ONBOARDING) + flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK + } + context.startActivity(intent) + } + + @JvmStatic + fun launchSetupAccount(context: Activity) { + val intent = Intent(context, FeatureLauncherActivity::class.java).apply { + putExtra(EXTRA_DESTINATION, DESTINATION_SETUP_ACCOUNT) + } + context.startActivity(intent) + } + } +} diff --git a/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/di/FeatureLauncherModule.kt b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/di/FeatureLauncherModule.kt new file mode 100644 index 000000000..7cc641f17 --- /dev/null +++ b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/di/FeatureLauncherModule.kt @@ -0,0 +1,10 @@ +package app.k9mail.feature.launcher.di + +import app.k9mail.feature.account.setup.featureAccountSetupModule +import org.koin.dsl.module + +val featureLauncherModule = module { + includes( + featureAccountSetupModule, + ) +} diff --git a/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt new file mode 100644 index 000000000..380ba5e09 --- /dev/null +++ b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt @@ -0,0 +1,43 @@ +package app.k9mail.feature.launcher.navigation + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.ui.Modifier +import androidx.navigation.NavHostController +import androidx.navigation.compose.NavHost +import app.k9mail.feature.account.setup.AccountSetupExternalContract.AccountSetupFinishedLauncher +import app.k9mail.feature.account.setup.navigation.accountSetupRoute +import app.k9mail.feature.account.setup.navigation.navigateToAccountSetup +import app.k9mail.feature.onboarding.navigation.NAVIGATION_ROUTE_ONBOARDING +import app.k9mail.feature.onboarding.navigation.onboardingRoute +import kotlinx.coroutines.launch +import org.koin.compose.koinInject + +@Composable +fun FeatureLauncherNavHost( + navController: NavHostController, + startDestination: String?, + modifier: Modifier = Modifier, + accountSetupFinishedLauncher: AccountSetupFinishedLauncher = koinInject(), +) { + val coroutineScope = rememberCoroutineScope() + + NavHost( + navController = navController, + startDestination = startDestination ?: NAVIGATION_ROUTE_ONBOARDING, + modifier = modifier, + ) { + onboardingRoute( + onStart = { navController.navigateToAccountSetup() }, + onImport = { /* TODO */ }, + ) + accountSetupRoute( + onBack = navController::popBackStack, + onFinish = { + coroutineScope.launch { + accountSetupFinishedLauncher.launch(it) + } + }, + ) + } +} diff --git a/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/ui/FeatureLauncherApp.kt b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/ui/FeatureLauncherApp.kt new file mode 100644 index 000000000..2d0049148 --- /dev/null +++ b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/ui/FeatureLauncherApp.kt @@ -0,0 +1,32 @@ +package app.k9mail.feature.launcher.ui + +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.safeDrawingPadding +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.navigation.compose.rememberNavController +import app.k9mail.core.ui.compose.designsystem.atom.Background +import app.k9mail.core.ui.compose.theme.K9Theme +import app.k9mail.feature.launcher.navigation.FeatureLauncherNavHost + +@Composable +fun FeatureLauncherApp( + startDestination: String?, + modifier: Modifier = Modifier, +) { + val navController = rememberNavController() + + K9Theme { + Background( + modifier = Modifier + .fillMaxSize() + .safeDrawingPadding() + .then(modifier), + ) { + FeatureLauncherNavHost( + navController = navController, + startDestination = startDestination, + ) + } + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 978f562b1..db0bd1ad4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -39,6 +39,7 @@ include( ) include( + ":feature:launcher", ":feature:account:setup", ":feature:account:oauth", ":feature:onboarding", From b9e9dced5d2e9b4498164dde947bb1439a30cbdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montwe=CC=81?= Date: Thu, 29 Jun 2023 11:27:00 +0200 Subject: [PATCH 2/6] Move OkHttp dependency injection to account setup --- .../main/java/app/k9mail/feature/preview/FeatureModule.kt | 6 ------ .../app/k9mail/feature/account/setup/AccountSetupModule.kt | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app-feature-preview/src/main/java/app/k9mail/feature/preview/FeatureModule.kt b/app-feature-preview/src/main/java/app/k9mail/feature/preview/FeatureModule.kt index 075a9c9c7..19d015362 100644 --- a/app-feature-preview/src/main/java/app/k9mail/feature/preview/FeatureModule.kt +++ b/app-feature-preview/src/main/java/app/k9mail/feature/preview/FeatureModule.kt @@ -13,7 +13,6 @@ import com.fsck.k9.mail.ssl.KeyStoreDirectoryProvider import com.fsck.k9.mail.ssl.LocalKeyStore import com.fsck.k9.mail.ssl.TrustManagerFactory import com.fsck.k9.mail.ssl.TrustedSocketFactory -import okhttp3.OkHttpClient import org.koin.android.ext.koin.androidContext import org.koin.core.module.Module import org.koin.dsl.module @@ -29,11 +28,6 @@ val accountModule: Module = module { } val featureModule: Module = module { - // TODO move to network module - single { - OkHttpClient() - } - single { AppOAuthConfigurationFactory() } factory { AndroidKeyStoreDirectoryProvider(context = get()) } diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/AccountSetupModule.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/AccountSetupModule.kt index 6484516a4..38a3fd087 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/AccountSetupModule.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/AccountSetupModule.kt @@ -23,11 +23,17 @@ import app.k9mail.feature.account.setup.ui.outgoing.AccountOutgoingConfigViewMod import com.fsck.k9.mail.store.imap.ImapServerSettingsValidator import com.fsck.k9.mail.store.pop3.Pop3ServerSettingsValidator import com.fsck.k9.mail.transport.smtp.SmtpServerSettingsValidator +import okhttp3.OkHttpClient import org.koin.androidx.viewmodel.dsl.viewModel import org.koin.core.module.Module import org.koin.dsl.module val featureAccountSetupModule: Module = module { + + single { + OkHttpClient() + } + single { RealAutoDiscoveryService( okHttpClient = get(), From 10e89e7e3e0bd822fad5026a264a83a49381bb46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montwe=CC=81?= Date: Thu, 29 Jun 2023 11:34:17 +0200 Subject: [PATCH 3/6] Add onboarding entry point --- app/ui/legacy/build.gradle.kts | 4 +++- app/ui/legacy/src/main/java/com/fsck/k9/UiKoinModules.kt | 2 ++ .../src/main/java/com/fsck/k9/activity/MessageList.kt | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/ui/legacy/build.gradle.kts b/app/ui/legacy/build.gradle.kts index 0aaedebda..c81af0aa7 100644 --- a/app/ui/legacy/build.gradle.kts +++ b/app/ui/legacy/build.gradle.kts @@ -10,9 +10,11 @@ dependencies { implementation(projects.feature.autodiscovery.providersxml) implementation(projects.mail.common) implementation(projects.uiUtils.toolbarBottomSheet) + + implementation(projects.feature.launcher) + // TODO: Remove AccountOauth dependency implementation(projects.feature.account.oauth) - // Remove AccountSetupIncoming's dependency on these compileOnly(projects.mail.protocols.imap) implementation(projects.plugins.openpgpApiLib.openpgpApi) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/UiKoinModules.kt b/app/ui/legacy/src/main/java/com/fsck/k9/UiKoinModules.kt index f4fa4c71d..301848051 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/UiKoinModules.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/UiKoinModules.kt @@ -2,6 +2,7 @@ package com.fsck.k9 import app.k9mail.autodiscovery.providersxml.autodiscoveryProvidersXmlModule import app.k9mail.feature.account.oauth.featureAccountOAuthModule +import app.k9mail.feature.launcher.di.featureLauncherModule import com.fsck.k9.account.accountModule import com.fsck.k9.activity.activityModule import com.fsck.k9.contacts.contactsModule @@ -42,4 +43,5 @@ val uiModules = listOf( messageDetailsUiModule, messageViewUiModule, identityUiModule, + featureLauncherModule, ) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt index 08318bd17..e7a5e160c 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt @@ -28,6 +28,7 @@ import androidx.fragment.app.commit import androidx.fragment.app.commitNow import app.k9mail.core.android.common.contact.CachingRepository import app.k9mail.core.android.common.contact.ContactRepository +import app.k9mail.feature.launcher.FeatureLauncherActivity import com.fsck.k9.Account import com.fsck.k9.K9 import com.fsck.k9.K9.SplitViewMode @@ -153,7 +154,12 @@ open class MessageList : deleteIncompleteAccounts(accounts) val hasAccountSetup = accounts.any { it.isFinishedSetup } if (!hasAccountSetup) { - OnboardingActivity.launch(this) + val useNewOnboarding = true + if (useNewOnboarding) { + FeatureLauncherActivity.launchOnboarding(this) + } else { + OnboardingActivity.launch(this) + } finish() return } From 9bf80c22667258d6a144abced1bbbc6489cc7e56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montwe=CC=81?= Date: Thu, 29 Jun 2023 12:12:17 +0200 Subject: [PATCH 4/6] Change AccountSetupFinishedLauncher to use custom intent for properly launching MessageList --- .../java/com/fsck/k9/account/AccountModule.kt | 1 - .../account/AccountSetupFinishedLauncher.kt | 20 +++++++------------ .../java/com/fsck/k9/activity/MessageList.kt | 2 +- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/app/k9mail/src/main/java/com/fsck/k9/account/AccountModule.kt b/app/k9mail/src/main/java/com/fsck/k9/account/AccountModule.kt index bd1580519..4ed23cb60 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/account/AccountModule.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/account/AccountModule.kt @@ -24,7 +24,6 @@ val newAccountModule = module { factory { AccountSetupFinishedLauncher( context = androidContext(), - preferences = get(), ) } } diff --git a/app/k9mail/src/main/java/com/fsck/k9/account/AccountSetupFinishedLauncher.kt b/app/k9mail/src/main/java/com/fsck/k9/account/AccountSetupFinishedLauncher.kt index 144b873f4..7a4d6416e 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/account/AccountSetupFinishedLauncher.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/account/AccountSetupFinishedLauncher.kt @@ -1,27 +1,21 @@ package com.fsck.k9.account import android.content.Context +import android.content.Intent import app.k9mail.feature.account.setup.AccountSetupExternalContract -import com.fsck.k9.Preferences import com.fsck.k9.activity.MessageList -import kotlinx.coroutines.CoroutineDispatcher -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.withContext class AccountSetupFinishedLauncher( private val context: Context, - private val preferences: Preferences, - private val coroutineDispatcher: CoroutineDispatcher = Dispatchers.IO, ) : AccountSetupExternalContract.AccountSetupFinishedLauncher { override suspend fun launch(accountUuid: String) { - val account = withContext(coroutineDispatcher) { - preferences.getAccount(accountUuid) + val intent = Intent(context, MessageList::class.java).apply { + addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) + addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) + putExtra(MessageList.EXTRA_ACCOUNT, accountUuid) } - if (account == null) { - MessageList.launch(context) - } else { - MessageList.launch(context, account) - } + context.startActivity(intent) } } diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt index e7a5e160c..0e67a24dd 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt @@ -1398,7 +1398,7 @@ open class MessageList : private const val ACTION_SHORTCUT = "shortcut" private const val EXTRA_SPECIAL_FOLDER = "special_folder" - private const val EXTRA_ACCOUNT = "account_uuid" + const val EXTRA_ACCOUNT = "account_uuid" private const val EXTRA_MESSAGE_REFERENCE = "message_reference" private const val EXTRA_MESSAGE_VIEW_ONLY = "message_view_only" From 6cfd9481aaacd3026d8c5307e231436736ac5b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montwe=CC=81?= Date: Thu, 29 Jun 2023 13:00:42 +0200 Subject: [PATCH 5/6] Move AccountSetupFinishedLauncher to feature launcher --- .../app/k9mail/feature/preview/FeatureModule.kt | 7 ------- .../account/AccountSetupFinishedLauncher.kt | 13 ------------- app/k9mail/build.gradle.kts | 3 +++ .../src/main/java/com/fsck/k9/Dependencies.kt | 2 ++ .../main/java/com/fsck/k9/account/AccountModule.kt | 7 ------- .../AccountSetupFinishedLauncher.kt | 8 ++++---- .../main/java/com/fsck/k9/feature/FeatureModule.kt | 13 +++++++++++++ .../account/setup/AccountSetupExternalContract.kt | 4 ---- .../launcher/FeatureLauncherExternalContract.kt | 8 ++++++++ .../launcher/navigation/FeatureLauncherNavHost.kt | 14 +++----------- 10 files changed, 33 insertions(+), 46 deletions(-) delete mode 100644 app-feature-preview/src/main/java/app/k9mail/feature/preview/account/AccountSetupFinishedLauncher.kt rename app/k9mail/src/main/java/com/fsck/k9/{account => feature}/AccountSetupFinishedLauncher.kt (70%) create mode 100644 app/k9mail/src/main/java/com/fsck/k9/feature/FeatureModule.kt create mode 100644 feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/FeatureLauncherExternalContract.kt diff --git a/app-feature-preview/src/main/java/app/k9mail/feature/preview/FeatureModule.kt b/app-feature-preview/src/main/java/app/k9mail/feature/preview/FeatureModule.kt index 19d015362..23dd89e99 100644 --- a/app-feature-preview/src/main/java/app/k9mail/feature/preview/FeatureModule.kt +++ b/app-feature-preview/src/main/java/app/k9mail/feature/preview/FeatureModule.kt @@ -5,7 +5,6 @@ import app.k9mail.feature.account.setup.AccountSetupExternalContract import app.k9mail.feature.account.setup.featureAccountSetupModule import app.k9mail.feature.preview.account.AccountCreator import app.k9mail.feature.preview.account.AccountOwnerNameProvider -import app.k9mail.feature.preview.account.AccountSetupFinishedLauncher import app.k9mail.feature.preview.auth.AndroidKeyStoreDirectoryProvider import app.k9mail.feature.preview.auth.AppOAuthConfigurationFactory import app.k9mail.feature.preview.auth.DefaultTrustedSocketFactory @@ -13,18 +12,12 @@ import com.fsck.k9.mail.ssl.KeyStoreDirectoryProvider import com.fsck.k9.mail.ssl.LocalKeyStore import com.fsck.k9.mail.ssl.TrustManagerFactory import com.fsck.k9.mail.ssl.TrustedSocketFactory -import org.koin.android.ext.koin.androidContext import org.koin.core.module.Module import org.koin.dsl.module val accountModule: Module = module { factory { AccountOwnerNameProvider() } factory { AccountCreator() } - factory { - AccountSetupFinishedLauncher( - context = androidContext(), - ) - } } val featureModule: Module = module { diff --git a/app-feature-preview/src/main/java/app/k9mail/feature/preview/account/AccountSetupFinishedLauncher.kt b/app-feature-preview/src/main/java/app/k9mail/feature/preview/account/AccountSetupFinishedLauncher.kt deleted file mode 100644 index 46a2acdcd..000000000 --- a/app-feature-preview/src/main/java/app/k9mail/feature/preview/account/AccountSetupFinishedLauncher.kt +++ /dev/null @@ -1,13 +0,0 @@ -package app.k9mail.feature.preview.account - -import android.content.Context -import android.widget.Toast -import app.k9mail.feature.account.setup.AccountSetupExternalContract - -class AccountSetupFinishedLauncher( - private val context: Context, -) : AccountSetupExternalContract.AccountSetupFinishedLauncher { - override suspend fun launch(accountUuid: String) { - Toast.makeText(context, "AccountSetupFinishedLauncher.launch($accountUuid)", Toast.LENGTH_SHORT).show() - } -} diff --git a/app/k9mail/build.gradle.kts b/app/k9mail/build.gradle.kts index 500792c8b..db201b8b8 100644 --- a/app/k9mail/build.gradle.kts +++ b/app/k9mail/build.gradle.kts @@ -17,6 +17,9 @@ dependencies { implementation(projects.backend.pop3) debugImplementation(projects.backend.demo) + implementation(projects.feature.launcher) + + // TODO remove account setup dependency implementation(projects.feature.account.setup) implementation(libs.androidx.appcompat) diff --git a/app/k9mail/src/main/java/com/fsck/k9/Dependencies.kt b/app/k9mail/src/main/java/com/fsck/k9/Dependencies.kt index d71c59223..427a1317c 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/Dependencies.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/Dependencies.kt @@ -8,6 +8,7 @@ import com.fsck.k9.backends.backendsModule import com.fsck.k9.controller.ControllerExtension import com.fsck.k9.crypto.EncryptionExtractor import com.fsck.k9.crypto.openpgp.OpenPgpEncryptionExtractor +import com.fsck.k9.feature.featureModule import com.fsck.k9.notification.notificationModule import com.fsck.k9.preferences.K9StoragePersister import com.fsck.k9.preferences.StoragePersister @@ -44,4 +45,5 @@ val appModules = listOf( backendsModule, storageModule, newAccountModule, + featureModule, ) diff --git a/app/k9mail/src/main/java/com/fsck/k9/account/AccountModule.kt b/app/k9mail/src/main/java/com/fsck/k9/account/AccountModule.kt index 4ed23cb60..e1a250f68 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/account/AccountModule.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/account/AccountModule.kt @@ -2,7 +2,6 @@ package com.fsck.k9.account import app.k9mail.feature.account.setup.AccountSetupExternalContract import org.koin.android.ext.koin.androidApplication -import org.koin.android.ext.koin.androidContext import org.koin.dsl.module val newAccountModule = module { @@ -20,10 +19,4 @@ val newAccountModule = module { context = androidApplication(), ) } - - factory { - AccountSetupFinishedLauncher( - context = androidContext(), - ) - } } diff --git a/app/k9mail/src/main/java/com/fsck/k9/account/AccountSetupFinishedLauncher.kt b/app/k9mail/src/main/java/com/fsck/k9/feature/AccountSetupFinishedLauncher.kt similarity index 70% rename from app/k9mail/src/main/java/com/fsck/k9/account/AccountSetupFinishedLauncher.kt rename to app/k9mail/src/main/java/com/fsck/k9/feature/AccountSetupFinishedLauncher.kt index 7a4d6416e..2578f76d6 100644 --- a/app/k9mail/src/main/java/com/fsck/k9/account/AccountSetupFinishedLauncher.kt +++ b/app/k9mail/src/main/java/com/fsck/k9/feature/AccountSetupFinishedLauncher.kt @@ -1,14 +1,14 @@ -package com.fsck.k9.account +package com.fsck.k9.feature import android.content.Context import android.content.Intent -import app.k9mail.feature.account.setup.AccountSetupExternalContract +import app.k9mail.feature.launcher.FeatureLauncherExternalContract import com.fsck.k9.activity.MessageList class AccountSetupFinishedLauncher( private val context: Context, -) : AccountSetupExternalContract.AccountSetupFinishedLauncher { - override suspend fun launch(accountUuid: String) { +) : FeatureLauncherExternalContract.AccountSetupFinishedLauncher { + override fun launch(accountUuid: String) { val intent = Intent(context, MessageList::class.java).apply { addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) diff --git a/app/k9mail/src/main/java/com/fsck/k9/feature/FeatureModule.kt b/app/k9mail/src/main/java/com/fsck/k9/feature/FeatureModule.kt new file mode 100644 index 000000000..d9e2e7c22 --- /dev/null +++ b/app/k9mail/src/main/java/com/fsck/k9/feature/FeatureModule.kt @@ -0,0 +1,13 @@ +package com.fsck.k9.feature + +import app.k9mail.feature.launcher.FeatureLauncherExternalContract +import org.koin.android.ext.koin.androidContext +import org.koin.dsl.module + +val featureModule = module { + factory { + AccountSetupFinishedLauncher( + context = androidContext(), + ) + } +} diff --git a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/AccountSetupExternalContract.kt b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/AccountSetupExternalContract.kt index 350e726c5..768153f06 100644 --- a/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/AccountSetupExternalContract.kt +++ b/feature/account/setup/src/main/kotlin/app/k9mail/feature/account/setup/AccountSetupExternalContract.kt @@ -16,8 +16,4 @@ interface AccountSetupExternalContract { fun interface AccountOwnerNameProvider { suspend fun getOwnerName(): String? } - - fun interface AccountSetupFinishedLauncher { - suspend fun launch(accountUuid: String) - } } diff --git a/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/FeatureLauncherExternalContract.kt b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/FeatureLauncherExternalContract.kt new file mode 100644 index 000000000..c80b72b08 --- /dev/null +++ b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/FeatureLauncherExternalContract.kt @@ -0,0 +1,8 @@ +package app.k9mail.feature.launcher + +interface FeatureLauncherExternalContract { + + fun interface AccountSetupFinishedLauncher { + fun launch(accountUuid: String) + } +} diff --git a/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt index 380ba5e09..4eb020ea7 100644 --- a/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt +++ b/feature/launcher/src/main/kotlin/app/k9mail/feature/launcher/navigation/FeatureLauncherNavHost.kt @@ -1,16 +1,14 @@ package app.k9mail.feature.launcher.navigation import androidx.compose.runtime.Composable -import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost -import app.k9mail.feature.account.setup.AccountSetupExternalContract.AccountSetupFinishedLauncher import app.k9mail.feature.account.setup.navigation.accountSetupRoute import app.k9mail.feature.account.setup.navigation.navigateToAccountSetup +import app.k9mail.feature.launcher.FeatureLauncherExternalContract.AccountSetupFinishedLauncher import app.k9mail.feature.onboarding.navigation.NAVIGATION_ROUTE_ONBOARDING import app.k9mail.feature.onboarding.navigation.onboardingRoute -import kotlinx.coroutines.launch import org.koin.compose.koinInject @Composable @@ -18,10 +16,8 @@ fun FeatureLauncherNavHost( navController: NavHostController, startDestination: String?, modifier: Modifier = Modifier, - accountSetupFinishedLauncher: AccountSetupFinishedLauncher = koinInject(), + accountSetupFinishedLauncher: AccountSetupFinishedLauncher = koinInject(), ) { - val coroutineScope = rememberCoroutineScope() - NavHost( navController = navController, startDestination = startDestination ?: NAVIGATION_ROUTE_ONBOARDING, @@ -33,11 +29,7 @@ fun FeatureLauncherNavHost( ) accountSetupRoute( onBack = navController::popBackStack, - onFinish = { - coroutineScope.launch { - accountSetupFinishedLauncher.launch(it) - } - }, + onFinish = { accountSetupFinishedLauncher.launch(it) }, ) } } From 771775c6c66e0b48ffa59bcefe82afd25755ce47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Martell=20Montwe=CC=81?= Date: Fri, 30 Jun 2023 14:51:10 +0200 Subject: [PATCH 6/6] Disable new onboarding --- app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt index 0e67a24dd..a1b6a2cce 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/MessageList.kt @@ -154,7 +154,7 @@ open class MessageList : deleteIncompleteAccounts(accounts) val hasAccountSetup = accounts.any { it.isFinishedSetup } if (!hasAccountSetup) { - val useNewOnboarding = true + val useNewOnboarding = false if (useNewOnboarding) { FeatureLauncherActivity.launchOnboarding(this) } else {