Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0bfb51f4 authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

mail: Load murena accounts

parent a566fa29
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -29,6 +29,10 @@
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
    <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />

    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />

    <application
        android:allowTaskReparenting="false"
        android:resizeableActivity="true"
@@ -36,6 +40,13 @@
        tools:ignore="UnusedAttribute"
        >

        <receiver android:name="com.fsck.k9.AccountReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.accounts.LOGIN_ACCOUNTS_CHANGED" />
            </intent-filter>
        </receiver>

        <!-- TODO: Remove once minSdkVersion has been changed to 24+ -->
        <meta-data
            android:name="com.lge.support.SPLIT_WINDOW"
+30 −0
Original line number Diff line number Diff line
package com.fsck.k9

import android.accounts.AccountManager
import android.accounts.AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import com.fsck.k9.activity.accountmanager.AccountManagerConstants
import com.fsck.k9.activity.accountmanager.EeloAccountCreator

class AccountReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context, intent: Intent?) {
        val action = intent?.action ?: return
        val accountCreator = EeloAccountCreator(context)

        when (action) {
            AccountManagerConstants.ACCOUNT_CREATION_ACTION, LOGIN_ACCOUNTS_CHANGED_ACTION -> {
                accountCreator.loadAccountsFromAccountManager()
            }
            AccountManagerConstants.ACCOUNT_REMOVAL_ACTION -> {
                intent.extras?.let { extras ->
                    val accountType = extras.getString(AccountManager.KEY_ACCOUNT_TYPE) ?: return
                    val accountName = extras.getString(AccountManager.KEY_ACCOUNT_NAME) ?: return
                    accountCreator.removeAccount(accountType, accountName)
                }
            }
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import app.k9mail.feature.account.oauth.featureAccountOAuthModule
import app.k9mail.feature.launcher.di.featureLauncherModule
import app.k9mail.legacy.ui.folder.uiFolderModule
import com.fsck.k9.account.accountModule
import com.fsck.k9.activity.accountmanager.providersxml.autodiscoveryProvidersXmlModule
import com.fsck.k9.activity.activityModule
import com.fsck.k9.contacts.contactsModule
import com.fsck.k9.ui.account.accountUiModule
@@ -36,6 +37,7 @@ val uiModules = listOf(
    chooseFolderUiModule,
    contactsModule,
    accountModule,
    autodiscoveryProvidersXmlModule,
    viewModule,
    changelogUiModule,
    messageSourceModule,
+7 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.fsck.k9.K9.PostRemoveNavigation
import com.fsck.k9.K9.SplitViewMode
import com.fsck.k9.Preferences
import com.fsck.k9.account.BackgroundAccountRemover
import com.fsck.k9.activity.accountmanager.EeloAccountCreator
import com.fsck.k9.activity.compose.MessageActions
import com.fsck.k9.controller.MessagingController
import com.fsck.k9.helper.ParcelableUtil
@@ -144,8 +145,13 @@ open class MessageList :
            return
        }

        val accounts = accountManager.getAccounts()
        var accounts = accountManager.getAccounts()
        deleteIncompleteAccounts(accounts)

        if (EeloAccountCreator(this).loadAccountsFromAccountManager()) {
            accounts = accountManager.getAccounts()
        }

        val hasAccountSetup = accounts.any { it.isFinishedSetup }
        if (!hasAccountSetup) {
            FeatureLauncherActivity.launch(this, FeatureLauncherTarget.Onboarding)
+16 −0
Original line number Diff line number Diff line
package com.fsck.k9.activity.accountmanager

object AccountManagerConstants {
    const val EELO_ACCOUNT_TYPE = "e.foundation.webdav.eelo"
    const val GOOGLE_ACCOUNT_TYPE = "e.foundation.webdav.google"
    const val YAHOO_ACCOUNT_TYPE = "e.foundation.webdav.yahoo"
    const val ACCOUNT_EMAIL_ADDRESS_KEY = "email_address"
    const val MAIL_CONTENT_AUTHORITY = "foundation.e.mail.provider.AppContentProvider"
    const val KEY_AUTH_STATE = "auth_state"

    val ACCOUNT_TYPES = listOf(EELO_ACCOUNT_TYPE, GOOGLE_ACCOUNT_TYPE, YAHOO_ACCOUNT_TYPE)

    private const val ACTION_PREFIX = "foundation.e.accountmanager.account"
    const val ACCOUNT_CREATION_ACTION = "$ACTION_PREFIX.create"
    const val ACCOUNT_REMOVAL_ACTION = "android.accounts.action.ACCOUNT_REMOVED"
}
Loading