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

Commit 2b2d6f58 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Gesture exclusion for seekbar thumbs/edit handles" into qt-dev

parents 0c7bac87 8624121b
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -38,6 +38,11 @@ import android.view.accessibility.AccessibilityNodeInfo;
import android.view.inspector.InspectableProperty;

import com.android.internal.R;
import com.android.internal.util.Preconditions;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


/**
@@ -91,6 +96,10 @@ public abstract class AbsSeekBar extends ProgressBar {
    @UnsupportedAppUsage
    private boolean mIsDragging;

    private List<Rect> mUserGestureExclusionRects = Collections.emptyList();
    private final List<Rect> mGestureExclusionRects = new ArrayList<>();
    private final Rect mThumbRect = new Rect();

    public AbsSeekBar(Context context) {
        super(context);
    }
@@ -735,6 +744,27 @@ public abstract class AbsSeekBar extends ProgressBar {

        // Canvas will be translated, so 0,0 is where we start drawing
        thumb.setBounds(left, top, right, bottom);
        updateGestureExclusionRects();
    }

    @Override
    public void setSystemGestureExclusionRects(@NonNull List<Rect> rects) {
        Preconditions.checkNotNull(rects, "rects must not be null");
        mUserGestureExclusionRects = rects;
        updateGestureExclusionRects();
    }

    private void updateGestureExclusionRects() {
        final Drawable thumb = mThumb;
        if (thumb == null) {
            super.setSystemGestureExclusionRects(mUserGestureExclusionRects);
            return;
        }
        mGestureExclusionRects.clear();
        thumb.copyBounds(mThumbRect);
        mGestureExclusionRects.add(mThumbRect);
        mGestureExclusionRects.addAll(mUserGestureExclusionRects);
        super.setSystemGestureExclusionRects(mGestureExclusionRects);
    }

    /**
+7 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ import java.lang.annotation.RetentionPolicy;
import java.text.BreakIterator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
@@ -5097,6 +5098,12 @@ public class Editor {
        void onHandleMoved() {}

        public void onDetached() {}

        @Override
        protected void onSizeChanged(int w, int h, int oldw, int oldh) {
            super.onSizeChanged(w, h, oldw, oldh);
            setSystemGestureExclusionRects(Collections.singletonList(new Rect(0, 0, w, h)));
        }
    }

    private class InsertionHandleView extends HandleView {