diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index ae49a5f558c00b6b850dbadbc48dc653ef566844..191c7e23acef0f25ce6a0a92936a9a8c72bfeee6 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -600,6 +600,8 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/java/at/bitfire/davdroid/MailAccountSyncHelper.kt b/app/src/main/java/at/bitfire/davdroid/MailAccountSyncHelper.kt
index cd83ad58d2c2e5be5eac0238dea89cd21f44d008..39ebc1fb7100d8ae4735339aec04297cb1f42be7 100644
--- a/app/src/main/java/at/bitfire/davdroid/MailAccountSyncHelper.kt
+++ b/app/src/main/java/at/bitfire/davdroid/MailAccountSyncHelper.kt
@@ -27,11 +27,7 @@ object MailAccountSyncHelper {
private const val MAIL_RECEIVER_CLASS = "com.fsck.k9.account.AccountSyncReceiver"
private const val ACTION_PREFIX = "foundation.e.accountmanager.account."
- fun onAccountLoggedIn(applicationContext: Context?, packageToBeOpened: String?) {
- if (isOpeningMailAppActivity(packageToBeOpened)) {
- return
- }
-
+ fun syncMailAccounts(applicationContext: Context?) {
val intent = getIntent()
intent.action = ACTION_PREFIX + "create"
applicationContext?.sendBroadcast(intent)
@@ -55,14 +51,4 @@ object MailAccountSyncHelper {
intent.component = ComponentName(MAIL_PACKAGE, MAIL_RECEIVER_CLASS)
return intent
}
-
- // if mail app's activity is needed to open after the auth, no need to send broadCast.
- // because, sending broadcast will fail. The cause is, mail app will be opened in a new task
- private fun isOpeningMailAppActivity(packageToBeOpened: String?): Boolean {
- if (packageToBeOpened == null || packageToBeOpened != MAIL_PACKAGE) {
- return false
- }
-
- return true
- }
}
\ No newline at end of file
diff --git a/app/src/main/java/at/bitfire/davdroid/syncadapter/EeloEmailSyncAdapterService.kt b/app/src/main/java/at/bitfire/davdroid/syncadapter/EeloEmailSyncAdapterService.kt
index ea1319c3b25595563a6d920e4f40fe01ce9fee02..c9d955939bc11cee76da557d0d07f0a40dbf00ed 100644
--- a/app/src/main/java/at/bitfire/davdroid/syncadapter/EeloEmailSyncAdapterService.kt
+++ b/app/src/main/java/at/bitfire/davdroid/syncadapter/EeloEmailSyncAdapterService.kt
@@ -20,6 +20,7 @@ import android.accounts.Account
import android.content.*
import android.os.Bundle
import at.bitfire.davdroid.HttpClient
+import at.bitfire.davdroid.MailAccountSyncHelper
import at.bitfire.davdroid.db.AppDatabase
class EeloEmailSyncAdapterService : SyncAdapterService() {
@@ -39,7 +40,7 @@ class EeloEmailSyncAdapterService : SyncAdapterService() {
provider: ContentProviderClient,
syncResult: SyncResult
) {
- // Unused
+ MailAccountSyncHelper.syncMailAccounts(context.applicationContext)
}
}
}
diff --git a/app/src/main/java/at/bitfire/davdroid/syncadapter/GoogleEmailSyncAdapterService.kt b/app/src/main/java/at/bitfire/davdroid/syncadapter/GoogleEmailSyncAdapterService.kt
index 458237d98fd1ed239721092801cf95b187cc7b6a..03d838817257b0de0cd6050ea03fcf1f5dec591e 100644
--- a/app/src/main/java/at/bitfire/davdroid/syncadapter/GoogleEmailSyncAdapterService.kt
+++ b/app/src/main/java/at/bitfire/davdroid/syncadapter/GoogleEmailSyncAdapterService.kt
@@ -20,6 +20,7 @@ import android.accounts.Account
import android.content.*
import android.os.Bundle
import at.bitfire.davdroid.HttpClient
+import at.bitfire.davdroid.MailAccountSyncHelper
import at.bitfire.davdroid.db.AppDatabase
class GoogleEmailSyncAdapterService : SyncAdapterService() {
@@ -39,7 +40,7 @@ class GoogleEmailSyncAdapterService : SyncAdapterService() {
provider: ContentProviderClient,
syncResult: SyncResult
) {
- // Unused
+ MailAccountSyncHelper.syncMailAccounts(context.applicationContext)
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/at/bitfire/davdroid/ui/setup/AccountDetailsFragment.kt b/app/src/main/java/at/bitfire/davdroid/ui/setup/AccountDetailsFragment.kt
index 2ccf8f682ec2487d00c646b007a7ef10fdb62ba0..18e5b88d722f44c8612aec0d3d95e6c4ed905aaf 100644
--- a/app/src/main/java/at/bitfire/davdroid/ui/setup/AccountDetailsFragment.kt
+++ b/app/src/main/java/at/bitfire/davdroid/ui/setup/AccountDetailsFragment.kt
@@ -193,7 +193,6 @@ class AccountDetailsFragment : Fragment() {
val packageToBeOpened = requireActivity().intent.getStringExtra(LoginActivity.OPEN_APP_PACKAGE_AFTER_AUTH)
val activityToBeOpened = requireActivity().intent.getStringExtra(LoginActivity.OPEN_APP_ACTIVITY_AFTER_AUTH)
openApp(packageToBeOpened, activityToBeOpened)
- MailAccountSyncHelper.onAccountLoggedIn(context?.applicationContext, packageToBeOpened)
}
private fun openApp(packageToBeOpened: String?, activityToBeOpened: String?) {
@@ -203,6 +202,9 @@ class AccountDetailsFragment : Fragment() {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
+ intent.putExtra(LoginActivity.IGNORE_ACCOUNT_SETUP, true)
+ // ignore account setup on open, because sync adapter will handle it
+ // intent.putExtra(LoginActivity.IGNORE_ACCOUNT_SETUP, true)
intent.component = ComponentName(packageToBeOpened!!, activityToBeOpened!!)
requireActivity().applicationContext.startActivity(intent)
}
diff --git a/app/src/main/java/at/bitfire/davdroid/ui/setup/LoginActivity.kt b/app/src/main/java/at/bitfire/davdroid/ui/setup/LoginActivity.kt
index f289bbe2a8af000359e4214a1abeb0cca475e04f..cfdcbceb779daf8ba893f36475ad8c0a4b91d2bf 100644
--- a/app/src/main/java/at/bitfire/davdroid/ui/setup/LoginActivity.kt
+++ b/app/src/main/java/at/bitfire/davdroid/ui/setup/LoginActivity.kt
@@ -52,6 +52,8 @@ class LoginActivity: AppCompatActivity() {
const val OPEN_APP_PACKAGE_AFTER_AUTH = "open_app_package_after_auth"
const val OPEN_APP_ACTIVITY_AFTER_AUTH = "open_app_activity_after_auth"
+ const val IGNORE_ACCOUNT_SETUP = "ignore_account_setup"
+
const val RETRY_ON_401 = "retry_on_401"
}