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

Commit b4b16923 authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Add better a11y support in QS

* Add ACTION_PAGE_LEFT/RIGHT to PagedTileLayout and proper focus after
  changing pages.
* Add CollectionInfo to TileLayout and CollectionItemInfo to
  QSTileViewImpl to indicate the position of the currently focused tile.
* Properly use ACTION_COLLAPSE/EXPAND in QSPanel/QuickQSPanel so the
  proper announcement is made, as well as the proper action is provided
  in the contextual menu.

Test: manual
Test: atest com.android.systemui.qs
Bug: 204726862
Change-Id: I9bb085002c99e75ab0bb91f287ded62793b932bb
parent 924b02bb
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
package com.android.systemui.plugins.qs;

import android.view.View;
import android.view.View.OnClickListener;

import com.android.systemui.plugins.FragmentBase;
import com.android.systemui.plugins.annotations.DependsOn;
@@ -34,7 +33,7 @@ public interface QS extends FragmentBase {

    String ACTION = "com.android.systemui.action.PLUGIN_QS";

    int VERSION = 13;
    int VERSION = 14;

    String TAG = "QS";

@@ -68,7 +67,12 @@ public interface QS extends FragmentBase {
    void setHeaderListening(boolean listening);
    void notifyCustomizeChanged();
    void setContainerController(QSContainerController controller);
    void setExpandClickListener(OnClickListener onClickListener);

    /**
     * Provide an action to collapse if expanded or expand if collapsed.
     * @param action
     */
    void setCollapseExpandAction(Runnable action);

    /**
     * Returns the height difference between the QSPanel container and the QuickQSPanel container
+4 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ import com.android.systemui.plugins.qs.QSTile.State;
@DependsOn(target = QSIconView.class)
@DependsOn(target = QSTile.class)
public abstract class QSTileView extends LinearLayout {
    public static final int VERSION = 2;
    public static final int VERSION = 3;

    public QSTileView(Context context) {
        super(context);
@@ -71,4 +71,7 @@ public abstract class QSTileView extends LinearLayout {
    public View getSecondaryLabel() {
        return null;
    }

    /** Sets the index of this tile in its layout */
    public abstract void setPosition(int position);
}
+6 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@
    android:orientation="vertical"
    android:layout_marginStart="@dimen/qs_label_container_margin"
    android:layout_marginEnd="0dp"
    android:focusable="false"
    android:importantForAccessibility="no"
    android:layout_gravity="center_vertical | start">

    <com.android.systemui.util.SafeMarqueeTextView
@@ -35,6 +37,8 @@
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="1"
        android:singleLine="true"
        android:focusable="false"
        android:importantForAccessibility="no"
        android:textAppearance="@style/TextAppearance.QS.TileLabel"/>

    <com.android.systemui.util.SafeMarqueeTextView
@@ -47,6 +51,8 @@
        android:marqueeRepeatLimit="1"
        android:singleLine="true"
        android:visibility="gone"
        android:focusable="false"
        android:importantForAccessibility="no"
        android:textAppearance="@style/TextAppearance.QS.TileLabel.Secondary"
        android:textColor="?android:attr/textColorSecondary"/>

+46 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.animation.Interpolator;
import android.view.animation.OvershootInterpolator;
import android.widget.Scroller;
@@ -552,6 +553,51 @@ public class PagedTileLayout extends ViewPager implements QSTileLayout {
        postInvalidateOnAnimation();
    }

    private int sanitizePageAction(int action) {
        int pageLeftId = AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_LEFT.getId();
        int pageRightId = AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_RIGHT.getId();
        if (action == pageLeftId || action == pageRightId) {
            if (!isLayoutRtl()) {
                if (action == pageLeftId) {
                    return AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD;
                } else {
                    return AccessibilityNodeInfo.ACTION_SCROLL_FORWARD;
                }
            } else {
                if (action == pageLeftId) {
                    return AccessibilityNodeInfo.ACTION_SCROLL_FORWARD;
                } else {
                    return AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD;
                }
            }
        }
        return action;
    }

    @Override
    public boolean performAccessibilityAction(int action, Bundle arguments) {
        action = sanitizePageAction(action);
        boolean performed = super.performAccessibilityAction(action, arguments);
        if (performed && (action == AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD
                || action == AccessibilityNodeInfo.ACTION_SCROLL_FORWARD)) {
            requestAccessibilityFocus();
        }
        return performed;
    }

    @Override
    public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfoInternal(info);
        // getCurrentItem does not respect RTL, so it works well together with page actions that
        // use left/right positioning.
        if (getCurrentItem() != 0) {
            info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_LEFT);
        }
        if (getCurrentItem() != mPages.size() - 1) {
            info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_PAGE_RIGHT);
        }
    }

    private static Animator setupBounceAnimator(View view, int ordinal) {
        view.setAlpha(0f);
        view.setScaleX(0f);
+0 −5
Original line number Diff line number Diff line
@@ -48,10 +48,5 @@ public interface QSFooter {
     */
    void setKeyguardShowing(boolean keyguardShowing);

    /**
     * Sets the {@link android.view.View.OnClickListener to be used on elements that expend QS.
     */
    void setExpandClickListener(View.OnClickListener onClickListener);

    default void disable(int state1, int state2, boolean animate) {}
}
Loading