Move system gesture exclusion rect to LauncherRootView
We translate DragLayer when going to -1, so the exclusion rect was off screen when you went back from there. Bug: 129297464 Change-Id: Ie079b2dadaca07886408ee9c1d130d7ac351a61d
This commit is contained in:
@@ -87,7 +87,7 @@ public class UiFactory extends RecentsUiFactory {
|
|||||||
OverviewInteractionState.INSTANCE.get(launcher)
|
OverviewInteractionState.INSTANCE.get(launcher)
|
||||||
.setBackButtonAlpha(shouldBackButtonBeHidden ? 0 : 1, true /* animate */);
|
.setBackButtonAlpha(shouldBackButtonBeHidden ? 0 : 1, true /* animate */);
|
||||||
if (launcher != null && launcher.getDragLayer() != null) {
|
if (launcher != null && launcher.getDragLayer() != null) {
|
||||||
launcher.getDragLayer().setDisallowBackGesture(shouldBackButtonBeHidden);
|
launcher.getRootView().setDisallowBackGesture(shouldBackButtonBeHidden);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,16 @@ import android.graphics.Insets;
|
|||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
|
import android.os.Build;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewDebug;
|
import android.view.ViewDebug;
|
||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class LauncherRootView extends InsettableFrameLayout {
|
public class LauncherRootView extends InsettableFrameLayout {
|
||||||
|
|
||||||
private final Launcher mLauncher;
|
private final Launcher mLauncher;
|
||||||
@@ -30,8 +34,14 @@ public class LauncherRootView extends InsettableFrameLayout {
|
|||||||
@ViewDebug.ExportedProperty(category = "launcher")
|
@ViewDebug.ExportedProperty(category = "launcher")
|
||||||
private final RectF mTouchExcludeRegion = new RectF();
|
private final RectF mTouchExcludeRegion = new RectF();
|
||||||
|
|
||||||
|
@ViewDebug.ExportedProperty(category = "launcher")
|
||||||
|
private static final List<Rect> SYSTEM_GESTURE_EXCLUSION_RECT =
|
||||||
|
Collections.singletonList(new Rect());
|
||||||
|
|
||||||
private View mAlignedView;
|
private View mAlignedView;
|
||||||
private WindowStateListener mWindowStateListener;
|
private WindowStateListener mWindowStateListener;
|
||||||
|
@ViewDebug.ExportedProperty(category = "launcher")
|
||||||
|
private boolean mDisallowBackGesture;
|
||||||
|
|
||||||
public LauncherRootView(Context context, AttributeSet attrs) {
|
public LauncherRootView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
@@ -177,6 +187,24 @@ public class LauncherRootView extends InsettableFrameLayout {
|
|||||||
return super.dispatchTouchEvent(ev);
|
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);
|
||||||
|
SYSTEM_GESTURE_EXCLUSION_RECT.get(0).set(l, t, r, b);
|
||||||
|
setDisallowBackGesture(mDisallowBackGesture);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.Q)
|
||||||
|
public void setDisallowBackGesture(boolean disallowBackGesture) {
|
||||||
|
if (!Utilities.ATLEAST_Q) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mDisallowBackGesture = disallowBackGesture;
|
||||||
|
setSystemGestureExclusionRects(mDisallowBackGesture
|
||||||
|
? SYSTEM_GESTURE_EXCLUSION_RECT
|
||||||
|
: Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
public interface WindowStateListener {
|
public interface WindowStateListener {
|
||||||
|
|
||||||
void onWindowFocusChanged(boolean hasFocus);
|
void onWindowFocusChanged(boolean hasFocus);
|
||||||
|
|||||||
@@ -24,12 +24,10 @@ import android.animation.AnimatorListenerAdapter;
|
|||||||
import android.animation.TimeInterpolator;
|
import android.animation.TimeInterpolator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.os.Build;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
@@ -45,7 +43,6 @@ import com.android.launcher3.DropTargetBar;
|
|||||||
import com.android.launcher3.Launcher;
|
import com.android.launcher3.Launcher;
|
||||||
import com.android.launcher3.R;
|
import com.android.launcher3.R;
|
||||||
import com.android.launcher3.ShortcutAndWidgetContainer;
|
import com.android.launcher3.ShortcutAndWidgetContainer;
|
||||||
import com.android.launcher3.Utilities;
|
|
||||||
import com.android.launcher3.Workspace;
|
import com.android.launcher3.Workspace;
|
||||||
import com.android.launcher3.anim.Interpolators;
|
import com.android.launcher3.anim.Interpolators;
|
||||||
import com.android.launcher3.folder.Folder;
|
import com.android.launcher3.folder.Folder;
|
||||||
@@ -57,8 +54,6 @@ import com.android.launcher3.util.Thunk;
|
|||||||
import com.android.launcher3.views.BaseDragLayer;
|
import com.android.launcher3.views.BaseDragLayer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ViewGroup that coordinates dragging across its descendants
|
* A ViewGroup that coordinates dragging across its descendants
|
||||||
@@ -73,9 +68,6 @@ public class DragLayer extends BaseDragLayer<Launcher> {
|
|||||||
public static final int ANIMATION_END_DISAPPEAR = 0;
|
public static final int ANIMATION_END_DISAPPEAR = 0;
|
||||||
public static final int ANIMATION_END_REMAIN_VISIBLE = 2;
|
public static final int ANIMATION_END_REMAIN_VISIBLE = 2;
|
||||||
|
|
||||||
private static final List<Rect> SYSTEM_GESTURE_EXCLUSION_RECT =
|
|
||||||
Collections.singletonList(new Rect());
|
|
||||||
|
|
||||||
@Thunk DragController mDragController;
|
@Thunk DragController mDragController;
|
||||||
|
|
||||||
// Variables relating to animation of views after drop
|
// Variables relating to animation of views after drop
|
||||||
@@ -94,8 +86,6 @@ public class DragLayer extends BaseDragLayer<Launcher> {
|
|||||||
private final ViewGroupFocusHelper mFocusIndicatorHelper;
|
private final ViewGroupFocusHelper mFocusIndicatorHelper;
|
||||||
private final WorkspaceAndHotseatScrim mScrim;
|
private final WorkspaceAndHotseatScrim mScrim;
|
||||||
|
|
||||||
private boolean mDisallowBackGesture;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to create a new DragLayer from XML.
|
* Used to create a new DragLayer from XML.
|
||||||
*
|
*
|
||||||
@@ -562,24 +552,6 @@ public class DragLayer extends BaseDragLayer<Launcher> {
|
|||||||
mScrim.onInsetsChanged(insets);
|
mScrim.onInsetsChanged(insets);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
||||||
super.onLayout(changed, l, t, r, b);
|
|
||||||
SYSTEM_GESTURE_EXCLUSION_RECT.get(0).set(l, t, r, b);
|
|
||||||
setDisallowBackGesture(mDisallowBackGesture);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.Q)
|
|
||||||
public void setDisallowBackGesture(boolean disallowBackGesture) {
|
|
||||||
if (!Utilities.ATLEAST_Q) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mDisallowBackGesture = disallowBackGesture;
|
|
||||||
setSystemGestureExclusionRects(mDisallowBackGesture
|
|
||||||
? SYSTEM_GESTURE_EXCLUSION_RECT
|
|
||||||
: Collections.emptyList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorkspaceAndHotseatScrim getScrim() {
|
public WorkspaceAndHotseatScrim getScrim() {
|
||||||
return mScrim;
|
return mScrim;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user