Add AccountSetupFinishedLauncher
This commit is contained in:
parent
09c00f3bf8
commit
dbdbb25cdb
7 changed files with 69 additions and 2 deletions
|
@ -2,6 +2,7 @@ package app.k9mail.feature.preview
|
|||
|
||||
import app.k9mail.core.common.oauth.OAuthConfigurationFactory
|
||||
import app.k9mail.feature.account.setup.featureAccountSetupModule
|
||||
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
|
||||
|
@ -10,11 +11,19 @@ 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
|
||||
|
||||
val featureModule: Module = module {
|
||||
val accountModule: Module = module {
|
||||
factory {
|
||||
AccountSetupFinishedLauncher(
|
||||
context = androidContext(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val featureModule: Module = module {
|
||||
// TODO move to network module
|
||||
single<OkHttpClient> {
|
||||
OkHttpClient()
|
||||
|
@ -27,5 +36,5 @@ val featureModule: Module = module {
|
|||
single { TrustManagerFactory.createInstance(get()) }
|
||||
single<TrustedSocketFactory> { DefaultTrustedSocketFactory(get(), get()) }
|
||||
|
||||
includes(featureAccountSetupModule)
|
||||
includes(featureAccountSetupModule, accountModule)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package app.k9mail.feature.preview.account
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.Toast
|
||||
import app.k9mail.feature.account.setup.domain.ExternalContract
|
||||
|
||||
class AccountSetupFinishedLauncher(
|
||||
private val context: Context,
|
||||
) : ExternalContract.AccountSetupFinishedLauncher {
|
||||
override fun launch(accountUuid: String) {
|
||||
Toast.makeText(context, "AccountSetupFinishedLauncher.launch($accountUuid)", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
|
@ -17,6 +17,8 @@ dependencies {
|
|||
implementation(projects.backend.pop3)
|
||||
debugImplementation(projects.backend.demo)
|
||||
|
||||
implementation(projects.feature.account.setup)
|
||||
|
||||
implementation(libs.androidx.appcompat)
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.work.ktx)
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.fsck.k9
|
|||
|
||||
import app.k9mail.core.common.oauth.OAuthConfigurationFactory
|
||||
import app.k9mail.ui.widget.list.messageListWidgetModule
|
||||
import com.fsck.k9.account.accountModule
|
||||
import com.fsck.k9.account.newAccountModule
|
||||
import com.fsck.k9.auth.AppOAuthConfigurationFactory
|
||||
import com.fsck.k9.backends.backendsModule
|
||||
import com.fsck.k9.controller.ControllerExtension
|
||||
|
@ -42,4 +44,5 @@ val appModules = listOf(
|
|||
resourcesModule,
|
||||
backendsModule,
|
||||
storageModule,
|
||||
newAccountModule,
|
||||
)
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.fsck.k9.account
|
||||
|
||||
import org.koin.android.ext.koin.androidContext
|
||||
import org.koin.dsl.module
|
||||
|
||||
val newAccountModule = module {
|
||||
factory {
|
||||
AccountSetupFinishedLauncher(
|
||||
context = androidContext(),
|
||||
preferences = get(),
|
||||
)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.fsck.k9.account
|
||||
|
||||
import android.content.Context
|
||||
import app.k9mail.feature.account.setup.domain.ExternalContract
|
||||
import com.fsck.k9.Preferences
|
||||
import com.fsck.k9.activity.MessageList
|
||||
|
||||
class AccountSetupFinishedLauncher(
|
||||
private val context: Context,
|
||||
private val preferences: Preferences,
|
||||
) : ExternalContract.AccountSetupFinishedLauncher {
|
||||
override fun launch(accountUuid: String) {
|
||||
val account = preferences.getAccount(accountUuid)
|
||||
if (account == null) {
|
||||
MessageList.launch(context)
|
||||
} else {
|
||||
MessageList.launch(context, account)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package app.k9mail.feature.account.setup.domain
|
||||
|
||||
interface ExternalContract {
|
||||
fun interface AccountSetupFinishedLauncher {
|
||||
fun launch(accountUuid: String)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue