From 739dc22918049491ff12b98ea5bfbdc314d252a9 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Wed, 5 Oct 2022 15:17:37 +0600 Subject: [PATCH] 5113-Update_redirect_to_listPage_logic issue: https://gitlab.e.foundation/e/backlog/-/issues/5113 Update redirect logic after google account login via accountManager. - simplify flow, now send package name & messageList class name to accountManager. AccountManager will handle the startActivity - remove no more required eventBus dependencies. --- .../fsck/k9/setup/AccountManagerConstants.kt | 3 ++ app/ui/legacy/build.gradle | 1 - .../fsck/k9/account/AccountSyncReceiver.kt | 8 ++--- .../k9/activity/setup/AccountSetupBasics.kt | 30 ++++--------------- 4 files changed, 12 insertions(+), 30 deletions(-) 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 1beb26693f..368a5a2abb 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 1e0ec82ae7..d2c66daac0 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 96ac4d2d93..ce18077553 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 229d7ee2dc..95d2b57c08 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() -- GitLab