diff --git a/app/core/src/main/java/com/fsck/k9/setup/AccountManagerConstants.kt b/app/core/src/main/java/com/fsck/k9/setup/AccountManagerConstants.kt index 1beb26693ffd2787f5391b9f6766a0e3f46be96f..368a5a2abb0a51a22b48397fa5a07ca8bd2b5ea6 100644 --- a/app/core/src/main/java/com/fsck/k9/setup/AccountManagerConstants.kt +++ b/app/core/src/main/java/com/fsck/k9/setup/AccountManagerConstants.kt @@ -23,4 +23,7 @@ object AccountManagerConstants { const val MAIL_CONTENT_AUTHORITY = "foundation.e.mail.provider.AppContentProvider" const val AUTH_TOKEN_TYPE = "oauth2-access-token" const val KEY_AUTH_STATE = "auth_state" + + const val OPEN_APP_PACKAGE_AFTER_AUTH = "open_app_package_after_auth" + const val OPEN_APP_ACTIVITY_AFTER_AUTH = "open_app_activity_after_auth" } diff --git a/app/ui/legacy/build.gradle b/app/ui/legacy/build.gradle index 1e0ec82ae7e1a92806d55e1d581b1664c4ae9208..d2c66daac0163fa4a9b7472bd264889b70c2ae41 100644 --- a/app/ui/legacy/build.gradle +++ b/app/ui/legacy/build.gradle @@ -70,7 +70,6 @@ dependencies { implementation "com.squareup.retrofit2:converter-simplexml:${versions.retrofit}" implementation "com.github.fahim44:FullScreenLoadingDialog:1.0.7" - implementation "org.greenrobot:eventbus:3.3.1" } android { diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/account/AccountSyncReceiver.kt b/app/ui/legacy/src/main/java/com/fsck/k9/account/AccountSyncReceiver.kt index 96ac4d2d9383957ef06036d9371b99508723ad07..ce18077553c243cf0bd1c72bb1963de692eeafcd 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/account/AccountSyncReceiver.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/account/AccountSyncReceiver.kt @@ -23,7 +23,6 @@ import com.fsck.k9.Preferences import com.fsck.k9.activity.setup.accountmanager.EeloAccountCreator import com.fsck.k9.controller.push.PushController import java.util.concurrent.Executors -import org.greenrobot.eventbus.EventBus import org.koin.core.component.KoinComponent import org.koin.core.component.inject @@ -56,10 +55,9 @@ class AccountSyncReceiver : BroadcastReceiver(), KoinComponent { EeloAccountCreator.loadAccountsFromAccountManager( it.applicationContext, preferences, - accountRemover - ) { - EventBus.getDefault().post(AccountCreationAction()) - } + accountRemover, + null + ) } } } diff --git a/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.kt b/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.kt index 229d7ee2dccc0280dc6da9e3cac6bf4ccf9efb7c..95d2b57c088b8aeffc7d4adaca514c26b2b5bfbf 100644 --- a/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.kt +++ b/app/ui/legacy/src/main/java/com/fsck/k9/activity/setup/AccountSetupBasics.kt @@ -5,6 +5,7 @@ import android.app.Activity import android.content.Context import android.content.Intent import android.os.Bundle +import android.provider.Settings import android.text.Editable import android.view.View import android.view.ViewGroup @@ -18,6 +19,7 @@ import com.fsck.k9.EmailAddressValidator import com.fsck.k9.Preferences import com.fsck.k9.account.AccountCreationAction import com.fsck.k9.account.AccountCreator +import com.fsck.k9.activity.MessageList import com.fsck.k9.activity.setup.AccountSetupCheckSettings.CheckDirection import com.fsck.k9.activity.setup.accountmanager.MailAutoConfigDiscovery import com.fsck.k9.autodiscovery.api.DiscoveredServerSettings @@ -42,9 +44,6 @@ import com.lamonjush.fullscreenloadingdialog.FullScreenLoadingDialog import com.lamonjush.fullscreenloadingdialog.SpinKitStyle import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import org.greenrobot.eventbus.EventBus -import org.greenrobot.eventbus.Subscribe -import org.greenrobot.eventbus.ThreadMode import org.koin.android.ext.android.inject /** @@ -76,7 +75,6 @@ class AccountSetupBasics : K9Activity() { private var uiState = UiState.EMAIL_ADDRESS_ONLY private var account: Account? = null private var checkedIncoming = false - private var accountManagerAuthRunning = false public override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -108,13 +106,6 @@ class AccountSetupBasics : K9Activity() { validateFields() updateUi() - - EventBus.getDefault().register(this) - } - - override fun onDestroy() { - EventBus.getDefault().unregister(this) - super.onDestroy() } private fun initializeViewListeners() { @@ -203,8 +194,6 @@ class AccountSetupBasics : K9Activity() { } private fun attemptAutoSetupUsingOnlyEmailAddress() { - accountManagerAuthRunning = false - val email = emailView.text?.toString() ?: error("Email missing") val extraConnectionSettings = ExtraAccountDiscovery.discover(email) @@ -238,16 +227,11 @@ class AccountSetupBasics : K9Activity() { } private fun startGoogleOAuthFlow() { - accountManagerAuthRunning = true val osAccountManager = AccountManager.get(this) - osAccountManager.addAccount(AccountManagerConstants.GOOGLE_ACCOUNT_TYPE, null, null, null, this, null, null) - } - - @Subscribe(threadMode = ThreadMode.MAIN_ORDERED) - fun onAccountCreatedViaAccountManager(accountCreationAction: AccountCreationAction) { - if (accountManagerAuthRunning) { - finish() - } + val options = Bundle() + options.putString(AccountManagerConstants.OPEN_APP_PACKAGE_AFTER_AUTH, packageName) + options.putString(AccountManagerConstants.OPEN_APP_ACTIVITY_AFTER_AUTH, MessageList::class.java.name) + osAccountManager.addAccount(AccountManagerConstants.GOOGLE_ACCOUNT_TYPE, null, null, options, this, null, null) } private fun startPasswordFlow() { @@ -260,8 +244,6 @@ class AccountSetupBasics : K9Activity() { } private fun attemptAutoSetup() { - accountManagerAuthRunning = false - if (clientCertificateCheckBox.isChecked) { // Auto-setup doesn't support client certificates. onManualSetup()