Merge "Fix fallback recents not updating list from app" into ub-launcher3-qt-dev
diff --git a/Android.bp b/Android.bp
index 5acec37..b80282e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -24,6 +24,7 @@
srcs: [
"tests/tapl/**/*.java",
"src/com/android/launcher3/util/SecureSettingsObserver.java",
+ "src/com/android/launcher3/ResourceUtils.java",
"src/com/android/launcher3/TestProtocol.java",
],
manifest: "tests/tapl/AndroidManifest.xml",
diff --git a/go/quickstep/res/values-sw480dp/dimens.xml b/go/quickstep/res/values-sw480dp/dimens.xml
index b48dafb..571b8a1 100644
--- a/go/quickstep/res/values-sw480dp/dimens.xml
+++ b/go/quickstep/res/values-sw480dp/dimens.xml
@@ -18,13 +18,13 @@
<dimen name="recents_list_width">480dp</dimen>
<dimen name="task_item_height">90dp</dimen>
- <dimen name="task_item_top_margin">16dp</dimen>
- <dimen name="task_thumbnail_icon_horiz_margin">20dp</dimen>
+ <dimen name="task_item_top_margin">24dp</dimen>
+ <dimen name="task_thumbnail_icon_horiz_margin">24dp</dimen>
<dimen name="task_thumbnail_corner_radius">4dp</dimen>
- <dimen name="clear_all_item_view_height">48dp</dimen>
+ <dimen name="clear_all_item_view_height">52dp</dimen>
<dimen name="clear_all_item_view_top_margin">28dp</dimen>
<dimen name="clear_all_item_view_bottom_margin">28dp</dimen>
- <dimen name="clear_all_button_width">140dp</dimen>
+ <dimen name="clear_all_button_width">160dp</dimen>
</resources>
\ No newline at end of file
diff --git a/go/quickstep/src/com/android/launcher3/GoLauncherAppTransitionManagerImpl.java b/go/quickstep/src/com/android/launcher3/GoLauncherAppTransitionManagerImpl.java
index d189c50..bcb1f5c 100644
--- a/go/quickstep/src/com/android/launcher3/GoLauncherAppTransitionManagerImpl.java
+++ b/go/quickstep/src/com/android/launcher3/GoLauncherAppTransitionManagerImpl.java
@@ -1,16 +1,20 @@
package com.android.launcher3;
+import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
import static com.android.launcher3.anim.Interpolators.LINEAR;
+import static com.android.quickstep.TaskUtils.taskIsATargetWithMode;
import static com.android.quickstep.views.IconRecentsView.CONTENT_ALPHA;
+import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
-import android.app.ActivityOptions;
import android.content.Context;
+import android.os.Handler;
import android.view.View;
import com.android.quickstep.views.IconRecentsView;
+import com.android.systemui.shared.system.RemoteAnimationRunnerCompat;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
/**
@@ -29,6 +33,12 @@
}
@Override
+ RemoteAnimationRunnerCompat getWallpaperOpenRunner(boolean fromUnlock) {
+ return new GoWallpaperOpenLauncherAnimationRunner(mHandler,
+ false /* startAtFrontOfQueue */, fromUnlock);
+ }
+
+ @Override
protected void composeRecentsLaunchAnimator(AnimatorSet anim, View v,
RemoteAnimationTargetCompat[] targets, boolean launcherClosing) {
// Stubbed. Recents launch animation will come from the recents view itself and will not
@@ -51,4 +61,34 @@
return mLauncher.getStateManager()::reapplyState;
}
+
+ /**
+ * Remote animation runner for animation from app to Launcher. For Go, when going to recents,
+ * we need to ensure that the recents view is ready for remote animation before starting.
+ */
+ private final class GoWallpaperOpenLauncherAnimationRunner extends
+ WallpaperOpenLauncherAnimationRunner {
+ public GoWallpaperOpenLauncherAnimationRunner(Handler handler, boolean startAtFrontOfQueue,
+ boolean fromUnlock) {
+ super(handler, startAtFrontOfQueue, fromUnlock);
+ }
+
+ @Override
+ public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats,
+ AnimationResult result) {
+ boolean isGoingToRecents =
+ taskIsATargetWithMode(targetCompats, mLauncher.getTaskId(), MODE_OPENING)
+ && (mLauncher.getStateManager().getState() == LauncherState.OVERVIEW);
+ if (isGoingToRecents) {
+ IconRecentsView recentsView = mLauncher.getOverviewPanel();
+ if (!recentsView.isReadyForRemoteAnim()) {
+ recentsView.setOnReadyForRemoteAnimCallback(() ->
+ postAsyncCallback(mHandler, () -> onCreateAnimation(targetCompats, result))
+ );
+ return;
+ }
+ }
+ super.onCreateAnimation(targetCompats, result);
+ }
+ }
}
diff --git a/go/quickstep/src/com/android/quickstep/ContentFillItemAnimator.java b/go/quickstep/src/com/android/quickstep/ContentFillItemAnimator.java
index 9282345..87ae695 100644
--- a/go/quickstep/src/com/android/quickstep/ContentFillItemAnimator.java
+++ b/go/quickstep/src/com/android/quickstep/ContentFillItemAnimator.java
@@ -250,7 +250,7 @@
}
mPendingAnims.remove(i);
}
- for (int i = 0; i < mRunningAnims.size(); i++) {
+ for (int i = mRunningAnims.size() - 1; i >= 0; i--) {
ObjectAnimator anim = mRunningAnims.get(i);
anim.end();
}
diff --git a/go/quickstep/src/com/android/quickstep/RecentsActivity.java b/go/quickstep/src/com/android/quickstep/RecentsActivity.java
index 34315f3..7f813ce 100644
--- a/go/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/go/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -42,7 +42,7 @@
@Override
protected void reapplyUi() {
- //TODO: Implement this depending on how insets will affect the view.
+ // No-op. Insets are automatically re-applied in the root view.
}
@Override
diff --git a/go/quickstep/src/com/android/quickstep/fallback/GoRecentsActivityRootView.java b/go/quickstep/src/com/android/quickstep/fallback/GoRecentsActivityRootView.java
index c0ebcb5..b550011 100644
--- a/go/quickstep/src/com/android/quickstep/fallback/GoRecentsActivityRootView.java
+++ b/go/quickstep/src/com/android/quickstep/fallback/GoRecentsActivityRootView.java
@@ -16,7 +16,10 @@
package com.android.quickstep.fallback;
import android.content.Context;
+import android.graphics.Insets;
+import android.graphics.Rect;
import android.util.AttributeSet;
+import android.view.WindowInsets;
import com.android.launcher3.util.TouchController;
import com.android.launcher3.views.BaseDragLayer;
@@ -30,5 +33,23 @@
super(context, attrs, 1 /* alphaChannelCount */);
// Go leaves touch control to the view itself.
mControllers = new TouchController[0];
+ setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | SYSTEM_UI_FLAG_LAYOUT_STABLE);
+ }
+
+ @Override
+ public void setInsets(Rect insets) {
+ if (insets.equals(mInsets)) {
+ return;
+ }
+ super.setInsets(insets);
+ }
+
+ @Override
+ public WindowInsets onApplyWindowInsets(WindowInsets insets) {
+ Insets sysInsets = insets.getSystemWindowInsets();
+ setInsets(new Rect(sysInsets.left, sysInsets.top, sysInsets.right, sysInsets.bottom));
+ return insets.consumeSystemWindowInsets();
}
}
diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
index 7225e57..07faa4b 100644
--- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
+++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
@@ -379,6 +379,36 @@
}
/**
+ * Whether this view has processed all data changes and is ready to animate from the app to
+ * the overview.
+ *
+ * @return true if ready to animate app to overview, false otherwise
+ */
+ public boolean isReadyForRemoteAnim() {
+ return !mTaskRecyclerView.hasPendingAdapterUpdates();
+ }
+
+ /**
+ * Set a callback for whenever this view is ready to do a remote animation from the app to
+ * overview. See {@link #isReadyForRemoteAnim()}.
+ *
+ * @param callback callback to run when view is ready to animate
+ */
+ public void setOnReadyForRemoteAnimCallback(onReadyForRemoteAnimCallback callback) {
+ mTaskRecyclerView.getViewTreeObserver().addOnGlobalLayoutListener(
+ new ViewTreeObserver.OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ if (isReadyForRemoteAnim()) {
+ callback.onReadyForRemoteAnim();
+ mTaskRecyclerView.getViewTreeObserver().
+ removeOnGlobalLayoutListener(this);
+ }
+ }
+ });
+ }
+
+ /**
* Clear all tasks and animate out.
*/
private void animateClearAllTasks() {
@@ -557,4 +587,12 @@
mTaskRecyclerView.setPadding(insets.left, insets.top, insets.right, insets.bottom);
mTaskRecyclerView.invalidateItemDecorations();
}
+
+ /**
+ * Callback for when this view is ready for a remote animation from app to overview.
+ */
+ public interface onReadyForRemoteAnimCallback {
+
+ void onReadyForRemoteAnim();
+ }
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java
index 81090c1..3b664b7 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java
@@ -28,9 +28,13 @@
import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
import static com.android.launcher3.anim.Interpolators.INSTANT;
import static com.android.launcher3.anim.Interpolators.LINEAR;
+import static com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW;
+import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD;
import android.view.MotionEvent;
+import androidx.annotation.Nullable;
+
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager;
@@ -45,8 +49,6 @@
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
-import androidx.annotation.Nullable;
-
/**
* Handles quick switching to a recent task from the home screen.
*/
@@ -128,6 +130,10 @@
private void updateFullscreenProgress(float progress) {
if (mTaskToLaunch != null) {
mTaskToLaunch.setFullscreenProgress(progress);
+ int sysuiFlags = progress > UPDATE_SYSUI_FLAGS_THRESHOLD
+ ? mTaskToLaunch.getThumbnail().getSysUiStatusNavFlags()
+ : 0;
+ mLauncher.getSystemUiController().updateUiState(UI_STATE_OVERVIEW, sysuiFlags);
}
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
index 50f25fb..e932452 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
@@ -270,9 +270,9 @@
playScaleDownAnim(anim, activity, endState);
anim.setDuration(transitionLength * 2);
- activity.getStateManager().setCurrentAnimation(anim);
AnimatorPlaybackController controller =
AnimatorPlaybackController.wrap(anim, transitionLength * 2);
+ activity.getStateManager().setCurrentUserControlledAnimation(controller);
// Since we are changing the start position of the UI, reapply the state, at the end
controller.setEndAction(() -> {
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java
index 96d2dca..5eecf17 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/RecentsAnimationWrapper.java
@@ -24,6 +24,7 @@
import android.view.MotionEvent;
import com.android.launcher3.util.Preconditions;
+import com.android.quickstep.inputconsumers.InputConsumer;
import com.android.quickstep.util.SwipeAnimationTargetSet;
import com.android.systemui.shared.system.InputConsumerController;
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskSystemShortcut.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskSystemShortcut.java
index e3dcadc..2c919b3 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskSystemShortcut.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskSystemShortcut.java
@@ -16,6 +16,7 @@
package com.android.quickstep;
+import static android.view.Display.DEFAULT_DISPLAY;
import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.TAP;
import android.app.Activity;
@@ -116,21 +117,22 @@
mHandler = new Handler(Looper.getMainLooper());
}
- protected abstract boolean isAvailable(BaseDraggingActivity activity);
+ protected abstract boolean isAvailable(BaseDraggingActivity activity, int displayId);
protected abstract ActivityOptions makeLaunchOptions(Activity activity);
protected abstract boolean onActivityStarted(BaseDraggingActivity activity);
@Override
public View.OnClickListener getOnClickListener(
BaseDraggingActivity activity, TaskView taskView) {
- if (!isAvailable(activity)) {
- return null;
- }
final Task task = taskView.getTask();
final int taskId = task.key.id;
+ final int displayId = task.key.displayId;
if (!task.isDockable) {
return null;
}
+ if (!isAvailable(activity, displayId)) {
+ return null;
+ }
final RecentsView recentsView = activity.getOverviewPanel();
final TaskThumbnailView thumbnailView = taskView.getThumbnail();
@@ -218,9 +220,13 @@
}
@Override
- protected boolean isAvailable(BaseDraggingActivity activity) {
- // Don't show menu-item if already in multi-window
- return !activity.getDeviceProfile().isMultiWindowMode;
+ protected boolean isAvailable(BaseDraggingActivity activity, int displayId) {
+ // Don't show menu-item if already in multi-window and the task is from
+ // the secondary display.
+ // TODO(b/118266305): Temporarily disable splitscreen for secondary display while new
+ // implementation is enabled
+ return !activity.getDeviceProfile().isMultiWindowMode
+ && displayId == DEFAULT_DISPLAY;
}
@Override
@@ -256,7 +262,7 @@
}
@Override
- protected boolean isAvailable(BaseDraggingActivity activity) {
+ protected boolean isAvailable(BaseDraggingActivity activity, int displayId) {
return ActivityManagerWrapper.getInstance().supportsFreeformMultiWindow(activity);
}
@@ -290,10 +296,6 @@
if (sysUiProxy == null) {
return null;
}
- if (SysUINavigationMode.getMode(activity) == SysUINavigationMode.Mode.NO_BUTTON) {
- // TODO(b/130225926): Temporarily disable pinning while gesture nav is enabled
- return null;
- }
if (!ActivityManagerWrapper.getInstance().isScreenPinningEnabled()) {
return null;
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
index a343a36..128fd45 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
@@ -35,7 +35,6 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.RectF;
import android.graphics.Region;
@@ -58,6 +57,7 @@
import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.R;
+import com.android.launcher3.ResourceUtils;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.logging.EventLogArray;
@@ -66,6 +66,13 @@
import com.android.launcher3.util.UiThreadHelper;
import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener;
+import com.android.quickstep.inputconsumers.AccessibilityInputConsumer;
+import com.android.quickstep.inputconsumers.AssistantTouchConsumer;
+import com.android.quickstep.inputconsumers.DeviceLockedInputConsumer;
+import com.android.quickstep.inputconsumers.InputConsumer;
+import com.android.quickstep.inputconsumers.OtherActivityInputConsumer;
+import com.android.quickstep.inputconsumers.OverviewInputConsumer;
+import com.android.quickstep.inputconsumers.ScreenPinnedInputConsumer;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -90,9 +97,6 @@
public static final LooperExecutor BACKGROUND_EXECUTOR =
new LooperExecutor(UiThreadHelper.getBackgroundLooper());
- private static final String NAVBAR_VERTICAL_SIZE = "navigation_bar_frame_height";
- private static final String NAVBAR_HORIZONTAL_SIZE = "navigation_bar_width";
-
public static final EventLogArray TOUCH_INTERACTION_LOG =
new EventLogArray("touch_interaction_log", 40);
@@ -291,15 +295,7 @@
}
private int getNavbarSize(String resName) {
- int frameSize;
- Resources res = getResources();
- int frameSizeResID = res.getIdentifier(resName, "dimen", "android");
- if (frameSizeResID != 0) {
- frameSize = res.getDimensionPixelSize(frameSizeResID);
- } else {
- frameSize = Utilities.pxFromDp(48, res.getDisplayMetrics());
- }
- return frameSize;
+ return ResourceUtils.getNavbarSize(resName, getResources());
}
private void initTouchBounds() {
@@ -312,20 +308,21 @@
defaultDisplay.getRealSize(realSize);
mSwipeTouchRegion.set(0, 0, realSize.x, realSize.y);
if (mMode == Mode.NO_BUTTON) {
- mSwipeTouchRegion.top = mSwipeTouchRegion.bottom - getNavbarSize(NAVBAR_VERTICAL_SIZE);
+ mSwipeTouchRegion.top = mSwipeTouchRegion.bottom - getNavbarSize(
+ ResourceUtils.NAVBAR_VERTICAL_SIZE);
} else {
switch (defaultDisplay.getRotation()) {
case Surface.ROTATION_90:
mSwipeTouchRegion.left = mSwipeTouchRegion.right
- - getNavbarSize(NAVBAR_HORIZONTAL_SIZE);
+ - getNavbarSize(ResourceUtils.NAVBAR_HORIZONTAL_SIZE);
break;
case Surface.ROTATION_270:
mSwipeTouchRegion.right = mSwipeTouchRegion.left
- + getNavbarSize(NAVBAR_HORIZONTAL_SIZE);
+ + getNavbarSize(ResourceUtils.NAVBAR_HORIZONTAL_SIZE);
break;
default:
mSwipeTouchRegion.top = mSwipeTouchRegion.bottom
- - getNavbarSize(NAVBAR_VERTICAL_SIZE);
+ - getNavbarSize(ResourceUtils.NAVBAR_VERTICAL_SIZE);
}
}
}
@@ -470,6 +467,12 @@
mInputMonitorCompat);
}
+ if (ActivityManagerWrapper.getInstance().isScreenPinningActive()) {
+ // Note: we only allow accessibility to wrap this, and it replaces the previous
+ // base input consumer (which should be NO_OP anyway since topTaskLocked == true).
+ base = new ScreenPinnedInputConsumer(this, mISystemUiProxy, activityControl);
+ }
+
if ((mSystemUiStateFlags & SYSUI_STATE_A11Y_BUTTON_CLICKABLE) != 0) {
base = new AccessibilityInputConsumer(this, mISystemUiProxy,
(mSystemUiStateFlags & SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE) != 0, base,
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
index 936f0aa..49c95f1 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -27,6 +27,7 @@
import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;
import static com.android.launcher3.util.RaceConditionTracker.ENTER;
import static com.android.launcher3.util.RaceConditionTracker.EXIT;
+import static com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW;
import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION;
import static com.android.quickstep.ActivityControlHelper.AnimationFactory.ShelfAnimState.HIDE;
import static com.android.quickstep.ActivityControlHelper.AnimationFactory.ShelfAnimState.PEEK;
@@ -66,6 +67,7 @@
import android.view.animation.Interpolator;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import com.android.launcher3.AbstractFloatingView;
@@ -90,6 +92,8 @@
import com.android.quickstep.ActivityControlHelper.AnimationFactory.ShelfAnimState;
import com.android.quickstep.ActivityControlHelper.HomeAnimationFactory;
import com.android.quickstep.SysUINavigationMode.Mode;
+import com.android.quickstep.inputconsumers.InputConsumer;
+import com.android.quickstep.inputconsumers.OverviewInputConsumer;
import com.android.quickstep.util.ClipAnimationHelper;
import com.android.quickstep.util.RectFSpringAnim;
import com.android.quickstep.util.RemoteAnimationTargetSet;
@@ -165,7 +169,7 @@
private static final int LAUNCHER_UI_STATES =
STATE_LAUNCHER_PRESENT | STATE_LAUNCHER_DRAWN | STATE_LAUNCHER_STARTED;
- enum GestureEndTarget {
+ public enum GestureEndTarget {
HOME(1, STATE_SCALED_CONTROLLER_HOME, true, false, ContainerType.WORKSPACE, false),
RECENTS(1, STATE_SCALED_CONTROLLER_RECENTS | STATE_CAPTURE_SCREENSHOT
@@ -219,8 +223,8 @@
private final ClipAnimationHelper mClipAnimationHelper;
private final ClipAnimationHelper.TransformParams mTransformParams;
- protected Runnable mGestureEndCallback;
- protected GestureEndTarget mGestureEndTarget;
+ private Runnable mGestureEndCallback;
+ private GestureEndTarget mGestureEndTarget;
// Either RectFSpringAnim (if animating home) or ObjectAnimator (from mCurrentShift) otherwise
private RunningWindowAnim mRunningWindowAnim;
private boolean mIsShelfPeeking;
@@ -272,7 +276,7 @@
private final long mTouchTimeMs;
private long mLauncherFrameDrawnTime;
- WindowTransformSwipeHandler(RunningTaskInfo runningTaskInfo, Context context,
+ public WindowTransformSwipeHandler(RunningTaskInfo runningTaskInfo, Context context,
long touchTimeMs, ActivityControlHelper<T> controller, boolean continuingLastGesture,
InputConsumerController inputConsumer) {
mContext = context;
@@ -654,8 +658,7 @@
mTransformParams.setProgress(shift).setOffsetX(offsetX).setOffsetScale(offsetScale);
mClipAnimationHelper.applyTransform(mRecentsAnimationWrapper.targetSet,
mTransformParams);
- mRecentsAnimationWrapper.setWindowThresholdCrossed(
- shift > 1 - UPDATE_SYSUI_FLAGS_THRESHOLD);
+ updateSysUiFlags(shift);
}
if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
@@ -700,6 +703,18 @@
? 0 : (progress - mShiftAtGestureStart) / (1 - mShiftAtGestureStart));
}
+ private void updateSysUiFlags(float windowProgress) {
+ if (mRecentsView != null) {
+ // We will handle the sysui flags based on the centermost task view.
+ mRecentsAnimationWrapper.setWindowThresholdCrossed(true);
+ int sysuiFlags = windowProgress > 1 - UPDATE_SYSUI_FLAGS_THRESHOLD
+ ? 0
+ : mRecentsView.getTaskViewAt(mRecentsView.getPageNearestToCenterOfScreen())
+ .getThumbnail().getSysUiStatusNavFlags();
+ mActivity.getSystemUiController().updateUiState(UI_STATE_OVERVIEW, sysuiFlags);
+ }
+ }
+
@Override
public void onRecentsAnimationStart(SwipeAnimationTargetSet targetSet) {
DeviceProfile dp = InvariantDeviceProfile.INSTANCE.get(mContext).getDeviceProfile(mContext);
@@ -1091,6 +1106,7 @@
windowAlphaThreshold, mClipAnimationHelper.getCurrentCornerRadius(), false);
}
+ updateSysUiFlags(Math.max(progress, mCurrentShift.value));
});
anim.addAnimatorListener(new AnimationSuccessListener() {
@Override
@@ -1112,6 +1128,13 @@
return anim;
}
+ /**
+ * @return The GestureEndTarget if the gesture has ended, else null.
+ */
+ public @Nullable GestureEndTarget getGestureEndTarget() {
+ return mGestureEndTarget;
+ }
+
@UiThread
private void resumeLastTask() {
mRecentsAnimationWrapper.finish(false /* toRecents */, null);
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/AccessibilityInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AccessibilityInputConsumer.java
similarity index 98%
rename from quickstep/recents_ui_overrides/src/com/android/quickstep/AccessibilityInputConsumer.java
rename to quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AccessibilityInputConsumer.java
index 8f8cd18..f8475ca 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/AccessibilityInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AccessibilityInputConsumer.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.quickstep;
+package com.android.quickstep.inputconsumers;
import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_DOWN;
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/AssistantTouchConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java
similarity index 73%
rename from quickstep/recents_ui_overrides/src/com/android/quickstep/AssistantTouchConsumer.java
rename to quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java
index 829e478..0448fd1 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/AssistantTouchConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/AssistantTouchConsumer.java
@@ -14,16 +14,16 @@
* limitations under the License.
*/
-package com.android.quickstep;
+package com.android.quickstep.inputconsumers;
import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_MOVE;
import static android.view.MotionEvent.ACTION_POINTER_UP;
import static android.view.MotionEvent.ACTION_UP;
-
import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction.UPLEFT;
import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction.UPRIGHT;
+import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.FLING;
import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.SWIPE;
import static com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch.SWIPE_NOOP;
import static com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType.NAVBAR;
@@ -38,11 +38,12 @@
import android.util.Log;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
-
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.R;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.logging.UserEventDispatcher;
+import com.android.launcher3.touch.SwipeDetector;
+import com.android.quickstep.ActivityControlHelper;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.system.InputMonitorCompat;
import com.android.systemui.shared.system.QuickStepContract;
@@ -50,12 +51,15 @@
/**
* Touch consumer for handling events to launch assistant from launcher
*/
-public class AssistantTouchConsumer extends DelegateInputConsumer {
+public class AssistantTouchConsumer extends DelegateInputConsumer
+ implements SwipeDetector.Listener {
+
private static final String TAG = "AssistantTouchConsumer";
private static final long RETRACT_ANIMATION_DURATION_MS = 300;
private static final String INVOCATION_TYPE_KEY = "invocation_type";
private static final int INVOCATION_TYPE_GESTURE = 1;
+ private static final int INVOCATION_TYPE_FLING = 6;
private final PointF mDownPos = new PointF();
private final PointF mLastPos = new PointF();
@@ -77,6 +81,7 @@
private final float mSlop;
private final ISystemUiProxy mSysUiProxy;
private final Context mContext;
+ private final SwipeDetector mSwipeDetector;
public AssistantTouchConsumer(Context context, ISystemUiProxy systemUiProxy,
ActivityControlHelper activityControlHelper, InputConsumer delegate,
@@ -90,6 +95,8 @@
mAngleThreshold = res.getInteger(R.integer.assistant_gesture_corner_deg_threshold);
mSlop = QuickStepContract.getQuickStepDragSlopPx();
mActivityControlHelper = activityControlHelper;
+ mSwipeDetector = new SwipeDetector(mContext, this, SwipeDetector.VERTICAL);
+ mSwipeDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, false);
}
@Override
@@ -100,6 +107,7 @@
@Override
public void onMotionEvent(MotionEvent ev) {
// TODO add logging
+ mSwipeDetector.onTouchEvent(ev);
switch (ev.getActionMasked()) {
case ACTION_DOWN: {
@@ -146,7 +154,7 @@
// Determine if angle is larger than threshold for assistant detection
float angle = (float) Math.toDegrees(
- Math.atan2(mDownPos.y - mLastPos.y, mDownPos.x - mLastPos.x));
+ Math.atan2(mDownPos.y - mLastPos.y, mDownPos.x - mLastPos.x));
mDirection = angle > 90 ? UPLEFT : UPRIGHT;
angle = angle > 90 ? 180 - angle : angle;
@@ -159,7 +167,7 @@
} else {
// Movement
mDistance = (float) Math.hypot(mLastPos.x - mStartDragPos.x,
- mLastPos.y - mStartDragPos.y);
+ mLastPos.y - mStartDragPos.y);
if (mDistance >= 0) {
final long diff = SystemClock.uptimeMillis() - mDragTime;
mTimeFraction = Math.min(diff * 1f / mTimeThreshold, 1);
@@ -172,18 +180,18 @@
case ACTION_UP:
if (mState != STATE_DELEGATE_ACTIVE && !mLaunchedAssistant) {
ValueAnimator animator = ValueAnimator.ofFloat(mLastProgress, 0)
- .setDuration(RETRACT_ANIMATION_DURATION_MS);
+ .setDuration(RETRACT_ANIMATION_DURATION_MS);
UserEventDispatcher.newInstance(mContext).logActionOnContainer(
- SWIPE_NOOP, mDirection, NAVBAR);
+ SWIPE_NOOP, mDirection, NAVBAR);
animator.addUpdateListener(valueAnimator -> {
- float progress = (float) valueAnimator.getAnimatedValue();
- try {
+ float progress = (float) valueAnimator.getAnimatedValue();
+ try {
- mSysUiProxy.onAssistantProgress(progress);
- } catch (RemoteException e) {
- Log.w(TAG, "Failed to send SysUI start/send assistant progress: "
- + progress, e);
- }
+ mSysUiProxy.onAssistantProgress(progress);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to send SysUI start/send assistant progress: "
+ + progress, e);
+ }
});
animator.setInterpolator(Interpolators.DEACCEL_2);
animator.start();
@@ -200,38 +208,58 @@
private void updateAssistantProgress() {
if (!mLaunchedAssistant) {
- float progress = Math.min(mDistance * 1f / mDistThreshold, 1) * mTimeFraction;
- mLastProgress = progress;
- try {
- mSysUiProxy.onAssistantProgress(progress);
- if (mDistance >= mDistThreshold && mTimeFraction >= 1) {
- UserEventDispatcher.newInstance(mContext).logActionOnContainer(
- SWIPE, mDirection, NAVBAR);
- Bundle args = new Bundle();
- args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
-
- BaseDraggingActivity launcherActivity =
- mActivityControlHelper.getCreatedActivity();
- if (launcherActivity != null) {
- launcherActivity.getRootView().
- performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
- HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
- }
-
- mSysUiProxy.startAssistant(args);
- mLaunchedAssistant = true;
- }
- } catch (RemoteException e) {
- Log.w(TAG, "Failed to send SysUI start/send assistant progress: " + progress, e);
- }
+ mLastProgress = Math.min(mDistance * 1f / mDistThreshold, 1) * mTimeFraction;
+ updateAssistant(SWIPE);
}
}
- static boolean withinTouchRegion(Context context, MotionEvent ev) {
+ private void updateAssistant(int gestureType) {
+ try {
+ mSysUiProxy.onAssistantProgress(mLastProgress);
+ if (gestureType == FLING || (mDistance >= mDistThreshold && mTimeFraction >= 1)) {
+ UserEventDispatcher.newInstance(mContext)
+ .logActionOnContainer(gestureType, mDirection, NAVBAR);
+ Bundle args = new Bundle();
+ args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
+
+ BaseDraggingActivity launcherActivity = mActivityControlHelper.getCreatedActivity();
+ if (launcherActivity != null) {
+ launcherActivity.getRootView().performHapticFeedback(
+ 13, // HapticFeedbackConstants.GESTURE_END
+ HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
+ }
+
+ mSysUiProxy.startAssistant(args);
+ mLaunchedAssistant = true;
+ }
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed to send SysUI start/send assistant progress: " + mLastProgress, e);
+ }
+ }
+
+ public static boolean withinTouchRegion(Context context, MotionEvent ev) {
final Resources res = context.getResources();
final int width = res.getDisplayMetrics().widthPixels;
final int height = res.getDisplayMetrics().heightPixels;
final int size = res.getDimensionPixelSize(R.dimen.gestures_assistant_size);
return (ev.getX() > width - size || ev.getX() < size) && ev.getY() > height - size;
}
+
+ @Override
+ public void onDragStart(boolean start) {
+ // do nothing
+ }
+
+ @Override
+ public boolean onDrag(float displacement) {
+ return false;
+ }
+
+ @Override
+ public void onDragEnd(float velocity, boolean fling) {
+ if (fling) {
+ mLastProgress = 1;
+ updateAssistant(FLING);
+ }
+ }
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/DelegateInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DelegateInputConsumer.java
similarity index 96%
rename from quickstep/recents_ui_overrides/src/com/android/quickstep/DelegateInputConsumer.java
rename to quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DelegateInputConsumer.java
index d36162f..311ddd2 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/DelegateInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DelegateInputConsumer.java
@@ -1,4 +1,4 @@
-package com.android.quickstep;
+package com.android.quickstep.inputconsumers;
import android.view.MotionEvent;
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/DeviceLockedInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java
similarity index 97%
rename from quickstep/recents_ui_overrides/src/com/android/quickstep/DeviceLockedInputConsumer.java
rename to quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java
index 7fd09f7..b1d175d 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/DeviceLockedInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.quickstep;
+package com.android.quickstep.inputconsumers;
import android.content.Context;
import android.content.Intent;
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/InputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/InputConsumer.java
similarity index 95%
rename from quickstep/recents_ui_overrides/src/com/android/quickstep/InputConsumer.java
rename to quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/InputConsumer.java
index 37b7288..2e8880d 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/InputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/InputConsumer.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.quickstep;
+package com.android.quickstep.inputconsumers;
import android.annotation.TargetApi;
import android.os.Build;
@@ -30,6 +30,7 @@
int TYPE_ASSISTANT = 1 << 3;
int TYPE_DEVICE_LOCKED = 1 << 4;
int TYPE_ACCESSIBILITY = 1 << 5;
+ int TYPE_SCREEN_PINNED = 1 << 6;
InputConsumer NO_OP = () -> TYPE_NO_OP;
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
similarity index 97%
rename from quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java
rename to quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
index db377b0..e862fa6 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.quickstep;
+package com.android.quickstep.inputconsumers;
import static android.view.MotionEvent.ACTION_CANCEL;
import static android.view.MotionEvent.ACTION_DOWN;
@@ -50,7 +50,13 @@
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.RaceConditionTracker;
import com.android.launcher3.util.TraceHelper;
+import com.android.quickstep.ActivityControlHelper;
+import com.android.quickstep.OverviewCallbacks;
+import com.android.quickstep.RecentsModel;
+import com.android.quickstep.SwipeSharedState;
+import com.android.quickstep.SysUINavigationMode;
import com.android.quickstep.SysUINavigationMode.Mode;
+import com.android.quickstep.WindowTransformSwipeHandler;
import com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget;
import com.android.quickstep.util.CachedEventDispatcher;
import com.android.quickstep.util.MotionPauseDetector;
@@ -376,7 +382,7 @@
// The consumer is being switched while we are active. Set up the shared state to be
// used by the next animation
removeListener();
- GestureEndTarget endTarget = mInteractionHandler.mGestureEndTarget;
+ GestureEndTarget endTarget = mInteractionHandler.getGestureEndTarget();
mSwipeSharedState.canGestureBeContinued = endTarget != null && endTarget.canBeContinued;
mSwipeSharedState.goingToLauncher = endTarget != null && endTarget.isLauncher;
if (mSwipeSharedState.canGestureBeContinued) {
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java
similarity index 96%
rename from quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewInputConsumer.java
rename to quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java
index bafc367..bab3c71 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.quickstep;
+package com.android.quickstep.inputconsumers;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.quickstep.TouchInteractionService.TOUCH_INTERACTION_LOG;
@@ -27,6 +27,8 @@
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.Utilities;
import com.android.launcher3.views.BaseDragLayer;
+import com.android.quickstep.ActivityControlHelper;
+import com.android.quickstep.OverviewCallbacks;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.InputMonitorCompat;
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java
new file mode 100644
index 0000000..a0e20f2
--- /dev/null
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/ScreenPinnedInputConsumer.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2019 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.inputconsumers;
+
+import android.content.Context;
+import android.os.RemoteException;
+import android.util.Log;
+import android.view.HapticFeedbackConstants;
+import android.view.MotionEvent;
+
+import com.android.launcher3.BaseDraggingActivity;
+import com.android.launcher3.R;
+import com.android.quickstep.ActivityControlHelper;
+import com.android.quickstep.util.MotionPauseDetector;
+import com.android.systemui.shared.recents.ISystemUiProxy;
+
+/**
+ * An input consumer that detects swipe up and hold to exit screen pinning mode.
+ */
+public class ScreenPinnedInputConsumer implements InputConsumer {
+
+ private static final String TAG = "ScreenPinnedConsumer";
+
+ private final float mMotionPauseMinDisplacement;
+ private final MotionPauseDetector mMotionPauseDetector;
+
+ private float mTouchDownY;
+
+ public ScreenPinnedInputConsumer(Context context, ISystemUiProxy sysuiProxy,
+ ActivityControlHelper activityControl) {
+ mMotionPauseMinDisplacement = context.getResources().getDimension(
+ R.dimen.motion_pause_detector_min_displacement_from_app);
+ mMotionPauseDetector = new MotionPauseDetector(context, true /* makePauseHarderToTrigger*/);
+ mMotionPauseDetector.setOnMotionPauseListener(isPaused -> {
+ if (isPaused) {
+ try {
+ sysuiProxy.stopScreenPinning();
+ BaseDraggingActivity launcherActivity = activityControl.getCreatedActivity();
+ if (launcherActivity != null) {
+ launcherActivity.getRootView().performHapticFeedback(
+ HapticFeedbackConstants.LONG_PRESS,
+ HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
+ }
+ mMotionPauseDetector.clear();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Unable to stop screen pinning ", e);
+ }
+ }
+ });
+ }
+
+ @Override
+ public int getType() {
+ return TYPE_SCREEN_PINNED;
+ }
+
+ @Override
+ public void onMotionEvent(MotionEvent ev) {
+ float y = ev.getY();
+ switch (ev.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ mTouchDownY = y;
+ break;
+ case MotionEvent.ACTION_MOVE:
+ float displacement = mTouchDownY - y;
+ mMotionPauseDetector.setDisallowPause(displacement < mMotionPauseMinDisplacement);
+ mMotionPauseDetector.addPosition(y, ev.getEventTime());
+ break;
+ case MotionEvent.ACTION_CANCEL:
+ case MotionEvent.ACTION_UP:
+ mMotionPauseDetector.clear();
+ break;
+ }
+ }
+}
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 32f312f..82d1aa6 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -36,6 +36,7 @@
<!-- These speeds are in dp / ms -->
<dimen name="motion_pause_detector_speed_very_slow">0.0285dp</dimen>
+ <dimen name="motion_pause_detector_speed_slow">0.15dp</dimen>
<dimen name="motion_pause_detector_speed_somewhat_fast">0.285dp</dimen>
<dimen name="motion_pause_detector_speed_fast">0.5dp</dimen>
<dimen name="motion_pause_detector_min_displacement_from_app">36dp</dimen>
diff --git a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
index e1a115a..3b75304 100644
--- a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
@@ -132,7 +132,7 @@
private final DragLayer mDragLayer;
private final AlphaProperty mDragLayerAlpha;
- private final Handler mHandler;
+ final Handler mHandler;
private final boolean mIsRtl;
private final float mContentTransY;
@@ -573,70 +573,9 @@
* @return Runner that plays when user goes to Launcher
* ie. pressing home, swiping up from nav bar.
*/
- private RemoteAnimationRunnerCompat getWallpaperOpenRunner(boolean fromUnlock) {
- return new LauncherAnimationRunner(mHandler, false /* startAtFrontOfQueue */) {
- @Override
- public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats,
- AnimationResult result) {
- if (!mLauncher.hasBeenResumed()) {
- // If launcher is not resumed, wait until new async-frame after resume
- mLauncher.setOnResumeCallback(() ->
- postAsyncCallback(mHandler, () ->
- onCreateAnimation(targetCompats, result)));
- return;
- }
-
- if (mLauncher.hasSomeInvisibleFlag(PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION)) {
- mLauncher.addForceInvisibleFlag(INVISIBLE_BY_PENDING_FLAGS);
- mLauncher.getStateManager().moveToRestState();
- }
-
- AnimatorSet anim = null;
- RemoteAnimationProvider provider = mRemoteAnimationProvider;
- if (provider != null) {
- anim = provider.createWindowAnimation(targetCompats);
- }
-
- if (anim == null) {
- anim = new AnimatorSet();
- anim.play(fromUnlock
- ? getUnlockWindowAnimator(targetCompats)
- : getClosingWindowAnimators(targetCompats));
-
- // Normally, we run the launcher content animation when we are transitioning
- // home, but if home is already visible, then we don't want to animate the
- // contents of launcher unless we know that we are animating home as a result
- // of the home button press with quickstep, which will result in launcher being
- // started on touch down, prior to the animation home (and won't be in the
- // targets list because it is already visible). In that case, we force
- // invisibility on touch down, and only reset it after the animation to home
- // is initialized.
- if (launcherIsATargetWithMode(targetCompats, MODE_OPENING)
- || mLauncher.isForceInvisible()) {
- // Only register the content animation for cancellation when state changes
- mLauncher.getStateManager().setCurrentAnimation(anim);
- if (fromUnlock) {
- Pair<AnimatorSet, Runnable> contentAnimator =
- getLauncherContentAnimator(false /* isAppOpening */,
- new float[] {mContentTransY, 0});
- contentAnimator.first.setStartDelay(0);
- anim.play(contentAnimator.first);
- anim.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- contentAnimator.second.run();
- }
- });
- } else {
- createLauncherResumeAnimation(anim);
- }
- }
- }
-
- mLauncher.clearForceInvisibleFlag(INVISIBLE_ALL);
- result.setAnimation(anim);
- }
- };
+ RemoteAnimationRunnerCompat getWallpaperOpenRunner(boolean fromUnlock) {
+ return new WallpaperOpenLauncherAnimationRunner(mHandler, false /* startAtFrontOfQueue */,
+ fromUnlock);
}
/**
@@ -773,4 +712,79 @@
return mLauncher.checkSelfPermission(CONTROL_REMOTE_APP_TRANSITION_PERMISSION)
== PackageManager.PERMISSION_GRANTED;
}
+
+ /**
+ * Remote animation runner for animation from the app to Launcher, including recents.
+ */
+ class WallpaperOpenLauncherAnimationRunner extends LauncherAnimationRunner {
+ private final boolean mFromUnlock;
+
+ public WallpaperOpenLauncherAnimationRunner(Handler handler, boolean startAtFrontOfQueue,
+ boolean fromUnlock) {
+ super(handler, startAtFrontOfQueue);
+ mFromUnlock = fromUnlock;
+ }
+
+ @Override
+ public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats,
+ LauncherAnimationRunner.AnimationResult result) {
+ if (!mLauncher.hasBeenResumed()) {
+ // If launcher is not resumed, wait until new async-frame after resume
+ mLauncher.setOnResumeCallback(() ->
+ postAsyncCallback(mHandler, () ->
+ onCreateAnimation(targetCompats, result)));
+ return;
+ }
+
+ if (mLauncher.hasSomeInvisibleFlag(PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION)) {
+ mLauncher.addForceInvisibleFlag(INVISIBLE_BY_PENDING_FLAGS);
+ mLauncher.getStateManager().moveToRestState();
+ }
+
+ AnimatorSet anim = null;
+ RemoteAnimationProvider provider = mRemoteAnimationProvider;
+ if (provider != null) {
+ anim = provider.createWindowAnimation(targetCompats);
+ }
+
+ if (anim == null) {
+ anim = new AnimatorSet();
+ anim.play(mFromUnlock
+ ? getUnlockWindowAnimator(targetCompats)
+ : getClosingWindowAnimators(targetCompats));
+
+ // Normally, we run the launcher content animation when we are transitioning
+ // home, but if home is already visible, then we don't want to animate the
+ // contents of launcher unless we know that we are animating home as a result
+ // of the home button press with quickstep, which will result in launcher being
+ // started on touch down, prior to the animation home (and won't be in the
+ // targets list because it is already visible). In that case, we force
+ // invisibility on touch down, and only reset it after the animation to home
+ // is initialized.
+ if (launcherIsATargetWithMode(targetCompats, MODE_OPENING)
+ || mLauncher.isForceInvisible()) {
+ // Only register the content animation for cancellation when state changes
+ mLauncher.getStateManager().setCurrentAnimation(anim);
+ if (mFromUnlock) {
+ Pair<AnimatorSet, Runnable> contentAnimator =
+ getLauncherContentAnimator(false /* isAppOpening */,
+ new float[] {mContentTransY, 0});
+ contentAnimator.first.setStartDelay(0);
+ anim.play(contentAnimator.first);
+ anim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ contentAnimator.second.run();
+ }
+ });
+ } else {
+ createLauncherResumeAnimation(anim);
+ }
+ }
+ }
+
+ mLauncher.clearForceInvisibleFlag(INVISIBLE_ALL);
+ result.setAnimation(anim);
+ }
+ }
}
diff --git a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
index f58f0d4..893c053 100644
--- a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
+++ b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
@@ -35,10 +35,18 @@
/** If no motion is added for this amount of time, assume the motion has paused. */
private static final long FORCE_PAUSE_TIMEOUT = 300;
+ /**
+ * After {@link #makePauseHarderToTrigger()}, must
+ * move slowly for this long to trigger a pause.
+ */
+ private static final long HARDER_TRIGGER_TIMEOUT = 400;
+
private final float mSpeedVerySlow;
+ private final float mSpeedSlow;
private final float mSpeedSomewhatFast;
private final float mSpeedFast;
private final Alarm mForcePauseTimeout;
+ private final boolean mMakePauseHarderToTrigger;
private Long mPreviousTime = null;
private Float mPreviousPosition = null;
@@ -52,19 +60,29 @@
private boolean mHasEverBeenPaused;
/** @see #setDisallowPause(boolean) */
private boolean mDisallowPause;
+ // Time at which speed became < mSpeedSlow (only used if mMakePauseHarderToTrigger == true).
+ private long mSlowStartTime;
public MotionPauseDetector(Context context) {
+ this(context, false);
+ }
+
+ /**
+ * @param makePauseHarderToTrigger Used for gestures that require a more explicit pause.
+ */
+ public MotionPauseDetector(Context context, boolean makePauseHarderToTrigger) {
Resources res = context.getResources();
mSpeedVerySlow = res.getDimension(R.dimen.motion_pause_detector_speed_very_slow);
+ mSpeedSlow = res.getDimension(R.dimen.motion_pause_detector_speed_slow);
mSpeedSomewhatFast = res.getDimension(R.dimen.motion_pause_detector_speed_somewhat_fast);
mSpeedFast = res.getDimension(R.dimen.motion_pause_detector_speed_fast);
mForcePauseTimeout = new Alarm();
mForcePauseTimeout.setOnAlarmListener(alarm -> updatePaused(true /* isPaused */));
+ mMakePauseHarderToTrigger = makePauseHarderToTrigger;
}
/**
- * Get callbacks for when motion pauses and resumes, including an
- * immediate callback with the current pause state.
+ * Get callbacks for when motion pauses and resumes.
*/
public void setOnMotionPauseListener(OnMotionPauseListener listener) {
mOnMotionPauseListener = listener;
@@ -88,13 +106,15 @@
if (mFirstPosition == null) {
mFirstPosition = position;
}
- mForcePauseTimeout.setAlarm(FORCE_PAUSE_TIMEOUT);
+ mForcePauseTimeout.setAlarm(mMakePauseHarderToTrigger
+ ? HARDER_TRIGGER_TIMEOUT
+ : FORCE_PAUSE_TIMEOUT);
if (mPreviousTime != null && mPreviousPosition != null) {
long changeInTime = Math.max(1, time - mPreviousTime);
float changeInPosition = position - mPreviousPosition;
float velocity = changeInPosition / changeInTime;
if (mPreviousVelocity != null) {
- checkMotionPaused(velocity, mPreviousVelocity);
+ checkMotionPaused(velocity, mPreviousVelocity, time);
}
mPreviousVelocity = velocity;
}
@@ -102,7 +122,7 @@
mPreviousPosition = position;
}
- private void checkMotionPaused(float velocity, float prevVelocity) {
+ private void checkMotionPaused(float velocity, float prevVelocity, long time) {
float speed = Math.abs(velocity);
float previousSpeed = Math.abs(prevVelocity);
boolean isPaused;
@@ -122,6 +142,17 @@
boolean isRapidDeceleration = speed < previousSpeed * RAPID_DECELERATION_FACTOR;
isPaused = isRapidDeceleration && speed < mSpeedSomewhatFast;
}
+ if (mMakePauseHarderToTrigger) {
+ if (speed < mSpeedSlow) {
+ if (mSlowStartTime == 0) {
+ mSlowStartTime = time;
+ }
+ isPaused = time - mSlowStartTime >= HARDER_TRIGGER_TIMEOUT;
+ } else {
+ mSlowStartTime = 0;
+ isPaused = false;
+ }
+ }
}
}
updatePaused(isPaused);
@@ -149,6 +180,7 @@
mFirstPosition = null;
setOnMotionPauseListener(null);
mIsPaused = mHasEverBeenPaused = false;
+ mSlowStartTime = 0;
mForcePauseTimeout.cancelAlarm();
}
diff --git a/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java b/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java
index 1817135..ffe3633 100644
--- a/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java
+++ b/quickstep/tests/src/com/android/quickstep/AppPredictionsUITests.java
@@ -40,7 +40,6 @@
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -70,6 +69,8 @@
// Disable app tracker
AppLaunchTracker.INSTANCE.initializeForTesting(new AppLaunchTracker());
+ PredictionUiStateManager.INSTANCE.initializeForTesting(null);
+
mCallback = PredictionUiStateManager.INSTANCE.get(mTargetContext).appPredictorCallback(
Client.HOME);
@@ -85,7 +86,6 @@
* Test that prediction UI is updated as soon as we get predictions from the system
*/
@Test
- @Ignore // b/131772711: this really fails (when being run as a part of the whole test suite)!
public void testPredictionExistsInAllApps() {
mActivityMonitor.startLauncher();
mLauncher.pressHome().switchToAllApps();
@@ -118,7 +118,6 @@
}
@Test
- @Ignore // b/131772711 - this was failing in the lab
public void testPredictionsDisabled() {
mActivityMonitor.startLauncher();
sendPredictionUpdate();
diff --git a/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java b/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java
index 8bdb90d..2111e2c 100644
--- a/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java
+++ b/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java
@@ -28,6 +28,7 @@
import com.android.launcher3.util.RaceConditionReproducer;
import com.android.quickstep.NavigationModeSwitchRule.Mode;
import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
+import com.android.quickstep.inputconsumers.OtherActivityInputConsumer;
import org.junit.Before;
import org.junit.Ignore;
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 3d2d7cf..d098b8c 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -213,7 +213,7 @@
// Add a bit of space between nav bar and hotseat in multi-window vertical bar layout.
hotseatBarSidePaddingStartPx = isMultiWindowMode && isVerticalBarLayout()
? edgeMarginPx : 0;
- hotseatBarSizePx = Utilities.pxFromDp(inv.iconSize, dm) + (isVerticalBarLayout()
+ hotseatBarSizePx = ResourceUtils.pxFromDp(inv.iconSize, dm) + (isVerticalBarLayout()
? (hotseatBarSidePaddingStartPx + hotseatBarSidePaddingEndPx)
: (res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size)
+ hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx));
@@ -319,7 +319,7 @@
// Workspace
final boolean isVerticalLayout = isVerticalBarLayout();
float invIconSizePx = isVerticalLayout ? inv.landscapeIconSize : inv.iconSize;
- iconSizePx = Math.max(1, (int) (Utilities.pxFromDp(invIconSizePx, dm) * scale));
+ iconSizePx = Math.max(1, (int) (ResourceUtils.pxFromDp(invIconSizePx, dm) * scale));
iconTextSizePx = (int) (Utilities.pxFromSp(inv.iconTextSize, dm) * scale);
iconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * scale);
@@ -399,7 +399,7 @@
}
private void updateFolderCellSize(float scale, DisplayMetrics dm, Resources res) {
- folderChildIconSizePx = (int) (Utilities.pxFromDp(inv.iconSize, dm) * scale);
+ folderChildIconSizePx = (int) (ResourceUtils.pxFromDp(inv.iconSize, dm) * scale);
folderChildTextSizePx =
(int) (res.getDimensionPixelSize(R.dimen.folder_child_text_size) * scale);
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 819a551..8a8a2fb 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -210,7 +210,7 @@
iconSize = interpolatedDisplayOption.iconSize;
iconShapePath = getIconShapePath(context);
landscapeIconSize = interpolatedDisplayOption.landscapeIconSize;
- iconBitmapSize = Utilities.pxFromDp(iconSize, dm);
+ iconBitmapSize = ResourceUtils.pxFromDp(iconSize, dm);
iconTextSize = interpolatedDisplayOption.iconTextSize;
fillResIconDpi = getLauncherIconDensity(iconBitmapSize);
diff --git a/src/com/android/launcher3/ResourceUtils.java b/src/com/android/launcher3/ResourceUtils.java
new file mode 100644
index 0000000..8df3290
--- /dev/null
+++ b/src/com/android/launcher3/ResourceUtils.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2019 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.launcher3;
+
+import android.content.res.Resources;
+import android.util.DisplayMetrics;
+import android.util.TypedValue;
+
+public class ResourceUtils {
+ public static final String NAVBAR_VERTICAL_SIZE = "navigation_bar_frame_height";
+ public static final String NAVBAR_HORIZONTAL_SIZE = "navigation_bar_width";
+
+ public static int getNavbarSize(String resName, Resources res) {
+ return getDimenByName(resName, res, 48);
+ }
+
+ private static int getDimenByName(String resName, Resources res, int defaultValue) {
+ final int frameSize;
+ final int frameSizeResID = res.getIdentifier(resName, "dimen", "android");
+ if (frameSizeResID != 0) {
+ frameSize = res.getDimensionPixelSize(frameSizeResID);
+ } else {
+ frameSize = pxFromDp(defaultValue, res.getDisplayMetrics());
+ }
+ return frameSize;
+ }
+
+ public static int pxFromDp(float size, DisplayMetrics metrics) {
+ return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, size, metrics));
+ }
+}
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 35b967f..5cfd95c 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -477,10 +477,7 @@
float densityRatio = (float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT;
return (size / densityRatio);
}
- public static int pxFromDp(float size, DisplayMetrics metrics) {
- return (int) Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
- size, metrics));
- }
+
public static int pxFromSp(float size, DisplayMetrics metrics) {
return (int) Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
size, metrics));
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index e2a5160..41252aa 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -604,4 +604,18 @@
return super.performAccessibilityAction(action, arguments);
}
+
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent ev) {
+ switch (ev.getActionMasked()) {
+ case MotionEvent.ACTION_DOWN:
+ mAllAppsStore.setDeferUpdates(true);
+ break;
+ case MotionEvent.ACTION_UP:
+ case MotionEvent.ACTION_CANCEL:
+ mAllAppsStore.setDeferUpdates(false);
+ break;
+ }
+ return super.dispatchTouchEvent(ev);
+ }
}
diff --git a/src/com/android/launcher3/folder/FolderAnimationManager.java b/src/com/android/launcher3/folder/FolderAnimationManager.java
index 2450039..0e2ddd4 100644
--- a/src/com/android/launcher3/folder/FolderAnimationManager.java
+++ b/src/com/android/launcher3/folder/FolderAnimationManager.java
@@ -39,6 +39,7 @@
import com.android.launcher3.CellLayout;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
+import com.android.launcher3.ResourceUtils;
import com.android.launcher3.ShortcutAndWidgetContainer;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.PropertyResetListener;
@@ -165,7 +166,7 @@
Math.round((totalOffsetX + initialSize) / initialScale),
Math.round((paddingOffsetY + initialSize) / initialScale));
Rect endRect = new Rect(0, 0, lp.width, lp.height);
- float finalRadius = Utilities.pxFromDp(2, mContext.getResources().getDisplayMetrics());
+ float finalRadius = ResourceUtils.pxFromDp(2, mContext.getResources().getDisplayMetrics());
// Create the animators.
AnimatorSet a = new AnimatorSet();
diff --git a/src/com/android/launcher3/graphics/WorkspaceAndHotseatScrim.java b/src/com/android/launcher3/graphics/WorkspaceAndHotseatScrim.java
index 66f9dbf..c0aa75f 100644
--- a/src/com/android/launcher3/graphics/WorkspaceAndHotseatScrim.java
+++ b/src/com/android/launcher3/graphics/WorkspaceAndHotseatScrim.java
@@ -43,7 +43,7 @@
import com.android.launcher3.CellLayout;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
-import com.android.launcher3.Utilities;
+import com.android.launcher3.ResourceUtils;
import com.android.launcher3.Workspace;
import com.android.launcher3.uioverrides.WallpaperColorInfo;
import com.android.launcher3.util.Themes;
@@ -148,7 +148,7 @@
mLauncher = Launcher.getLauncher(view.getContext());
mWallpaperColorInfo = WallpaperColorInfo.getInstance(mLauncher);
- mMaskHeight = Utilities.pxFromDp(ALPHA_MASK_BITMAP_DP,
+ mMaskHeight = ResourceUtils.pxFromDp(ALPHA_MASK_BITMAP_DP,
view.getResources().getDisplayMetrics());
mTopScrim = Themes.getAttrDrawable(view.getContext(), R.attr.workspaceStatusBarScrim);
mBottomMask = mTopScrim == null ? null : createDitheredAlphaMask();
@@ -297,8 +297,8 @@
public Bitmap createDitheredAlphaMask() {
DisplayMetrics dm = mLauncher.getResources().getDisplayMetrics();
- int width = Utilities.pxFromDp(ALPHA_MASK_WIDTH_DP, dm);
- int gradientHeight = Utilities.pxFromDp(ALPHA_MASK_HEIGHT_DP, dm);
+ int width = ResourceUtils.pxFromDp(ALPHA_MASK_WIDTH_DP, dm);
+ int gradientHeight = ResourceUtils.pxFromDp(ALPHA_MASK_HEIGHT_DP, dm);
Bitmap dst = Bitmap.createBitmap(width, mMaskHeight, Bitmap.Config.ALPHA_8);
Canvas c = new Canvas(dst);
Paint paint = new Paint(Paint.DITHER_FLAG);
diff --git a/src/com/android/launcher3/provider/RestoreDbTask.java b/src/com/android/launcher3/provider/RestoreDbTask.java
index e6e20e1..053c493 100644
--- a/src/com/android/launcher3/provider/RestoreDbTask.java
+++ b/src/com/android/launcher3/provider/RestoreDbTask.java
@@ -201,7 +201,7 @@
*/
private UserHandle getUserForAncestralSerialNumber(BackupManager backupManager,
long ancestralSerialNumber) {
- if (Build.VERSION.SDK_INT < 29) {
+ if (!Utilities.ATLEAST_Q) {
return null;
}
return backupManager.getUserForAncestralSerialNumber(ancestralSerialNumber);
diff --git a/src/com/android/launcher3/widget/WidgetsBottomSheet.java b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
index 3e2c0ae..a7078a2 100644
--- a/src/com/android/launcher3/widget/WidgetsBottomSheet.java
+++ b/src/com/android/launcher3/widget/WidgetsBottomSheet.java
@@ -36,7 +36,7 @@
import com.android.launcher3.ItemInfo;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
-import com.android.launcher3.Utilities;
+import com.android.launcher3.ResourceUtils;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.model.WidgetItem;
import com.android.launcher3.util.PackageUserKey;
@@ -126,7 +126,7 @@
// Otherwise, add an empty view to the start as padding (but still scroll edge to edge).
View leftPaddingView = LayoutInflater.from(getContext()).inflate(
R.layout.widget_list_divider, widgetRow, false);
- leftPaddingView.getLayoutParams().width = Utilities.pxFromDp(
+ leftPaddingView.getLayoutParams().width = ResourceUtils.pxFromDp(
16, getResources().getDisplayMetrics());
widgetCells.addView(leftPaddingView, 0);
}
diff --git a/tests/Android.mk b/tests/Android.mk
index 080c98b..0991a04 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -30,6 +30,7 @@
LOCAL_STATIC_JAVA_LIBRARIES += libSharedSystemUI
LOCAL_SRC_FILES := $(call all-java-files-under, tapl) \
+ ../src/com/android/launcher3/ResourceUtils.java \
../src/com/android/launcher3/util/SecureSettingsObserver.java \
../src/com/android/launcher3/TestProtocol.java
endif
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index 75db2f1..b6878bb 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -51,6 +51,7 @@
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherState;
import com.android.launcher3.MainThreadExecutor;
+import com.android.launcher3.ResourceUtils;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.LauncherAppsCompat;
import com.android.launcher3.tapl.LauncherInstrumentation;
@@ -208,7 +209,9 @@
* @return the matching object.
*/
protected UiObject2 scrollAndFind(UiObject2 container, BySelector condition) {
- container.setGestureMargins(0, 0, 0, 200);
+ final int margin = ResourceUtils.getNavbarSize(
+ ResourceUtils.NAVBAR_VERTICAL_SIZE, mLauncher.getResources()) + 1;
+ container.setGestureMargins(0, 0, 0, margin);
int i = 0;
for (; ; ) {
@@ -216,7 +219,8 @@
mDevice.wait(Until.findObject(condition), SHORT_UI_TIMEOUT);
UiObject2 widget = container.findObject(condition);
if (widget != null && widget.getVisibleBounds().intersects(
- 0, 0, mDevice.getDisplayWidth(), mDevice.getDisplayHeight() - 200)) {
+ 0, 0, mDevice.getDisplayWidth(),
+ mDevice.getDisplayHeight() - margin)) {
return widget;
}
if (++i > 40) fail("Too many attempts");
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index 581e886..7578dff 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -24,7 +24,6 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import android.content.Intent;
import android.util.Log;
import androidx.test.filters.LargeTest;
@@ -241,9 +240,8 @@
}
public static void runIconLaunchFromAllAppsTest(AbstractLauncherUiTest test, AllApps allApps) {
- final AppIcon app = allApps.getAppIcon("Calculator");
- assertNotNull("AppIcon.launch returned null", app.launch(
- test.resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR)));
+ final AppIcon app = allApps.getAppIcon("TestActivity7");
+ assertNotNull("AppIcon.launch returned null", app.launch(getAppPackageName()));
test.executeOnLauncher(launcher -> assertTrue(
"Launcher activity is the top activity; expecting another activity to be the top "
+ "one",
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java
index 1ad0037..68bdfe3 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java
@@ -23,6 +23,7 @@
import androidx.test.uiautomator.Direction;
import androidx.test.uiautomator.UiObject2;
+import com.android.launcher3.ResourceUtils;
import com.android.launcher3.TestProtocol;
/**
@@ -66,12 +67,9 @@
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to get app icon on all apps")) {
final UiObject2 allAppsContainer = verifyActiveContainer();
- if (mLauncher.getNavigationModel() != ZERO_BUTTON) {
- final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame");
- allAppsContainer.setGestureMargins(0, 0, 0, navBar.getVisibleBounds().height() + 1);
- } else {
- allAppsContainer.setGestureMargins(0, 0, 0, 200);
- }
+ allAppsContainer.setGestureMargins(0, 0, 0,
+ ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_VERTICAL_SIZE,
+ mLauncher.getResources()) + 1);
final BySelector appIconSelector = AppIcon.getAppIconSelector(appName, mLauncher);
if (!hasClickableIcon(allAppsContainer, appIconSelector)) {
scrollBackToBeginning();
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index 3b2a7b8..60d2850 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -78,7 +78,8 @@
final long downTime = SystemClock.uptimeMillis();
mLauncher.sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, start);
- mLauncher.movePointer(downTime, ZERO_BUTTON_SWIPE_UP_GESTURE_DURATION, start, end);
+ mLauncher.movePointer(
+ downTime, downTime, ZERO_BUTTON_SWIPE_UP_GESTURE_DURATION, start, end);
LauncherInstrumentation.sleep(ZERO_BUTTON_SWIPE_UP_HOLD_DURATION);
mLauncher.sendPointer(
downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, end);
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 87ef044..4d8ff1b 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -70,6 +70,7 @@
private static final String TAG = "Tapl";
private static final int ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME = 20;
+ private static final int GESTURE_STEP_MS = 16;
// Types for launcher containers that the user is interacting with. "Background" is a
// pseudo-container corresponding to inactive launcher covered by another app.
@@ -359,7 +360,7 @@
? NORMAL_STATE_ORDINAL : BACKGROUND_APP_STATE_ORDINAL;
final Point displaySize = getRealDisplaySize();
- swipe(
+ swipeViaMovePointer(
displaySize.x / 2, displaySize.y - 1,
displaySize.x / 2, 0,
finalState, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME);
@@ -543,8 +544,28 @@
}
void swipe(int startX, int startY, int endX, int endY, int expectedState, int steps) {
+ changeStateViaGesture(startX, startY, endX, endY, expectedState,
+ () -> mDevice.swipe(startX, startY, endX, endY, steps));
+ }
+
+ void swipeViaMovePointer(
+ int startX, int startY, int endX, int endY, int expectedState, int steps) {
+ changeStateViaGesture(startX, startY, endX, endY, expectedState, () -> {
+ final long downTime = SystemClock.uptimeMillis();
+ final Point start = new Point(startX, startY);
+ final Point end = new Point(endX, endY);
+ sendPointer(downTime, downTime, MotionEvent.ACTION_DOWN, start);
+ final long endTime = movePointer(downTime, downTime, steps * GESTURE_STEP_MS, start,
+ end);
+ sendPointer(
+ downTime, endTime, MotionEvent.ACTION_UP, end);
+ });
+ }
+
+ private void changeStateViaGesture(int startX, int startY, int endX, int endY,
+ int expectedState, Runnable gesture) {
final Bundle parcel = (Bundle) executeAndWaitForEvent(
- () -> mDevice.swipe(startX, startY, endX, endY, steps),
+ gesture,
event -> TestProtocol.SWITCHED_TO_STATE_MESSAGE.equals(event.getClassName()),
"Swipe failed to receive an event for the swipe end: " + startX + ", " + startY
+ ", " + endX + ", " + endY);
@@ -565,6 +586,10 @@
return ViewConfiguration.get(getContext()).getScaledTouchSlop();
}
+ public Resources getResources() {
+ return getContext().getResources();
+ }
+
private static MotionEvent getMotionEvent(long downTime, long eventTime, int action,
float x, float y) {
MotionEvent.PointerProperties properties = new MotionEvent.PointerProperties();
@@ -589,21 +614,22 @@
event.recycle();
}
- void movePointer(long downTime, long duration, Point from, Point to) {
+ long movePointer(long downTime, long startTime, long duration, Point from, Point to) {
final Point point = new Point();
- final long startTime = SystemClock.uptimeMillis();
- for (; ; ) {
- sleep(16);
+ long steps = duration / GESTURE_STEP_MS;
+ long currentTime = startTime;
+ for (long i = 0; i < steps; ++i) {
+ sleep(GESTURE_STEP_MS);
- final long currentTime = SystemClock.uptimeMillis();
+ currentTime += GESTURE_STEP_MS;
final float progress = (currentTime - startTime) / (float) duration;
- if (progress > 1) return;
point.x = from.x + (int) (progress * (to.x - from.x));
point.y = from.y + (int) (progress * (to.y - from.y));
sendPointer(downTime, currentTime, MotionEvent.ACTION_MOVE, point);
}
+ return currentTime;
}
public static boolean isGesturalMode(Context context) {
diff --git a/tests/tapl/com/android/launcher3/tapl/Widgets.java b/tests/tapl/com/android/launcher3/tapl/Widgets.java
index 100a11c..f7e0b6c 100644
--- a/tests/tapl/com/android/launcher3/tapl/Widgets.java
+++ b/tests/tapl/com/android/launcher3/tapl/Widgets.java
@@ -19,6 +19,8 @@
import androidx.test.uiautomator.Direction;
import androidx.test.uiautomator.UiObject2;
+import com.android.launcher3.ResourceUtils;
+
/**
* All widgets container.
*/
@@ -38,7 +40,9 @@
"want to fling forward in widgets")) {
LauncherInstrumentation.log("Widgets.flingForward enter");
final UiObject2 widgetsContainer = verifyActiveContainer();
- widgetsContainer.setGestureMargins(0, 0, 0, 200);
+ widgetsContainer.setGestureMargins(0, 0, 0,
+ ResourceUtils.getNavbarSize(ResourceUtils.NAVBAR_VERTICAL_SIZE,
+ mLauncher.getResources()) + 1);
widgetsContainer.fling(Direction.DOWN,
(int) (FLING_SPEED * mLauncher.getDisplayDensity()));
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("flung forward")) {
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 9a47aef..e8a0b54 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -150,7 +150,8 @@
LauncherInstrumentation.log("dragIconToWorkspace: sent down");
launcher.waitForLauncherObject(longPressIndicator);
LauncherInstrumentation.log("dragIconToWorkspace: indicator");
- launcher.movePointer(downTime, DRAG_DURACTION, launchableCenter, dest);
+ launcher.movePointer(
+ downTime, SystemClock.uptimeMillis(), DRAG_DURACTION, launchableCenter, dest);
LauncherInstrumentation.log("dragIconToWorkspace: moved pointer");
launcher.sendPointer(
downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, dest);