From f30fbc433ffe9baca4deade8f273e60546bc24be Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Wed, 2 Nov 2022 19:45:34 +0600 Subject: [PATCH 1/4] Add missing mail sync adapter athority in query issue: https://gitlab.e.foundation/e/backlog/-/issues/3081 From android 30, custom provider's authority needs to be addressed in tne androidMainfest file to pass data to contentProvider. --- app/src/main/AndroidManifest.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ae49a5f55..191c7e23a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -600,6 +600,8 @@ + + \ No newline at end of file -- GitLab From 5d5b4934654574a28745bf5a0c9e2c59d051c43a Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Wed, 2 Nov 2022 19:50:47 +0600 Subject: [PATCH 2/4] Ignore mail account creation after login issue: https://gitlab.e.foundation/e/backlog/-/issues/3081 The mail account creation will be handled from the mail sync adapters. So no mail account needs to setup after the account setup. --- .../java/at/bitfire/davdroid/ui/setup/AccountDetailsFragment.kt | 2 +- app/src/main/java/at/bitfire/davdroid/ui/setup/LoginActivity.kt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 2ccf8f682..db333b419 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,7 @@ 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.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 971ad07b1..7e16158ac 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 @@ -51,6 +51,7 @@ 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" } @Inject -- GitLab From 20a398610b63a6d2b9b42eb8559cc171555398b9 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Wed, 2 Nov 2022 19:54:07 +0600 Subject: [PATCH 3/4] Sync mail accounts on performSync issue: https://gitlab.e.foundation/e/backlog/-/issues/3081 Create mail accounts when performSync is called from the murena & google mail syncAdapters. --- .../at/bitfire/davdroid/MailAccountSyncHelper.kt | 16 +--------------- .../syncadapter/EeloEmailSyncAdapterService.kt | 3 ++- .../syncadapter/GoogleEmailSyncAdapterService.kt | 3 ++- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/at/bitfire/davdroid/MailAccountSyncHelper.kt b/app/src/main/java/at/bitfire/davdroid/MailAccountSyncHelper.kt index cd83ad58d..39ebc1fb7 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 ea1319c3b..c9d955939 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 458237d98..03d838817 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 -- GitLab From af88fed4e7861781854c74271648f8f3fc66a259 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Mon, 7 Nov 2022 12:52:35 +0000 Subject: [PATCH 4/4] Apply 1 suggestion(s) to 1 file(s) --- .../at/bitfire/davdroid/ui/setup/AccountDetailsFragment.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 db333b419..18e5b88d7 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 @@ -202,7 +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) + // 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) } -- GitLab