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

Commit 23b0a4e9 authored by Casey Burkhardt's avatar Casey Burkhardt
Browse files

Properly populates AccessibilityEvents for notification and quick settings shades

Previously, our method of announcing the expansion of the notification shade
and quick notification shade relied on populating a contentDescription
attribute on the highest-level container.  This behavior is incorrect as it
causes accessibility services to infer importance and assign the view
accessibility focus.  This change adds descriptive text to the
AccessibilityEvent fired when the shade opens without modifying the
container's description.

Bug: 8699624
Change-Id: Id909b60d63cdec96c307dea2624b0651ab4f1f36
parent f6a2598f
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.util.EventLog;
import android.util.Slog;
import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;

import com.android.systemui.EventLogTags;
import com.android.systemui.R;
@@ -56,8 +57,6 @@ public class NotificationPanelView extends PanelView {
        mHandleBar = resources.getDrawable(R.drawable.status_bar_close);
        mHandleBarHeight = resources.getDimensionPixelSize(R.dimen.close_handle_height);
        mHandleView = findViewById(R.id.handle);

        setContentDescription(resources.getString(R.string.accessibility_desc_notification_shade));
    }

    @Override
@@ -71,6 +70,17 @@ public class NotificationPanelView extends PanelView {
        super.fling(vel, always);
    }

    @Override
    public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
        if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
            event.getText()
                    .add(getContext().getString(R.string.accessibility_desc_notification_shade));
            return true;
        }

        return super.dispatchPopulateAccessibilityEvent(event);
    }

    // We draw the handle ourselves so that it's always glued to the bottom of the window.
    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+13 −3
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;

import com.android.systemui.EventLogTags;
import com.android.systemui.R;
@@ -62,8 +63,6 @@ public class SettingsPanelView extends PanelView {
        mHandleBar = resources.getDrawable(R.drawable.status_bar_close);
        mHandleBarHeight = resources.getDimensionPixelSize(R.dimen.close_handle_height);
        mHandleView = findViewById(R.id.handle);

        setContentDescription(resources.getString(R.string.accessibility_desc_quick_settings));
    }

    public void setQuickSettings(QuickSettings qs) {
@@ -120,6 +119,17 @@ public class SettingsPanelView extends PanelView {
        }
    }

    @Override
    public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
        if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
            event.getText()
                    .add(getContext().getString(R.string.accessibility_desc_quick_settings));
            return true;
        }

        return super.dispatchPopulateAccessibilityEvent(event);
    }

    // We draw the handle ourselves so that it's always glued to the bottom of the window.
    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {