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

Commit 0c61ba6c authored by Michael Enoma's avatar Michael Enoma 👽
Browse files

App Crash Fix

parent a3e30186
Loading
Loading
Loading
Loading
Loading
+53 −34
Original line number Diff line number Diff line
package com.fsck.k9.activity

import android.annotation.SuppressLint
import android.accounts.AccountManager
import android.annotation.SuppressLint
import android.app.SearchManager
import android.content.Context
import android.content.Intent
import android.content.IntentSender
import android.content.res.Configuration
import android.graphics.Color
import android.util.TypedValue
import android.os.Bundle
import com.fsck.k9.activity.setup.accountmanager.AccountManagerConstants.ACCOUNT_EMAIL_ADDRESS_KEY
import com.fsck.k9.activity.setup.accountmanager.AccountManagerConstants.EELO_ACCOUNT_TYPE
import com.fsck.k9.activity.setup.accountmanager.AccountManagerConstants.GOOGLE_ACCOUNT_TYPE
import com.fsck.k9.activity.setup.accountmanager.EeloAccountCreator
import com.fsck.k9.helper.EmailHelper
import android.os.Parcelable
import android.util.TypedValue
import android.view.KeyEvent
import android.view.Menu
import android.view.MenuItem
@@ -24,7 +19,6 @@ import android.view.animation.AnimationUtils
import android.widget.ProgressBar
import android.widget.Toast
import androidx.appcompat.app.ActionBar
import androidx.appcompat.widget.SearchView
import androidx.appcompat.widget.Toolbar
import androidx.drawerlayout.widget.DrawerLayout
import androidx.drawerlayout.widget.DrawerLayout.DrawerListener
@@ -39,6 +33,10 @@ import com.fsck.k9.Preferences
import com.fsck.k9.account.BackgroundAccountRemover
import com.fsck.k9.activity.compose.MessageActions
import com.fsck.k9.activity.setup.AccountSetupBasics
import com.fsck.k9.activity.setup.accountmanager.AccountManagerConstants.ACCOUNT_EMAIL_ADDRESS_KEY
import com.fsck.k9.activity.setup.accountmanager.AccountManagerConstants.EELO_ACCOUNT_TYPE
import com.fsck.k9.activity.setup.accountmanager.AccountManagerConstants.GOOGLE_ACCOUNT_TYPE
import com.fsck.k9.activity.setup.accountmanager.EeloAccountCreator
import com.fsck.k9.controller.MessageReference
import com.fsck.k9.fragment.MessageListFragment
import com.fsck.k9.fragment.MessageListFragment.MessageListFragmentListener
@@ -76,9 +74,7 @@ import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
import timber.log.Timber
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.component.inject
import androidx.appcompat.widget.SearchView

/**
 * MessageList is the primary user interface for the program. This Activity shows a list of messages.
@@ -95,6 +91,9 @@ open class MessageList :

    private val recentChangesViewModel: RecentChangesViewModel by viewModel()

    private lateinit var accountManager: AccountManager
    private lateinit var searchView: SearchView

    protected val searchStatusManager: SearchStatusManager by inject()
    private val preferences: Preferences by inject()
    private val channelUtils: NotificationChannelManager by inject()
@@ -104,7 +103,6 @@ open class MessageList :
    private val permissionUiHelper: PermissionUiHelper = K9PermissionUiHelper(this)

    private lateinit var actionBar: ActionBar
    private lateinit var searchView: SearchView
    private var drawer: K9Drawer? = null
    private var openFolderTransaction: FragmentTransaction? = null
    private var menu: Menu? = null
@@ -136,9 +134,6 @@ open class MessageList :
     */
    private var messageListWasDisplayed = false
    private var viewSwitcher: ViewSwitcher? = null

    private lateinit var accountManager: AccountManager

    private lateinit var recentChangesSnackbar: Snackbar

    public override fun onCreate(savedInstanceState: Bundle?) {
@@ -153,9 +148,7 @@ open class MessageList :
            finish()
            return
        }

        var accounts = preferences.accounts
        deleteIncompleteAccounts(accounts)

        accountManager = AccountManager.get(this)

