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

Commit 364d006c authored by Wes Okuhara's avatar Wes Okuhara Committed by Android (Google) Code Review
Browse files

Merge "[SettingsLib] Dynamically update StatusBannerPreference icon tint" into main

parents f9b4f093 cd18c514
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ class StatusBannerPreference @JvmOverloads constructor(
    var iconLevel: BannerStatus = BannerStatus.GENERIC
        set(value) {
            field = value
            updateIconTint(value)
            notifyChanged()
        }
    var buttonLevel: BannerStatus = BannerStatus.GENERIC
@@ -81,7 +82,7 @@ class StatusBannerPreference @JvmOverloads constructor(
            if (icon == null) {
                icon = getIconDrawable(iconLevel)
            } else {
                icon!!.setTintList(ColorStateList.valueOf(getBackgroundColor(iconLevel)))
                updateIconTint(iconLevel)
            }
            buttonLevel = getInteger(R.styleable.StatusBanner_buttonLevel, 0).toBannerStatus()
            buttonText = getString(R.styleable.StatusBanner_buttonText) ?: ""
@@ -252,4 +253,12 @@ class StatusBannerPreference @JvmOverloads constructor(
            )
        }
    }

    /**
     * Sets the icon's tint color based on the icon level. If an icon is not defined, this is a
     * no-op.
     */
    private fun updateIconTint(iconLevel: BannerStatus) {
        icon?.setTintList(ColorStateList.valueOf(getBackgroundColor(iconLevel)))
    }
}