Updating the touch proxy logic:

In draglayer, we always dispatch touch events to child views. If the
touch originated from gesture area, when we dont route it through touch
controllers.
The proxy events are only send to touch controller. If any controller consumes
the event, then we cancel the view touch (pilferPointers)

This allows the controllers to work outside the dragView area, and prevents normal
view interaction when there is a window on top (like keyboard) while keeping our
activity focused

Bug: 131088901
Bug: 130618737
Change-Id: If033dde3a0f9cb6a6e449c9586c1fa050af5bdcb
This commit is contained in:
Sunny Goyal
2019-04-25 18:04:41 -07:00
parent efe8475093
commit bfaa9760dd
7 changed files with 153 additions and 184 deletions

View File

@@ -8,13 +8,10 @@ import android.app.ActivityManager;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Insets;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewDebug;
import android.view.WindowInsets;
@@ -31,9 +28,6 @@ public class LauncherRootView extends InsettableFrameLayout {
@ViewDebug.ExportedProperty(category = "launcher")
private final Rect mConsumedInsets = new Rect();
@ViewDebug.ExportedProperty(category = "launcher")
private final RectF mTouchExcludeRegion = new RectF();
@ViewDebug.ExportedProperty(category = "launcher")
private static final List<Rect> SYSTEM_GESTURE_EXCLUSION_RECT =
Collections.singletonList(new Rect());
@@ -164,29 +158,10 @@ public class LauncherRootView extends InsettableFrameLayout {
@Override
public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
if (Utilities.ATLEAST_Q) {
Insets gestureInsets = insets.getMandatorySystemGestureInsets();
mTouchExcludeRegion.set(gestureInsets.left, gestureInsets.top,
gestureInsets.right, gestureInsets.bottom);
}
mLauncher.getDragLayer().updateTouchExcludeRegion(insets);
return super.dispatchApplyWindowInsets(insets);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
float x = ev.getX();
float y = ev.getY();
if (y < mTouchExcludeRegion.top
|| x < mTouchExcludeRegion.left
|| x > (getWidth() - mTouchExcludeRegion.right)
|| y > (getHeight() - mTouchExcludeRegion.bottom)) {
return false;
}
}
return super.dispatchTouchEvent(ev);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);