@@ -164,7 +157,6 @@ open class MessageList :
            accounts = preferences.accounts
        }


        deleteIncompleteAccounts(accounts)
        val hasAccountSetup = accounts.any { it.isFinishedSetup }
        if (!hasAccountSetup) {
@@ -173,7 +165,6 @@ open class MessageList :
            return
        }


        if (UpgradeDatabases.actionUpgradeDatabases(this, intent)) {
            finish()
            return
@@ -685,8 +676,6 @@ open class MessageList :
            drawer!!.close()
        } else if (displayMode == DisplayMode.MESSAGE_VIEW && messageListWasDisplayed) {
            showMessageList()
        } else if (this::searchView.isInitialized && !searchView.isIconified) {
            searchView.isIconified = true
        } else {
            if (isDrawerEnabled && account != null && supportFragmentManager.backStackEntryCount == 0) {
                if (K9.isShowUnifiedInbox) {
@@ -1119,6 +1108,7 @@ open class MessageList :
                }
                val typedArray = obtainStyledAttributes(drawableAttr)
                menu.findItem(R.id.toggle_unread).icon = typedArray.getDrawable(0)
                menu.findItem(R.id.toggle_unread).icon.setTint(resources.getColor(getResId(R.attr.colorAccent)))
                typedArray.recycle()
            }

@@ -1210,6 +1200,7 @@ open class MessageList :

    override fun setMessageListTitle(title: String, subtitle: String?) {
        if (displayMode != DisplayMode.MESSAGE_VIEW) {

            setActionBarTitle(title, subtitle)
        }
    }
@@ -1449,16 +1440,6 @@ open class MessageList :
        configureMenu(menu)
    }

    private fun setDrawerLockState() {
        if (!isDrawerEnabled) return

        if (isAdditionalMessageListDisplayed) {
            lockDrawer()
        } else {
            unlockDrawer()
        }
    }

    private fun showMessageView() {
        displayMode = DisplayMode.MESSAGE_VIEW

@@ -1483,6 +1464,16 @@ open class MessageList :
        menu!!.findItem(R.id.delete).isEnabled = false
    }

    private fun setDrawerLockState() {
        if (!isDrawerEnabled) return

        if (isAdditionalMessageListDisplayed) {
            lockDrawer()
        } else {
            unlockDrawer()
        }
    }

    private fun onToggleTheme() {
        themeManager.toggleMessageViewTheme()
        recreate()
@@ -1546,7 +1537,7 @@ open class MessageList :

    private fun unlockDrawer() {
        drawer!!.unlock()
        actionBar.setHomeAsUpIndicator(R.drawable.ic_menu)
        actionBar.setHomeAsUpIndicator(getResId(R.attr.iconMenu))
    }

    private fun initializeFromLocalSearch(search: LocalSearch?) {
@@ -1567,6 +1558,15 @@ open class MessageList :
        configureDrawer()
    }

    private fun getResId(resAttribute: Int): Int {
        val typedValue = TypedValue()
        val found = theme.resolveAttribute(resAttribute, typedValue, true)
        if (!found) {
            throw AssertionError("Couldn't find resource with attribute $resAttribute")
        }
        return typedValue.resourceId
    }

    private fun LocalSearch.firstAccount(): Account? {
        return if (searchAllAccounts()) {
            preferences.defaultAccount
@@ -1641,7 +1641,27 @@ open class MessageList :
                    accountWasAdded = true
                }
            }

//            for (googleAccount in googleAccounts) {
//                val emailId: String = accountManager.getUserData(
//                    googleAccount,
//                    ACCOUNT_EMAIL_ADDRESS_KEY
//                )
//                var accountIsSignedIn = false
//                for (account in accounts) {
//                    if (emailId == account.email) {
//                        if (account.name == null) { // we need to fix an old bug
//                            account.name = emailId
//                            account.save(Preferences.getPreferences(this))
//                        }
//                        accountIsSignedIn = true
//                        break
//                    }
//                }
//                if (!accountIsSignedIn) {
//                    GoogleAccountCreator.createAccount(this, emailId)
//                    accountWasAdded = true
//                }
//            }
            for (googleAccount in googleAccounts) {
                val emailId: String = accountManager.getUserData(googleAccount, ACCOUNT_EMAIL_ADDRESS_KEY)
                var accountIsSignedIn = false
@@ -1798,4 +1818,3 @@ open class MessageList :
        }
    }
}
+52 −51
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import com.fsck.k9.fragment.ConfirmationDialogFragment.ConfirmationDialogFragmen
import com.fsck.k9.mail.AuthenticationFailedException;
import com.fsck.k9.mail.CertificateValidationException;
import com.fsck.k9.mail.MailServerDirection;

import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.filter.Hex;
import com.fsck.k9.preferences.Protocols;