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

Commit c49afd61 authored by Stefan Maftei's avatar Stefan Maftei Committed by Android Build Coastguard Worker
Browse files

[ExpressiveDesign] Add menuButtonContentDescription to MenuHandler

MenuHandler is implemented by both menu and order menu. Thus they
can override the content description property.

Bug: 441617900
Test: talkback & visual
Flag: EXEMPT BUGFIX
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:d8e20902c47cc7b87e2e439dd39c0d39a3a95f39
Merged-In: I9980b8253fc78a81aa6ec7c5bbd425928ed52305
Change-Id: I9980b8253fc78a81aa6ec7c5bbd425928ed52305
parent a694f06f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@ interface MenuHandler {
    var preference: Preference?
    var showIconsInPopupMenu: Boolean

    /** Provides a content description for the menu button. */
    var menuButtonContentDescription: String?

    interface OnMenuItemClickListener {
        fun onMenuItemClick(item: MenuItem, pref: Preference): Boolean
    }
+1 −2
Original line number Diff line number Diff line
@@ -40,8 +40,7 @@ class MenuPreference @JvmOverloads constructor(
    override var preference: Preference? = this
    override var showIconsInPopupMenu: Boolean = false

    /** Provides a content description for the menu button. */
    var menuButtonContentDescription: String? = null
    override var menuButtonContentDescription: String? = null
        set(value) {
            field = value
            notifyChanged()
+9 −0
Original line number Diff line number Diff line
@@ -44,6 +44,12 @@ class OrderMenuPreference @JvmOverloads constructor(
    override var preference: Preference? = this
    override var showIconsInPopupMenu: Boolean = false

    override var menuButtonContentDescription: String? = null
        set(value) {
            field = value
            notifyChanged()
        }

    var number: Int = 0
        set(value) {
            if (field != value) {
@@ -80,6 +86,9 @@ class OrderMenuPreference @JvmOverloads constructor(

        menuButton = holder.findViewById(R.id.settingslib_menu_button) as? MaterialButton
        (menuButton as android.view.View).visibility = if (isMenuButtonVisible) VISIBLE else GONE
        if (menuButtonContentDescription != null) {
            menuButton?.contentDescription = menuButtonContentDescription
        }

        // setup the onClickListener
        setupMenuButton(context)