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

Commit 04b6077b authored by Yvonne Jiang's avatar Yvonne Jiang Committed by Android (Google) Code Review
Browse files

Merge "[Settingslib] Add support to set a content description for...

Merge "[Settingslib] Add support to set a content description for SettingsSpinnerPreference." into main
parents c63b8dbe bf200804
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.settingslib.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
@@ -44,6 +45,7 @@ public class SettingsSpinnerPreference extends Preference
    private int mPosition;
    private boolean mShouldPerformClick;
    private int mOffset;
    private CharSequence mContentDescription;

    /**
     * Perform inflation from XML and apply a class-specific base style.
@@ -148,6 +150,12 @@ public class SettingsSpinnerPreference extends Preference
        notifyChanged();
    }

    /** Sets the content description of the spinner. */
    public void setContentDescription(@Nullable CharSequence contentDescription) {
        mContentDescription = contentDescription;
        notifyChanged();
    }

    @Override
    public void onBindViewHolder(PreferenceViewHolder holder) {
        super.onBindViewHolder(holder);
@@ -180,6 +188,9 @@ public class SettingsSpinnerPreference extends Preference
            // To show dropdown view.
            spinner.performClick();
        }
        if (!TextUtils.isEmpty(mContentDescription)) {
            spinner.setContentDescription(mContentDescription);
        }
    }

    private final AdapterView.OnItemSelectedListener mOnSelectedListener =