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

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

Merge "PreviewPageFrame checked state updates" into main

parents 44a905df e5fd8ebc
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.printspooler.widget;

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

import android.content.Context;
import android.util.AttributeSet;
import android.view.accessibility.AccessibilityEvent;
@@ -37,6 +39,20 @@ public final class PreviewPageFrame extends LinearLayout {
        return CompoundButton.class.getName();
    }

    @Override
    public boolean performClick() {
        final boolean result = super.performClick();
        // This widget is incorrectly using the notion of "selection"
        // to represent checked state. We can't send this event in
        // setSelected() because setSelected() is called when this widget
        // is not attached.
        if (triStateChecked()) {
            notifyViewAccessibilityStateChangedIfNeeded(
                    AccessibilityEvent.CONTENT_CHANGE_TYPE_CHECKED);
        }
        return result;
    }

    @Override
    public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
        super.onInitializeAccessibilityEvent(event);
@@ -48,6 +64,11 @@ public final class PreviewPageFrame extends LinearLayout {
        super.onInitializeAccessibilityNodeInfo(info);
        info.setSelected(false);
        info.setCheckable(true);
        if (triStateChecked()) {
            info.setChecked(isSelected() ? AccessibilityNodeInfo.CHECKED_STATE_TRUE :
                    AccessibilityNodeInfo.CHECKED_STATE_FALSE);
        } else {
            info.setChecked(isSelected());
        }
    }
}