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

Commit 6ce4a30b authored by Yining Liu's avatar Yining Liu
Browse files

Improve accessibility for notification shelf on lock screen

We added the "Expand" action before to make it clear that the user can
expand the Shelf. But the action didn't have any affect at the time of
addition. This change links the action to the clicking action, which
expands the notification shade. Note that both click and expand actions
have the same effect, which is as intended.

Fix: 378385684
Flag: EXEMPT bugfix
Test: atest Manual, disable "Auto-select" for the Switch Access and
enable Switch Access, select the NotificationShelf on lockscreen. The
action "Expand" should expand the notification shade.

Change-Id: I5b020dbe7c4d79b24b869eb6209b4a59852ba323
parent 25c889de
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Rect;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.IndentingPrintWriter;
import android.util.MathUtils;
@@ -30,6 +31,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.view.animation.Interpolator;
import android.view.animation.PathInterpolator;

@@ -1014,12 +1016,24 @@ public class NotificationShelf extends ActivatableNotificationView {
    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfo(info);
        if (mInteractive) {
            // Add two accessibility actions that both performs expanding the notification shade
            info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_EXPAND);
            AccessibilityNodeInfo.AccessibilityAction unlock
                    = new AccessibilityNodeInfo.AccessibilityAction(

            AccessibilityAction seeAll = new AccessibilityAction(
                    AccessibilityNodeInfo.ACTION_CLICK,
                    getContext().getString(R.string.accessibility_overflow_action));
            info.addAction(unlock);
                    getContext().getString(R.string.accessibility_overflow_action)
            );
            info.addAction(seeAll);
        }
    }

    @Override
    public boolean performAccessibilityAction(int action, Bundle args) {
        // override ACTION_EXPAND with ACTION_CLICK
        if (action == AccessibilityNodeInfo.ACTION_EXPAND) {
            return super.performAccessibilityAction(AccessibilityNodeInfo.ACTION_CLICK, args);
        } else {
            return super.performAccessibilityAction(action, args);
        }
    }