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

Unverified Commit 8dbba4d8 authored by Rafael Tonholo's avatar Rafael Tonholo Committed by GitHub
Browse files

Merge pull request #9337 from rafaeltonholo/fix/9318/fix-configure-drawer-null-pointer-crash

Fix MessageList.configureDrawer throwing NullPointerException when the device orientation changes
parents ed37be97 878ca22d
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import java.util.Set;
import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;
import net.thunderbird.feature.search.api.SearchCondition;


@@ -256,4 +257,16 @@ public class ConditionsTreeNode implements Parcelable {
            mRight.mParent = this;
        }
    }

    @NonNull
    @Override
    public String toString() {
        return "ConditionsTreeNode(" +
            "mLeft=" + mLeft +
            ", mRight=" + mRight +
            ", mParent=" + mParent +
            ", mValue=" + mValue +
            ", mCondition=" + mCondition +
            ')';
    }
}
+13 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import java.util.Set;
import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;
import net.thunderbird.feature.search.api.SearchAttribute;
import net.thunderbird.feature.search.api.SearchCondition;
import net.thunderbird.feature.search.api.SearchField;
@@ -294,4 +295,16 @@ public class LocalSearch implements SearchSpecification {
            mLeafSet = mConditions.getLeafSet();
        }
    }

    @NonNull
    @Override
    public String toString() {
        return "LocalSearch(" +
            "id='" + id + '\'' +
            ", mManualSearch=" + mManualSearch +
            ", mAccountUuids=" + mAccountUuids +
            ", mConditions=" + mConditions +
            ", mLeafSet=" + mLeafSet +
            ')';
    }
}
+22 −9
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import net.thunderbird.core.android.account.AccountManager
import net.thunderbird.core.android.account.LegacyAccount
import net.thunderbird.core.featureflag.FeatureFlagKey
import net.thunderbird.core.featureflag.FeatureFlagProvider
import net.thunderbird.core.logging.Logger
import net.thunderbird.core.logging.legacy.Log
import net.thunderbird.core.preference.GeneralSettingsManager
import net.thunderbird.feature.navigation.drawer.api.NavigationDrawer
@@ -80,6 +81,8 @@ import org.koin.android.ext.android.inject
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject

private const val TAG = "MessageList"

/**
 * MessageList is the primary user interface for the program. This Activity shows a list of messages.
 *
@@ -103,6 +106,7 @@ open class MessageList :
    private val coreResourceProvider: CoreResourceProvider by inject()
    private val fundingManager: FundingManager by inject()
    private val featureFlagProvider: FeatureFlagProvider by inject()
    private val logger: Logger by inject()

    private lateinit var actionBar: ActionBar
    private var searchView: SearchView? = null
@@ -1473,16 +1477,25 @@ open class MessageList :

    private fun configureDrawer() {
        val drawer = navigationDrawer ?: return
        drawer.selectAccount(account!!.uuid)
        val accountUuid = account?.uuid ?: return Unit.also {
            logger.warn(TAG) { "The account property is null. Skipping drawer configuration. " }
            logger.verbose(TAG) { "drawer = $drawer, localSearch = $search" }
        }
        drawer.selectAccount(accountUuid)

        search?.let { search ->
            when {
            singleFolderMode -> drawer.selectFolder(search!!.accountUuids[0], search!!.folderIds[0])
            // Don't select any item in the drawer because the Unified Inbox is displayed, but not listed in the drawer
            search!!.id == SearchAccount.UNIFIED_INBOX &&
                singleFolderMode -> drawer.selectFolder(search.accountUuids[0], search.folderIds[0])

                // Don't select any item in the drawer because the Unified Inbox is displayed,
                // but not listed in the drawer
                search.id == SearchAccount.UNIFIED_INBOX &&
                    !generalSettingsManager.getSettings().isShowUnifiedInbox -> drawer.deselect()

            search!!.id == SearchAccount.UNIFIED_INBOX -> drawer.selectUnifiedInbox()
                search.id == SearchAccount.UNIFIED_INBOX -> drawer.selectUnifiedInbox()
                else -> drawer.deselect()
            }
        } ?: logger.warn(TAG) { "Couldn't select folder for $accountUuid as LocalSearch is null." }
    }

    private fun createSearchAccount(): SearchAccount {