diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java index 482bbdee1a..b263a4c963 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java +++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java @@ -42,7 +42,6 @@ import com.android.launcher3.LauncherStateManager; import com.android.launcher3.LauncherStateManager.StateHandler; import com.android.launcher3.QuickstepAppTransitionManagerImpl; import com.android.launcher3.Utilities; -import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dragndrop.DragLayer; import com.android.quickstep.OverviewInteractionState; import com.android.quickstep.RecentsModel; @@ -87,6 +86,9 @@ public class UiFactory extends RecentsUiFactory { } OverviewInteractionState.INSTANCE.get(launcher) .setBackButtonAlpha(shouldBackButtonBeHidden ? 0 : 1, true /* animate */); + if (launcher != null && launcher.getDragLayer() != null) { + launcher.getDragLayer().setDisallowBackGesture(shouldBackButtonBeHidden); + } } public static void onCreate(Launcher launcher) { diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java index 9f902ed1b4..6cc49de67a 100644 --- a/src/com/android/launcher3/dragndrop/DragLayer.java +++ b/src/com/android/launcher3/dragndrop/DragLayer.java @@ -24,10 +24,12 @@ import android.animation.AnimatorListenerAdapter; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; +import android.annotation.TargetApi; import android.content.Context; import android.content.res.Resources; import android.graphics.Canvas; import android.graphics.Rect; +import android.os.Build; import android.util.AttributeSet; import android.view.KeyEvent; import android.view.MotionEvent; @@ -43,6 +45,7 @@ import com.android.launcher3.DropTargetBar; import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.ShortcutAndWidgetContainer; +import com.android.launcher3.Utilities; import com.android.launcher3.Workspace; import com.android.launcher3.anim.Interpolators; import com.android.launcher3.folder.Folder; @@ -54,6 +57,8 @@ import com.android.launcher3.util.Thunk; import com.android.launcher3.views.BaseDragLayer; import java.util.ArrayList; +import java.util.Collections; +import java.util.List; /** * A ViewGroup that coordinates dragging across its descendants @@ -68,6 +73,9 @@ public class DragLayer extends BaseDragLayer { public static final int ANIMATION_END_DISAPPEAR = 0; public static final int ANIMATION_END_REMAIN_VISIBLE = 2; + private static final List SYSTEM_GESTURE_EXCLUSION_RECT = + Collections.singletonList(new Rect()); + @Thunk DragController mDragController; // Variables relating to animation of views after drop @@ -86,6 +94,8 @@ public class DragLayer extends BaseDragLayer { private final ViewGroupFocusHelper mFocusIndicatorHelper; private final WorkspaceAndHotseatScrim mScrim; + private boolean mDisallowBackGesture; + /** * Used to create a new DragLayer from XML. * @@ -552,6 +562,24 @@ public class DragLayer extends BaseDragLayer { 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() { return mScrim; } diff --git a/src/com/android/launcher3/views/RecyclerViewFastScroller.java b/src/com/android/launcher3/views/RecyclerViewFastScroller.java index 883cbeed9c..56538016df 100644 --- a/src/com/android/launcher3/views/RecyclerViewFastScroller.java +++ b/src/com/android/launcher3/views/RecyclerViewFastScroller.java @@ -24,6 +24,7 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; +import android.graphics.RectF; import android.util.AttributeSet; import android.util.Property; import android.view.MotionEvent; @@ -31,13 +32,16 @@ import android.view.View; import android.view.ViewConfiguration; import android.widget.TextView; +import androidx.recyclerview.widget.RecyclerView; + import com.android.launcher3.BaseRecyclerView; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.graphics.FastScrollThumbDrawable; import com.android.launcher3.util.Themes; -import androidx.recyclerview.widget.RecyclerView; +import java.util.Collections; +import java.util.List; /** * The track and scrollbar that shows when you scroll the list. @@ -65,6 +69,9 @@ public class RecyclerViewFastScroller extends View { private final static int SCROLL_BAR_VIS_DURATION = 150; private static final float FAST_SCROLL_OVERLAY_Y_OFFSET_FACTOR = 0.75f; + private static final List SYSTEM_GESTURE_EXCLUSION_RECT = + Collections.singletonList(new Rect()); + private final int mMinWidth; private final int mMaxWidth; private final int mThumbPadding; @@ -81,6 +88,8 @@ public class RecyclerViewFastScroller extends View { private final Paint mThumbPaint; protected final int mThumbHeight; + private final RectF mThumbBounds = new RectF(); + private final Point mThumbDrawOffset = new Point(); private final Paint mTrackPaint; @@ -292,15 +301,23 @@ public class RecyclerViewFastScroller extends View { } int saveCount = canvas.save(); canvas.translate(getWidth() / 2, mRv.getScrollBarTop()); + mThumbDrawOffset.set(getWidth() / 2, mRv.getScrollBarTop()); // Draw the track float halfW = mWidth / 2; canvas.drawRoundRect(-halfW, 0, halfW, mRv.getScrollbarTrackHeight(), mWidth, mWidth, mTrackPaint); canvas.translate(0, mThumbOffsetY); + mThumbDrawOffset.y += mThumbOffsetY; halfW += mThumbPadding; float r = getScrollThumbRadius(); - canvas.drawRoundRect(-halfW, 0, halfW, mThumbHeight, r, r, mThumbPaint); + mThumbBounds.set(-halfW, 0, halfW, mThumbHeight); + canvas.drawRoundRect(mThumbBounds, r, r, mThumbPaint); + if (Utilities.ATLEAST_Q) { + mThumbBounds.roundOut(SYSTEM_GESTURE_EXCLUSION_RECT.get(0)); + SYSTEM_GESTURE_EXCLUSION_RECT.get(0).offset(mThumbDrawOffset.x, mThumbDrawOffset.y); + setSystemGestureExclusionRects(SYSTEM_GESTURE_EXCLUSION_RECT); + } canvas.restoreToCount(saveCount); }