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

Commit ba5e8ea3 authored by Yinglei Wang's avatar Yinglei Wang Committed by Android (Google) Code Review
Browse files

Merge "CompoundButton accessibility checked state updates" into main

parents 128ec793 ab05d30f
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.widget;

import static android.view.accessibility.Flags.triStateChecked;

import android.annotation.DrawableRes;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -209,6 +211,10 @@ public abstract class CompoundButton extends Button implements Checkable {
            mCheckedFromResource = false;
            mChecked = checked;
            refreshDrawableState();
            if (triStateChecked()) {
                notifyViewAccessibilityStateChangedIfNeeded(
                        AccessibilityEvent.CONTENT_CHANGE_TYPE_CHECKED);
            }

            // Avoid infinite recursions if setChecked() is called from a listener
            if (mBroadcasting) {
@@ -490,8 +496,13 @@ public abstract class CompoundButton extends Button implements Checkable {
    public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfoInternal(info);
        info.setCheckable(true);
        if (triStateChecked()) {
            info.setChecked(mChecked ? AccessibilityNodeInfo.CHECKED_STATE_TRUE :
                    AccessibilityNodeInfo.CHECKED_STATE_FALSE);
        } else {
            info.setChecked(mChecked);
        }
    }

    @Override
    public int getCompoundPaddingLeft() {