Remove DRAWER_ACCOUNT_SHIFT
The drawer now uses two adapters for the account list and the folder list. So there's no need to keep the ID space separate.
@@ -258,7 +258,6 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K
var newActiveProfile: IProfile? = null
val accountItems = displayAccounts.map { displayAccount ->
val account = displayAccount.account
- val drawerId = (account.accountNumber + 1 shl DRAWER_ACCOUNT_SHIFT).toLong()
val drawerColors = getDrawerColorsForAccount(account)
val selectedTextColor = drawerColors.accentColor.toSelectedColorStateList()
@@ -267,7 +266,7 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K
isNameShown = true
nameText = account.description ?: ""
descriptionText = account.email
- identifier = drawerId
+ identifier = account.drawerId
tag = account
textColor = selectedTextColor
descriptionTextColor = selectedTextColor
@@ -309,7 +308,7 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K
fun updateUserAccountsAndFolders(account: Account?) {
if (account != null) {
initializeWithAccountColor(account)
- headerView.setActiveProfile((account.accountNumber + 1 shl DRAWER_ACCOUNT_SHIFT).toLong())
+ headerView.setActiveProfile(account.drawerId)
foldersViewModel.loadFolders(account)
}
@@ -522,10 +521,12 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K
private val IProfile.accountUuid: String?
get() = (this.tag as? Account)?.uuid
+ private val Account.drawerId: Long
+ get() = (accountNumber + 1).toLong()
+
companion object {
// Bit shift for identifiers of user folders items, to leave space for other items
private const val DRAWER_FOLDER_SHIFT: Int = 20
- private const val DRAWER_ACCOUNT_SHIFT: Int = 3
private const val DRAWER_ID_UNIFIED_INBOX: Long = 0
private const val DRAWER_ID_DIVIDER: Long = 1
