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

Commit 185e51e8 authored by Matt Casey's avatar Matt Casey Committed by Automerger Merge Worker
Browse files

Merge "Ignore all input outside of clipboard UI" into tm-dev am: 15bb168f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17085683

Change-Id: I5a6661b06a09af4393afd1a3c11039b574ebebc4
parents 281c6861 15bb168f
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);
    }
}