Merge "Updating the card size logic" into ub-launcher3-master
diff --git a/proguard.flags b/proguard.flags
index 086337d..e9f6db4 100644
--- a/proguard.flags
+++ b/proguard.flags
@@ -107,6 +107,11 @@
public <init>(...);
}
+# MainProcessInitializer
+-keep class com.android.quickstep.QuickstepProcessInitializer {
+ public <init>(...);
+}
+
-keep interface com.android.launcher3.userevent.nano.LauncherLogProto.** {
*;
}
diff --git a/quickstep/libs/sysui_shared.jar b/quickstep/libs/sysui_shared.jar
index b75a193..cebeea2 100644
--- a/quickstep/libs/sysui_shared.jar
+++ b/quickstep/libs/sysui_shared.jar
Binary files differ
diff --git a/quickstep/res/values/override.xml b/quickstep/res/values/override.xml
index 2bd9f8f..d683659 100644
--- a/quickstep/res/values/override.xml
+++ b/quickstep/res/values/override.xml
@@ -18,5 +18,7 @@
<string name="app_transition_manager_class" translatable="false">com.android.launcher3.LauncherAppTransitionManagerImpl</string>
<string name="instant_app_resolver_class" translatable="false">com.android.quickstep.InstantAppResolverImpl</string>
+
+ <string name="main_process_initializer_class" translatable="false">com.android.quickstep.QuickstepProcessInitializer</string>
</resources>
diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
index a2567c8..ad0b734 100644
--- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
@@ -363,6 +363,7 @@
t.show(target.leash);
}
}
+ t.setEarlyWakeup();
t.apply();
matrix.reset();
@@ -636,6 +637,7 @@
t.show(target.leash);
}
}
+ t.setEarlyWakeup();
t.apply();
matrix.reset();
@@ -763,6 +765,7 @@
t.show(app.leash);
}
}
+ t.setEarlyWakeup();
t.apply();
matrix.reset();
diff --git a/quickstep/src/com/android/launcher3/uioverrides/LandscapeStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/LandscapeStatesTouchController.java
index 355b88d..30ceb43 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/LandscapeStatesTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/LandscapeStatesTouchController.java
@@ -60,12 +60,13 @@
@Override
protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) {
- if (fromState == ALL_APPS) {
+ if (fromState == ALL_APPS && !isDragTowardPositive) {
// Should swipe down go to OVERVIEW instead?
return TouchInteractionService.isConnected() ?
mLauncher.getStateManager().getLastState() : NORMAL;
- } else {
+ } else if (isDragTowardPositive) {
return ALL_APPS;
}
+ return fromState;
}
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
index 1b65ca0..012b545 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
@@ -37,6 +37,7 @@
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.touch.AbstractStateChangeTouchController;
import com.android.launcher3.touch.SwipeDetector;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.quickstep.TouchInteractionService;
import com.android.quickstep.util.SysuiEventLogger;
@@ -140,7 +141,7 @@
@Override
protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) {
- if (fromState == ALL_APPS) {
+ if (fromState == ALL_APPS && !isDragTowardPositive) {
// Should swipe down go to OVERVIEW instead?
return TouchInteractionService.isConnected() ?
mLauncher.getStateManager().getLastState() : NORMAL;
@@ -182,7 +183,7 @@
}
if (mPendingAnimation != null) {
- mPendingAnimation.finish(false);
+ mPendingAnimation.finish(false, Touch.SWIPE);
mPendingAnimation = null;
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java
index e73b219..84a60bd 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/TaskViewTouchController.java
@@ -30,11 +30,10 @@
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.touch.SwipeDetector;
-import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
+import com.android.launcher3.util.PendingAnimation;
import com.android.launcher3.util.TouchController;
import com.android.launcher3.views.BaseDragLayer;
-import com.android.launcher3.util.PendingAnimation;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
@@ -152,7 +151,7 @@
mCurrentAnimation.setPlayFraction(0);
}
if (mPendingAnimation != null) {
- mPendingAnimation.finish(false);
+ mPendingAnimation.finish(false, Touch.SWIPE);
mPendingAnimation = null;
}
@@ -249,15 +248,9 @@
private void onCurrentAnimationEnd(boolean wasSuccess, int logAction) {
if (mPendingAnimation != null) {
- mPendingAnimation.finish(wasSuccess);
+ mPendingAnimation.finish(wasSuccess, logAction);
mPendingAnimation = null;
}
- if (wasSuccess) {
- if (!mCurrentAnimationIsGoingUp) {
- mActivity.getUserEventDispatcher().logTaskLaunch(logAction,
- Direction.DOWN, mTaskBeingDragged.getTask().getTopComponent());
- }
- }
mDetector.finishedScrolling();
mTaskBeingDragged = null;
mCurrentAnimation = null;
diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
index 2fb4127..d76c49a 100644
--- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
+++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
@@ -15,7 +15,6 @@
*/
package com.android.quickstep;
-import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;
@@ -35,11 +34,8 @@
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseDraggingActivity;
-import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherAppState;
import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.anim.AnimatorPlaybackController;
-import com.android.launcher3.states.InternalStateHandler;
import com.android.quickstep.ActivityControlHelper.ActivityInitListener;
import com.android.quickstep.ActivityControlHelper.FallbackActivityControllerHelper;
import com.android.quickstep.ActivityControlHelper.LauncherActivityControllerHelper;
@@ -54,7 +50,7 @@
* Helper class to handle various atomic commands for switching between Overview.
*/
@TargetApi(Build.VERSION_CODES.P)
-public class OverviewCommandHelper extends InternalStateHandler {
+public class OverviewCommandHelper {
private static final long RECENTS_LAUNCH_DURATION = 200;
@@ -95,55 +91,18 @@
homeIntent.setComponent(launcher).setPackage(null);
}
- private void openRecents() {
- Intent intent = addToIntent(new Intent(homeIntent));
- mContext.startActivity(intent);
- initWhenReady();
- }
-
public void onOverviewToggle() {
// If currently screen pinning, do not enter overview
- if (ActivityManagerWrapper.getInstance().isScreenPinningActive()) {
+ if (mAM.isScreenPinningActive()) {
return;
}
- ActivityManagerWrapper.getInstance().closeSystemWindows("recentapps");
+ mAM.closeSystemWindows("recentapps");
mMainThreadExecutor.execute(new RecentsActivityCommand<>());
}
public void onOverviewShown() {
- getLauncher().runOnUiThread(() -> {
- if (isOverviewAlmostVisible()) {
- final RecentsView rv = getLauncher().getOverviewPanel();
- rv.snapToTaskAfterNext();
- } else {
- openRecents();
- }
- }
- );
- }
-
- private boolean isOverviewAlmostVisible() {
- if (clearReference()) {
- return true;
- }
- if (!mAM.getRunningTask().topActivity.equals(launcher)) {
- return false;
- }
- Launcher launcher = getLauncher();
- return launcher != null && launcher.isStarted() && launcher.isInState(OVERVIEW);
- }
-
- private Launcher getLauncher() {
- return (Launcher) LauncherAppState.getInstance(mContext).getModel().getCallback();
- }
-
- @Override
- protected boolean init(Launcher launcher, boolean alreadyOnHome) {
- AbstractFloatingView.closeAllOpenViews(launcher, alreadyOnHome);
- launcher.getStateManager().goToState(OVERVIEW, alreadyOnHome);
- clearReference();
- return false;
+ mMainThreadExecutor.execute(new ShowRecentsCommand());
}
public ActivityControlHelper getActivityControlHelper() {
@@ -154,9 +113,23 @@
}
}
+ private class ShowRecentsCommand extends RecentsActivityCommand {
+
+ @Override
+ protected boolean handleCommand(long elapsedTime) {
+ RecentsView recents = mHelper.getVisibleRecentsView();
+ if (recents != null) {
+ recents.snapToTaskAfterNext();
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+
private class RecentsActivityCommand<T extends BaseDraggingActivity> implements Runnable {
- private final ActivityControlHelper<T> mHelper;
+ protected final ActivityControlHelper<T> mHelper;
private final long mCreateTime;
private final int mRunningTaskId;
@@ -166,7 +139,7 @@
public RecentsActivityCommand() {
mHelper = getActivityControlHelper();
mCreateTime = SystemClock.elapsedRealtime();
- mRunningTaskId = ActivityManagerWrapper.getInstance().getRunningTask().id;
+ mRunningTaskId = mAM.getRunningTask().id;
// Preload the plan
mRecentsModel.loadTasks(mRunningTaskId, null);
@@ -177,20 +150,7 @@
long elapsedTime = mCreateTime - mLastToggleTime;
mLastToggleTime = mCreateTime;
- // TODO: We need to fix this case with PIP, when an activity first enters PIP, it shows
- // the menu activity which takes window focus, preventing the right condition from
- // being run below
- RecentsView recents = mHelper.getVisibleRecentsView();
- if (recents != null) {
- // Launch the next task
- recents.showNextTask();
- } else {
- if (elapsedTime < ViewConfiguration.getDoubleTapTimeout()) {
- // The user tried to launch back into overview too quickly, either after
- // launching an app, or before overview has actually shown, just ignore for now
- return;
- }
-
+ if (!handleCommand(elapsedTime)) {
// Start overview
if (mHelper.switchToRecentsIfVisible()) {
SysuiEventLogger.writeDummyRecentsTransition(0);
@@ -203,6 +163,23 @@
}
}
+ protected boolean handleCommand(long elapsedTime) {
+ // TODO: We need to fix this case with PIP, when an activity first enters PIP, it shows
+ // the menu activity which takes window focus, preventing the right condition from
+ // being run below
+ RecentsView recents = mHelper.getVisibleRecentsView();
+ if (recents != null) {
+ // Launch the next task
+ recents.showNextTask();
+ return true;
+ } else if (elapsedTime < ViewConfiguration.getDoubleTapTimeout()) {
+ // The user tried to launch back into overview too quickly, either after
+ // launching an app, or before overview has actually shown, just ignore for now
+ return true;
+ }
+ return false;
+ }
+
private boolean onActivityReady(T activity, Boolean wasVisible) {
activity.<RecentsView>getOverviewPanel().setCurrentTask(mRunningTaskId);
AbstractFloatingView.closeAllOpenViews(activity, wasVisible);
diff --git a/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java
new file mode 100644
index 0000000..aed9959
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.quickstep;
+
+import android.content.Context;
+
+import com.android.launcher3.MainProcessInitializer;
+import com.android.systemui.shared.system.ThreadedRendererCompat;
+
+public class QuickstepProcessInitializer extends MainProcessInitializer {
+
+ public QuickstepProcessInitializer(Context context) { }
+
+ @Override
+ protected void init(Context context) {
+ super.init(context);
+
+ // Elevate GPU priority for Quickstep and Remote animations.
+ ThreadedRendererCompat.setContextPriority(ThreadedRendererCompat.EGL_CONTEXT_PRIORITY_HIGH_IMG);
+ }
+}
diff --git a/quickstep/src/com/android/quickstep/TaskUtils.java b/quickstep/src/com/android/quickstep/TaskUtils.java
index 2df951b..5bf1d07 100644
--- a/quickstep/src/com/android/quickstep/TaskUtils.java
+++ b/quickstep/src/com/android/quickstep/TaskUtils.java
@@ -24,6 +24,7 @@
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.compat.UserManagerCompat;
+import com.android.launcher3.util.ComponentKey;
import com.android.systemui.shared.recents.model.Task;
/**
@@ -48,4 +49,8 @@
return userManagerCompat.getBadgedLabelForUser(
applicationInfo.loadLabel(packageManager), user);
}
+
+ public static ComponentKey getComponentKeyForTask(Task.TaskKey taskKey) {
+ return new ComponentKey(taskKey.getComponent(), UserHandle.of(taskKey.userId));
+ }
}
diff --git a/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java b/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java
index 0f895b8..493e9e2 100644
--- a/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java
+++ b/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java
@@ -121,6 +121,7 @@
transaction.show(app.leash);
}
}
+ transaction.setEarlyWakeup();
transaction.apply();
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index c19f5dd..7e81ba9 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -60,12 +60,15 @@
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.PropertyListBuilder;
import com.android.launcher3.config.FeatureFlags;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
import com.android.launcher3.util.PendingAnimation;
import com.android.launcher3.util.Themes;
import com.android.quickstep.QuickScrubController;
import com.android.quickstep.RecentsAnimationInterpolator;
import com.android.quickstep.RecentsAnimationInterpolator.TaskWindowBounds;
import com.android.quickstep.RecentsModel;
+import com.android.quickstep.TaskUtils;
import com.android.systemui.shared.recents.model.RecentsTaskLoadPlan;
import com.android.systemui.shared.recents.model.RecentsTaskLoader;
import com.android.systemui.shared.recents.model.Task;
@@ -315,7 +318,7 @@
private void applyLoadPlan(RecentsTaskLoadPlan loadPlan) {
if (mPendingAnimation != null) {
- mPendingAnimation.addEndListener((b) -> applyLoadPlan(loadPlan));
+ mPendingAnimation.addEndListener((onEndListener) -> applyLoadPlan(loadPlan));
return;
}
TaskStack stack = loadPlan != null ? loadPlan.getTaskStack() : null;
@@ -696,10 +699,16 @@
}
mPendingAnimation = pendingAnimation;
- mPendingAnimation.addEndListener((isSuccess) -> {
- if (isSuccess) {
+ mPendingAnimation.addEndListener((onEndListener) -> {
+ if (onEndListener.isSuccess) {
if (removeTask) {
- ActivityManagerWrapper.getInstance().removeTask(taskView.getTask().key.id);
+ Task task = taskView.getTask();
+ if (task != null) {
+ ActivityManagerWrapper.getInstance().removeTask(task.key.id);
+ mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss(
+ onEndListener.logAction, Direction.UP,
+ TaskUtils.getComponentKeyForTask(task.key));
+ }
}
removeView(taskView);
if (getChildCount() == 0) {
@@ -741,7 +750,7 @@
AnimatorPlaybackController controller = AnimatorPlaybackController.wrap(
pendingAnim.anim, DISMISS_TASK_DURATION);
controller.dispatchOnStart();
- controller.setEndAction(() -> pendingAnim.finish(true));
+ controller.setEndAction(() -> pendingAnim.finish(true, Touch.SWIPE));
controller.getAnimationPlayer().setInterpolator(FAST_OUT_SLOW_IN);
controller.start();
}
@@ -780,11 +789,6 @@
snapToPageRelative(1);
}
- public void launchNextTask() {
- final TaskView nextTask = (TaskView) getChildAt(getNextPage());
- nextTask.launchTask(true);
- }
-
public void setContentAlpha(float alpha) {
if (mContentAlpha == alpha) {
return;
@@ -998,9 +1002,15 @@
anim.setDuration(duration);
mPendingAnimation = new PendingAnimation(anim);
- mPendingAnimation.addEndListener((isSuccess) -> {
- if (isSuccess) {
+ mPendingAnimation.addEndListener((onEndListener) -> {
+ if (onEndListener.isSuccess) {
tv.launchTask(false);
+ Task task = tv.getTask();
+ if (task != null) {
+ mActivity.getUserEventDispatcher().logTaskLaunchOrDismiss(
+ onEndListener.logAction, Direction.DOWN,
+ TaskUtils.getComponentKeyForTask(task.key));
+ }
} else {
resetTaskVisuals();
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index 42da472..f04acaf 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -31,11 +31,15 @@
import android.widget.FrameLayout;
import android.widget.ImageView;
+import com.android.launcher3.BaseActivity;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
import com.android.quickstep.RecentsAnimationInterpolator;
import com.android.quickstep.TaskSystemShortcut;
+import com.android.quickstep.TaskUtils;
import com.android.quickstep.views.RecentsView.PageCallbacks;
import com.android.quickstep.views.RecentsView.ScrollState;
import com.android.systemui.shared.recents.model.Task;
@@ -82,7 +86,13 @@
public TaskView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- setOnClickListener((view) -> launchTask(true /* animate */));
+ setOnClickListener((view) -> {
+ if (mTask != null) {
+ launchTask(true /* animate */);
+ BaseActivity.fromContext(context).getUserEventDispatcher().logTaskLaunchOrDismiss(
+ Touch.TAP, Direction.NONE, TaskUtils.getComponentKeyForTask(mTask.key));
+ }
+ });
setOutlineProvider(new TaskOutlineProvider(getResources()));
}
@@ -138,7 +148,10 @@
mSnapshotView.setThumbnail(task, thumbnailData);
mIconView.setImageDrawable(task.icon);
mIconView.setOnClickListener(icon -> TaskMenuView.showForTask(this));
- mIconView.setOnLongClickListener(icon -> TaskMenuView.showForTask(this));
+ mIconView.setOnLongClickListener(icon -> {
+ requestDisallowInterceptTouchEvent(true);
+ return TaskMenuView.showForTask(this);
+ });
}
@Override
diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java
index 90355bd..bf870cc 100644
--- a/src/com/android/launcher3/logging/UserEventDispatcher.java
+++ b/src/com/android/launcher3/logging/UserEventDispatcher.java
@@ -16,6 +16,14 @@
package com.android.launcher3.logging;
+import static com.android.launcher3.logging.LoggerUtils.newCommandAction;
+import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
+import static com.android.launcher3.logging.LoggerUtils.newDropTarget;
+import static com.android.launcher3.logging.LoggerUtils.newItemTarget;
+import static com.android.launcher3.logging.LoggerUtils.newLauncherEvent;
+import static com.android.launcher3.logging.LoggerUtils.newTarget;
+import static com.android.launcher3.logging.LoggerUtils.newTouchAction;
+
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
@@ -38,20 +46,13 @@
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.launcher3.userevent.nano.LauncherLogProto.LauncherEvent;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
+import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.InstantAppResolver;
import com.android.launcher3.util.LogConfig;
import java.util.Locale;
import java.util.UUID;
-import static com.android.launcher3.logging.LoggerUtils.newCommandAction;
-import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
-import static com.android.launcher3.logging.LoggerUtils.newDropTarget;
-import static com.android.launcher3.logging.LoggerUtils.newItemTarget;
-import static com.android.launcher3.logging.LoggerUtils.newLauncherEvent;
-import static com.android.launcher3.logging.LoggerUtils.newTarget;
-import static com.android.launcher3.logging.LoggerUtils.newTouchAction;
-
/**
* Manages the creation of {@link LauncherEvent}.
* To debug this class, execute following command before side loading a new apk.
@@ -162,14 +163,15 @@
dispatchUserEvent(event, intent);
}
- public void logTaskLaunch(int action, int direction, ComponentName componentName){
- LauncherEvent event = newLauncherEvent(newTouchAction(action), // TAP or SWIPE
+ public void logTaskLaunchOrDismiss(int action, int direction, ComponentKey componentKey) {
+ LauncherEvent event = newLauncherEvent(newTouchAction(action), // TAP or SWIPE or FLING
newTarget(Target.Type.ITEM));
if (action == Action.Touch.SWIPE || action == Action.Touch.FLING) {
+ // Direction DOWN means the task was launched, UP means it was dismissed.
event.action.dir = direction;
}
event.srcTarget[0].itemType = LauncherLogProto.ItemType.TASK;
- fillComponentInfo(event.srcTarget[0], componentName);
+ fillComponentInfo(event.srcTarget[0], componentKey.componentName);
dispatchUserEvent(event, null);
}
diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
index 9726704..f1195ed 100644
--- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
+++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
@@ -124,6 +124,10 @@
return mLauncher.getAllAppsController().getShiftRange();
}
+ /**
+ * Returns the state to go to from fromState given the drag direction. If there is no state in
+ * that direction, returns fromState.
+ */
protected abstract LauncherState getTargetState(LauncherState fromState,
boolean isDragTowardPositive);
@@ -246,24 +250,24 @@
}
protected void onSwipeInteractionCompleted(LauncherState targetState, int logAction) {
- if (targetState != mFromState) {
- // Transition complete. log the action
- mLauncher.getUserEventDispatcher().logStateChangeAction(logAction,
- getDirectionForLog(),
- mStartContainerType,
- mFromState.containerType,
- mToState.containerType,
- mLauncher.getWorkspace().getCurrentPage());
- }
clearState();
boolean shouldGoToTargetState = true;
if (mPendingAnimation != null) {
boolean reachedTarget = mToState == targetState;
- mPendingAnimation.finish(reachedTarget);
+ mPendingAnimation.finish(reachedTarget, logAction);
mPendingAnimation = null;
shouldGoToTargetState = !reachedTarget;
}
if (shouldGoToTargetState) {
+ if (targetState != mFromState) {
+ // Transition complete. log the action
+ mLauncher.getUserEventDispatcher().logStateChangeAction(logAction,
+ getDirectionForLog(),
+ mStartContainerType,
+ mFromState.containerType,
+ mToState.containerType,
+ mLauncher.getWorkspace().getCurrentPage());
+ }
mLauncher.getStateManager().goToState(targetState, false /* animated */);
}
}
diff --git a/src/com/android/launcher3/util/PendingAnimation.java b/src/com/android/launcher3/util/PendingAnimation.java
index 4116d56..617a38b 100644
--- a/src/com/android/launcher3/util/PendingAnimation.java
+++ b/src/com/android/launcher3/util/PendingAnimation.java
@@ -32,7 +32,7 @@
@TargetApi(Build.VERSION_CODES.O)
public class PendingAnimation {
- private final ArrayList<Consumer<Boolean>> mEndListeners = new ArrayList<>();
+ private final ArrayList<Consumer<OnEndListener>> mEndListeners = new ArrayList<>();
public final AnimatorSet anim;
@@ -40,14 +40,24 @@
this.anim = anim;
}
- public void finish(boolean isSuccess) {
- for (Consumer<Boolean> listeners : mEndListeners) {
- listeners.accept(isSuccess);
+ public void finish(boolean isSuccess, int logAction) {
+ for (Consumer<OnEndListener> listeners : mEndListeners) {
+ listeners.accept(new OnEndListener(isSuccess, logAction));
}
mEndListeners.clear();
}
- public void addEndListener(Consumer<Boolean> listener) {
+ public void addEndListener(Consumer<OnEndListener> listener) {
mEndListeners.add(listener);
}
+
+ public static class OnEndListener {
+ public boolean isSuccess;
+ public int logAction;
+
+ public OnEndListener(boolean isSuccess, int logAction) {
+ this.isSuccess = isSuccess;
+ this.logAction = logAction;
+ }
+ }
}
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java
index c97c3cc..d1cddc1 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsSwipeController.java
@@ -54,7 +54,12 @@
@Override
protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) {
- return fromState == ALL_APPS ? NORMAL : ALL_APPS;
+ if (fromState == NORMAL && isDragTowardPositive) {
+ return ALL_APPS;
+ } else if (fromState == ALL_APPS && !isDragTowardPositive) {
+ return NORMAL;
+ }
+ return fromState;
}
@Override