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

Commit 611d01e3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Improve a11y of role UI." into qt-dev

parents 149ef4b1 d76b792f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -703,7 +703,7 @@
    <style name="RequestRoleViewCheckbox">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:minHeight">40dp</item>
        <item name="android:minHeight">?android:listPreferredItemHeightSmall</item>
        <item name="android:paddingStart">16dp</item>
        <item name="android:textAppearance">@style/android:TextAppearance.Material.Subhead</item>
    </style>
+22 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.packageinstaller.role.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Checkable;
import android.widget.LinearLayout;

@@ -71,6 +73,7 @@ public class CheckableLinearLayout extends LinearLayout implements Checkable {

        mChecked = checked;
        refreshDrawableState();
        updateChildrenChecked();
    }

    @Override
@@ -87,4 +90,23 @@ public class CheckableLinearLayout extends LinearLayout implements Checkable {
        }
        return state;
    }

    private void updateChildrenChecked() {
        updateChildrenChecked(this, mChecked);
    }

    // We call setChecked() on checkable children so that accessibility can get the correct state.
    private static void updateChildrenChecked(@NonNull ViewGroup viewGroup, boolean checked) {
        int count = viewGroup.getChildCount();
        for (int i = 0; i < count; i++) {
            View child = viewGroup.getChildAt(i);
            if (child.isDuplicateParentStateEnabled()) {
                if (child instanceof Checkable) {
                    ((Checkable) child).setChecked(checked);
                } else if (child instanceof ViewGroup) {
                    updateChildrenChecked((ViewGroup) child, checked);
                }
            }
        }
    }
}