summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2019-04-09 15:34:01 -0700
committerTony Wickham <twickham@google.com>2019-04-09 18:28:43 -0700
commit5dc60a0543da4e8c0dacd4de018c7382aa326274 (patch)
tree6e60ac541e575ae4ea7975280569abca929ff7d1 /src
parent9edc8eb756835c507226947c040845c356357283 (diff)
downloadandroid_packages_apps_Trebuchet-5dc60a0543da4e8c0dacd4de018c7382aa326274.tar.gz
android_packages_apps_Trebuchet-5dc60a0543da4e8c0dacd4de018c7382aa326274.tar.bz2
android_packages_apps_Trebuchet-5dc60a0543da4e8c0dacd4de018c7382aa326274.zip
Add some egregious back exclusion rects
- Don't allow back gesture at all whenever we hid back button before - Exclude RecyclerViewFastScroller thumb rect Bug: 129297464 Change-Id: I40a33697592b02619218c18d1b3def7c3c203f56
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/dragndrop/DragLayer.java28
-rw-r--r--src/com/android/launcher3/views/RecyclerViewFastScroller.java21
2 files changed, 47 insertions, 2 deletions
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index 9f902ed1b..6cc49de67 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<Launcher> {
public static final int ANIMATION_END_DISAPPEAR = 0;
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;
// Variables relating to animation of views after drop
@@ -86,6 +94,8 @@ public class DragLayer extends BaseDragLayer<Launcher> {
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<Launcher> {
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 883cbeed9..56538016d 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<Rect> 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);
}