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

Commit 217b2e9c authored by Mady Mellor's avatar Mady Mellor
Browse files

Make bubbles slightly more accessible; provide actions

* Bubbles can be focused
* Accessibility actions added for:
   - dismissing stack
   - expanding stack
   - collapasing stack

There will be more work to do here with content descriptions and
individual bubble actions.

Bug: 123541035
Fixes: 126284597
Test: manual 1) turn on talkback and open local context menu while focusing
               a bubble; note that dismiss / expand are available
             => ensure expand and dismiss from this state do whats expected
             2) from expanded state open local context menu; note that
                dismiss / collapse are available
             => ensure collapse and dismiss from this state do whats expected
Change-Id: I259d34d3fa78ad07f55fc64767b72382d023c2ab
parent 475f8da0
Loading
Loading
Loading
Loading
+41 −2
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Bundle;
import android.service.notification.StatusBarNotification;
import android.util.Log;
import android.util.StatsLog;
@@ -36,6 +37,7 @@ import android.view.ViewOutlineProvider;
import android.view.ViewTreeObserver;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.FrameLayout;

import androidx.annotation.MainThread;
@@ -205,10 +207,15 @@ public class BubbleStackView extends FrameLayout {
                        .setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY));

        setClipChildren(false);

        setFocusable(true);
        mBubbleContainer.bringToFront();
    }

    @Override
    public void getBoundsOnScreen(Rect outRect, boolean clipToParent) {
        getBoundsOnScreen(outRect);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
@@ -227,6 +234,36 @@ public class BubbleStackView extends FrameLayout {
        }
    }

    @Override
    public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
        super.onInitializeAccessibilityNodeInfoInternal(info);
        info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_DISMISS);
        if (mIsExpanded) {
            info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_COLLAPSE);
        } else {
            info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_EXPAND);
        }
    }

    @Override
    public boolean performAccessibilityActionInternal(int action, Bundle arguments) {
        if (super.performAccessibilityActionInternal(action, arguments)) {
            return true;
        }
        switch (action) {
            case AccessibilityNodeInfo.ACTION_DISMISS:
                stackDismissed();
                return true;
            case AccessibilityNodeInfo.ACTION_COLLAPSE:
                collapseStack();
                return true;
            case AccessibilityNodeInfo.ACTION_EXPAND:
                expandStack();
                return true;
        }
        return false;
    }

    /**
     * Updates the visibility of the 'dot' indicating an update on the bubble.
     * @param key the {@link NotificationEntry#key} associated with the bubble.
@@ -719,7 +756,9 @@ public class BubbleStackView extends FrameLayout {
    @Override
    public void getBoundsOnScreen(Rect outRect) {
        if (!mIsExpanded) {
            if (mBubbleContainer.getChildCount() > 0) {
                mBubbleContainer.getChildAt(0).getBoundsOnScreen(outRect);
            }
        } else {
            mBubbleContainer.getBoundsOnScreen(outRect);
        }