summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/AbstractFloatingView.java38
-rw-r--r--src/com/android/launcher3/AppWidgetResizeFrame.java46
-rw-r--r--src/com/android/launcher3/Launcher.java33
-rw-r--r--src/com/android/launcher3/Workspace.java8
-rw-r--r--src/com/android/launcher3/dragndrop/DragLayer.java90
-rw-r--r--src/com/android/launcher3/folder/Folder.java49
-rw-r--r--src/com/android/launcher3/popup/PopupContainerWithArrow.java38
-rw-r--r--src/com/android/launcher3/widget/WidgetsBottomSheet.java34
8 files changed, 150 insertions, 186 deletions
diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java
index 597e93703..49968189b 100644
--- a/src/com/android/launcher3/AbstractFloatingView.java
+++ b/src/com/android/launcher3/AbstractFloatingView.java
@@ -25,6 +25,8 @@ import android.view.View;
import android.widget.LinearLayout;
import com.android.launcher3.dragndrop.DragLayer;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
+import com.android.launcher3.util.TouchController;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -32,18 +34,20 @@ import java.lang.annotation.RetentionPolicy;
/**
* Base class for a View which shows a floating UI on top of the launcher UI.
*/
-public abstract class AbstractFloatingView extends LinearLayout {
+public abstract class AbstractFloatingView extends LinearLayout implements TouchController {
@IntDef(flag = true, value = {
TYPE_FOLDER,
TYPE_POPUP_CONTAINER_WITH_ARROW,
- TYPE_WIDGETS_BOTTOM_SHEET
+ TYPE_WIDGETS_BOTTOM_SHEET,
+ TYPE_WIDGET_RESIZE_FRAME
})
@Retention(RetentionPolicy.SOURCE)
public @interface FloatingViewType {}
public static final int TYPE_FOLDER = 1 << 0;
public static final int TYPE_POPUP_CONTAINER_WITH_ARROW = 1 << 1;
public static final int TYPE_WIDGETS_BOTTOM_SHEET = 1 << 2;
+ public static final int TYPE_WIDGET_RESIZE_FRAME = 1 << 3;
protected boolean mIsOpen;
@@ -72,21 +76,7 @@ public abstract class AbstractFloatingView extends LinearLayout {
protected abstract void handleClose(boolean animate);
- /**
- * If the view is current handling keyboard, return the active target, null otherwise
- */
- public ExtendedEditText getActiveTextView() {
- return null;
- }
-
-
- /**
- * Any additional view (outside of this container) where touch should be allowed while this
- * view is visible.
- */
- public View getExtendedTouchView() {
- return null;
- }
+ public abstract void logActionCommand(int command);
public final boolean isOpen() {
return mIsOpen;
@@ -97,6 +87,16 @@ public abstract class AbstractFloatingView extends LinearLayout {
protected abstract boolean isOfType(@FloatingViewType int type);
+ public void onBackPressed() {
+ logActionCommand(Action.Command.BACK);
+ close(true);
+ }
+
+ @Override
+ public boolean onControllerTouchEvent(MotionEvent ev) {
+ return false;
+ }
+
protected static <T extends AbstractFloatingView> T getOpenView(
Launcher launcher, @FloatingViewType int type) {
DragLayer dragLayer = launcher.getDragLayer();
@@ -139,8 +139,6 @@ public abstract class AbstractFloatingView extends LinearLayout {
public static AbstractFloatingView getTopOpenView(Launcher launcher) {
return getOpenView(launcher, TYPE_FOLDER | TYPE_POPUP_CONTAINER_WITH_ARROW
- | TYPE_WIDGETS_BOTTOM_SHEET);
+ | TYPE_WIDGETS_BOTTOM_SHEET | TYPE_WIDGET_RESIZE_FRAME);
}
-
- public abstract int getLogContainerType();
}
diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java
index d0b1c3082..1e95333ff 100644
--- a/src/com/android/launcher3/AppWidgetResizeFrame.java
+++ b/src/com/android/launcher3/AppWidgetResizeFrame.java
@@ -14,15 +14,13 @@ import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
-import android.widget.FrameLayout;
+import android.view.ViewGroup;
import com.android.launcher3.accessibility.DragViewStateAnnouncer;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.util.FocusLogic;
-import com.android.launcher3.util.TouchController;
-public class AppWidgetResizeFrame extends FrameLayout
- implements View.OnKeyListener, TouchController {
+public class AppWidgetResizeFrame extends AbstractFloatingView implements View.OnKeyListener {
private static final int SNAP_DURATION = 150;
private static final float DIMMED_HANDLE_ALPHA = 0f;
private static final float RESIZE_THRESHOLD = 0.66f;
@@ -108,12 +106,28 @@ public class AppWidgetResizeFrame extends FrameLayout
protected void onFinishInflate() {
super.onFinishInflate();
+ ViewGroup content = (ViewGroup) getChildAt(0);
for (int i = 0; i < HANDLE_COUNT; i ++) {
- mDragHandles[i] = getChildAt(i);
+ mDragHandles[i] = content.getChildAt(i);
}
}
- public void setupForWidget(LauncherAppWidgetHostView widgetView, CellLayout cellLayout,
+ public static void showForWidget(LauncherAppWidgetHostView widget, CellLayout cellLayout) {
+ Launcher launcher = Launcher.getLauncher(cellLayout.getContext());
+ AbstractFloatingView.closeAllOpenViews(launcher);
+
+ DragLayer dl = launcher.getDragLayer();
+ AppWidgetResizeFrame frame = (AppWidgetResizeFrame) launcher.getLayoutInflater()
+ .inflate(R.layout.app_widget_resize_frame, dl, false);
+ frame.setupForWidget(widget, cellLayout, dl);
+ ((DragLayer.LayoutParams) frame.getLayoutParams()).customPosition = true;
+
+ dl.addView(frame);
+ frame.mIsOpen = true;
+ frame.snapToWidget(false);
+ }
+
+ private void setupForWidget(LauncherAppWidgetHostView widgetView, CellLayout cellLayout,
DragLayer dragLayer) {
mCellLayout = cellLayout;
mWidgetView = widgetView;
@@ -384,7 +398,7 @@ public class AppWidgetResizeFrame extends FrameLayout
out.bottom = out.top + height;
}
- public void snapToWidget(boolean animate) {
+ private void snapToWidget(boolean animate) {
getSnappedRectRelativeToDragLayer(sTmpRect);
int newWidth = sTmpRect.width();
int newHeight = sTmpRect.height();
@@ -448,7 +462,7 @@ public class AppWidgetResizeFrame extends FrameLayout
public boolean onKey(View v, int keyCode, KeyEvent event) {
// Clear the frame and give focus to the widget host view when a directional key is pressed.
if (FocusLogic.shouldConsume(keyCode)) {
- mDragLayer.clearResizeFrame();
+ close(false);
mWidgetView.requestFocus();
return true;
}
@@ -498,9 +512,25 @@ public class AppWidgetResizeFrame extends FrameLayout
if (ev.getAction() == MotionEvent.ACTION_DOWN && handleTouchDown(ev)) {
return true;
}
+ close(false);
return false;
}
+ @Override
+ protected void handleClose(boolean animate) {
+ mDragLayer.removeView(this);
+ }
+
+ @Override
+ public void logActionCommand(int command) {
+ // TODO: Log this case.
+ }
+
+ @Override
+ protected boolean isOfType(int type) {
+ return (type & TYPE_WIDGET_RESIZE_FRAME) != 0;
+ }
+
/**
* A mutable class for describing the range of two int values.
*/
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 3a8d260c4..4388eb4a0 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1091,9 +1091,6 @@ public class Launcher extends BaseActivity
// Close any open floating view
AbstractFloatingView.closeAllOpenViews(this);
- // Stop resizing any widgets
- mWorkspace.exitWidgetResizeMode();
-
// Show the overview mode if we are on the workspace
if (mState == State.WORKSPACE && !mWorkspace.isInOverviewMode() &&
!mWorkspace.isSwitchingState()) {
@@ -1411,8 +1408,6 @@ public class Launcher extends BaseActivity
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (Intent.ACTION_SCREEN_OFF.equals(action)) {
- mDragLayer.clearResizeFrame();
-
// Reset AllApps to its initial state only if we are not in the middle of
// processing a multi-step drop
if (mAppsView != null && mWidgetsView != null && mPendingRequestArgs == null) {
@@ -1574,17 +1569,9 @@ public class Launcher extends BaseActivity
// Note: There should be at most one log per method call. This is enforced implicitly
// by using if-else statements.
UserEventDispatcher ued = getUserEventDispatcher();
-
- // TODO: Log this case.
- mWorkspace.exitWidgetResizeMode();
-
AbstractFloatingView topOpenView = AbstractFloatingView.getTopOpenView(this);
- if (topOpenView instanceof PopupContainerWithArrow) {
- ued.logActionCommand(Action.Command.HOME_INTENT,
- topOpenView.getExtendedTouchView(), ContainerType.DEEPSHORTCUTS);
- } else if (topOpenView instanceof Folder) {
- ued.logActionCommand(Action.Command.HOME_INTENT,
- ((Folder) topOpenView).getFolderIcon(), ContainerType.FOLDER);
+ if (topOpenView != null) {
+ topOpenView.logActionCommand(Action.Command.HOME_INTENT);
} else if (alreadyOnHome) {
ued.logActionCommand(Action.Command.HOME_INTENT,
mWorkspace.getState().containerType, mWorkspace.getCurrentPage());
@@ -2062,18 +2049,7 @@ public class Launcher extends BaseActivity
UserEventDispatcher ued = getUserEventDispatcher();
AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(this);
if (topView != null) {
- if (topView.getActiveTextView() != null) {
- topView.getActiveTextView().dispatchBackKey();
- } else {
- if (topView instanceof PopupContainerWithArrow) {
- ued.logActionCommand(Action.Command.BACK,
- topView.getExtendedTouchView(), ContainerType.DEEPSHORTCUTS);
- } else if (topView instanceof Folder) {
- ued.logActionCommand(Action.Command.BACK,
- ((Folder) topView).getFolderIcon(), ContainerType.FOLDER);
- }
- topView.close(true);
- }
+ topView.onBackPressed();
} else if (isAppsViewVisible()) {
ued.logActionCommand(Action.Command.BACK, ContainerType.ALLAPPS);
showWorkspace(true);
@@ -2084,9 +2060,6 @@ public class Launcher extends BaseActivity
ued.logActionCommand(Action.Command.BACK, ContainerType.OVERVIEW);
showWorkspace(true);
} else {
- // TODO: Log this case.
- mWorkspace.exitWidgetResizeMode();
-
// Back button is a no-op here, but give at least some feedback for the button press
mWorkspace.showOutlinesTemporarily();
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index c82731ff8..74c96a310 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1593,11 +1593,6 @@ public class Workspace extends PagedView
mOutlineProvider = outlineProvider;
}
- public void exitWidgetResizeMode() {
- DragLayer dragLayer = mLauncher.getDragLayer();
- dragLayer.clearResizeFrame();
- }
-
public void onStartReordering() {
super.onStartReordering();
// Reordering handles its own animations, disable the automatic ones.
@@ -2237,8 +2232,7 @@ public class Workspace extends PagedView
mDelayedResizeRunnable = new Runnable() {
public void run() {
if (!isPageInTransition()) {
- DragLayer dragLayer = mLauncher.getDragLayer();
- dragLayer.addResizeFrame(hostView, cellLayout);
+ AppWidgetResizeFrame.showForWidget(hostView, cellLayout);
}
}
};
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index fde7995ce..60ce3c36a 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -24,13 +24,11 @@ import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
-import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.Region;
import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet;
import android.view.KeyEvent;
-import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@@ -42,13 +40,10 @@ import android.widget.FrameLayout;
import android.widget.TextView;
import com.android.launcher3.AbstractFloatingView;
-import com.android.launcher3.AppWidgetResizeFrame;
import com.android.launcher3.CellLayout;
import com.android.launcher3.DropTargetBar;
-import com.android.launcher3.ExtendedEditText;
import com.android.launcher3.InsettableFrameLayout;
import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherAppWidgetHostView;
import com.android.launcher3.PinchToOverviewListener;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutAndWidgetContainer;
@@ -59,11 +54,9 @@ import com.android.launcher3.dynamicui.WallpaperColorInfo;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
-import com.android.launcher3.logging.LoggerUtils;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.TouchController;
-import com.android.launcher3.widget.WidgetsBottomSheet;
import java.util.ArrayList;
@@ -81,10 +74,6 @@ public class DragLayer extends InsettableFrameLayout {
private Launcher mLauncher;
- // Variables relating to resizing widgets
- private final boolean mIsRtl;
- private AppWidgetResizeFrame mCurrentResizeFrame;
-
// Variables relating to animation of views after drop
private ValueAnimator mDropAnim = null;
private final TimeInterpolator mCubicEaseOutInterpolator = new DecelerateInterpolator(1.5f);
@@ -105,7 +94,6 @@ public class DragLayer extends InsettableFrameLayout {
private float mBackgroundAlpha = 0;
// Related to adjacent page hints
- private final Rect mScrollChildPosition = new Rect();
private final ViewGroupFocusHelper mFocusIndicatorHelper;
private final WallpaperColorInfo mWallpaperColorInfo;
@@ -129,7 +117,6 @@ public class DragLayer extends InsettableFrameLayout {
setMotionEventSplittingEnabled(false);
setChildrenDrawingOrderEnabled(true);
- mIsRtl = Utilities.isRtl(getResources());
mFocusIndicatorHelper = new ViewGroupFocusHelper(this);
mWallpaperColorInfo = WallpaperColorInfo.getInstance(getContext());
}
@@ -159,10 +146,6 @@ public class DragLayer extends InsettableFrameLayout {
? null : new PinchToOverviewListener(mLauncher);
}
- public boolean isEventOverPageIndicator(MotionEvent ev) {
- return isEventOverView(mLauncher.getWorkspace().getPageIndicator(), ev);
- }
-
public boolean isEventOverHotseat(MotionEvent ev) {
return isEventOverView(mLauncher.getHotseat(), ev);
}
@@ -180,36 +163,6 @@ public class DragLayer extends InsettableFrameLayout {
return mHitRect.contains((int) ev.getX(), (int) ev.getY());
}
- private boolean handleTouchDown(MotionEvent ev, boolean intercept) {
- AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mLauncher);
- if (topView != null && intercept) {
- ExtendedEditText textView = topView.getActiveTextView();
- if (textView != null) {
- if (!isEventOverView(textView, ev)) {
- textView.dispatchBackKey();
- return true;
- }
- } else if (!isEventOverView(topView, ev)) {
- if (isInAccessibleDrag()) {
- // Do not close the container if in drag and drop.
- if (!isEventOverDropTargetBar(ev)) {
- return true;
- }
- } else {
- mLauncher.getUserEventDispatcher().logActionTapOutside(
- LoggerUtils.newContainerTarget(topView.getLogContainerType()));
- topView.close(true);
-
- // We let touches on the original icon go through so that users can launch
- // the app with one tap if they don't find a shortcut they want.
- View extendedTouch = topView.getExtendedTouchView();
- return extendedTouch == null || !isEventOverView(extendedTouch, ev);
- }
- }
- }
- return false;
- }
-
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
int action = ev.getAction();
@@ -219,9 +172,6 @@ public class DragLayer extends InsettableFrameLayout {
// dray layer even if mAllAppsController is NOT the active controller.
// TODO: handle other input other than touch
mAllAppsController.cancelDiscoveryAnimation();
- if (handleTouchDown(ev, true)) {
- return true;
- }
} else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
if (mTouchCompleteListener != null) {
mTouchCompleteListener.onTouchComplete();
@@ -230,12 +180,10 @@ public class DragLayer extends InsettableFrameLayout {
}
mActiveController = null;
- if (mCurrentResizeFrame != null
- && mCurrentResizeFrame.onControllerInterceptTouchEvent(ev)) {
- mActiveController = mCurrentResizeFrame;
+ AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mLauncher);
+ if (topView != null && topView.onControllerInterceptTouchEvent(ev)) {
+ mActiveController = topView;
return true;
- } else {
- clearResizeFrame();
}
if (mDragController.onControllerInterceptTouchEvent(ev)) {
@@ -248,12 +196,6 @@ public class DragLayer extends InsettableFrameLayout {
return true;
}
- WidgetsBottomSheet widgetsBottomSheet = WidgetsBottomSheet.getOpen(mLauncher);
- if (widgetsBottomSheet != null && widgetsBottomSheet.onControllerInterceptTouchEvent(ev)) {
- mActiveController = widgetsBottomSheet;
- return true;
- }
-
if (mPinchListener != null && mPinchListener.onControllerInterceptTouchEvent(ev)) {
// Stop listening for scrolling etc. (onTouchEvent() handles the rest of the pinch.)
mActiveController = mPinchListener;
@@ -357,12 +299,7 @@ public class DragLayer extends InsettableFrameLayout {
@Override
public boolean onTouchEvent(MotionEvent ev) {
int action = ev.getAction();
-
- if (action == MotionEvent.ACTION_DOWN) {
- if (handleTouchDown(ev, false)) {
- return true;
- }
- } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
+ if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
if (mTouchCompleteListener != null) {
mTouchCompleteListener.onTouchComplete();
}
@@ -542,25 +479,6 @@ public class DragLayer extends InsettableFrameLayout {
}
}
- public void clearResizeFrame() {
- if (mCurrentResizeFrame != null) {
- removeView(mCurrentResizeFrame);
- mCurrentResizeFrame = null;
- }
- }
-
- public void addResizeFrame(LauncherAppWidgetHostView widget, CellLayout cellLayout) {
- clearResizeFrame();
-
- mCurrentResizeFrame = (AppWidgetResizeFrame) LayoutInflater.from(mLauncher)
- .inflate(R.layout.app_widget_resize_frame, this, false);
- mCurrentResizeFrame.setupForWidget(widget, cellLayout, this);
- ((LayoutParams) mCurrentResizeFrame.getLayoutParams()).customPosition = true;
-
- addView(mCurrentResizeFrame);
- mCurrentResizeFrame.snapToWidget(false);
- }
-
public void animateViewIntoPosition(DragView dragView, final int[] pos, float alpha,
float scaleX, float scaleY, int animationEndStyle, Runnable onFinishRunnable,
int duration) {
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index 64a2dabab..de4de36e8 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -32,6 +32,7 @@ import android.view.FocusFinder;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.MotionEvent;
import android.view.View;
import android.view.ViewDebug;
import android.view.accessibility.AccessibilityEvent;
@@ -66,6 +67,7 @@ import com.android.launcher3.dragndrop.DragController;
import com.android.launcher3.dragndrop.DragController.DragListener;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragOptions;
+import com.android.launcher3.logging.LoggerUtils;
import com.android.launcher3.pageindicators.PageIndicatorDots;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
@@ -368,11 +370,6 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC
return false;
}
- @Override
- public ExtendedEditText getActiveTextView() {
- return isEditingName() ? mFolderName : null;
- }
-
public FolderIcon getFolderIcon() {
return mFolderIcon;
}
@@ -1532,7 +1529,45 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC
}
@Override
- public int getLogContainerType() {
- return ContainerType.FOLDER;
+ public void logActionCommand(int command) {
+ mLauncher.getUserEventDispatcher().logActionCommand(
+ command, getFolderIcon(), ContainerType.FOLDER);
+ }
+
+ @Override
+ public void onBackPressed() {
+ if (isEditingName()) {
+ mFolderName.dispatchBackKey();
+ } else {
+ super.onBackPressed();
+ }
+ }
+
+ @Override
+ public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
+ if (ev.getAction() == MotionEvent.ACTION_DOWN) {
+ DragLayer dl = mLauncher.getDragLayer();
+
+ if (isEditingName()) {
+ if (!dl.isEventOverView(mFolderName, ev)) {
+ mFolderName.dispatchBackKey();
+ return true;
+ }
+ return false;
+ } else if (!dl.isEventOverView(this, ev)) {
+ if (mLauncher.getAccessibilityDelegate().isInAccessibleDrag()) {
+ // Do not close the container if in drag and drop.
+ if (!dl.isEventOverView(mLauncher.getDropTargetBar(), ev)) {
+ return true;
+ }
+ } else {
+ mLauncher.getUserEventDispatcher().logActionTapOutside(
+ LoggerUtils.newContainerTarget(ContainerType.FOLDER));
+ close(true);
+ return true;
+ }
+ }
+ }
+ return false;
}
}
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index 8441598cf..409e5aefd 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -16,6 +16,11 @@
package com.android.launcher3.popup;
+import static com.android.launcher3.popup.PopupPopulator.MAX_SHORTCUTS_IF_NOTIFICATIONS;
+import static com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
+import static com.android.launcher3.userevent.nano.LauncherLogProto.ItemType;
+import static com.android.launcher3.userevent.nano.LauncherLogProto.Target;
+
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
@@ -66,6 +71,7 @@ import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.graphics.IconPalette;
import com.android.launcher3.graphics.TriangleShape;
+import com.android.launcher3.logging.LoggerUtils;
import com.android.launcher3.notification.NotificationItemView;
import com.android.launcher3.notification.NotificationKeyData;
import com.android.launcher3.shortcuts.DeepShortcutManager;
@@ -81,11 +87,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import static com.android.launcher3.popup.PopupPopulator.MAX_SHORTCUTS_IF_NOTIFICATIONS;
-import static com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
-import static com.android.launcher3.userevent.nano.LauncherLogProto.ItemType;
-import static com.android.launcher3.userevent.nano.LauncherLogProto.Target;
-
/**
* A container for shortcuts to deep links within apps.
*/
@@ -593,11 +594,6 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
return arrowView;
}
- @Override
- public View getExtendedTouchView() {
- return mOriginalIcon;
- }
-
/**
* Determines when the deferred drag should be started.
*
@@ -950,7 +946,25 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
}
@Override
- public int getLogContainerType() {
- return ContainerType.DEEPSHORTCUTS;
+ public void logActionCommand(int command) {
+ mLauncher.getUserEventDispatcher().logActionCommand(
+ command, mOriginalIcon, ContainerType.DEEPSHORTCUTS);
+ }
+
+ @Override
+ public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
+ if (ev.getAction() == MotionEvent.ACTION_DOWN) {
+ DragLayer dl = mLauncher.getDragLayer();
+ if (!dl.isEventOverView(this, ev)) {
+ mLauncher.getUserEventDispatcher().logActionTapOutside(
+ LoggerUtils.newContainerTarget(ContainerType.DEEPSHORTCUTS));
+ close(true);
+
+ // We let touches on the original icon go through so that users can launch
+ // the app with one tap if they don't find a shortcut they want.
+ return mOriginalIcon == null || !dl.isEventOverView(mOriginalIcon, ev);
+ }
+ }
+ return false;
}
}
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 {
@@ -242,18 +241,6 @@ public class WidgetsBottomSheet extends AbstractFloatingView implements Insettab
}
@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.
int leftInset = insets.left - mInsets.left;
@@ -302,12 +289,27 @@ 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);
}
@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(