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

Commit ab05d30f authored by Yinglei Wang's avatar Yinglei Wang
Browse files

CompoundButton accessibility checked state updates

Send the new checked event. Updated to the new checked api.

Test: tested a radio button sends out the new event when
changing from not selected to selected.

Flag: android.view.accessibility.tri_state_checked
Bug: 380327448

Change-Id: Iffe9767ca6d651780d9fb84fd13e21f6a18e073f
parent 3fa794b6
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() {