From 37920966888587900885c88a63785cb16567684c Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 28 Sep 2017 13:43:24 -0700 Subject: Allowing the widgetBottomSheet to be dragged even when the touch is started from outside the panel Removing various instanceOf checks in onNewIntent and onBackPress and moving all the corresponding logging in the FloatingView This simplifies handling of panel specific log and avoids missing a particular panel type in the if-else statement. Bug: 64751884 Bug: 64751923 Change-Id: I98f5aae18560a64be73c9efcf495479740d49a00 --- .../launcher3/widget/WidgetsBottomSheet.java | 34 ++++++++++++---------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src/com/android/launcher3/widget') diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java index 01101ac74..432efa75e 100644 --- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java +++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java @@ -40,24 +40,23 @@ import com.android.launcher3.LauncherAnimUtils; import com.android.launcher3.LauncherAppState; import com.android.launcher3.R; import com.android.launcher3.Utilities; -import com.android.launcher3.touch.SwipeDetector; import com.android.launcher3.anim.PropertyListBuilder; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragOptions; import com.android.launcher3.graphics.GradientView; import com.android.launcher3.model.WidgetItem; -import com.android.launcher3.userevent.nano.LauncherLogProto; +import com.android.launcher3.touch.SwipeDetector; +import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.util.SystemUiController; import com.android.launcher3.util.Themes; -import com.android.launcher3.util.TouchController; import java.util.List; /** * Bottom sheet for the "Widgets" system shortcut in the long-press popup. */ -public class WidgetsBottomSheet extends AbstractFloatingView implements Insettable, TouchController, +public class WidgetsBottomSheet extends AbstractFloatingView implements Insettable, SwipeDetector.Listener, View.OnClickListener, View.OnLongClickListener, DragController.DragListener { @@ -241,18 +240,6 @@ public class WidgetsBottomSheet extends AbstractFloatingView implements Insettab return (type & TYPE_WIDGETS_BOTTOM_SHEET) != 0; } - @Override - public int getLogContainerType() { - return LauncherLogProto.ContainerType.WIDGETS; // TODO: be more specific - } - - /** - * Returns a {@link WidgetsBottomSheet} which is already open or null - */ - public static WidgetsBottomSheet getOpen(Launcher launcher) { - return getOpenView(launcher, TYPE_WIDGETS_BOTTOM_SHEET); - } - @Override public void setInsets(Rect insets) { // Extend behind left, right, and bottom insets. @@ -301,6 +288,12 @@ public class WidgetsBottomSheet extends AbstractFloatingView implements Insettab } } + @Override + public void logActionCommand(int command) { + // TODO: be more specific + mLauncher.getUserEventDispatcher().logActionCommand(command, ContainerType.WIDGETS); + } + @Override public boolean onControllerTouchEvent(MotionEvent ev) { return mSwipeDetector.onTouchEvent(ev); @@ -308,6 +301,15 @@ public class WidgetsBottomSheet extends AbstractFloatingView implements Insettab @Override public boolean onControllerInterceptTouchEvent(MotionEvent ev) { + if (ev.getAction() == MotionEvent.ACTION_UP) { + // If we got ACTION_UP without ever returning true on intercept, + // the user never started dragging the bottom sheet. + if (!mLauncher.getDragLayer().isEventOverView(this, ev)) { + close(true); + return false; + } + } + int directionsToDetectScroll = mSwipeDetector.isIdleState() ? SwipeDetector.DIRECTION_NEGATIVE : 0; mSwipeDetector.setDetectableScrollConditions( -- cgit v1.2.3