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

Commit 8b7e88c4 authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury
Browse files

Update drawer icon color on select stage

issue: https://gitlab.e.foundation/e/backlog/-/issues/4723

retrieve drawable from resourceId, setTint=color_default_accent,
set the icon as the `selectedIcon` of drawerItems
parent f0af835c
Loading
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -11,6 +11,10 @@ import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.Toast
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.view.GravityCompat
import androidx.drawerlayout.widget.DrawerLayout
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
@@ -365,8 +369,13 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K
        }

        folderList.unifiedInbox?.let { unifiedInbox ->
            val unwrappedDrawable = AppCompatResources.getDrawable(parent.applicationContext, R.drawable.ic_inbox_multiple)
            val wrappedSelectedDrawable = DrawableCompat.wrap(unwrappedDrawable!!)
            DrawableCompat.setTint(wrappedSelectedDrawable, ContextCompat.getColor(parent.applicationContext, R.color.color_default_accent))

            val unifiedInboxItem = PrimaryDrawerItem().apply {
                iconRes = R.drawable.ic_inbox_multiple //getResId(R.attr.iconUnifiedInbox)
                selectedIcon = ImageHolder(wrappedSelectedDrawable)
                identifier = DRAWER_ID_UNIFIED_INBOX
                nameRes = R.string.integrated_inbox_title
                selectedColorInt = selectedBackgroundColor
@@ -391,8 +400,14 @@ class K9Drawer(private val parent: MessageList, savedInstanceState: Bundle?) : K
            val folder = displayFolder.folder
            val drawerId = accountOffset + folder.id

            val iconId = folderIconProvider.getFolderIcon(folder.type)
            val unwrappedDrawable = AppCompatResources.getDrawable(parent.applicationContext, iconId)
            val wrappedSelectedDrawable = DrawableCompat.wrap(unwrappedDrawable!!)
            DrawableCompat.setTint(wrappedSelectedDrawable, ContextCompat.getColor(parent.applicationContext, R.color.color_default_accent))

            val drawerItem = FolderDrawerItem().apply {
                iconRes = folderIconProvider.getFolderIcon(folder.type)
                iconRes = iconId
                selectedIcon = ImageHolder(wrappedSelectedDrawable)
                identifier = drawerId
                tag = folder
                nameText = getFolderDisplayName(folder)