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

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

[ExpressiveDesign] Add a method to provide a content description for the menu button

This is to fix no real context been given to a talk back user when they select the menu preference.

Bug: 441617900
Test: talkback & visual
Flag: EXEMPT BUGFIX
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:68dbc8364571b16d2397fa5ba252cacb7b7819e8
Merged-In: I7220411a96336cbd44de7943f138a1e3632d0185
Change-Id: I7220411a96336cbd44de7943f138a1e3632d0185
parent 7932f9e4
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -40,6 +40,13 @@ 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
        set(value) {
            field = value
            notifyChanged()
        }

    init {
        layoutResource =
            if (SettingsThemeHelper.isExpressiveTheme(context)) {
@@ -63,6 +70,9 @@ class MenuPreference @JvmOverloads constructor(
        holder.isDividerAllowedAbove = false

        menuButton = holder.findViewById(R.id.settingslib_menu_button) as MaterialButton
        if (menuButtonContentDescription != null) {
            menuButton?.contentDescription = menuButtonContentDescription
        }

        // setup the onClickListener
        setupMenuButton(context)