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

Commit 640d60a5 authored by Yinglei Wang's avatar Yinglei Wang
Browse files

CheckedTextView accessibility checked state updates

Send the new checked event. Updated to the new checked api.
Test: not needed since were are just sending a new event and update
to new api.
Flag: android.view.accessibility.tri_state_checked
Bug: 380327448

Change-Id: I7fd17fb1cc4b87b9d008751ee9cf1196099b767b
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;
@@ -141,6 +143,10 @@ public class CheckedTextView extends TextView implements Checkable {
        if (mChecked != checked) {
            mChecked = checked;
            refreshDrawableState();
            if (triStateChecked()) {
                notifyViewAccessibilityStateChangedIfNeeded(
                        AccessibilityEvent.CONTENT_CHANGE_TYPE_CHECKED);
            }
            notifyViewAccessibilityStateChangedIfNeeded(
                    AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED);
        }
@@ -570,8 +576,13 @@ public class CheckedTextView extends TextView 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);
        }
    }

    /** @hide */
    @Override