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

Commit 15bb168f authored by Matt Casey's avatar Matt Casey Committed by Android (Google) Code Review
Browse files

Merge "Ignore all input outside of clipboard UI" into tm-dev

parents 410e1b73 b4f55ed7
Loading
Loading
Loading
Loading
+29 −6
Original line number Diff line number Diff line
@@ -19,10 +19,12 @@ package com.android.systemui.clipboardoverlay;
import android.animation.Animator;
import android.content.Context;
import android.graphics.Rect;
import android.graphics.Region;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewTreeObserver;

import androidx.constraintlayout.widget.ConstraintLayout;

@@ -34,7 +36,8 @@ import java.util.function.Consumer;
/**
 * ConstraintLayout that is draggable when touched in a specific region
 */
public class DraggableConstraintLayout extends ConstraintLayout {
public class DraggableConstraintLayout extends ConstraintLayout
        implements ViewTreeObserver.OnComputeInternalInsetsListener {
    private final SwipeDismissHandler mSwipeDismissHandler;
    private final GestureDetector mSwipeDetector;
    private Consumer<Animator> mOnDismissInitiated;
@@ -95,11 +98,6 @@ public class DraggableConstraintLayout extends ConstraintLayout {
        mSwipeDetector.setIsLongpressEnabled(false);
    }

    @Override // View
    protected void onFinishInflate() {

    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
@@ -137,4 +135,29 @@ public class DraggableConstraintLayout extends ConstraintLayout {
    public void setOnInteractionCallback(Runnable callback) {
        mOnInteraction = callback;
    }

    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        getViewTreeObserver().addOnComputeInternalInsetsListener(this);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        getViewTreeObserver().removeOnComputeInternalInsetsListener(this);
    }

    @Override
    public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo inoutInfo) {
        // Only child views are touchable.
        Region r = new Region();
        Rect rect = new Rect();
        for (int i = 0; i < getChildCount(); i++) {
            getChildAt(i).getGlobalVisibleRect(rect);
            r.op(rect, Region.Op.UNION);
        }
        inoutInfo.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION);
        inoutInfo.touchableRegion.set(r);
    }
}