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

Commit b3fa2787 authored by Svet Ganov's avatar Svet Ganov
Browse files

When accessibility on cannot click on a view covered by a HorizontalScrollView

In accessibility mode we send down and up events activate a view. We will later
switch to accessibility actions but for now as a bridge-gap we compute a point on
the screen where to click for activating the view. The heuristic we use has edge
cases such as a view that handles all touch events but does not have any listeners.
In this case we do not ignore the target view's area covered by a view that handles
all touch events. As a result we click on the wrong target. While we cannot solve
this generically, in the case of standard components such as HorizontalScrollView
we can.

bug:18612258

Change-Id: If8482aac0d0ea53c5c90367d099d1b8d3a4559ed
parent 54daab10
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -5938,9 +5938,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * layer.
     *
     * @param outRects List to which to add clickable areas.
     *
     * @hide
     */
    void addClickableRectsForAccessibility(List<RectF> outRects) {
        if (isClickable() || isLongClickable()) {
    public void addClickableRectsForAccessibility(List<RectF> outRects) {
        if (isClickable() || isLongClickable()
                || (mListenerInfo != null && mListenerInfo.mOnTouchListener != null)) {
            RectF bounds = new RectF();
            bounds.set(0, 0, getWidth(), getHeight());
            outRects.add(bounds);
+4 −1
Original line number Diff line number Diff line
@@ -880,8 +880,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
        return true;
    }

    /**
     * @hide
     */
    @Override
    void addClickableRectsForAccessibility(List<RectF> outRects) {
    public void addClickableRectsForAccessibility(List<RectF> outRects) {
        int sizeBefore = outRects.size();

        super.addClickableRectsForAccessibility(outRects);
+14 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcel;
@@ -761,6 +762,18 @@ public class HorizontalScrollView extends FrameLayout {
        awakenScrollBars();
    }

    /**
     * @hide
     */
    @Override
    public void addClickableRectsForAccessibility(List<RectF> outRects) {
        // This class always consumes touch events, therefore if it
        // covers a view we do not want to send a click over it.
        RectF bounds = new RectF();
        bounds.set(0, 0, getWidth(), getHeight());
        outRects.add(bounds);
    }

    @Override
    public boolean performAccessibilityAction(int action, Bundle arguments) {
        if (super.performAccessibilityAction(action, arguments)) {