Merging ub-launcher3-master, build 5429374
Test: Manual **
Bug:111926330 [Quickstep 2] Nav bar, gestures, edge-to-edge, and OEM updates
Bug:114136250 Have a more spartan RecentsActivity on android go
Bug:118085499 UI looks different for Contacts widgets in widget screen
Bug:122843905 Polish app opening transition
Bug:126596417 [Gesture Nav] Can't quick switch from home screen
Bug:128129398 Navigation bar should be at the bottom in landscape
Bug:128348746 Gestural Nav enable/disable state should be logged to pixel launcher clearcut logging
Bug:128531133 Make TAPL diagnostics clearer
Bug:129146690 [Gesture Nav] Rounded Corners on Pixel (sailfish) flicker during Quickswitch
Bug:129328259 [Regression] Suspended app icons turn full colour during open animation
Bug:129434166 Lab-only flake: drag to workspace doesn't happen
Bug:129474866 Gesture nav crash: Can't set scaleX to infinity
Bug:129571305 [Fully Gestural Navigation] Go home on swipe up from Recents and App Drawer
Bug:129697378 [Many tests broken, PTL ASAP] "Can't detect navigation mode"Merge branch 'ub-launcher3-master' into merge_5429374
Change-Id: I458c40075bc40d22f658e02ea0673d1de452f3ce
diff --git a/Android.bp b/Android.bp
index 1121a79..5acec37 100644
--- a/Android.bp
+++ b/Android.bp
@@ -23,7 +23,6 @@
],
srcs: [
"tests/tapl/**/*.java",
- "quickstep/src/com/android/quickstep/SwipeUpSetting.java",
"src/com/android/launcher3/util/SecureSettingsObserver.java",
"src/com/android/launcher3/TestProtocol.java",
],
diff --git a/go/quickstep/src/com/android/launcher3/uioverrides/BackgroundAppState.java b/go/quickstep/src/com/android/launcher3/uioverrides/BackgroundAppState.java
deleted file mode 100644
index 4038c99..0000000
--- a/go/quickstep/src/com/android/launcher3/uioverrides/BackgroundAppState.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.uioverrides;
-
-/**
- * State indicating that the Launcher is behind an app. Same as {@link OverviewState} for Go as we
- * do not support swipe to overview or swipe to home.
- */
-public final class BackgroundAppState extends OverviewState {
- public BackgroundAppState(int id) {
- super(id);
- }
-}
diff --git a/go/quickstep/src/com/android/launcher3/uioverrides/RecentsUiFactory.java b/go/quickstep/src/com/android/launcher3/uioverrides/RecentsUiFactory.java
index 29e650c..d9b9686 100644
--- a/go/quickstep/src/com/android/launcher3/uioverrides/RecentsUiFactory.java
+++ b/go/quickstep/src/com/android/launcher3/uioverrides/RecentsUiFactory.java
@@ -17,7 +17,6 @@
package com.android.launcher3.uioverrides;
import static android.view.View.VISIBLE;
-
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import android.view.View;
@@ -26,8 +25,12 @@
import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
+import com.android.launcher3.uioverrides.touchcontrollers.LandscapeEdgeSwipeController;
+import com.android.launcher3.uioverrides.touchcontrollers.LandscapeStatesTouchController;
+import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController;
+import com.android.launcher3.uioverrides.touchcontrollers.StatusBarTouchController;
import com.android.launcher3.util.TouchController;
-import com.android.quickstep.OverviewInteractionState;
+import com.android.quickstep.SysUINavigationMode;
import com.android.quickstep.views.IconRecentsView;
import java.util.ArrayList;
@@ -49,8 +52,8 @@
list.add(new LandscapeStatesTouchController(launcher));
list.add(new LandscapeEdgeSwipeController(launcher));
} else {
- boolean allowDragToOverview = OverviewInteractionState.INSTANCE.get(launcher)
- .isSwipeUpGestureEnabled();
+ boolean allowDragToOverview = SysUINavigationMode.INSTANCE.get(launcher)
+ .getMode().hasGestures;
list.add(new PortraitStatesTouchController(launcher, allowDragToOverview));
}
if (FeatureFlags.PULL_DOWN_STATUS_BAR && Utilities.IS_DEBUG_DEVICE
diff --git a/go/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java b/go/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
similarity index 89%
rename from go/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
rename to go/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
index 14c3495..6730e97 100644
--- a/go/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java
+++ b/go/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher3.uioverrides;
+package com.android.launcher3.uioverrides.states;
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
@@ -91,4 +91,17 @@
public static float getDefaultSwipeHeight(DeviceProfile dp) {
return dp.allAppsCellHeightPx - dp.allAppsIconTextSizePx;
}
+
+
+ public static OverviewState newBackgroundState(int id) {
+ return new OverviewState(id);
+ }
+
+ public static OverviewState newPeekState(int id) {
+ return new OverviewState(id);
+ }
+
+ public static OverviewState newSwitchState(int id) {
+ return new OverviewState(id);
+ }
}
diff --git a/go/quickstep/src/com/android/launcher3/uioverrides/LandscapeStatesTouchController.java b/go/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/LandscapeStatesTouchController.java
similarity index 97%
rename from go/quickstep/src/com/android/launcher3/uioverrides/LandscapeStatesTouchController.java
rename to go/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/LandscapeStatesTouchController.java
index 2c91bc3..1ccd7d7 100644
--- a/go/quickstep/src/com/android/launcher3/uioverrides/LandscapeStatesTouchController.java
+++ b/go/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/LandscapeStatesTouchController.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.launcher3.uioverrides;
+package com.android.launcher3.uioverrides.touchcontrollers;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
diff --git a/go/quickstep/src/com/android/launcher3/uioverrides/PortraitOverviewStateTouchHelper.java b/go/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitOverviewStateTouchHelper.java
similarity index 97%
rename from go/quickstep/src/com/android/launcher3/uioverrides/PortraitOverviewStateTouchHelper.java
rename to go/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitOverviewStateTouchHelper.java
index a3b41b0..011a4e7 100644
--- a/go/quickstep/src/com/android/launcher3/uioverrides/PortraitOverviewStateTouchHelper.java
+++ b/go/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitOverviewStateTouchHelper.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.android.launcher3.uioverrides;
+package com.android.launcher3.uioverrides.touchcontrollers;
import android.view.MotionEvent;
diff --git a/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java b/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java
index 051c80f..d1d697c 100644
--- a/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java
+++ b/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java
@@ -173,8 +173,10 @@
// Keep recents visible throughout the animation.
SurfaceParams[] params = new SurfaceParams[2];
+ // Closing app should stay on top.
+ int boostedMode = MODE_CLOSING;
params[0] = new SurfaceParams(recentsTarget.leash, 1f, null /* matrix */,
- null /* windowCrop */, getLayer(recentsTarget, MODE_OPENING), 0 /* cornerRadius */);
+ null /* windowCrop */, getLayer(recentsTarget, boostedMode), 0 /* cornerRadius */);
valueAnimator.addUpdateListener(new MultiValueUpdateListener() {
private final FloatProp mScaleX;
@@ -214,7 +216,7 @@
m.postTranslate(mTranslationX.value, mTranslationY.value);
params[1] = new SurfaceParams(appTarget.leash, mAlpha.value, m,
- null /* windowCrop */, getLayer(appTarget, MODE_CLOSING),
+ null /* windowCrop */, getLayer(appTarget, boostedMode),
0 /* cornerRadius */);
surfaceApplier.scheduleApply(params);
}
diff --git a/go/quickstep/src/com/android/quickstep/RecentsActivity.java b/go/quickstep/src/com/android/quickstep/RecentsActivity.java
index 447e7e7..f2ca368 100644
--- a/go/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/go/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -67,9 +67,7 @@
@Override
protected void onStart() {
- // Set the alpha to 1 before calling super, as it may get set back to 0 due to
- // onActivityStart callback.
- mIconRecentsView.setAlpha(0);
+ mIconRecentsView.onBeginTransitionToOverview();
super.onStart();
}
}
diff --git a/go/quickstep/src/com/android/quickstep/TaskActionController.java b/go/quickstep/src/com/android/quickstep/TaskActionController.java
index b2d495b..77b287b 100644
--- a/go/quickstep/src/com/android/quickstep/TaskActionController.java
+++ b/go/quickstep/src/com/android/quickstep/TaskActionController.java
@@ -71,7 +71,6 @@
* Clears all tasks and updates the model and view.
*/
public void clearAllTasks() {
- // TODO: Play an animation so transition is more natural.
int count = mAdapter.getItemCount();
ActivityManagerWrapper.getInstance().removeAllRecentTasks();
mLoader.clearAllTasks();
diff --git a/go/quickstep/src/com/android/quickstep/TaskAdapter.java b/go/quickstep/src/com/android/quickstep/TaskAdapter.java
index e56cc51..c98eca6 100644
--- a/go/quickstep/src/com/android/quickstep/TaskAdapter.java
+++ b/go/quickstep/src/com/android/quickstep/TaskAdapter.java
@@ -75,8 +75,20 @@
// Task list has updated.
return;
}
- holder.bindTask(tasks.get(position));
-
+ Task task = tasks.get(position);
+ holder.bindTask(task);
+ mLoader.loadTaskIconAndLabel(task, () -> {
+ // Ensure holder still has the same task.
+ if (task.equals(holder.getTask())) {
+ holder.getTaskItemView().setIcon(task.icon);
+ holder.getTaskItemView().setLabel(task.titleDescription);
+ }
+ });
+ mLoader.loadTaskThumbnail(task, () -> {
+ if (task.equals(holder.getTask())) {
+ holder.getTaskItemView().setThumbnail(task.thumbnail.thumbnail);
+ }
+ });
}
@Override
diff --git a/go/quickstep/src/com/android/quickstep/TaskHolder.java b/go/quickstep/src/com/android/quickstep/TaskHolder.java
index a89229f..744afd7 100644
--- a/go/quickstep/src/com/android/quickstep/TaskHolder.java
+++ b/go/quickstep/src/com/android/quickstep/TaskHolder.java
@@ -35,17 +35,18 @@
mTaskItemView = itemView;
}
+ public TaskItemView getTaskItemView() {
+ return mTaskItemView;
+ }
+
/**
- * Bind task content to the view. This includes the task icon and title as well as binding
- * input handlers such as which task to launch/remove.
+ * Bind a task to the holder, resetting the view and preparing it for content to load in.
*
* @param task the task to bind to the view
*/
public void bindTask(Task task) {
mTask = task;
- mTaskItemView.setLabel(task.titleDescription);
- mTaskItemView.setIcon(task.icon);
- mTaskItemView.setThumbnail(task.thumbnail.thumbnail);
+ mTaskItemView.resetTaskItemView();
}
/**
diff --git a/go/quickstep/src/com/android/quickstep/TaskListLoader.java b/go/quickstep/src/com/android/quickstep/TaskListLoader.java
index c86c24e..1234989 100644
--- a/go/quickstep/src/com/android/quickstep/TaskListLoader.java
+++ b/go/quickstep/src/com/android/quickstep/TaskListLoader.java
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
/**
@@ -39,35 +38,48 @@
private ArrayList<Task> mTaskList = new ArrayList<>();
private int mTaskListChangeId;
+ private RecentsModel.TaskThumbnailChangeListener listener = (taskId, thumbnailData) -> {
+ Task foundTask = null;
+ for (Task task : mTaskList) {
+ if (task.key.id == taskId) {
+ foundTask = task;
+ break;
+ }
+ }
+ if (foundTask != null) {
+ foundTask.thumbnail = thumbnailData;
+ }
+ return foundTask;
+ };
public TaskListLoader(Context context) {
mRecentsModel = RecentsModel.INSTANCE.get(context);
+ mRecentsModel.addThumbnailChangeListener(listener);
}
/**
- * Returns the current task list as of the last completed load (see
- * {@link #loadTaskList}) as a read-only list. This list of tasks is guaranteed to always have
- * all its task content loaded.
+ * Returns the current task list as of the last completed load (see {@link #loadTaskList}) as a
+ * read-only list. This list of tasks is not guaranteed to have all content loaded.
*
- * @return the current list of tasks w/ all content loaded
+ * @return the current list of tasks
*/
public List<Task> getCurrentTaskList() {
return Collections.unmodifiableList(mTaskList);
}
/**
- * Fetches the most recent tasks and updates the task list asynchronously. In addition it
- * loads the content for each task (icon and label). The callback and task list being updated
- * only occur when all task content is fully loaded and up-to-date.
+ * Fetches the most recent tasks and updates the task list asynchronously. This call does not
+ * provide guarantees the task content (icon, thumbnail, label) are loaded but will fill in
+ * what it has. May run the callback immediately if there have been no changes in the task
+ * list.
*
- * @param onTasksLoadedCallback callback for when the tasks are fully loaded. Done on the UI
- * thread
+ * @param onLoadedCallback callback to run when task list is loaded
*/
- public void loadTaskList(@Nullable Consumer<ArrayList<Task>> onTasksLoadedCallback) {
+ public void loadTaskList(@Nullable Consumer<ArrayList<Task>> onLoadedCallback) {
if (mRecentsModel.isTaskListValid(mTaskListChangeId)) {
// Current task list is already up to date. No need to update.
- if (onTasksLoadedCallback != null) {
- onTasksLoadedCallback.accept(mTaskList);
+ if (onLoadedCallback != null) {
+ onLoadedCallback.accept(mTaskList);
}
return;
}
@@ -76,16 +88,46 @@
// Reverse tasks to put most recent at the bottom of the view
Collections.reverse(tasks);
// Load task content
- loadTaskContents(tasks, () -> {
- mTaskList = tasks;
- if (onTasksLoadedCallback != null) {
- onTasksLoadedCallback.accept(mTaskList);
+ for (Task task : tasks) {
+ int loadedPos = mTaskList.indexOf(task);
+ if (loadedPos == -1) {
+ continue;
}
- });
+ Task loadedTask = mTaskList.get(loadedPos);
+ task.icon = loadedTask.icon;
+ task.titleDescription = loadedTask.titleDescription;
+ task.thumbnail = loadedTask.thumbnail;
+ }
+ mTaskList = tasks;
+ onLoadedCallback.accept(tasks);
});
}
/**
+ * Load task icon and label asynchronously if it is not already loaded in the task. If the task
+ * already has an icon, this calls the callback immediately.
+ *
+ * @param task task to update with icon + label
+ * @param onLoadedCallback callback to run when task has icon and label
+ */
+ public void loadTaskIconAndLabel(Task task, @Nullable Runnable onLoadedCallback) {
+ mRecentsModel.getIconCache().updateIconInBackground(task,
+ loadedTask -> onLoadedCallback.run());
+ }
+
+ /**
+ * Load thumbnail asynchronously if not already loaded in the task. If the task already has a
+ * thumbnail or if the thumbnail is cached, this calls the callback immediately.
+ *
+ * @param task task to update with the thumbnail
+ * @param onLoadedCallback callback to run when task has thumbnail
+ */
+ public void loadTaskThumbnail(Task task, @Nullable Runnable onLoadedCallback) {
+ mRecentsModel.getThumbnailCache().updateThumbnailInBackground(task,
+ thumbnail -> onLoadedCallback.run());
+ }
+
+ /**
* Removes the task from the current task list.
*/
void removeTask(Task task) {
@@ -98,42 +140,4 @@
void clearAllTasks() {
mTaskList.clear();
}
-
- /**
- * Loads task content for a list of tasks, including the label, icon, and thumbnail. For content
- * that isn't cached, load the content asynchronously in the background.
- *
- * @param tasksToLoad list of tasks that need to load their content
- * @param onFullyLoadedCallback runnable to run after all tasks have loaded their content
- */
- private void loadTaskContents(ArrayList<Task> tasksToLoad,
- @Nullable Runnable onFullyLoadedCallback) {
- // Make two load requests per task, one for the icon/title and one for the thumbnail.
- AtomicInteger loadRequestsCount = new AtomicInteger(tasksToLoad.size() * 2);
- Runnable itemLoadedRunnable = () -> {
- if (loadRequestsCount.decrementAndGet() == 0 && onFullyLoadedCallback != null) {
- onFullyLoadedCallback.run();
- }
- };
- for (Task task : tasksToLoad) {
- // Load icon and title.
- int index = mTaskList.indexOf(task);
- if (index >= 0) {
- // If we've already loaded the task and have its content then just copy it over.
- Task loadedTask = mTaskList.get(index);
- task.titleDescription = loadedTask.titleDescription;
- task.icon = loadedTask.icon;
- itemLoadedRunnable.run();
- } else {
- // Otherwise, load the content in the background.
- mRecentsModel.getIconCache().updateIconInBackground(task,
- loadedTask -> itemLoadedRunnable.run());
- }
-
- // Load the thumbnail. May return immediately and synchronously if the thumbnail is
- // cached.
- mRecentsModel.getThumbnailCache().updateThumbnailInBackground(task,
- thumbnail -> itemLoadedRunnable.run());
- }
- }
}
diff --git a/go/quickstep/src/com/android/quickstep/fallback/GoRecentsActivityRootView.java b/go/quickstep/src/com/android/quickstep/fallback/GoRecentsActivityRootView.java
index d748e89..c0ebcb5 100644
--- a/go/quickstep/src/com/android/quickstep/fallback/GoRecentsActivityRootView.java
+++ b/go/quickstep/src/com/android/quickstep/fallback/GoRecentsActivityRootView.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.util.AttributeSet;
+import com.android.launcher3.util.TouchController;
import com.android.launcher3.views.BaseDragLayer;
import com.android.quickstep.RecentsActivity;
@@ -27,5 +28,7 @@
public final class GoRecentsActivityRootView extends BaseDragLayer<RecentsActivity> {
public GoRecentsActivityRootView(Context context, AttributeSet attrs) {
super(context, attrs, 1 /* alphaChannelCount */);
+ // Go leaves touch control to the view itself.
+ mControllers = new TouchController[0];
}
}
diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
index a1d62c2..5bb4c5a 100644
--- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
+++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
@@ -19,6 +19,10 @@
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
+import android.animation.PropertyValuesHolder;
+import android.animation.ValueAnimator;
import android.content.Context;
import android.util.AttributeSet;
import android.util.FloatProperty;
@@ -65,6 +69,10 @@
}
};
private static final long CROSSFADE_DURATION = 300;
+ private static final long ITEM_ANIMATE_OUT_DURATION = 150;
+ private static final long ITEM_ANIMATE_OUT_DELAY_BETWEEN = 40;
+ private static final float ITEM_ANIMATE_OUT_TRANSLATION_X_RATIO = .25f;
+ private static final long CLEAR_ALL_FADE_DELAY = 120;
/**
* A ratio representing the view's relative placement within its padded space. For example, 0
@@ -81,6 +89,7 @@
private RecyclerView mTaskRecyclerView;
private View mEmptyView;
private View mContentView;
+ private View mClearAllView;
private boolean mTransitionedFromApp;
public IconRecentsView(Context context, AttributeSet attrs) {
@@ -117,12 +126,22 @@
updateContentViewVisibility();
}
});
-
- View clearAllView = findViewById(R.id.clear_all_button);
- clearAllView.setOnClickListener(v -> mTaskActionController.clearAllTasks());
+ mClearAllView = findViewById(R.id.clear_all_button);
+ mClearAllView.setOnClickListener(v -> animateClearAllTasks());
}
}
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ TaskItemView[] itemViews = getTaskViews();
+ for (TaskItemView itemView : itemViews) {
+ itemView.setEnabled(enabled);
+ }
+ mClearAllView.setEnabled(enabled);
+ }
+
/**
* Set activity helper for the view to callback to.
*
@@ -136,8 +155,6 @@
* Logic for when we know we are going to overview/recents and will be putting up the recents
* view. This should be used to prepare recents (e.g. load any task data, etc.) before it
* becomes visible.
- *
- * TODO: Hook this up for fallback recents activity as well
*/
public void onBeginTransitionToOverview() {
// Load any task changes
@@ -195,6 +212,78 @@
}
/**
+ * Clear all tasks and animate out.
+ */
+ private void animateClearAllTasks() {
+ setEnabled(false);
+ TaskItemView[] itemViews = getTaskViews();
+
+ AnimatorSet clearAnim = new AnimatorSet();
+ long currentDelay = 0;
+
+ // Animate each item view to the right and fade out.
+ for (TaskItemView itemView : itemViews) {
+ PropertyValuesHolder transXproperty = PropertyValuesHolder.ofFloat(TRANSLATION_X,
+ 0, itemView.getWidth() * ITEM_ANIMATE_OUT_TRANSLATION_X_RATIO);
+ PropertyValuesHolder alphaProperty = PropertyValuesHolder.ofFloat(ALPHA, 1.0f, 0f);
+ ObjectAnimator itemAnim = ObjectAnimator.ofPropertyValuesHolder(itemView,
+ transXproperty, alphaProperty);
+ itemAnim.setDuration(ITEM_ANIMATE_OUT_DURATION);
+ itemAnim.setStartDelay(currentDelay);
+
+ clearAnim.play(itemAnim);
+ currentDelay += ITEM_ANIMATE_OUT_DELAY_BETWEEN;
+ }
+
+ // Animate view fading and leave recents when faded enough.
+ ValueAnimator contentAlpha = ValueAnimator.ofFloat(1.0f, 0f)
+ .setDuration(CROSSFADE_DURATION);
+ contentAlpha.setStartDelay(CLEAR_ALL_FADE_DELAY);
+ contentAlpha.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ private boolean mLeftRecents = false;
+
+ @Override
+ public void onAnimationUpdate(ValueAnimator valueAnimator) {
+ mContentView.setAlpha((float) valueAnimator.getAnimatedValue());
+ // Leave recents while fading out.
+ if ((float) valueAnimator.getAnimatedValue() < .5f && !mLeftRecents) {
+ mActivityHelper.leaveRecents();
+ mLeftRecents = true;
+ }
+ }
+ });
+
+ clearAnim.play(contentAlpha);
+ clearAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ for (TaskItemView itemView : itemViews) {
+ itemView.setTranslationX(0);
+ itemView.setAlpha(1.0f);
+ }
+ setEnabled(true);
+ mContentView.setVisibility(GONE);
+ mTaskActionController.clearAllTasks();
+ }
+ });
+ clearAnim.start();
+ }
+
+ /**
+ * Get attached task item views ordered by most recent.
+ *
+ * @return array of attached task item views
+ */
+ private TaskItemView[] getTaskViews() {
+ int taskCount = mTaskRecyclerView.getChildCount();
+ TaskItemView[] itemViews = new TaskItemView[taskCount];
+ for (int i = 0; i < taskCount; i ++) {
+ itemViews[i] = (TaskItemView) mTaskRecyclerView.getChildAt(i);
+ }
+ return itemViews;
+ }
+
+ /**
* Update the content view so that the appropriate view is shown based off the current list
* of tasks.
*/
diff --git a/go/quickstep/src/com/android/quickstep/views/TaskItemView.java b/go/quickstep/src/com/android/quickstep/views/TaskItemView.java
index 373f107..d831b20 100644
--- a/go/quickstep/src/com/android/quickstep/views/TaskItemView.java
+++ b/go/quickstep/src/com/android/quickstep/views/TaskItemView.java
@@ -17,6 +17,7 @@
import android.content.Context;
import android.graphics.Bitmap;
+import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
@@ -24,6 +25,8 @@
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.annotation.Nullable;
+
import com.android.launcher3.R;
/**
@@ -31,12 +34,16 @@
*/
public final class TaskItemView extends LinearLayout {
+ private static final String DEFAULT_LABEL = "...";
+ private final Drawable mDefaultIcon;
private TextView mLabelView;
private ImageView mIconView;
private ImageView mThumbnailView;
public TaskItemView(Context context, AttributeSet attrs) {
super(context, attrs);
+ mDefaultIcon = context.getResources().getDrawable(
+ android.R.drawable.sym_def_app_icon, context.getTheme());
}
@Override
@@ -48,33 +55,56 @@
}
/**
- * Set the label for the task item.
+ * Resets task item view to default values.
+ */
+ public void resetTaskItemView() {
+ setLabel(DEFAULT_LABEL);
+ setIcon(null);
+ setThumbnail(null);
+ }
+
+ /**
+ * Set the label for the task item. Sets to a default label if null.
*
* @param label task label
*/
- public void setLabel(String label) {
+ public void setLabel(@Nullable String label) {
+ if (label == null) {
+ mLabelView.setText(DEFAULT_LABEL);
+ return;
+ }
mLabelView.setText(label);
}
/**
- * Set the icon for the task item.
+ * Set the icon for the task item. Sets to a default icon if null.
*
* @param icon task icon
*/
- public void setIcon(Drawable icon) {
+ public void setIcon(@Nullable Drawable icon) {
// TODO: Scale the icon up based off the padding on the side
// The icon proper is actually smaller than the drawable and has "padding" on the side for
// the purpose of drawing the shadow, allowing the icon to pop up, so we need to scale the
// view if we want the icon to be flush with the bottom of the thumbnail.
+ if (icon == null) {
+ mIconView.setImageDrawable(mDefaultIcon);
+ return;
+ }
mIconView.setImageDrawable(icon);
}
/**
- * Set the task thumbnail for the task.
+ * Set the task thumbnail for the task. Sets to a default thumbnail if null.
*
* @param thumbnail task thumbnail for the task
*/
- public void setThumbnail(Bitmap thumbnail) {
+ public void setThumbnail(@Nullable Bitmap thumbnail) {
+ if (thumbnail == null) {
+ mThumbnailView.setImageBitmap(null);
+ mThumbnailView.setBackgroundColor(Color.GRAY);
+ return;
+ }
+ mThumbnailView.setBackgroundColor(Color.TRANSPARENT);
mThumbnailView.setImageBitmap(thumbnail);
}
diff --git a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
index 96b0a9e..ab4b64c 100644
--- a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
+++ b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java
@@ -61,6 +61,7 @@
mCanvas = new Canvas();
mCanvas.setDrawFilter(new PaintFlagsDrawFilter(DITHER_FLAG, FILTER_BITMAP_FLAG));
+ clear();
}
protected void clear() {
@@ -114,11 +115,6 @@
}
public BitmapInfo createBadgedIconBitmap(Drawable icon, UserHandle user,
- boolean shrinkNonAdaptiveIcons, boolean isInstantApp) {
- return createBadgedIconBitmap(icon, user, shrinkNonAdaptiveIcons, isInstantApp, null);
- }
-
- public BitmapInfo createBadgedIconBitmap(Drawable icon, UserHandle user,
int iconAppTargetSdk) {
return createBadgedIconBitmap(icon, user, iconAppTargetSdk, false);
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/FlingAndHoldTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/FlingAndHoldTouchController.java
deleted file mode 100644
index a9c8f0d..0000000
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/FlingAndHoldTouchController.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.uioverrides;
-
-import static com.android.launcher3.LauncherState.NORMAL;
-import static com.android.launcher3.LauncherState.OVERVIEW;
-import static com.android.launcher3.LauncherStateManager.NON_ATOMIC_COMPONENT;
-
-import android.animation.ValueAnimator;
-
-import com.android.launcher3.Launcher;
-import com.android.launcher3.anim.AnimatorSetBuilder;
-import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
-import com.android.quickstep.util.MotionPauseDetector;
-import com.android.quickstep.views.RecentsView;
-
-/**
- * Touch controller which handles swipe and hold to go to Overview
- */
-public class FlingAndHoldTouchController extends PortraitStatesTouchController {
-
- private final MotionPauseDetector mMotionPauseDetector;
-
- public FlingAndHoldTouchController(Launcher l) {
- super(l, false /* allowDragToOverview */);
- mMotionPauseDetector = new MotionPauseDetector(l);
- }
-
- @Override
- public void onDragStart(boolean start) {
- mMotionPauseDetector.clear();
-
- super.onDragStart(start);
-
- if (handlingOverviewAnim()) {
- mMotionPauseDetector.setOnMotionPauseListener(isPaused -> {
- RecentsView recentsView = mLauncher.getOverviewPanel();
- recentsView.setOverviewStateEnabled(isPaused);
- maybeUpdateAtomicAnim(NORMAL, OVERVIEW, isPaused ? 1 : 0);
- });
- }
- }
-
- /**
- * @return Whether we are handling the overview animation, rather than
- * having it as part of the existing animation to the target state.
- */
- private boolean handlingOverviewAnim() {
- return mStartState == NORMAL;
- }
-
- @Override
- public boolean onDrag(float displacement) {
- mMotionPauseDetector.addPosition(displacement, 0);
- return super.onDrag(displacement);
- }
-
- @Override
- public void onDragEnd(float velocity, boolean fling) {
- if (mMotionPauseDetector.isPaused() && handlingOverviewAnim()) {
- float range = getShiftRange();
- long maxAccuracy = (long) (2 * range);
-
- // Let the state manager know that the animation didn't go to the target state,
- // but don't cancel ourselves (we already clean up when the animation completes).
- Runnable onCancel = mCurrentAnimation.getOnCancelRunnable();
- mCurrentAnimation.setOnCancelRunnable(null);
- mCurrentAnimation.dispatchOnCancel();
- mCurrentAnimation = mLauncher.getStateManager()
- .createAnimationToNewWorkspace(OVERVIEW, new AnimatorSetBuilder(), maxAccuracy,
- onCancel, NON_ATOMIC_COMPONENT);
-
- final int logAction = fling ? Touch.FLING : Touch.SWIPE;
- mCurrentAnimation.setEndAction(() -> onSwipeInteractionCompleted(OVERVIEW, logAction));
-
-
- ValueAnimator anim = mCurrentAnimation.getAnimationPlayer();
- maybeUpdateAtomicAnim(NORMAL, OVERVIEW, 1f);
- mCurrentAnimation.dispatchOnStartWithVelocity(1, velocity);
-
- // TODO: Find a better duration
- anim.setDuration(100);
- anim.start();
- settleAtomicAnimation(1f, anim.getDuration());
- } else {
- super.onDragEnd(velocity, fling);
- }
- mMotionPauseDetector.clear();
- }
-
- @Override
- protected void updateAnimatorBuilderOnReinit(AnimatorSetBuilder builder) {
- if (handlingOverviewAnim()) {
- // We don't want the state transition to all apps to animate overview,
- // as that will cause a jump after our atomic animation.
- builder.addFlag(AnimatorSetBuilder.FLAG_DONT_ANIMATE_OVERVIEW);
- }
- }
-}
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java
index 81ff0c7..f507d0f 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java
@@ -17,11 +17,9 @@
package com.android.launcher3.uioverrides;
import static android.view.View.VISIBLE;
-
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
-import static com.android.launcher3.config.FeatureFlags.SWIPE_HOME;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
@@ -30,10 +28,19 @@
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.config.FeatureFlags;
+import com.android.launcher3.uioverrides.touchcontrollers.FlingAndHoldTouchController;
+import com.android.launcher3.uioverrides.touchcontrollers.LandscapeEdgeSwipeController;
+import com.android.launcher3.uioverrides.touchcontrollers.NavBarToHomeTouchController;
+import com.android.launcher3.uioverrides.touchcontrollers.OverviewToAllAppsTouchController;
+import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController;
+import com.android.launcher3.uioverrides.touchcontrollers.StatusBarTouchController;
+import com.android.launcher3.uioverrides.touchcontrollers.QuickSwitchTouchController;
+import com.android.launcher3.uioverrides.touchcontrollers.TaskViewTouchController;
import com.android.launcher3.util.TouchController;
import com.android.launcher3.util.UiThreadHelper;
import com.android.launcher3.util.UiThreadHelper.AsyncCommand;
-import com.android.quickstep.OverviewInteractionState;
+import com.android.quickstep.SysUINavigationMode;
+import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.system.WindowManagerWrapper;
@@ -52,15 +59,13 @@
private static final float RECENTS_PREPARE_SCALE = 1.33f;
public static TouchController[] createTouchControllers(Launcher launcher) {
- boolean swipeUpEnabled = OverviewInteractionState.INSTANCE.get(launcher)
- .isSwipeUpGestureEnabled();
- boolean swipeUpToHome = swipeUpEnabled && SWIPE_HOME.get();
-
+ Mode mode = SysUINavigationMode.INSTANCE.get(launcher).getMode();
ArrayList<TouchController> list = new ArrayList<>();
list.add(launcher.getDragController());
-
- if (swipeUpToHome) {
+ if (mode == Mode.NO_BUTTON) {
+ list.add(new QuickSwitchTouchController(launcher));
+ list.add(new NavBarToHomeTouchController(launcher));
list.add(new FlingAndHoldTouchController(launcher));
} else {
if (launcher.getDeviceProfile().isVerticalBarLayout()) {
@@ -68,7 +73,10 @@
list.add(new LandscapeEdgeSwipeController(launcher));
} else {
list.add(new PortraitStatesTouchController(launcher,
- swipeUpEnabled /* allowDragToOverview */));
+ mode.hasGestures /* allowDragToOverview */));
+ if (mode.hasGestures) {
+ list.add(new QuickSwitchTouchController(launcher));
+ }
}
}
@@ -98,6 +106,10 @@
* @param launcher the launcher activity
*/
public static void prepareToShowOverview(Launcher launcher) {
+ if (FeatureFlags.SWIPE_HOME.get()) {
+ // Overview lives on the side, so doesn't scale in from above.
+ return;
+ }
RecentsView overview = launcher.getOverviewPanel();
if (overview.getVisibility() != VISIBLE || overview.getContentAlpha() == 0) {
SCALE_PROPERTY.set(overview, RECENTS_PREPARE_SCALE);
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/BackgroundAppState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java
similarity index 98%
rename from quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/BackgroundAppState.java
rename to quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java
index 726ae05..d8f1628 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/BackgroundAppState.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.launcher3.uioverrides;
+package com.android.launcher3.uioverrides.states;
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewPeekState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewPeekState.java
new file mode 100644
index 0000000..bc1d4ba
--- /dev/null
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewPeekState.java
@@ -0,0 +1,32 @@
+/*
+ * 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.uioverrides.states;
+import com.android.launcher3.Launcher;
+import com.android.launcher3.R;
+
+public class OverviewPeekState extends OverviewState {
+ public OverviewPeekState(int id) {
+ super(id);
+ }
+
+ @Override
+ public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) {
+ ScaleAndTranslation result = super.getOverviewScaleAndTranslation(launcher);
+ result.translationX = NORMAL.getOverviewScaleAndTranslation(launcher).translationX
+ - launcher.getResources().getDimension(R.dimen.overview_peek_distance);
+ return result;
+ }
+}
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java
similarity index 89%
rename from quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewState.java
rename to quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java
index db02c53..94c1545 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewState.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java
@@ -13,11 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.launcher3.uioverrides;
+package com.android.launcher3.uioverrides.states;
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
+import static com.android.launcher3.logging.LoggerUtils.getTargetStr;
import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
import static com.android.launcher3.states.RotationHelper.REQUEST_ROTATE;
@@ -52,7 +53,11 @@
}
protected OverviewState(int id, int transitionDuration, int stateFlags) {
- super(id, ContainerType.TASKSWITCHER, transitionDuration, stateFlags);
+ this(id, ContainerType.TASKSWITCHER, transitionDuration, stateFlags);
+ }
+
+ protected OverviewState(int id, int logContainer, int transitionDuration, int stateFlags) {
+ super(id, logContainer, transitionDuration, stateFlags);
}
@Override
@@ -92,6 +97,7 @@
DiscoveryBounce.showForOverviewIfNeeded(launcher);
}
+ @Override
public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) {
return new PageAlphaProvider(DEACCEL_2) {
@Override
@@ -151,4 +157,16 @@
super.onBackPressed(launcher);
}
}
+
+ public static OverviewState newBackgroundState(int id) {
+ return new BackgroundAppState(id);
+ }
+
+ public static OverviewState newPeekState(int id) {
+ return new OverviewPeekState(id);
+ }
+
+ public static OverviewState newSwitchState(int id) {
+ return new QuickSwitchState(id);
+ }
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java
new file mode 100644
index 0000000..fa07e27
--- /dev/null
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java
@@ -0,0 +1,89 @@
+/*
+ * 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.uioverrides.states;
+
+import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
+
+import android.graphics.Rect;
+
+import com.android.launcher3.Launcher;
+import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.quickstep.util.ClipAnimationHelper;
+import com.android.quickstep.views.RecentsView;
+import com.android.quickstep.views.TaskThumbnailView;
+import com.android.quickstep.views.TaskView;
+
+/**
+ * State to indicate we are about to launch a recent task. Note that this state is only used when
+ * quick switching from launcher; quick switching from an app uses WindowTransformSwipeHelper.
+ * @see com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget#NEW_TASK
+ */
+public class QuickSwitchState extends OverviewState {
+ private static final int STATE_FLAGS =
+ FLAG_DISABLE_RESTORE | FLAG_OVERVIEW_UI | FLAG_DISABLE_ACCESSIBILITY;
+
+ public QuickSwitchState(int id) {
+ super(id, LauncherLogProto.ContainerType.APP, OVERVIEW_TRANSITION_MS, STATE_FLAGS);
+ }
+
+ @Override
+ public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) {
+ RecentsView recentsView = launcher.getOverviewPanel();
+ if (recentsView.getTaskViewCount() == 0) {
+ return super.getOverviewScaleAndTranslation(launcher);
+ }
+ // Compute scale and translation y such that the most recent task view fills the screen.
+ TaskThumbnailView dummyThumbnail = recentsView.getTaskViewAt(0).getThumbnail();
+ ClipAnimationHelper clipAnimationHelper = new ClipAnimationHelper(launcher);
+ clipAnimationHelper.fromTaskThumbnailView(dummyThumbnail, recentsView);
+ Rect targetRect = new Rect();
+ recentsView.getTaskSize(targetRect);
+ clipAnimationHelper.updateTargetRect(targetRect);
+ float toScale = clipAnimationHelper.getSourceRect().width()
+ / clipAnimationHelper.getTargetRect().width();
+ float toTranslationY = clipAnimationHelper.getSourceRect().centerY()
+ - clipAnimationHelper.getTargetRect().centerY();
+ return new ScaleAndTranslation(toScale, 0, toTranslationY);
+ }
+
+ @Override
+ public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
+ float shiftRange = launcher.getAllAppsController().getShiftRange();
+ float shiftProgress = getVerticalProgress(launcher) - NORMAL.getVerticalProgress(launcher);
+ float translationY = shiftProgress * shiftRange;
+ return new ScaleAndTranslation(1, 0, translationY);
+ }
+
+ @Override
+ public float getVerticalProgress(Launcher launcher) {
+ return BACKGROUND_APP.getVerticalProgress(launcher);
+ }
+
+ @Override
+ public int getVisibleElements(Launcher launcher) {
+ return NONE;
+ }
+
+ @Override
+ public void onStateTransitionEnd(Launcher launcher) {
+ TaskView tasktolaunch = launcher.<RecentsView>getOverviewPanel().getTaskViewAt(0);
+ if (tasktolaunch != null) {
+ tasktolaunch.launchTask(false);
+ } else {
+ launcher.getStateManager().goToState(NORMAL);
+ }
+ }
+}
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/FlingAndHoldTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/FlingAndHoldTouchController.java
new file mode 100644
index 0000000..0757e85
--- /dev/null
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/FlingAndHoldTouchController.java
@@ -0,0 +1,136 @@
+/*
+ * 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.uioverrides.touchcontrollers;
+
+import static com.android.launcher3.LauncherState.NORMAL;
+import static com.android.launcher3.LauncherState.OVERVIEW;
+import static com.android.launcher3.LauncherState.OVERVIEW_PEEK;
+import static com.android.launcher3.LauncherStateManager.ANIM_ALL;
+import static com.android.launcher3.LauncherStateManager.ATOMIC_OVERVIEW_PEEK_COMPONENT;
+import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.AnimatorSet;
+import android.view.HapticFeedbackConstants;
+
+import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherState;
+import com.android.launcher3.anim.AnimatorSetBuilder;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
+import com.android.quickstep.util.MotionPauseDetector;
+import com.android.quickstep.views.RecentsView;
+
+/**
+ * Touch controller which handles swipe and hold to go to Overview
+ */
+public class FlingAndHoldTouchController extends PortraitStatesTouchController {
+
+ private static final long PEEK_ANIM_DURATION = 100;
+
+ private final MotionPauseDetector mMotionPauseDetector;
+
+ private AnimatorSet mPeekAnim;
+
+ public FlingAndHoldTouchController(Launcher l) {
+ super(l, false /* allowDragToOverview */);
+ mMotionPauseDetector = new MotionPauseDetector(l);
+ }
+
+ @Override
+ protected long getAtomicDuration() {
+ return 300;
+ }
+
+ @Override
+ public void onDragStart(boolean start) {
+ mMotionPauseDetector.clear();
+
+ super.onDragStart(start);
+
+ if (handlingOverviewAnim()) {
+ mMotionPauseDetector.setOnMotionPauseListener(isPaused -> {
+ RecentsView recentsView = mLauncher.getOverviewPanel();
+ recentsView.setOverviewStateEnabled(isPaused);
+ if (mPeekAnim != null) {
+ mPeekAnim.cancel();
+ }
+ LauncherState fromState = isPaused ? NORMAL : OVERVIEW_PEEK;
+ LauncherState toState = isPaused ? OVERVIEW_PEEK : NORMAL;
+ mPeekAnim = mLauncher.getStateManager().createAtomicAnimation(fromState, toState,
+ new AnimatorSetBuilder(), ATOMIC_OVERVIEW_PEEK_COMPONENT,
+ PEEK_ANIM_DURATION);
+ mPeekAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mPeekAnim = null;
+ }
+ });
+ mPeekAnim.start();
+ recentsView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
+ HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
+ });
+ }
+ }
+
+ /**
+ * @return Whether we are handling the overview animation, rather than
+ * having it as part of the existing animation to the target state.
+ */
+ private boolean handlingOverviewAnim() {
+ return mStartState == NORMAL;
+ }
+
+ @Override
+ public boolean onDrag(float displacement) {
+ mMotionPauseDetector.addPosition(displacement, 0);
+ return super.onDrag(displacement);
+ }
+
+ @Override
+ public void onDragEnd(float velocity, boolean fling) {
+ if (mMotionPauseDetector.isPaused() && handlingOverviewAnim()) {
+ if (mPeekAnim != null) {
+ mPeekAnim.cancel();
+ }
+
+ AnimatorSetBuilder builder = new AnimatorSetBuilder();
+ builder.setInterpolator(AnimatorSetBuilder.ANIM_VERTICAL_PROGRESS, OVERSHOOT_1_2);
+ AnimatorSet overviewAnim = mLauncher.getStateManager().createAtomicAnimation(
+ NORMAL, OVERVIEW, builder, ANIM_ALL, ATOMIC_DURATION);
+ overviewAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ onSwipeInteractionCompleted(OVERVIEW, Touch.SWIPE);
+ }
+ });
+ overviewAnim.start();
+ } else {
+ super.onDragEnd(velocity, fling);
+ }
+ mMotionPauseDetector.clear();
+ }
+
+ @Override
+ protected void updateAnimatorBuilderOnReinit(AnimatorSetBuilder builder) {
+ if (handlingOverviewAnim()) {
+ // We don't want the state transition to all apps to animate overview,
+ // as that will cause a jump after our atomic animation.
+ builder.addFlag(AnimatorSetBuilder.FLAG_DONT_ANIMATE_OVERVIEW);
+ }
+ }
+}
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java
new file mode 100644
index 0000000..673beff
--- /dev/null
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NavBarToHomeTouchController.java
@@ -0,0 +1,141 @@
+/*
+ * 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.uioverrides.touchcontrollers;
+
+import static com.android.launcher3.LauncherState.ALL_APPS;
+import static com.android.launcher3.LauncherState.NORMAL;
+import static com.android.launcher3.LauncherState.OVERVIEW;
+import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
+import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
+
+import android.animation.Animator;
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.animation.Interpolator;
+
+import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherState;
+import com.android.launcher3.LauncherStateManager.AnimationConfig;
+import com.android.launcher3.Utilities;
+import com.android.launcher3.allapps.AllAppsTransitionController;
+import com.android.launcher3.anim.AnimatorPlaybackController;
+import com.android.launcher3.anim.AnimatorSetBuilder;
+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;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
+import com.android.quickstep.views.RecentsView;
+
+/**
+ * Handles swiping up on the nav bar to go home from overview or all apps.
+ */
+public class NavBarToHomeTouchController extends AbstractStateChangeTouchController {
+
+ private static final Interpolator PULLBACK_INTERPOLATOR = DEACCEL_3;
+
+ public NavBarToHomeTouchController(Launcher launcher) {
+ super(launcher, SwipeDetector.VERTICAL);
+ }
+
+ @Override
+ protected boolean canInterceptTouch(MotionEvent ev) {
+ boolean cameFromNavBar = (ev.getEdgeFlags() & Utilities.EDGE_NAV_BAR) != 0;
+ return cameFromNavBar && (mLauncher.isInState(OVERVIEW) || mLauncher.isInState(ALL_APPS));
+ }
+
+ @Override
+ protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) {
+ return isDragTowardPositive ? NORMAL : fromState;
+ }
+
+ @Override
+ protected float initCurrentAnimation(int animComponents) {
+ long accuracy = (long) (getShiftRange() * 2);
+ final AnimatorSet anim;
+ if (mFromState == OVERVIEW) {
+ anim = new AnimatorSet();
+ RecentsView recentsView = mLauncher.getOverviewPanel();
+ float pullbackDistance = recentsView.getPaddingStart() / 2;
+ if (!recentsView.isRtl()) {
+ pullbackDistance = -pullbackDistance;
+ }
+ anim.play(ObjectAnimator.ofFloat(recentsView, View.TRANSLATION_X, pullbackDistance));
+ anim.setInterpolator(PULLBACK_INTERPOLATOR);
+ } else { // if (mFromState == ALL_APPS)
+ AnimatorSetBuilder builder = new AnimatorSetBuilder();
+ AllAppsTransitionController allAppsController = mLauncher.getAllAppsController();
+ final float pullbackDistance = mLauncher.getDeviceProfile().allAppsIconSizePx / 2;
+ Animator allAppsProgress = ObjectAnimator.ofFloat(allAppsController, ALL_APPS_PROGRESS,
+ -pullbackDistance / allAppsController.getShiftRange());
+ allAppsProgress.setInterpolator(PULLBACK_INTERPOLATOR);
+ builder.play(allAppsProgress);
+ // Slightly fade out all apps content to further distinguish from scrolling.
+ builder.setInterpolator(AnimatorSetBuilder.ANIM_ALL_APPS_FADE, Interpolators
+ .mapToProgress(PULLBACK_INTERPOLATOR, 0, 0.5f));
+ AnimationConfig config = new AnimationConfig();
+ config.duration = accuracy;
+ allAppsController.setAlphas(mToState.getVisibleElements(mLauncher), config, builder);
+ anim = builder.build();
+ }
+ anim.setDuration(accuracy);
+ mCurrentAnimation = AnimatorPlaybackController.wrap(anim, accuracy, this::clearState);
+ return -1 / getShiftRange();
+ }
+
+ @Override
+ public void onDragStart(boolean start) {
+ super.onDragStart(start);
+ mStartContainerType = LauncherLogProto.ContainerType.NAVBAR;
+ }
+
+ @Override
+ public void onDragEnd(float velocity, boolean fling) {
+ final int logAction = fling ? Touch.FLING : Touch.SWIPE;
+ float interpolatedProgress = PULLBACK_INTERPOLATOR.getInterpolation(
+ mCurrentAnimation.getProgressFraction());
+ if (interpolatedProgress >= SUCCESS_TRANSITION_PROGRESS || velocity < 0 && fling) {
+ mLauncher.getStateManager().goToState(mToState, true,
+ () -> onSwipeInteractionCompleted(mToState, logAction));
+ } else {
+ // Quickly return to the state we came from (we didn't move far).
+ AnimatorPlaybackController anim = mLauncher.getStateManager()
+ .createAnimationToNewWorkspace(mFromState, 80);
+ anim.setEndAction(() -> onSwipeInteractionCompleted(mFromState, logAction));
+ anim.start();
+ }
+ mCurrentAnimation.dispatchOnCancel();
+ }
+
+ @Override
+ protected int getDirectionForLog() {
+ return LauncherLogProto.Action.Direction.UP;
+ }
+
+ @Override
+ protected boolean goingBetweenNormalAndOverview(LauncherState fromState,
+ LauncherState toState) {
+ // We don't want to create an atomic animation to/from overview.
+ return false;
+ }
+
+ @Override
+ protected int getLogContainerTypeForNormalState() {
+ return LauncherLogProto.ContainerType.NAVBAR;
+ }
+}
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewToAllAppsTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/OverviewToAllAppsTouchController.java
similarity index 97%
rename from quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewToAllAppsTouchController.java
rename to quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/OverviewToAllAppsTouchController.java
index a069ed5..82ab34b 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewToAllAppsTouchController.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/OverviewToAllAppsTouchController.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.launcher3.uioverrides;
+package com.android.launcher3.uioverrides.touchcontrollers;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.NORMAL;
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PortraitOverviewStateTouchHelper.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitOverviewStateTouchHelper.java
similarity index 94%
rename from quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PortraitOverviewStateTouchHelper.java
rename to quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitOverviewStateTouchHelper.java
index eead4c8..5337c39 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/PortraitOverviewStateTouchHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitOverviewStateTouchHelper.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package com.android.launcher3.uioverrides;
+package com.android.launcher3.uioverrides.touchcontrollers;
-import static com.android.launcher3.uioverrides.PortraitStatesTouchController.isTouchOverHotseat;
+import static com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController.isTouchOverHotseat;
import android.view.MotionEvent;
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
new file mode 100644
index 0000000..91a31dd
--- /dev/null
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/QuickSwitchTouchController.java
@@ -0,0 +1,147 @@
+/*
+ * 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.uioverrides.touchcontrollers;
+
+import static com.android.launcher3.LauncherState.NORMAL;
+import static com.android.launcher3.LauncherState.QUICK_SWITCH;
+import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_ALL_APPS_FADE;
+import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE;
+import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE;
+import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATE_Y;
+import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_VERTICAL_PROGRESS;
+import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_FADE;
+import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_TRANSLATE;
+import static com.android.launcher3.anim.Interpolators.ACCEL_2;
+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 android.view.MotionEvent;
+
+import com.android.launcher3.Launcher;
+import com.android.launcher3.LauncherState;
+import com.android.launcher3.LauncherStateManager;
+import com.android.launcher3.Utilities;
+import com.android.launcher3.anim.AnimatorSetBuilder;
+import com.android.launcher3.config.FeatureFlags;
+import com.android.launcher3.touch.AbstractStateChangeTouchController;
+import com.android.launcher3.touch.SwipeDetector;
+import com.android.launcher3.userevent.nano.LauncherLogProto;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction;
+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.
+ */
+public class QuickSwitchTouchController extends AbstractStateChangeTouchController {
+
+ private @Nullable TaskView mTaskToLaunch;
+
+ public QuickSwitchTouchController(Launcher launcher) {
+ super(launcher, SwipeDetector.HORIZONTAL);
+ }
+
+ @Override
+ protected boolean canInterceptTouch(MotionEvent ev) {
+ if (mCurrentAnimation != null) {
+ return true;
+ }
+ if (!mLauncher.isInState(LauncherState.NORMAL)) {
+ return false;
+ }
+ if ((ev.getEdgeFlags() & Utilities.EDGE_NAV_BAR) == 0) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) {
+ return isDragTowardPositive ? QUICK_SWITCH : NORMAL;
+ }
+
+ @Override
+ public void onDragStart(boolean start) {
+ super.onDragStart(start);
+ mStartContainerType = LauncherLogProto.ContainerType.NAVBAR;
+ mTaskToLaunch = mLauncher.<RecentsView>getOverviewPanel().getTaskViewAt(0);
+ }
+
+ @Override
+ protected void onSwipeInteractionCompleted(LauncherState targetState, int logAction) {
+ super.onSwipeInteractionCompleted(targetState, logAction);
+ mTaskToLaunch = null;
+ }
+
+ @Override
+ protected float initCurrentAnimation(int animComponents) {
+ AnimatorSetBuilder animatorSetBuilder = new AnimatorSetBuilder();
+ setupInterpolators(animatorSetBuilder);
+ long accuracy = (long) (getShiftRange() * 2);
+ mCurrentAnimation = mLauncher.getStateManager().createAnimationToNewWorkspace(mToState,
+ animatorSetBuilder, accuracy, this::clearState, LauncherStateManager.ANIM_ALL);
+ mCurrentAnimation.getAnimationPlayer().addUpdateListener(valueAnimator -> {
+ updateFullscreenProgress((Float) valueAnimator.getAnimatedValue());
+ });
+ return 1 / getShiftRange();
+ }
+
+ private void setupInterpolators(AnimatorSetBuilder animatorSetBuilder) {
+ animatorSetBuilder.setInterpolator(ANIM_WORKSPACE_FADE, DEACCEL_2);
+ animatorSetBuilder.setInterpolator(ANIM_ALL_APPS_FADE, DEACCEL_2);
+ if (FeatureFlags.SWIPE_HOME.get()) {
+ // Overview lives to the left of workspace, so translate down later than over
+ animatorSetBuilder.setInterpolator(ANIM_WORKSPACE_TRANSLATE, ACCEL_2);
+ animatorSetBuilder.setInterpolator(ANIM_VERTICAL_PROGRESS, ACCEL_2);
+ animatorSetBuilder.setInterpolator(ANIM_OVERVIEW_SCALE, ACCEL_2);
+ animatorSetBuilder.setInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, ACCEL_2);
+ animatorSetBuilder.setInterpolator(ANIM_OVERVIEW_FADE, INSTANT);
+ } else {
+ animatorSetBuilder.setInterpolator(ANIM_WORKSPACE_TRANSLATE, LINEAR);
+ animatorSetBuilder.setInterpolator(ANIM_VERTICAL_PROGRESS, LINEAR);
+ }
+ }
+
+ @Override
+ protected void updateProgress(float progress) {
+ super.updateProgress(progress);
+ updateFullscreenProgress(progress);
+ }
+
+ private void updateFullscreenProgress(float progress) {
+ if (mTaskToLaunch != null) {
+ mTaskToLaunch.setFullscreenProgress(progress);
+ }
+ }
+
+ @Override
+ protected float getShiftRange() {
+ return mLauncher.getDeviceProfile().widthPx / 2f;
+ }
+
+ @Override
+ protected int getLogContainerTypeForNormalState() {
+ return LauncherLogProto.ContainerType.NAVBAR;
+ }
+
+ @Override
+ protected int getDirectionForLog() {
+ return Utilities.isRtl(mLauncher.getResources()) ? Direction.LEFT : Direction.RIGHT;
+ }
+}
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/TaskViewTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
similarity index 97%
rename from quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/TaskViewTouchController.java
rename to quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
index fb1828b..62d954b 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/TaskViewTouchController.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.launcher3.uioverrides;
+package com.android.launcher3.uioverrides.touchcontrollers;
import static com.android.launcher3.AbstractFloatingView.TYPE_ACCESSIBLE;
import static com.android.launcher3.Utilities.SINGLE_FRAME_MS;
@@ -38,7 +38,7 @@
import com.android.launcher3.util.PendingAnimation;
import com.android.launcher3.util.TouchController;
import com.android.launcher3.views.BaseDragLayer;
-import com.android.quickstep.OverviewInteractionState;
+import com.android.quickstep.SysUINavigationMode;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
@@ -123,8 +123,7 @@
if (mRecentsView.isTaskViewVisible(view) && mActivity.getDragLayer()
.isEventOverView(view, ev)) {
mTaskBeingDragged = view;
- if (!OverviewInteractionState.INSTANCE.get(mActivity)
- .isSwipeUpGestureEnabled()) {
+ if (!SysUINavigationMode.INSTANCE.get(mActivity).getMode().hasGestures) {
// Don't allow swipe down to open if we don't support swipe up
// to enter overview.
directionsToDetectScroll = SwipeDetector.DIRECTION_POSITIVE;
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityControllerHelper.java
index 8f4818b..73fcf78 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityControllerHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityControllerHelper.java
@@ -16,6 +16,7 @@
package com.android.quickstep;
import static com.android.launcher3.anim.Interpolators.LINEAR;
+import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA;
import android.animation.Animator;
@@ -60,7 +61,7 @@
public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect) {
LayoutUtils.calculateFallbackTaskSize(context, dp, outRect);
if (dp.isVerticalBarLayout()
- && !NavBarModeOverlayResourceObserver.isEdgeToEdgeModeEnabled(context)) {
+ && SysUINavigationMode.INSTANCE.get(context).getMode() != NO_BUTTON) {
Rect targetInsets = dp.getInsets();
int hotseatInset = dp.isSeascape() ? targetInsets.left : targetInsets.right;
return dp.hotseatBarSizePx + hotseatInset;
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 07fa2a5..df2b687 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
@@ -24,6 +24,7 @@
import static com.android.launcher3.allapps.AllAppsTransitionController.SPRING_STIFFNESS;
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
import static com.android.launcher3.anim.Interpolators.LINEAR;
+import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -75,7 +76,7 @@
public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect) {
LayoutUtils.calculateLauncherTaskSize(context, dp, outRect);
if (dp.isVerticalBarLayout()
- && !NavBarModeOverlayResourceObserver.isEdgeToEdgeModeEnabled(context)) {
+ && SysUINavigationMode.INSTANCE.get(context).getMode() != NO_BUTTON) {
Rect targetInsets = dp.getInsets();
int hotseatInset = dp.isSeascape() ? targetInsets.left : targetInsets.right;
return dp.hotseatBarSizePx + hotseatInset;
@@ -114,8 +115,7 @@
final Rect iconLocation = new Rect();
final FloatingIconView floatingView = workspaceView == null ? null
: FloatingIconView.getFloatingIconView(activity, workspaceView,
- true /* hideOriginal */, false /* useDrawableAsIs */,
- activity.getDeviceProfile().getAspectRatioWithInsets(), iconLocation, null);
+ true /* hideOriginal */, iconLocation, false /* isOpening */, null /* recycle */);
return new HomeAnimationFactory() {
@Nullable
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java
index bcde13f..63c2e5d 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/OtherActivityInputConsumer.java
@@ -24,6 +24,7 @@
import static com.android.launcher3.util.RaceConditionTracker.ENTER;
import static com.android.launcher3.util.RaceConditionTracker.EXIT;
import static com.android.launcher3.Utilities.EDGE_NAV_BAR;
+import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
import static com.android.quickstep.TouchInteractionService.TOUCH_INTERACTION_LOG;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS;
@@ -284,12 +285,12 @@
}
private boolean isNavBarOnRight() {
- return !NavBarModeOverlayResourceObserver.isEdgeToEdgeModeEnabled(getBaseContext())
+ return SysUINavigationMode.INSTANCE.get(getBaseContext()).getMode() != NO_BUTTON
&& mDisplayRotation == Surface.ROTATION_90 && mStableInsets.right > 0;
}
private boolean isNavBarOnLeft() {
- return !NavBarModeOverlayResourceObserver.isEdgeToEdgeModeEnabled(getBaseContext())
+ return SysUINavigationMode.INSTANCE.get(getBaseContext()).getMode() != NO_BUTTON
&& mDisplayRotation == Surface.ROTATION_270 && mStableInsets.left > 0;
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewInputConsumer.java
index cda2a1a..3ebe968 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/OverviewInputConsumer.java
@@ -19,7 +19,6 @@
import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_MOVE;
import static android.view.MotionEvent.ACTION_UP;
-
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.quickstep.TouchInteractionService.TOUCH_INTERACTION_LOG;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS;
@@ -46,7 +45,7 @@
private final BaseDragLayer mTarget;
private final int[] mLocationOnScreen = new int[2];
private final PointF mDownPos = new PointF();
- private final int mTouchSlop;
+ private final int mTouchSlopSquared;
private final boolean mStartingInActivityBounds;
@@ -56,7 +55,8 @@
OverviewInputConsumer(T activity, boolean startingInActivityBounds) {
mActivity = activity;
mTarget = activity.getDragLayer();
- mTouchSlop = ViewConfiguration.get(mActivity).getScaledTouchSlop();
+ int touchSlop = ViewConfiguration.get(mActivity).getScaledTouchSlop();
+ mTouchSlopSquared = touchSlop * touchSlop;
mStartingInActivityBounds = startingInActivityBounds;
}
@@ -88,10 +88,11 @@
false /* closeActiveWindows */);
break;
case ACTION_MOVE: {
- float displacement = mActivity.getDeviceProfile().isLandscape ?
- ev.getX() - mDownPos.x : ev.getY() - mDownPos.y;
- if (Math.abs(displacement) >= mTouchSlop) {
- // Start tracking only when mTouchSlop is crossed.
+ float x = ev.getX() - mDownPos.x;
+ float y = ev.getY() - mDownPos.y;
+ double hypotSquared = x * x + y * y;
+ if (hypotSquared >= mTouchSlopSquared) {
+ // Start tracking only when touch slop is crossed.
startTouchTracking(ev, true /* updateLocationOffset */,
true /* closeActiveWindows */);
}
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 8fe0461..323dd9a 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java
@@ -44,10 +44,10 @@
import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.UserManagerCompat;
-import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.EventLogArray;
import com.android.launcher3.util.LooperExecutor;
import com.android.launcher3.util.UiThreadHelper;
+import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -315,8 +315,8 @@
mOverviewComponentObserver.getActivityControlHelper();
if (runningTaskInfo == null && !mSwipeSharedState.goingToLauncher) {
return InputConsumer.NO_OP;
- } else if (mAssistantAvailable && mOverviewInteractionState.isSwipeUpGestureEnabled()
- && FeatureFlags.ENABLE_ASSISTANT_GESTURE.get()
+ } else if (mAssistantAvailable
+ && SysUINavigationMode.INSTANCE.get(this).getMode() == Mode.NO_BUTTON
&& AssistantTouchConsumer.withinTouchRegion(this, event)) {
return new AssistantTouchConsumer(this, mISystemUiProxy, !activityControl.isResumed()
? createOtherActivityInputConsumer(event, runningTaskInfo) : null);
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 15072a2..0065cb5 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -28,6 +28,7 @@
import static com.android.launcher3.config.FeatureFlags.SWIPE_HOME;
import static com.android.launcher3.util.RaceConditionTracker.ENTER;
import static com.android.launcher3.util.RaceConditionTracker.EXIT;
+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;
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
@@ -945,7 +946,7 @@
// We want the window alpha to be 0 once this threshold is met, so that the
// FolderIconView can be seen morphing into the icon shape.
- final float windowAlphaThreshold = isFloatingIconView ? 0.75f : 1f;
+ final float windowAlphaThreshold = isFloatingIconView ? 1f - SHAPE_PROGRESS_DURATION : 1f;
anim.addOnUpdateListener((currentRect, progress) -> {
float interpolatedProgress = Interpolators.ACCEL_1_5.getInterpolation(progress);
@@ -959,7 +960,7 @@
if (isFloatingIconView) {
((FloatingIconView) floatingView).update(currentRect, iconAlpha, progress,
- windowAlphaThreshold);
+ windowAlphaThreshold, mClipAnimationHelper.getCurrentCornerRadius(), false);
}
});
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/fallback/RecentsTaskController.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/fallback/RecentsTaskController.java
index 9463cc9..a113604 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/fallback/RecentsTaskController.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/fallback/RecentsTaskController.java
@@ -15,7 +15,7 @@
*/
package com.android.quickstep.fallback;
-import com.android.launcher3.uioverrides.TaskViewTouchController;
+import com.android.launcher3.uioverrides.touchcontrollers.TaskViewTouchController;
import com.android.quickstep.RecentsActivity;
public class RecentsTaskController extends TaskViewTouchController<RecentsActivity> {
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java
index 8da1d2b..329436b 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/LauncherRecentsView.java
@@ -32,9 +32,7 @@
import android.graphics.Rect;
import android.os.Build;
import android.util.AttributeSet;
-import android.util.FloatProperty;
import android.view.View;
-import android.view.ViewDebug;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
@@ -44,7 +42,7 @@
import com.android.launcher3.util.PendingAnimation;
import com.android.launcher3.views.BaseDragLayer;
import com.android.launcher3.views.ScrimView;
-import com.android.quickstep.OverviewInteractionState;
+import com.android.quickstep.SysUINavigationMode;
import com.android.quickstep.hints.ChipsContainer;
import com.android.quickstep.util.ClipAnimationHelper;
import com.android.quickstep.util.ClipAnimationHelper.TransformParams;
@@ -132,7 +130,7 @@
ClipAnimationHelper helper) {
AnimatorSet anim = super.createAdjacentPageAnimForTaskLaunch(tv, helper);
- if (!OverviewInteractionState.INSTANCE.get(mActivity).isSwipeUpGestureEnabled()) {
+ if (!SysUINavigationMode.INSTANCE.get(mActivity).getMode().hasGestures) {
// Hotseat doesn't move when opening recents with the button,
// so don't animate it here either.
return anim;
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
index a02df62..ddb94d2 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
@@ -24,7 +24,7 @@
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
import static com.android.launcher3.config.FeatureFlags.QUICKSTEP_SPRINGS;
-import static com.android.launcher3.uioverrides.TaskViewTouchController.SUCCESS_TRANSITION_PROGRESS;
+import static com.android.launcher3.uioverrides.touchcontrollers.TaskViewTouchController.SUCCESS_TRANSITION_PROGRESS;
import static com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW;
import static com.android.quickstep.TaskUtils.checkCurrentOrManagedUserId;
import static com.android.launcher3.Utilities.EDGE_NAV_BAR;
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java
index 90604ef..a9f6311 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -46,6 +46,7 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.SystemUiController;
import com.android.launcher3.util.Themes;
+import com.android.quickstep.RecentsModel;
import com.android.quickstep.TaskOverlayFactory;
import com.android.quickstep.TaskOverlayFactory.TaskOverlay;
import com.android.systemui.shared.recents.model.Task;
@@ -81,6 +82,7 @@
private final Paint mBackgroundPaint = new Paint();
private final Paint mClearPaint = new Paint();
private final Paint mDimmingPaintAfterClearing = new Paint();
+ private final float mWindowCornerRadius;
private final Matrix mMatrix = new Matrix();
@@ -114,6 +116,7 @@
mDimmingPaintAfterClearing.setColor(Color.BLACK);
mActivity = BaseActivity.fromContext(context);
mIsDarkTextTheme = Themes.getAttrBoolean(mActivity, R.attr.isWorkspaceDarkText);
+ mWindowCornerRadius = RecentsModel.INSTANCE.get(context).getWindowCornerRadius();
}
public void bind(Task task) {
@@ -196,19 +199,22 @@
@Override
protected void onDraw(Canvas canvas) {
- float fullscreenProgress = ((TaskView) getParent()).getFullscreenProgress();
+ TaskView taskView = (TaskView) getParent();
+ float fullscreenProgress = taskView.getFullscreenProgress();
if (mIsRotated) {
// Don't show insets in the wrong orientation.
fullscreenProgress = 0;
}
if (fullscreenProgress > 0) {
// Draw the insets if we're being drawn fullscreen (we do this for quick switch).
+ float cornerRadius = Utilities.mapRange(fullscreenProgress, mCornerRadius,
+ mWindowCornerRadius);
drawOnCanvas(canvas,
-mScaledInsets.left * fullscreenProgress,
-mScaledInsets.top * fullscreenProgress,
getMeasuredWidth() + mScaledInsets.right * fullscreenProgress,
getMeasuredHeight() + mScaledInsets.bottom * fullscreenProgress,
- mCornerRadius);
+ cornerRadius / taskView.getRecentsView().getScaleX());
} else {
drawOnCanvas(canvas, 0, 0, getMeasuredWidth(), getMeasuredHeight(), mCornerRadius);
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
index 10029a1..747c480 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java
@@ -431,6 +431,7 @@
}
private void resetViewTransforms() {
+ setCurveScale(1);
setZoomScale(1);
setTranslationX(0f);
setTranslationY(0f);
diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index 9c97c8c..97f2de7 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -24,7 +24,7 @@
<dimen name="task_corner_radius_small">2dp</dimen>
<dimen name="recents_page_spacing">10dp</dimen>
<dimen name="recents_clear_all_deadzone_vertical_margin">70dp</dimen>
- <dimen name="quickscrub_adjacent_visible_width">20dp</dimen>
+ <dimen name="overview_peek_distance">32dp</dimen>
<!-- The speed in dp/s at which the user needs to be scrolling in recents such that we start
loading full resolution screenshots. -->
diff --git a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
index c5475d6..f77bd65 100644
--- a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java
@@ -20,15 +20,16 @@
import static com.android.launcher3.BaseActivity.INVISIBLE_BY_APP_TRANSITIONS;
import static com.android.launcher3.BaseActivity.INVISIBLE_BY_PENDING_FLAGS;
import static com.android.launcher3.BaseActivity.PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION;
-import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.LauncherState.ALL_APPS;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.Utilities.postAsyncCallback;
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PROGRESS;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE;
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
+import static com.android.launcher3.anim.Interpolators.EXAGGERATED_EASE;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_TRANSITIONS;
+import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION;
import static com.android.quickstep.TaskUtils.taskIsATargetWithMode;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING;
@@ -45,6 +46,7 @@
import android.content.res.Resources;
import android.graphics.Matrix;
import android.graphics.Rect;
+import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.CancellationSignal;
@@ -52,10 +54,8 @@
import android.os.Looper;
import android.util.Pair;
import android.view.View;
-import android.view.ViewGroup;
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
-import com.android.launcher3.InsettableFrameLayout.LayoutParams;
import com.android.launcher3.allapps.AllAppsTransitionController;
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.dragndrop.DragLayer;
@@ -103,13 +103,18 @@
private static final String CONTROL_REMOTE_APP_TRANSITION_PERMISSION =
"android.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS";
- private static final int APP_LAUNCH_DURATION = 500;
+ private static final long APP_LAUNCH_DURATION = 500;
// Use a shorter duration for x or y translation to create a curve effect
- private static final int APP_LAUNCH_CURVED_DURATION = APP_LAUNCH_DURATION / 2;
+ private static final long APP_LAUNCH_CURVED_DURATION = APP_LAUNCH_DURATION / 2;
+ private static final long APP_LAUNCH_ALPHA_DURATION = 50;
+
// We scale the durations for the downward app launch animations (minus the scale animation).
private static final float APP_LAUNCH_DOWN_DUR_SCALE_FACTOR = 0.8f;
- private static final int APP_LAUNCH_ALPHA_START_DELAY = 32;
- private static final int APP_LAUNCH_ALPHA_DURATION = 50;
+ private static final long APP_LAUNCH_DOWN_DURATION =
+ (long) (APP_LAUNCH_DURATION * APP_LAUNCH_DOWN_DUR_SCALE_FACTOR);
+ private static final long APP_LAUNCH_DOWN_CURVED_DURATION = APP_LAUNCH_DOWN_DURATION / 2;
+ private static final long APP_LAUNCH_ALPHA_DOWN_DURATION =
+ (long) (APP_LAUNCH_ALPHA_DURATION * APP_LAUNCH_DOWN_DUR_SCALE_FACTOR);
public static final int RECENTS_LAUNCH_DURATION = 336;
private static final int LAUNCHER_RESUME_START_DELAY = 100;
@@ -207,11 +212,11 @@
// Note that this duration is a guess as we do not know if the animation will be a
// recents launch or not for sure until we know the opening app targets.
- int duration = fromRecents
+ long duration = fromRecents
? RECENTS_LAUNCH_DURATION
: APP_LAUNCH_DURATION;
- int statusBarTransitionDelay = duration - STATUS_BAR_TRANSITION_DURATION
+ long statusBarTransitionDelay = duration - STATUS_BAR_TRANSITION_DURATION
- STATUS_BAR_TRANSITION_PRE_DELAY;
return ActivityOptionsCompat.makeRemoteAnimation(new RemoteAnimationAdapterCompat(
runner, duration, statusBarTransitionDelay));
@@ -266,7 +271,8 @@
}
if (!isAllOpeningTargetTrs) break;
}
- playIconAnimators(anim, v, windowTargetBounds, !isAllOpeningTargetTrs);
+ anim.play(getOpeningWindowAnimators(v, targets, windowTargetBounds,
+ !isAllOpeningTargetTrs));
if (launcherClosing) {
Pair<AnimatorSet, Runnable> launcherContentAnimator =
getLauncherContentAnimator(true /* isAppOpening */,
@@ -279,7 +285,6 @@
}
});
}
- anim.play(getOpeningWindowAnimators(v, targets, windowTargetBounds));
}
/**
@@ -398,124 +403,13 @@
float[] alphas, float[] trans);
/**
- * Animators for the "floating view" of the view used to launch the target.
- */
- private void playIconAnimators(AnimatorSet appOpenAnimator, View v, Rect windowTargetBounds,
- boolean toggleVisibility) {
- final boolean isBubbleTextView = v instanceof BubbleTextView;
- if (mFloatingView != null) {
- mFloatingView.setTranslationX(0);
- mFloatingView.setTranslationY(0);
- mFloatingView.setScaleX(1);
- mFloatingView.setScaleY(1);
- mFloatingView.setAlpha(1);
- mFloatingView.setBackground(null);
- }
- Rect rect = new Rect();
- mFloatingView = FloatingIconView.getFloatingIconView(mLauncher, v, toggleVisibility,
- true /* useDrawableAsIs */, -1 /* aspectRatio */, rect, mFloatingView);
-
- int viewLocationStart = mIsRtl ? windowTargetBounds.width() - rect.right : rect.left;
- LayoutParams lp = (LayoutParams) mFloatingView.getLayoutParams();
- // Special RTL logic is needed to handle the window target bounds.
- lp.leftMargin = mIsRtl ? windowTargetBounds.width() - rect.right : rect.left;
- mFloatingView.setLayoutParams(lp);
-
- int[] dragLayerBounds = new int[2];
- mDragLayer.getLocationOnScreen(dragLayerBounds);
-
- // Animate the app icon to the center of the window bounds in screen coordinates.
- float centerX = windowTargetBounds.centerX() - dragLayerBounds[0];
- float centerY = windowTargetBounds.centerY() - dragLayerBounds[1];
-
- float xPosition = mIsRtl
- ? windowTargetBounds.width() - lp.getMarginStart() - rect.width()
- : lp.getMarginStart();
- float dX = centerX - xPosition - (lp.width / 2f);
- float dY = centerY - lp.topMargin - (lp.height / 2f);
-
- ObjectAnimator x = ObjectAnimator.ofFloat(mFloatingView, View.TRANSLATION_X, 0f, dX);
- ObjectAnimator y = ObjectAnimator.ofFloat(mFloatingView, View.TRANSLATION_Y, 0f, dY);
-
- // Use upward animation for apps that are either on the bottom half of the screen, or are
- // relatively close to the center.
- boolean useUpwardAnimation = lp.topMargin > centerY
- || Math.abs(dY) < mLauncher.getDeviceProfile().cellHeightPx;
- if (useUpwardAnimation) {
- x.setDuration(APP_LAUNCH_CURVED_DURATION);
- y.setDuration(APP_LAUNCH_DURATION);
- } else {
- x.setDuration((long) (APP_LAUNCH_DOWN_DUR_SCALE_FACTOR * APP_LAUNCH_DURATION));
- y.setDuration((long) (APP_LAUNCH_DOWN_DUR_SCALE_FACTOR * APP_LAUNCH_CURVED_DURATION));
- }
- x.setInterpolator(AGGRESSIVE_EASE);
- y.setInterpolator(AGGRESSIVE_EASE);
- appOpenAnimator.play(x);
- appOpenAnimator.play(y);
-
- // Scale the app icon to take up the entire screen. This simplifies the math when
- // animating the app window position / scale.
- float maxScaleX = windowTargetBounds.width() / (float) rect.width();
- float maxScaleY = windowTargetBounds.height() / (float) rect.height();
- float scale = Math.max(maxScaleX, maxScaleY);
- float startScale = 1f;
- if (isBubbleTextView && !(v.getParent() instanceof DeepShortcutView)) {
- Drawable dr = ((BubbleTextView) v).getIcon();
- if (dr instanceof FastBitmapDrawable) {
- startScale = ((FastBitmapDrawable) dr).getAnimatedScale();
- }
- }
-
- ObjectAnimator scaleAnim = ObjectAnimator
- .ofFloat(mFloatingView, SCALE_PROPERTY, startScale, scale);
- scaleAnim.setDuration(APP_LAUNCH_DURATION)
- .setInterpolator(Interpolators.EXAGGERATED_EASE);
- appOpenAnimator.play(scaleAnim);
-
- // Fade out the app icon.
- ObjectAnimator alpha = ObjectAnimator.ofFloat(mFloatingView, View.ALPHA, 1f, 0f);
- if (useUpwardAnimation) {
- alpha.setStartDelay(APP_LAUNCH_ALPHA_START_DELAY);
- alpha.setDuration(APP_LAUNCH_ALPHA_DURATION);
- } else {
- alpha.setStartDelay((long) (APP_LAUNCH_DOWN_DUR_SCALE_FACTOR
- * APP_LAUNCH_ALPHA_START_DELAY));
- alpha.setDuration((long) (APP_LAUNCH_DOWN_DUR_SCALE_FACTOR * APP_LAUNCH_ALPHA_DURATION));
- }
- alpha.setInterpolator(LINEAR);
- appOpenAnimator.play(alpha);
-
- appOpenAnimator.addListener(mFloatingView);
- appOpenAnimator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- // Reset launcher to normal state
- if (isBubbleTextView) {
- ((BubbleTextView) v).setStayPressed(false);
- }
- v.setVisibility(View.VISIBLE);
- ((ViewGroup) mDragLayer.getParent()).getOverlay().remove(mFloatingView);
- }
- });
- }
-
- /**
* @return Animator that controls the window of the opening targets.
*/
private ValueAnimator getOpeningWindowAnimators(View v, RemoteAnimationTargetCompat[] targets,
- Rect windowTargetBounds) {
+ Rect windowTargetBounds, boolean toggleVisibility) {
Rect bounds = new Rect();
- if (v.getParent() instanceof DeepShortcutView) {
- // Deep shortcut views have their icon drawn in a separate view.
- DeepShortcutView view = (DeepShortcutView) v.getParent();
- mDragLayer.getDescendantRectRelativeToSelf(view.getIconView(), bounds);
- } else if (v instanceof BubbleTextView) {
- ((BubbleTextView) v).getIconBounds(bounds);
- } else {
- mDragLayer.getDescendantRectRelativeToSelf(v, bounds);
- }
- int[] floatingViewBounds = new int[2];
-
+ mFloatingView = FloatingIconView.getFloatingIconView(mLauncher, v, toggleVisibility,
+ bounds, true /* isOpening */, mFloatingView);
Rect crop = new Rect();
Matrix matrix = new Matrix();
@@ -526,37 +420,99 @@
SyncRtSurfaceTransactionApplierCompat surfaceApplier =
new SyncRtSurfaceTransactionApplierCompat(mFloatingView);
+ // Scale the app icon to take up the entire screen. This simplifies the math when
+ // animating the app window position / scale.
+ float maxScaleX = windowTargetBounds.width() / (float) bounds.width();
+ // We use windowTargetBounds.width for scaleY too since we start off the animation where the
+ // window is clipped to a square.
+ float maxScaleY = windowTargetBounds.width() / (float) bounds.height();
+ float scale = Math.max(maxScaleX, maxScaleY);
+ float startScale = 1f;
+ if (v instanceof BubbleTextView && !(v.getParent() instanceof DeepShortcutView)) {
+ Drawable dr = ((BubbleTextView) v).getIcon();
+ if (dr instanceof FastBitmapDrawable) {
+ startScale = ((FastBitmapDrawable) dr).getAnimatedScale();
+ }
+ }
+ final float initialStartScale = startScale;
+
+ int[] dragLayerBounds = new int[2];
+ mDragLayer.getLocationOnScreen(dragLayerBounds);
+
+ // Animate the app icon to the center of the window bounds in screen coordinates.
+ float centerX = windowTargetBounds.centerX() - dragLayerBounds[0];
+ float centerY = windowTargetBounds.centerY() - dragLayerBounds[1];
+
+ float dX = centerX - bounds.centerX();
+ float dY = centerY - bounds.centerY();
+
+ boolean useUpwardAnimation = bounds.top > centerY
+ || Math.abs(dY) < mLauncher.getDeviceProfile().cellHeightPx;
+ final long xDuration = useUpwardAnimation ? APP_LAUNCH_CURVED_DURATION
+ : APP_LAUNCH_DOWN_DURATION;
+ final long yDuration = useUpwardAnimation ? APP_LAUNCH_DURATION
+ : APP_LAUNCH_DOWN_CURVED_DURATION;
+ final long alphaDuration = useUpwardAnimation ? APP_LAUNCH_ALPHA_DURATION
+ : APP_LAUNCH_ALPHA_DOWN_DURATION;
+
+ RectF targetBounds = new RectF(windowTargetBounds);
+ RectF currentBounds = new RectF();
+ RectF temp = new RectF();
+
ValueAnimator appAnimator = ValueAnimator.ofFloat(0, 1);
appAnimator.setDuration(APP_LAUNCH_DURATION);
+ appAnimator.setInterpolator(LINEAR);
+ appAnimator.addListener(mFloatingView);
+ appAnimator.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ if (v instanceof BubbleTextView) {
+ ((BubbleTextView) v).setStayPressed(false);
+ }
+ }
+ });
+
+ float shapeRevealDuration = APP_LAUNCH_DURATION * SHAPE_PROGRESS_DURATION;
appAnimator.addUpdateListener(new MultiValueUpdateListener() {
- // Fade alpha for the app window.
- FloatProp mAlpha = new FloatProp(0f, 1f, 0, 60, LINEAR);
+ FloatProp mDx = new FloatProp(0, dX, 0, xDuration, AGGRESSIVE_EASE);
+ FloatProp mDy = new FloatProp(0, dY, 0, yDuration, AGGRESSIVE_EASE);
+ FloatProp mIconScale = new FloatProp(initialStartScale, scale, 0, APP_LAUNCH_DURATION,
+ EXAGGERATED_EASE);
+ FloatProp mIconAlpha = new FloatProp(1f, 0f, shapeRevealDuration, alphaDuration,
+ LINEAR);
+ FloatProp mCropHeight = new FloatProp(windowTargetBounds.width(),
+ windowTargetBounds.height(), 0, shapeRevealDuration, AGGRESSIVE_EASE);
@Override
public void onUpdate(float percent) {
- final float easePercent = AGGRESSIVE_EASE.getInterpolation(percent);
-
// Calculate app icon size.
- float iconWidth = bounds.width() * mFloatingView.getScaleX();
- float iconHeight = bounds.height() * mFloatingView.getScaleY();
+ float iconWidth = bounds.width() * mIconScale.value;
+ float iconHeight = bounds.height() * mIconScale.value;
+
+ // Animate the window crop so that it starts off as a square, and then reveals
+ // horizontally.
+ int windowWidth = windowTargetBounds.width();
+ int windowHeight = (int) mCropHeight.value;
+ crop.set(0, 0, windowWidth, windowHeight);
// Scale the app window to match the icon size.
- float scaleX = iconWidth / windowTargetBounds.width();
- float scaleY = iconHeight / windowTargetBounds.height();
- float scale = Math.min(1f, Math.min(scaleX, scaleY));
+ float scaleX = iconWidth / windowWidth;
+ float scaleY = iconHeight / windowHeight;
+ float scale = Math.min(1f, Math.max(scaleX, scaleY));
- // Position the scaled window on top of the icon
- int windowWidth = windowTargetBounds.width();
- int windowHeight = windowTargetBounds.height();
float scaledWindowWidth = windowWidth * scale;
float scaledWindowHeight = windowHeight * scale;
float offsetX = (scaledWindowWidth - iconWidth) / 2;
float offsetY = (scaledWindowHeight - iconHeight) / 2;
- mFloatingView.getLocationOnScreen(floatingViewBounds);
- float transX0 = floatingViewBounds[0] - offsetX;
- float transY0 = floatingViewBounds[1] - offsetY;
+ // Calculate the window position
+ temp.set(bounds);
+ temp.offset(dragLayerBounds[0], dragLayerBounds[1]);
+ temp.offset(mDx.value, mDy.value);
+ Utilities.scaleRectFAboutCenter(temp, mIconScale.value);
+ float transX0 = temp.left - offsetX;
+ float transY0 = temp.top - offsetY;
float windowRadius = 0;
if (!mDeviceProfile.isMultiWindowMode &&
@@ -565,19 +521,9 @@
.getWindowCornerRadius();
}
- // Animate the window crop so that it starts off as a square, and then reveals
- // horizontally.
- float cropHeight = windowHeight * easePercent + windowWidth * (1 - easePercent);
- float initialTop = (windowHeight - windowWidth) / 2f;
- crop.left = 0;
- crop.top = (int) (initialTop * (1 - easePercent));
- crop.right = windowWidth;
- crop.bottom = (int) (crop.top + cropHeight);
-
SurfaceParams[] params = new SurfaceParams[targets.length];
for (int i = targets.length - 1; i >= 0; i--) {
RemoteAnimationTargetCompat target = targets[i];
-
Rect targetCrop;
final float alpha;
final float cornerRadius;
@@ -585,12 +531,15 @@
matrix.setScale(scale, scale);
matrix.postTranslate(transX0, transY0);
targetCrop = crop;
- alpha = mAlpha.value;
+ alpha = 1f - mIconAlpha.value;
cornerRadius = windowRadius;
+ matrix.mapRect(currentBounds, targetBounds);
+ mFloatingView.update(currentBounds, mIconAlpha.value, percent, 0f,
+ cornerRadius * scale, true /* isOpening */);
} else {
matrix.setTranslate(target.position.x, target.position.y);
- alpha = 1f;
targetCrop = target.sourceContainerBounds;
+ alpha = 1f;
cornerRadius = 0;
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java
index 7b86990..f0204b9 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/BaseRecentsViewStateController.java
@@ -19,7 +19,8 @@
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE;
-import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATE;
+import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATE_X;
+import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATE_Y;
import static com.android.launcher3.anim.AnimatorSetBuilder.FLAG_DONT_ANIMATE_OVERVIEW;
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE_IN_OUT;
import static com.android.launcher3.anim.Interpolators.LINEAR;
@@ -71,7 +72,9 @@
@Override
public final void setStateWithAnimation(@NonNull final LauncherState toState,
@NonNull AnimatorSetBuilder builder, @NonNull AnimationConfig config) {
- if (!config.playAtomicComponent()) {
+ boolean playAtomicOverviewComponent = config.playAtomicOverviewScaleComponent()
+ || config.playAtomicOverviewPeekComponent();
+ if (!playAtomicOverviewComponent) {
// The entire recents animation is played atomically.
return;
}
@@ -94,15 +97,17 @@
ScaleAndTranslation scaleAndTranslation = toState.getOverviewScaleAndTranslation(mLauncher);
Interpolator scaleInterpolator = builder.getInterpolator(ANIM_OVERVIEW_SCALE, LINEAR);
setter.setFloat(mRecentsView, SCALE_PROPERTY, scaleAndTranslation.scale, scaleInterpolator);
- Interpolator translateInterpolator = builder.getInterpolator(
- ANIM_OVERVIEW_TRANSLATE, LINEAR);
+ Interpolator translateXInterpolator = builder.getInterpolator(
+ ANIM_OVERVIEW_TRANSLATE_X, LINEAR);
+ Interpolator translateYInterpolator = builder.getInterpolator(
+ ANIM_OVERVIEW_TRANSLATE_Y, LINEAR);
float translationX = scaleAndTranslation.translationX;
if (mRecentsView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
translationX = -translationX;
}
- setter.setFloat(mRecentsView, View.TRANSLATION_X, translationX, translateInterpolator);
+ setter.setFloat(mRecentsView, View.TRANSLATION_X, translationX, translateXInterpolator);
setter.setFloat(mRecentsView, View.TRANSLATION_Y, scaleAndTranslation.translationY,
- translateInterpolator);
+ translateYInterpolator);
setter.setFloat(mRecentsView, getContentAlphaProperty(), toState.overviewUi ? 1 : 0,
builder.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT));
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
index 25e1c89..6d730b6 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
@@ -41,8 +41,11 @@
import com.android.launcher3.LauncherStateManager.StateHandler;
import com.android.launcher3.QuickstepAppTransitionManagerImpl;
import com.android.launcher3.Utilities;
+import com.android.launcher3.dragndrop.DragLayer;
import com.android.quickstep.OverviewInteractionState;
import com.android.quickstep.RecentsModel;
+import com.android.quickstep.SysUINavigationMode;
+import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener;
import com.android.quickstep.util.RemoteFadeOutAnimationListener;
import com.android.systemui.shared.system.ActivityCompat;
@@ -52,8 +55,11 @@
public class UiFactory extends RecentsUiFactory {
- public static void setOnTouchControllersChangedListener(Context context, Runnable listener) {
- OverviewInteractionState.INSTANCE.get(context).setOnSwipeUpSettingChangedListener(listener);
+ public static Runnable enableLiveTouchControllerChanges(DragLayer dl) {
+ NavigationModeChangeListener listener = m -> dl.recreateControllers();
+ SysUINavigationMode mode = SysUINavigationMode.INSTANCE.get(dl.getContext());
+ mode.addModeChangeListener(listener);
+ return () -> mode.removeModeChangeListener(listener);
}
public static StateHandler[] getStateHandler(Launcher launcher) {
@@ -89,8 +95,8 @@
@Override
public void onStateTransitionComplete(LauncherState finalState) {
- boolean swipeUpEnabled = OverviewInteractionState.INSTANCE.get(launcher)
- .isSwipeUpGestureEnabled();
+ boolean swipeUpEnabled = SysUINavigationMode.INSTANCE.get(launcher).getMode()
+ .hasGestures;
LauncherState prevState = launcher.getStateManager().getLastState();
if (((swipeUpEnabled && finalState == OVERVIEW) || (!swipeUpEnabled
diff --git a/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
similarity index 98%
rename from quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java
rename to quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
index c629e33..ab24f5f 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.launcher3.uioverrides;
+package com.android.launcher3.uioverrides.states;
import static com.android.launcher3.LauncherAnimUtils.ALL_APPS_TRANSITION_MS;
import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
diff --git a/quickstep/src/com/android/launcher3/uioverrides/LandscapeEdgeSwipeController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/LandscapeEdgeSwipeController.java
similarity index 96%
rename from quickstep/src/com/android/launcher3/uioverrides/LandscapeEdgeSwipeController.java
rename to quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/LandscapeEdgeSwipeController.java
index 086cbdb..0605953 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/LandscapeEdgeSwipeController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/LandscapeEdgeSwipeController.java
@@ -1,4 +1,4 @@
-package com.android.launcher3.uioverrides;
+package com.android.launcher3.uioverrides.touchcontrollers;
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
@@ -41,7 +41,7 @@
@Override
protected LauncherState getTargetState(LauncherState fromState, boolean isDragTowardPositive) {
- boolean draggingFromNav = mLauncher.getDeviceProfile().isSeascape() != isDragTowardPositive;
+ boolean draggingFromNav = mLauncher.getDeviceProfile().isSeascape() == isDragTowardPositive;
return draggingFromNav ? OVERVIEW : NORMAL;
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
similarity index 98%
rename from quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
rename to quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
index 62e525c..ce50b68 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/PortraitStatesTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.launcher3.uioverrides;
+package com.android.launcher3.uioverrides.touchcontrollers;
import static com.android.launcher3.AbstractFloatingView.TYPE_ACCESSIBLE;
import static com.android.launcher3.LauncherState.ALL_APPS;
@@ -43,6 +43,8 @@
import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.touch.AbstractStateChangeTouchController;
import com.android.launcher3.touch.SwipeDetector;
+import com.android.launcher3.uioverrides.states.OverviewState;
+import com.android.launcher3.uioverrides.touchcontrollers.PortraitOverviewStateTouchHelper;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.quickstep.RecentsModel;
diff --git a/quickstep/src/com/android/launcher3/uioverrides/StatusBarTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java
similarity index 98%
rename from quickstep/src/com/android/launcher3/uioverrides/StatusBarTouchController.java
rename to quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java
index 8f33e40..12e6f12 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/StatusBarTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.launcher3.uioverrides;
+package com.android.launcher3.uioverrides.touchcontrollers;
import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_MOVE;
diff --git a/quickstep/src/com/android/quickstep/InstantAppResolverImpl.java b/quickstep/src/com/android/quickstep/InstantAppResolverImpl.java
index 12757c0..3e9872a 100644
--- a/quickstep/src/com/android/quickstep/InstantAppResolverImpl.java
+++ b/quickstep/src/com/android/quickstep/InstantAppResolverImpl.java
@@ -19,16 +19,11 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ApplicationInfo;
-import android.content.pm.InstantAppInfo;
import android.content.pm.PackageManager;
-import android.util.Log;
import com.android.launcher3.AppInfo;
import com.android.launcher3.util.InstantAppResolver;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* Implementation of InstantAppResolver using platform APIs
*/
@@ -40,8 +35,7 @@
private final PackageManager mPM;
- public InstantAppResolverImpl(Context context)
- throws NoSuchMethodException, ClassNotFoundException {
+ public InstantAppResolverImpl(Context context) {
mPM = context.getPackageManager();
}
@@ -55,23 +49,4 @@
ComponentName cn = info.getTargetComponent();
return cn != null && cn.getClassName().equals(COMPONENT_CLASS_MARKER);
}
-
- @Override
- public List<ApplicationInfo> getInstantApps() {
- try {
- List<ApplicationInfo> result = new ArrayList<>();
- for (InstantAppInfo iai : mPM.getInstantApps()) {
- ApplicationInfo info = iai.getApplicationInfo();
- if (info != null) {
- result.add(info);
- }
- }
- return result;
- } catch (SecurityException se) {
- Log.w(TAG, "getInstantApps failed. Launcher may not be the default home app.", se);
- } catch (Exception e) {
- Log.e(TAG, "Error calling API: getInstantApps", e);
- }
- return super.getInstantApps();
- }
}
diff --git a/quickstep/src/com/android/quickstep/NavBarModeOverlayResourceObserver.java b/quickstep/src/com/android/quickstep/NavBarModeOverlayResourceObserver.java
deleted file mode 100644
index 577ad47..0000000
--- a/quickstep/src/com/android/quickstep/NavBarModeOverlayResourceObserver.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.res.Resources;
-import android.util.Log;
-
-import com.android.systemui.shared.system.QuickStepContract;
-
-/**
- * Observer for the resource config that specifies the navigation bar mode.
- */
-public class NavBarModeOverlayResourceObserver extends BroadcastReceiver {
-
- private static final String TAG = "NavBarModeOverlayResourceObserver";
-
- private final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
- private static final String NAV_BAR_INTERACTION_MODE_RES_NAME =
- "config_navBarInteractionMode";
-
- private final Context mContext;
- private final OnChangeListener mOnChangeListener;
-
- public NavBarModeOverlayResourceObserver(Context context, OnChangeListener listener) {
- mContext = context;
- mOnChangeListener = listener;
- }
-
- public void register() {
- IntentFilter filter = new IntentFilter(ACTION_OVERLAY_CHANGED);
- filter.addDataScheme("package");
- mContext.registerReceiver(this, filter);
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
- mOnChangeListener.onNavBarModeChanged(getSystemIntegerRes(context,
- NAV_BAR_INTERACTION_MODE_RES_NAME));
- }
-
- public interface OnChangeListener {
- void onNavBarModeChanged(int mode);
- }
-
- public static boolean isSwipeUpModeEnabled(Context context) {
- return QuickStepContract.isSwipeUpMode(getSystemIntegerRes(context,
- NAV_BAR_INTERACTION_MODE_RES_NAME));
- }
-
- public static boolean isEdgeToEdgeModeEnabled(Context context) {
- return QuickStepContract.isGesturalMode(getSystemIntegerRes(context,
- NAV_BAR_INTERACTION_MODE_RES_NAME));
- }
-
- public static boolean isLegacyModeEnabled(Context context) {
- return QuickStepContract.isLegacyMode(getSystemIntegerRes(context,
- NAV_BAR_INTERACTION_MODE_RES_NAME));
- }
-
- private static int getSystemIntegerRes(Context context, String resName) {
- Resources res = context.getResources();
- int resId = res.getIdentifier(resName, "integer", "android");
-
- if (resId != 0) {
- return res.getInteger(resId);
- } else {
- Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
- return -1;
- }
- }
-}
diff --git a/quickstep/src/com/android/quickstep/OverviewInteractionState.java b/quickstep/src/com/android/quickstep/OverviewInteractionState.java
index 903701d..ce472c6 100644
--- a/quickstep/src/com/android/quickstep/OverviewInteractionState.java
+++ b/quickstep/src/com/android/quickstep/OverviewInteractionState.java
@@ -30,8 +30,8 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.MainThreadInitializedObject;
import com.android.launcher3.util.UiThreadHelper;
+import com.android.quickstep.SysUINavigationMode.Mode;
import com.android.systemui.shared.recents.ISystemUiProxy;
-import com.android.systemui.shared.system.QuickStepContract;
import androidx.annotation.WorkerThread;
@@ -56,10 +56,7 @@
private static final int MSG_SET_PROXY = 200;
private static final int MSG_SET_BACK_BUTTON_ALPHA = 201;
- private static final int MSG_SET_SWIPE_UP_ENABLED = 202;
-
- // TODO: Discriminate between swipe up and edge to edge
- private final NavBarModeOverlayResourceObserver mSwipeUpSettingObserver;
+ private static final int MSG_APPLY_FLAGS = 202;
private final Context mContext;
private final Handler mUiHandler;
@@ -70,8 +67,6 @@
private boolean mSwipeUpEnabled;
private float mBackButtonAlpha = 1;
- private Runnable mOnSwipeUpSettingChangedListener;
-
private OverviewInteractionState(Context context) {
mContext = context;
@@ -81,20 +76,8 @@
mUiHandler = new Handler(this::handleUiMessage);
mBgHandler = new Handler(UiThreadHelper.getBackgroundLooper(), this::handleBgMessage);
- mSwipeUpEnabled = NavBarModeOverlayResourceObserver.isSwipeUpModeEnabled(mContext)
- || NavBarModeOverlayResourceObserver.isEdgeToEdgeModeEnabled(mContext);
- if (SwipeUpSetting.isSystemNavigationSettingAvailable()) {
- mSwipeUpSettingObserver = new NavBarModeOverlayResourceObserver(context,
- this::notifySwipeUpSettingChanged);
- mSwipeUpSettingObserver.register();
- resetHomeBounceSeenOnQuickstepEnabledFirstTime();
- } else {
- mSwipeUpSettingObserver = null;
- }
- }
-
- public boolean isSwipeUpGestureEnabled() {
- return mSwipeUpEnabled;
+ onNavigationModeChanged(SysUINavigationMode.INSTANCE.get(context)
+ .addModeChangeListener(this::onNavigationModeChanged));
}
public float getBackButtonAlpha() {
@@ -130,23 +113,13 @@
case MSG_SET_BACK_BUTTON_ALPHA:
applyBackButtonAlpha((float) msg.obj, msg.arg1 == 1);
return true;
- case MSG_SET_SWIPE_UP_ENABLED:
- mSwipeUpEnabled = msg.arg1 != 0;
- resetHomeBounceSeenOnQuickstepEnabledFirstTime();
-
- if (mOnSwipeUpSettingChangedListener != null) {
- mOnSwipeUpSettingChangedListener.run();
- }
+ case MSG_APPLY_FLAGS:
break;
}
applyFlags();
return true;
}
- public void setOnSwipeUpSettingChangedListener(Runnable listener) {
- mOnSwipeUpSettingChangedListener = listener;
- }
-
@WorkerThread
private void applyFlags() {
if (mISystemUiProxy == null) {
@@ -176,16 +149,12 @@
}
}
- private void notifySwipeUpSettingChanged(int mode) {
- boolean swipeUpEnabled = !QuickStepContract.isLegacyMode(mode);
- boolean gesturalEnabled = QuickStepContract.isGesturalMode(mode);
+ private void onNavigationModeChanged(SysUINavigationMode.Mode mode) {
+ FeatureFlags.SWIPE_HOME.updateStorage(mContext, mode == Mode.NO_BUTTON);
- FeatureFlags.SWIPE_HOME.updateStorage(mContext, gesturalEnabled);
- FeatureFlags.ENABLE_ASSISTANT_GESTURE.updateStorage(mContext, gesturalEnabled);
-
- mUiHandler.removeMessages(MSG_SET_SWIPE_UP_ENABLED);
- mUiHandler.obtainMessage(MSG_SET_SWIPE_UP_ENABLED, swipeUpEnabled ? 1 : 0, 0).
- sendToTarget();
+ mSwipeUpEnabled = mode.hasGestures;
+ resetHomeBounceSeenOnQuickstepEnabledFirstTime();
+ mBgHandler.obtainMessage(MSG_APPLY_FLAGS).sendToTarget();
}
private void resetHomeBounceSeenOnQuickstepEnabledFirstTime() {
diff --git a/quickstep/src/com/android/quickstep/SwipeUpSetting.java b/quickstep/src/com/android/quickstep/SwipeUpSetting.java
deleted file mode 100644
index 7f830f9..0000000
--- a/quickstep/src/com/android/quickstep/SwipeUpSetting.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.res.Resources;
-import android.util.Log;
-
-public final class SwipeUpSetting {
- private static final String TAG = "SwipeUpSetting";
-
- private static final String SWIPE_UP_SETTING_AVAILABLE_RES_NAME =
- "config_swipe_up_gesture_setting_available";
-
- public static boolean isSystemNavigationSettingAvailable() {
- return getSystemBooleanRes(SWIPE_UP_SETTING_AVAILABLE_RES_NAME);
- }
-
- private static boolean getSystemBooleanRes(String resName) {
- Resources res = Resources.getSystem();
- int resId = res.getIdentifier(resName, "bool", "android");
-
- if (resId != 0) {
- return res.getBoolean(resId);
- } else {
- Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
- return false;
- }
- }
-}
diff --git a/quickstep/src/com/android/quickstep/SysUINavigationMode.java b/quickstep/src/com/android/quickstep/SysUINavigationMode.java
new file mode 100644
index 0000000..1953ecb
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/SysUINavigationMode.java
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.res.Resources;
+import android.util.Log;
+
+import com.android.launcher3.util.MainThreadInitializedObject;
+import com.android.systemui.shared.system.QuickStepContract;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Observer for the resource config that specifies the navigation bar mode.
+ */
+public class SysUINavigationMode {
+
+ public enum Mode {
+ THREE_BUTTONS(false, 0),
+ TWO_BUTTONS(true, 1),
+ NO_BUTTON(true, 2);
+
+ public final boolean hasGestures;
+ public final int resValue;
+
+ Mode(boolean hasGestures, int resValue) {
+ this.hasGestures = hasGestures;
+ this.resValue = resValue;
+ }
+ }
+
+ public static MainThreadInitializedObject<SysUINavigationMode> INSTANCE =
+ new MainThreadInitializedObject<>(SysUINavigationMode::new);
+
+ private static final String TAG = "SysUINavigationMode";
+
+ private final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
+ private static final String NAV_BAR_INTERACTION_MODE_RES_NAME =
+ "config_navBarInteractionMode";
+
+ private final Context mContext;
+ private Mode mMode;
+
+ private final List<NavigationModeChangeListener> mChangeListeners = new ArrayList<>();
+
+ public SysUINavigationMode(Context context) {
+ mContext = context;
+ initializeMode();
+
+ IntentFilter filter = new IntentFilter(ACTION_OVERLAY_CHANGED);
+ filter.addDataScheme("package");
+ mContext.registerReceiver(new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Mode oldMode = mMode;
+ initializeMode();
+ if (mMode != oldMode) {
+ dispatchModeChange();
+ }
+ }
+ }, filter);
+ }
+
+ private void initializeMode() {
+ int modeInt = getSystemIntegerRes(mContext, NAV_BAR_INTERACTION_MODE_RES_NAME);
+ for(Mode m : Mode.values()) {
+ if (m.resValue == modeInt) {
+ mMode = m;
+ }
+ }
+ }
+
+ private void dispatchModeChange() {
+ for (NavigationModeChangeListener listener : mChangeListeners) {
+ listener.onNavigationModeChanged(mMode);
+ }
+ }
+
+ public Mode addModeChangeListener(NavigationModeChangeListener listener) {
+ mChangeListeners.add(listener);
+ return mMode;
+ }
+
+ public void removeModeChangeListener(NavigationModeChangeListener listener) {
+ mChangeListeners.remove(listener);
+ }
+
+ public Mode getMode() {
+ return mMode;
+ }
+
+ private static int getSystemIntegerRes(Context context, String resName) {
+ Resources res = context.getResources();
+ int resId = res.getIdentifier(resName, "integer", "android");
+
+ if (resId != 0) {
+ return res.getInteger(resId);
+ } else {
+ Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
+ return -1;
+ }
+ }
+
+ public interface NavigationModeChangeListener {
+
+ void onNavigationModeChanged(Mode newMode);
+ }
+}
\ No newline at end of file
diff --git a/quickstep/src/com/android/quickstep/TestInformationProvider.java b/quickstep/src/com/android/quickstep/TestInformationProvider.java
index e57d3ec..b37ddda 100644
--- a/quickstep/src/com/android/quickstep/TestInformationProvider.java
+++ b/quickstep/src/com/android/quickstep/TestInformationProvider.java
@@ -30,7 +30,7 @@
import com.android.launcher3.LauncherState;
import com.android.launcher3.TestProtocol;
import com.android.launcher3.Utilities;
-import com.android.launcher3.uioverrides.OverviewState;
+import com.android.launcher3.uioverrides.states.OverviewState;
import com.android.quickstep.util.LayoutUtils;
public class TestInformationProvider extends ContentProvider {
diff --git a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
index 8a117c8..96620bd 100644
--- a/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
+++ b/quickstep/src/com/android/quickstep/util/MotionPauseDetector.java
@@ -71,9 +71,6 @@
*/
public void setOnMotionPauseListener(OnMotionPauseListener listener) {
mOnMotionPauseListener = listener;
- if (mOnMotionPauseListener != null) {
- mOnMotionPauseListener.onMotionPauseChanged(mIsPaused);
- }
}
/**
diff --git a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java
index 6854aa8..c77726e 100644
--- a/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java
+++ b/quickstep/tests/src/com/android/quickstep/AbstractQuickStepTest.java
@@ -27,5 +27,5 @@
public abstract class AbstractQuickStepTest extends AbstractLauncherUiTest {
@Rule
public TestRule mQuickstepOnOffExecutor =
- new QuickStepOnOffRule(mMainThreadExecutor, mLauncher);
+ new NavigationModeSwitchRule(mLauncher);
}
diff --git a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java
index 88b50d9..f436831 100644
--- a/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java
+++ b/quickstep/tests/src/com/android/quickstep/FallbackRecentsTest.java
@@ -17,26 +17,31 @@
import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
+import static androidx.test.InstrumentationRegistry.getInstrumentation;
+
import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS;
import static com.android.launcher3.tapl.TestHelpers.getHomeIntentInPackage;
import static com.android.launcher3.tapl.TestHelpers.getLauncherInMyProcess;
import static com.android.launcher3.util.rule.ShellCommandRule.disableHeadsUpNotification;
import static com.android.launcher3.util.rule.ShellCommandRule.getLauncherCommand;
-import static com.android.quickstep.QuickStepOnOffRule.Mode.OFF;
+import static com.android.quickstep.NavigationModeSwitchRule.Mode.THREE_BUTTON;
import static org.junit.Assert.assertTrue;
-import static androidx.test.InstrumentationRegistry.getInstrumentation;
-
import android.app.Instrumentation;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
-import com.android.launcher3.MainThreadExecutor;
+import androidx.test.filters.LargeTest;
+import androidx.test.runner.AndroidJUnit4;
+import androidx.test.uiautomator.By;
+import androidx.test.uiautomator.UiDevice;
+import androidx.test.uiautomator.Until;
+
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.testcomponent.TestCommandReceiver;
-import com.android.quickstep.QuickStepOnOffRule.QuickstepOnOff;
+import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
import org.junit.Rule;
import org.junit.Test;
@@ -44,12 +49,6 @@
import org.junit.runner.RunWith;
import org.junit.runners.model.Statement;
-import androidx.test.filters.LargeTest;
-import androidx.test.runner.AndroidJUnit4;
-import androidx.test.uiautomator.By;
-import androidx.test.uiautomator.UiDevice;
-import androidx.test.uiautomator.Until;
-
@LargeTest
@RunWith(AndroidJUnit4.class)
/**
@@ -72,7 +71,7 @@
mDevice = UiDevice.getInstance(instrumentation);
mLauncher = new LauncherInstrumentation(instrumentation);
- mQuickstepOnOffExecutor = new QuickStepOnOffRule(new MainThreadExecutor(), mLauncher);
+ mQuickstepOnOffExecutor = new NavigationModeSwitchRule(mLauncher);
mOtherLauncherActivity = context.getPackageManager().queryIntentActivities(
getHomeIntentInPackage(context),
MATCH_DISABLED_COMPONENTS).get(0).activityInfo;
@@ -94,7 +93,7 @@
};
}
- @QuickstepOnOff(mode = OFF)
+ @NavigationModeSwitch(mode = THREE_BUTTON)
@Test
public void goToOverviewFromHome() {
mDevice.pressHome();
@@ -104,7 +103,7 @@
mLauncher.getBackground().switchToOverview();
}
- @QuickstepOnOff(mode = OFF)
+ @NavigationModeSwitch(mode = THREE_BUTTON)
@Test
public void goToOverviewFromApp() {
startAppFast("com.android.settings");
diff --git a/quickstep/tests/src/com/android/quickstep/QuickStepOnOffRule.java b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
similarity index 60%
rename from quickstep/tests/src/com/android/quickstep/QuickStepOnOffRule.java
rename to quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
index 12bd0ca..f5ac9c9 100644
--- a/quickstep/tests/src/com/android/quickstep/QuickStepOnOffRule.java
+++ b/quickstep/tests/src/com/android/quickstep/NavigationModeSwitchRule.java
@@ -17,84 +17,80 @@
package com.android.quickstep;
import static androidx.test.InstrumentationRegistry.getInstrumentation;
-
-import static com.android.quickstep.QuickStepOnOffRule.Mode.BOTH;
-import static com.android.quickstep.QuickStepOnOffRule.Mode.OFF;
-import static com.android.quickstep.QuickStepOnOffRule.Mode.ON;
+import static com.android.quickstep.NavigationModeSwitchRule.Mode.ALL;
+import static com.android.quickstep.NavigationModeSwitchRule.Mode.THREE_BUTTON;
+import static com.android.quickstep.NavigationModeSwitchRule.Mode.TWO_BUTTON;
import static com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_2BUTTON_OVERLAY;
import static com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_3BUTTON_OVERLAY;
import static com.android.systemui.shared.system.QuickStepContract.NAV_BAR_MODE_GESTURAL_OVERLAY;
import android.content.Context;
import android.util.Log;
-
import androidx.test.uiautomator.UiDevice;
-
import com.android.launcher3.tapl.LauncherInstrumentation;
import com.android.launcher3.tapl.TestHelpers;
-import com.android.systemui.shared.system.QuickStepContract;
-
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-
-import java.io.IOException;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import java.util.concurrent.Executor;
+import org.junit.Assert;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
/**
* Test rule that allows executing a test with Quickstep on and then Quickstep off.
* The test should be annotated with @QuickstepOnOff.
*/
-public class QuickStepOnOffRule implements TestRule {
+public class NavigationModeSwitchRule implements TestRule {
static final String TAG = "QuickStepOnOffRule";
public enum Mode {
- ON, OFF, BOTH
+ THREE_BUTTON, TWO_BUTTON, ZERO_BUTTON, ALL
}
// Annotation for tests that need to be run with quickstep enabled and disabled.
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
- public @interface QuickstepOnOff {
- Mode mode() default BOTH;
+ public @interface NavigationModeSwitch {
+ Mode mode() default ALL;
}
- private final Executor mMainThreadExecutor;
private final LauncherInstrumentation mLauncher;
- public QuickStepOnOffRule(Executor mainThreadExecutor, LauncherInstrumentation launcher) {
+ public NavigationModeSwitchRule(LauncherInstrumentation launcher) {
mLauncher = launcher;
- this.mMainThreadExecutor = mainThreadExecutor;
}
@Override
public Statement apply(Statement base, Description description) {
if (TestHelpers.isInLauncherProcess() &&
- description.getAnnotation(QuickstepOnOff.class) != null) {
- Mode mode = description.getAnnotation(QuickstepOnOff.class).mode();
+ description.getAnnotation(NavigationModeSwitch.class) != null) {
+ Mode mode = description.getAnnotation(NavigationModeSwitch.class).mode();
return new Statement() {
@Override
public void evaluate() throws Throwable {
final Context context = getInstrumentation().getContext();
- final String prevOverlayPkg = QuickStepContract.isGesturalMode(context)
+ final String prevOverlayPkg = LauncherInstrumentation.isGesturalMode(context)
? NAV_BAR_MODE_GESTURAL_OVERLAY
- : QuickStepContract.isSwipeUpMode(context)
+ : LauncherInstrumentation.isSwipeUpMode(context)
? NAV_BAR_MODE_2BUTTON_OVERLAY
: NAV_BAR_MODE_3BUTTON_OVERLAY;
+ final LauncherInstrumentation.NavigationModel originalMode =
+ mLauncher.getNavigationModel();
try {
- if (mode == ON || mode == BOTH) {
- evaluateWithQuickstepOn();
+// if (mode == ZERO_BUTTON || mode == ALL) {
+// evaluateWithZeroButtons();
+// }
+ if (mode == TWO_BUTTON || mode == ALL) {
+ evaluateWithTwoButtons();
}
- if (mode == OFF || mode == BOTH) {
- evaluateWithQuickstepOff();
+ if (mode == THREE_BUTTON || mode == ALL) {
+ evaluateWithThreeButtons();
}
} finally {
- setActiveOverlay(prevOverlayPkg);
+ setActiveOverlay(prevOverlayPkg, originalMode);
}
}
@@ -102,17 +98,26 @@
base.evaluate();
}
- private void evaluateWithQuickstepOff() throws Throwable {
- setActiveOverlay(NAV_BAR_MODE_3BUTTON_OVERLAY);
+ private void evaluateWithThreeButtons() throws Throwable {
+ setActiveOverlay(NAV_BAR_MODE_3BUTTON_OVERLAY,
+ LauncherInstrumentation.NavigationModel.THREE_BUTTON);
evaluateWithoutChangingSetting(base);
}
- private void evaluateWithQuickstepOn() throws Throwable {
- setActiveOverlay(NAV_BAR_MODE_2BUTTON_OVERLAY);
+ private void evaluateWithTwoButtons() throws Throwable {
+ setActiveOverlay(NAV_BAR_MODE_2BUTTON_OVERLAY,
+ LauncherInstrumentation.NavigationModel.TWO_BUTTON);
base.evaluate();
}
- private void setActiveOverlay(String overlayPackage) {
+ private void evaluateWithZeroButtons() throws Throwable {
+ setActiveOverlay(NAV_BAR_MODE_GESTURAL_OVERLAY,
+ LauncherInstrumentation.NavigationModel.ZERO_BUTTON);
+ base.evaluate();
+ }
+
+ private void setActiveOverlay(String overlayPackage,
+ LauncherInstrumentation.NavigationModel expectedMode) throws Exception {
setOverlayPackageEnabled(NAV_BAR_MODE_3BUTTON_OVERLAY,
overlayPackage == NAV_BAR_MODE_3BUTTON_OVERLAY);
setOverlayPackageEnabled(NAV_BAR_MODE_2BUTTON_OVERLAY,
@@ -120,18 +125,19 @@
setOverlayPackageEnabled(NAV_BAR_MODE_GESTURAL_OVERLAY,
overlayPackage == NAV_BAR_MODE_GESTURAL_OVERLAY);
- // TODO: Wait until nav bar mode has applied
+ for (int i = 0; i != 100; ++i) {
+ if (mLauncher.getNavigationModel() == expectedMode) return;
+ Thread.sleep(100);
+ }
+ Assert.fail("Couldn't switch to " + overlayPackage);
}
- private void setOverlayPackageEnabled(String overlayPackage, boolean enable) {
+ private void setOverlayPackageEnabled(String overlayPackage, boolean enable)
+ throws Exception {
Log.d(TAG, "setOverlayPackageEnabled: " + overlayPackage + " " + enable);
final String action = enable ? "enable" : "disable";
- try {
- UiDevice.getInstance(getInstrumentation()).executeShellCommand(
- "cmd overlay " + action + " " + overlayPackage);
- } catch (IOException e) {
- e.printStackTrace();
- }
+ UiDevice.getInstance(getInstrumentation()).executeShellCommand(
+ "cmd overlay " + action + " " + overlayPackage);
}
};
} else {
diff --git a/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java b/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java
index 6031dcd..554aef4 100644
--- a/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java
+++ b/quickstep/tests/src/com/android/quickstep/StartLauncherViaGestureTests.java
@@ -26,8 +26,8 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.util.RaceConditionReproducer;
-import com.android.quickstep.QuickStepOnOffRule.Mode;
-import com.android.quickstep.QuickStepOnOffRule.QuickstepOnOff;
+import com.android.quickstep.NavigationModeSwitchRule.Mode;
+import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
import org.junit.Before;
import org.junit.Ignore;
@@ -62,7 +62,7 @@
@Test
@Ignore // Ignoring until gestural navigation event sequence settles
- @QuickstepOnOff(mode = Mode.ON)
+ @NavigationModeSwitch(mode = Mode.TWO_BUTTON)
public void testPressHome() {
runTest(enterEvt(Launcher.ON_CREATE_EVT),
exitEvt(Launcher.ON_CREATE_EVT),
@@ -77,14 +77,14 @@
@Test
@Ignore // Ignoring until gestural navigation event sequence settles
- @QuickstepOnOff(mode = Mode.ON)
+ @NavigationModeSwitch(mode = Mode.TWO_BUTTON)
public void testSwipeToOverview() {
closeLauncherActivity();
mLauncher.getBackground().switchToOverview();
}
@Test
- @QuickstepOnOff
+ @NavigationModeSwitch
public void testStressPressHome() {
for (int i = 0; i < STRESS_REPEAT_COUNT; ++i) {
// Destroy Launcher activity.
@@ -96,7 +96,7 @@
}
@Test
- @QuickstepOnOff
+ @NavigationModeSwitch
public void testStressSwipeToOverview() {
for (int i = 0; i < STRESS_REPEAT_COUNT; ++i) {
// Destroy Launcher activity.
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
index c60cf45..6623861 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java
@@ -37,10 +37,11 @@
import com.android.launcher3.tapl.OverviewTask;
import com.android.launcher3.tapl.TestHelpers;
import com.android.launcher3.ui.TaplTestsLauncher3;
-import com.android.quickstep.QuickStepOnOffRule.QuickstepOnOff;
+import com.android.quickstep.NavigationModeSwitchRule.NavigationModeSwitch;
import com.android.quickstep.views.RecentsView;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestWatcher;
@@ -71,6 +72,7 @@
@Test
@PortraitLandscape
+ @Ignore
public void testPressRecentAppsLauncherAndGetOverview() throws RemoteException {
mDevice.pressRecentApps();
waitForState("Launcher internal state didn't switch to Overview", LauncherState.OVERVIEW);
@@ -79,7 +81,7 @@
}
@Test
- @QuickstepOnOff
+ @NavigationModeSwitch
@PortraitLandscape
public void testWorkspaceSwitchToAllApps() {
assertNotNull("switchToAllApps() returned null",
@@ -198,7 +200,7 @@
}
@Test
- @QuickstepOnOff
+ @NavigationModeSwitch
@PortraitLandscape
public void testSwitchToOverview() throws Exception {
assertNotNull("Workspace.switchToOverview() returned null",
@@ -208,7 +210,7 @@
}
@Test
- @QuickstepOnOff
+ @NavigationModeSwitch
@PortraitLandscape
public void testBackground() throws Exception {
startAppFast(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 6397e14..6a3a26f 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -51,6 +51,9 @@
public final int heightPx;
public final int availableWidthPx;
public final int availableHeightPx;
+
+ public final float aspectRatio;
+
/**
* The maximum amount of left/right workspace padding as a percentage of the screen width.
* To be clear, this means that up to 7% of the screen width can be used as left padding, and
@@ -160,7 +163,7 @@
isTablet = res.getBoolean(R.bool.is_tablet);
isLargeTablet = res.getBoolean(R.bool.is_large_tablet);
isPhone = !isTablet && !isLargeTablet;
- float aspectRatio = ((float) Math.max(widthPx, heightPx)) / Math.min(widthPx, heightPx);
+ aspectRatio = ((float) Math.max(widthPx, heightPx)) / Math.min(widthPx, heightPx);
boolean isTallDevice = Float.compare(aspectRatio, TALL_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0;
// Some more constants
@@ -618,12 +621,6 @@
}
}
- public float getAspectRatioWithInsets() {
- int w = widthPx - mInsets.left - mInsets.right;
- int h = heightPx - mInsets.top - mInsets.bottom;
- return ((float) Math.max(w, h)) / Math.min(w, h);
- }
-
private static Context getContext(Context c, int orientation) {
Configuration context = new Configuration(c.getResources().getConfiguration());
context.orientation = orientation;
diff --git a/src/com/android/launcher3/FastBitmapDrawable.java b/src/com/android/launcher3/FastBitmapDrawable.java
index 964e8b6..7ab88a0 100644
--- a/src/com/android/launcher3/FastBitmapDrawable.java
+++ b/src/com/android/launcher3/FastBitmapDrawable.java
@@ -103,9 +103,14 @@
}
protected FastBitmapDrawable(Bitmap b, int iconColor) {
+ this(b, iconColor, false);
+ }
+
+ protected FastBitmapDrawable(Bitmap b, int iconColor, boolean isDisabled) {
mBitmap = b;
mIconColor = iconColor;
setFilterBitmap(true);
+ setIsDisabled(isDisabled);
}
@Override
@@ -249,6 +254,10 @@
}
}
+ protected boolean isDisabled() {
+ return mIsDisabled;
+ }
+
/**
* Sets the saturation of this icon, 0 [full color] -> 1 [desaturated]
*/
@@ -338,21 +347,23 @@
@Override
public ConstantState getConstantState() {
- return new MyConstantState(mBitmap, mIconColor);
+ return new MyConstantState(mBitmap, mIconColor, mIsDisabled);
}
protected static class MyConstantState extends ConstantState {
protected final Bitmap mBitmap;
protected final int mIconColor;
+ protected final boolean mIsDisabled;
- public MyConstantState(Bitmap bitmap, int color) {
+ public MyConstantState(Bitmap bitmap, int color, boolean isDisabled) {
mBitmap = bitmap;
mIconColor = color;
+ mIsDisabled = isDisabled;
}
@Override
public Drawable newDrawable() {
- return new FastBitmapDrawable(mBitmap, mIconColor);
+ return new FastBitmapDrawable(mBitmap, mIconColor, mIsDisabled);
}
@Override
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 867001a..89236aa 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -257,6 +257,7 @@
public ViewGroupFocusHelper mFocusHandler;
private RotationHelper mRotationHelper;
+ private Runnable mCancelTouchController;
final Handler mHandler = new Handler();
private final Runnable mHandleDeferredResume = this::handleDeferredResume;
@@ -946,7 +947,7 @@
// Setup the drag layer
mDragLayer.setup(mDragController, mWorkspace);
- UiFactory.setOnTouchControllersChangedListener(this, mDragLayer::recreateControllers);
+ mCancelTouchController = UiFactory.enableLiveTouchControllerChanges(mDragLayer);
mWorkspace.setup(mDragController);
// Until the workspace is bound, ensure that we keep the wallpaper offset locked to the
@@ -1318,7 +1319,10 @@
unregisterReceiver(mScreenOffReceiver);
mWorkspace.removeFolderListeners();
- UiFactory.setOnTouchControllersChangedListener(this, null);
+ if (mCancelTouchController != null) {
+ mCancelTouchController.run();
+ mCancelTouchController = null;
+ }
// Stop callbacks from LauncherModel
// It's possible to receive onDestroy after a new Launcher activity has
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index 7bb6071..dc27516 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -131,6 +131,7 @@
if ((changeFlags & CHANGE_FLAG_ICON_PARAMS) != 0) {
LauncherIcons.clearPool();
mIconCache.updateIconParams(idp.fillResIconDpi, idp.iconBitmapSize);
+ mWidgetCache.refresh();
}
mModel.forceReload();
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index b6e00cc..c65a871 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -18,22 +18,23 @@
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_AUTO;
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS;
import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED;
-
import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL;
import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
import static com.android.launcher3.TestProtocol.NORMAL_STATE_ORDINAL;
+import static com.android.launcher3.TestProtocol.OVERVIEW_PEEK_STATE_ORDINAL;
import static com.android.launcher3.TestProtocol.OVERVIEW_STATE_ORDINAL;
+import static com.android.launcher3.TestProtocol.QUICK_SWITCH_STATE_ORDINAL;
import static com.android.launcher3.TestProtocol.SPRING_LOADED_STATE_ORDINAL;
import static com.android.launcher3.anim.Interpolators.ACCEL_2;
import static com.android.launcher3.states.RotationHelper.REQUEST_NONE;
import android.view.animation.Interpolator;
+import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.states.SpringLoadedState;
-import com.android.launcher3.uioverrides.AllAppsState;
-import com.android.launcher3.uioverrides.BackgroundAppState;
-import com.android.launcher3.uioverrides.OverviewState;
import com.android.launcher3.uioverrides.UiFactory;
+import com.android.launcher3.uioverrides.states.AllAppsState;
+import com.android.launcher3.uioverrides.states.OverviewState;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@@ -77,7 +78,7 @@
}
};
- private static final LauncherState[] sAllStates = new LauncherState[6];
+ private static final LauncherState[] sAllStates = new LauncherState[7];
/**
* TODO: Create a separate class for NORMAL state.
@@ -92,10 +93,15 @@
*/
public static final LauncherState SPRING_LOADED = new SpringLoadedState(
SPRING_LOADED_STATE_ORDINAL);
- public static final LauncherState OVERVIEW = new OverviewState(OVERVIEW_STATE_ORDINAL);
public static final LauncherState ALL_APPS = new AllAppsState(ALL_APPS_STATE_ORDINAL);
- public static final LauncherState BACKGROUND_APP = new BackgroundAppState(
- BACKGROUND_APP_STATE_ORDINAL);
+
+ public static final LauncherState OVERVIEW = new OverviewState(OVERVIEW_STATE_ORDINAL);
+ public static final LauncherState OVERVIEW_PEEK =
+ OverviewState.newPeekState(OVERVIEW_PEEK_STATE_ORDINAL);
+ public static final LauncherState QUICK_SWITCH =
+ OverviewState.newSwitchState(QUICK_SWITCH_STATE_ORDINAL);
+ public static final LauncherState BACKGROUND_APP =
+ OverviewState.newBackgroundState(BACKGROUND_APP_STATE_ORDINAL);
public final int ordinal;
@@ -193,6 +199,11 @@
}
public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) {
+ if (FeatureFlags.SWIPE_HOME.get()) {
+ float offscreenTranslationX = launcher.getDragLayer().getWidth()
+ - launcher.getOverviewPanel().getPaddingStart();
+ return new ScaleAndTranslation(1f, offscreenTranslationX, 0f);
+ }
return new ScaleAndTranslation(1.1f, 0f, 0f);
}
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index 97c8f51..5f7538b 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -18,14 +18,20 @@
import static android.view.View.VISIBLE;
import static com.android.launcher3.LauncherState.NORMAL;
+import static com.android.launcher3.LauncherState.OVERVIEW;
+import static com.android.launcher3.LauncherState.OVERVIEW_PEEK;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE;
+import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_TRANSLATE_X;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_FADE;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_SCALE;
import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
+import static com.android.launcher3.anim.Interpolators.INSTANT;
+import static com.android.launcher3.anim.Interpolators.NEVER;
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
+import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_7;
import static com.android.launcher3.anim.Interpolators.clampToProgress;
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
@@ -96,17 +102,21 @@
// We separate the state animations into "atomic" and "non-atomic" components. The atomic
// components may be run atomically - that is, all at once, instead of user-controlled. However,
// atomic components are not restricted to this purpose; they can be user-controlled alongside
- // non atomic components as well.
+ // non atomic components as well. Note that each gesture model has exactly one atomic component,
+ // ATOMIC_OVERVIEW_SCALE_COMPONENT *or* ATOMIC_OVERVIEW_PEEK_COMPONENT.
@IntDef(flag = true, value = {
NON_ATOMIC_COMPONENT,
- ATOMIC_COMPONENT
+ ATOMIC_OVERVIEW_SCALE_COMPONENT,
+ ATOMIC_OVERVIEW_PEEK_COMPONENT,
})
@Retention(RetentionPolicy.SOURCE)
public @interface AnimationComponents {}
public static final int NON_ATOMIC_COMPONENT = 1 << 0;
- public static final int ATOMIC_COMPONENT = 1 << 1;
+ public static final int ATOMIC_OVERVIEW_SCALE_COMPONENT = 1 << 1;
+ public static final int ATOMIC_OVERVIEW_PEEK_COMPONENT = 1 << 2;
- public static final int ANIM_ALL = NON_ATOMIC_COMPONENT | ATOMIC_COMPONENT;
+ public static final int ANIM_ALL = NON_ATOMIC_COMPONENT | ATOMIC_OVERVIEW_SCALE_COMPONENT
+ | ATOMIC_OVERVIEW_PEEK_COMPONENT;
private final AnimationConfig mConfig = new AnimationConfig();
private final Handler mUiHandler;
@@ -282,18 +292,20 @@
*/
public void prepareForAtomicAnimation(LauncherState fromState, LauncherState toState,
AnimatorSetBuilder builder) {
- if (fromState == NORMAL && toState.overviewUi) {
+ if (fromState == NORMAL && toState == OVERVIEW) {
builder.setInterpolator(ANIM_WORKSPACE_SCALE, OVERSHOOT_1_2);
builder.setInterpolator(ANIM_WORKSPACE_FADE, OVERSHOOT_1_2);
builder.setInterpolator(ANIM_OVERVIEW_SCALE, OVERSHOOT_1_2);
+ builder.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, OVERSHOOT_1_7);
builder.setInterpolator(ANIM_OVERVIEW_FADE, OVERSHOOT_1_2);
// Start from a higher overview scale, but only if we're invisible so we don't jump.
UiFactory.prepareToShowOverview(mLauncher);
- } else if (fromState.overviewUi && toState == NORMAL) {
+ } else if (fromState == OVERVIEW && toState == NORMAL) {
builder.setInterpolator(ANIM_WORKSPACE_SCALE, DEACCEL);
builder.setInterpolator(ANIM_WORKSPACE_FADE, ACCEL);
builder.setInterpolator(ANIM_OVERVIEW_SCALE, clampToProgress(ACCEL, 0, 0.9f));
+ builder.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, ACCEL);
builder.setInterpolator(ANIM_OVERVIEW_FADE, DEACCEL_1_7);
Workspace workspace = mLauncher.getWorkspace();
@@ -311,9 +323,25 @@
workspace.getHotseat().setScaleX(0.92f);
workspace.getHotseat().setScaleY(0.92f);
}
+ } else if (fromState == NORMAL && toState == OVERVIEW_PEEK) {
+ builder.setInterpolator(ANIM_OVERVIEW_FADE, INSTANT);
+ } else if (fromState == OVERVIEW_PEEK && toState == NORMAL) {
+ builder.setInterpolator(ANIM_OVERVIEW_FADE, NEVER);
}
}
+ public AnimatorSet createAtomicAnimation(LauncherState fromState, LauncherState toState,
+ AnimatorSetBuilder builder, @AnimationComponents int atomicComponent, long duration) {
+ prepareForAtomicAnimation(fromState, toState, builder);
+ AnimationConfig config = new AnimationConfig();
+ config.animComponents = atomicComponent;
+ config.duration = duration;
+ for (StateHandler handler : mLauncher.getStateManager().getStateHandlers()) {
+ handler.setStateWithAnimation(toState, builder, config);
+ }
+ return builder.build();
+ }
+
/**
* Creates a {@link AnimatorPlaybackController} that can be used for a controlled
* state transition. The UI is force-set to fromState before creating the controller.
@@ -593,8 +621,12 @@
mCurrentAnimation.addListener(this);
}
- public boolean playAtomicComponent() {
- return (animComponents & ATOMIC_COMPONENT) != 0;
+ public boolean playAtomicOverviewScaleComponent() {
+ return (animComponents & ATOMIC_OVERVIEW_SCALE_COMPONENT) != 0;
+ }
+
+ public boolean playAtomicOverviewPeekComponent() {
+ return (animComponents & ATOMIC_OVERVIEW_PEEK_COMPONENT) != 0;
}
public boolean playNonAtomicComponent() {
diff --git a/src/com/android/launcher3/TestProtocol.java b/src/com/android/launcher3/TestProtocol.java
index 4eb3627..7d3715e 100644
--- a/src/com/android/launcher3/TestProtocol.java
+++ b/src/com/android/launcher3/TestProtocol.java
@@ -28,8 +28,31 @@
public static final int NORMAL_STATE_ORDINAL = 0;
public static final int SPRING_LOADED_STATE_ORDINAL = 1;
public static final int OVERVIEW_STATE_ORDINAL = 2;
- public static final int ALL_APPS_STATE_ORDINAL = 3;
- public static final int BACKGROUND_APP_STATE_ORDINAL = 4;
+ public static final int OVERVIEW_PEEK_STATE_ORDINAL = 3;
+ public static final int QUICK_SWITCH_STATE_ORDINAL = 4;
+ public static final int ALL_APPS_STATE_ORDINAL = 5;
+ public static final int BACKGROUND_APP_STATE_ORDINAL = 6;
+
+ public static String stateOrdinalToString(int ordinal) {
+ switch (ordinal) {
+ case NORMAL_STATE_ORDINAL:
+ return "Normal";
+ case SPRING_LOADED_STATE_ORDINAL:
+ return "SpringLoaded";
+ case OVERVIEW_STATE_ORDINAL:
+ return "Overview";
+ case OVERVIEW_PEEK_STATE_ORDINAL:
+ return "OverviewPeek";
+ case QUICK_SWITCH_STATE_ORDINAL:
+ return "QuickSwitch";
+ case ALL_APPS_STATE_ORDINAL:
+ return "AllApps";
+ case BACKGROUND_APP_STATE_ORDINAL:
+ return "Background";
+ default:
+ return null;
+ }
+ }
public static final String TEST_INFO_RESPONSE_FIELD = "response";
public static final String REQUEST_HOME_TO_OVERVIEW_SWIPE_HEIGHT =
@@ -40,4 +63,7 @@
"all-apps-to-overview-swipe-height";
public static final String REQUEST_HOME_TO_ALL_APPS_SWIPE_HEIGHT =
"home-to-all-apps-swipe-height";
+
+ public static boolean sDebugTracing = false;
+ public static final String NO_DRAG_TAG = "b/129434166";
}
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index dd755cb..fd4b508 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -308,10 +308,14 @@
Log.e(TAG, "mapToRange: range has 0 length");
return toMin;
}
- float progress = Math.abs(t - fromMin) / Math.abs(fromMax - fromMin);
+ float progress = getProgress(t, fromMin, fromMax);
return mapRange(interpolator.getInterpolation(progress), toMin, toMax);
}
+ public static float getProgress(float current, float min, float max) {
+ return Math.abs(current - min) / Math.abs(max - min);
+ }
+
public static float mapRange(float value, float min, float max) {
return min + (value * (max - min));
}
diff --git a/src/com/android/launcher3/WidgetPreviewLoader.java b/src/com/android/launcher3/WidgetPreviewLoader.java
index 050849c..6d1bc1a 100644
--- a/src/com/android/launcher3/WidgetPreviewLoader.java
+++ b/src/com/android/launcher3/WidgetPreviewLoader.java
@@ -24,6 +24,7 @@
import android.os.AsyncTask;
import android.os.CancellationSignal;
import android.os.Handler;
+import android.os.Process;
import android.os.UserHandle;
import android.util.Log;
import android.util.LongSparseArray;
@@ -73,7 +74,6 @@
private final Context mContext;
private final IconCache mIconCache;
private final UserManagerCompat mUserManager;
- private final AppWidgetManagerCompat mWidgetManager;
private final CacheDb mDb;
private final MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor();
@@ -82,7 +82,6 @@
public WidgetPreviewLoader(Context context, IconCache iconCache) {
mContext = context;
mIconCache = iconCache;
- mWidgetManager = AppWidgetManagerCompat.getInstance(context);
mUserManager = UserManagerCompat.getInstance(context);
mDb = new CacheDb(context);
mWorkerHandler = new Handler(LauncherModel.getWorkerLooper());
@@ -107,6 +106,10 @@
return signal;
}
+ public void refresh() {
+ mDb.clear();
+
+ }
/**
* The DB holds the generated previews for various components. Previews can also have different
* sizes (landscape vs portrait).
@@ -474,8 +477,9 @@
RectF boxRect = drawBoxWithShadow(c, size, size);
LauncherIcons li = LauncherIcons.obtain(mContext);
- Bitmap icon = li.createScaledBitmapWithoutShadow(
- mutateOnMainThread(info.getFullResIcon(mIconCache)), 0);
+ Bitmap icon = li.createBadgedIconBitmap(
+ mutateOnMainThread(info.getFullResIcon(mIconCache)),
+ Process.myUserHandle(), 0).icon;
li.recycle();
Rect src = new Rect(0, 0, icon.getWidth(), icon.getHeight());
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index d05f916..d24a5a6 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1446,6 +1446,10 @@
public DragView beginDragShared(View child, DragSource source, ItemInfo dragObject,
DragPreviewProvider previewProvider, DragOptions dragOptions) {
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "beginDragShared");
+ }
float iconScale = 1f;
if (child instanceof BubbleTextView) {
Drawable icon = ((BubbleTextView) child).getIcon();
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index bed61a1..99a8801 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -21,6 +21,7 @@
import static com.android.launcher3.LauncherState.HOTSEAT_ICONS;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_FADE;
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_SCALE;
+import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_WORKSPACE_TRANSLATE;
import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.anim.Interpolators.ZOOM_OUT;
import static com.android.launcher3.anim.PropertySetter.NO_ANIM_PROPERTY_SETTER;
@@ -86,7 +87,7 @@
int elements = state.getVisibleElements(mLauncher);
Interpolator fadeInterpolator = builder.getInterpolator(ANIM_WORKSPACE_FADE,
pageAlphaProvider.interpolator);
- boolean playAtomicComponent = config.playAtomicComponent();
+ boolean playAtomicComponent = config.playAtomicOverviewScaleComponent();
Hotseat hotseat = mWorkspace.getHotseat();
if (playAtomicComponent) {
Interpolator scaleInterpolator = builder.getInterpolator(ANIM_WORKSPACE_SCALE, ZOOM_OUT);
@@ -114,7 +115,9 @@
return;
}
- Interpolator translationInterpolator = !playAtomicComponent ? LINEAR : ZOOM_OUT;
+ Interpolator translationInterpolator = !playAtomicComponent
+ ? LINEAR
+ : builder.getInterpolator(ANIM_WORKSPACE_TRANSLATE, ZOOM_OUT);
propertySetter.setFloat(mWorkspace, View.TRANSLATION_X,
scaleAndTranslation.translationX, translationInterpolator);
propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y,
@@ -147,7 +150,7 @@
propertySetter.setInt(cl.getScrimBackground(),
DRAWABLE_ALPHA, drawableAlpha, ZOOM_OUT);
}
- if (config.playAtomicComponent()) {
+ if (config.playAtomicOverviewScaleComponent()) {
Interpolator fadeInterpolator = builder.getInterpolator(ANIM_WORKSPACE_FADE,
pageAlphaProvider.interpolator);
propertySetter.setFloat(cl.getShortcutsAndWidgets(), View.ALPHA,
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index a4ecec7..4a1d432 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -205,7 +205,7 @@
mAppsView.getSearchUiManager().setContentVisibility(visibleElements, setter, allAppsFade);
setter.setInt(mScrimView, ScrimView.DRAG_HANDLE_ALPHA,
- (visibleElements & VERTICAL_SWIPE_INDICATOR) != 0 ? 255 : 0, LINEAR);
+ (visibleElements & VERTICAL_SWIPE_INDICATOR) != 0 ? 255 : 0, allAppsFade);
}
public AnimatorListenerAdapter getProgressAnimatorListener() {
diff --git a/src/com/android/launcher3/anim/AnimatorSetBuilder.java b/src/com/android/launcher3/anim/AnimatorSetBuilder.java
index 3ac9d3c..5c498f8 100644
--- a/src/com/android/launcher3/anim/AnimatorSetBuilder.java
+++ b/src/com/android/launcher3/anim/AnimatorSetBuilder.java
@@ -30,11 +30,13 @@
public static final int ANIM_VERTICAL_PROGRESS = 0;
public static final int ANIM_WORKSPACE_SCALE = 1;
- public static final int ANIM_WORKSPACE_FADE = 2;
- public static final int ANIM_OVERVIEW_SCALE = 3;
- public static final int ANIM_OVERVIEW_TRANSLATE = 4;
- public static final int ANIM_OVERVIEW_FADE = 5;
- public static final int ANIM_ALL_APPS_FADE = 6;
+ public static final int ANIM_WORKSPACE_TRANSLATE = 2;
+ public static final int ANIM_WORKSPACE_FADE = 3;
+ public static final int ANIM_OVERVIEW_SCALE = 4;
+ public static final int ANIM_OVERVIEW_TRANSLATE_X = 5;
+ public static final int ANIM_OVERVIEW_TRANSLATE_Y = 6;
+ public static final int ANIM_OVERVIEW_FADE = 7;
+ public static final int ANIM_ALL_APPS_FADE = 8;
public static final int FLAG_DONT_ANIMATE_OVERVIEW = 1 << 0;
diff --git a/src/com/android/launcher3/anim/Interpolators.java b/src/com/android/launcher3/anim/Interpolators.java
index 675e26d..217b6db 100644
--- a/src/com/android/launcher3/anim/Interpolators.java
+++ b/src/com/android/launcher3/anim/Interpolators.java
@@ -57,6 +57,9 @@
public static final Interpolator EXAGGERATED_EASE;
+ public static final Interpolator INSTANT = t -> 1;
+ public static final Interpolator NEVER = t -> 0;
+
private static final int MIN_SETTLE_DURATION = 200;
private static final float OVERSHOOT_FACTOR = 0.9f;
@@ -69,6 +72,7 @@
}
public static final Interpolator OVERSHOOT_1_2 = new OvershootInterpolator(1.2f);
+ public static final Interpolator OVERSHOOT_1_7 = new OvershootInterpolator(1.7f);
public static final Interpolator TOUCH_RESPONSE_INTERPOLATOR =
new PathInterpolator(0.3f, 0f, 0.1f, 1f);
diff --git a/src/com/android/launcher3/config/BaseFlags.java b/src/com/android/launcher3/config/BaseFlags.java
index 106d901..656151f 100644
--- a/src/com/android/launcher3/config/BaseFlags.java
+++ b/src/com/android/launcher3/config/BaseFlags.java
@@ -118,10 +118,6 @@
"ENABLE_HINTS_IN_OVERVIEW", false,
"Show chip hints and gleams on the overview screen");
- public static final TogglableFlag ENABLE_ASSISTANT_GESTURE = new ToggleableGlobalSettingsFlag(
- "ENABLE_ASSISTANT_GESTURE", false,
- "Enable swipe up from the bottom right corner to start assistant");
-
public static void initialize(Context context) {
// Avoid the disk read for user builds
if (Utilities.IS_DEBUG_DEVICE) {
diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java
index 03dc66e..8b100d9 100644
--- a/src/com/android/launcher3/dragndrop/DragController.java
+++ b/src/com/android/launcher3/dragndrop/DragController.java
@@ -219,6 +219,9 @@
}
private void callOnDragStart() {
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, "callOnDragStart");
+ }
if (mOptions.preDragCondition != null) {
mOptions.preDragCondition.onPreDragEnd(mDragObject, true /* dragStarted*/);
}
@@ -472,6 +475,9 @@
}
private void handleMoveEvent(int x, int y) {
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG, "handleMoveEvent1");
+ }
mDragObject.dragView.move(x, y);
// Drop on someone?
@@ -488,6 +494,10 @@
if (mIsInPreDrag && mOptions.preDragCondition != null
&& mOptions.preDragCondition.shouldStartDrag(mDistanceSinceScroll)) {
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "handleMoveEvent2");
+ }
callOnDragStart();
}
}
@@ -525,6 +535,10 @@
* Call this from a drag source view.
*/
public boolean onControllerTouchEvent(MotionEvent ev) {
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "onControllerTouchEvent1");
+ }
if (mDragDriver == null || mOptions == null || mOptions.isAccessibleDrag) {
return false;
}
@@ -545,6 +559,10 @@
break;
}
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "onControllerTouchEvent2");
+ }
return mDragDriver.onTouchEvent(ev);
}
diff --git a/src/com/android/launcher3/dragndrop/DragDriver.java b/src/com/android/launcher3/dragndrop/DragDriver.java
index 84fc94d..551f2d0 100644
--- a/src/com/android/launcher3/dragndrop/DragDriver.java
+++ b/src/com/android/launcher3/dragndrop/DragDriver.java
@@ -45,10 +45,18 @@
public void onDragViewAnimationEnd() { }
public boolean onTouchEvent(MotionEvent ev) {
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "onTouchEvent " + ev);
+ }
final int action = ev.getAction();
switch (action) {
case MotionEvent.ACTION_MOVE:
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "onTouchEvent MOVE");
+ }
mEventListener.onDriverDragMove(ev.getX(), ev.getY());
break;
case MotionEvent.ACTION_UP:
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index 6950a1f..9f902ed 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -126,6 +126,10 @@
protected boolean findActiveController(MotionEvent ev) {
if (mActivity.getStateManager().getState().disableInteraction) {
// You Shall Not Pass!!!
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "mActiveController = null");
+ }
mActiveController = null;
return true;
}
diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java
index 521f5c1..bcd5701 100644
--- a/src/com/android/launcher3/folder/FolderIcon.java
+++ b/src/com/android/launcher3/folder/FolderIcon.java
@@ -199,6 +199,7 @@
}
public void getPreviewBounds(Rect outBounds) {
+ mPreviewItemManager.recomputePreviewDrawingParams();
mBackground.getBounds(outBounds);
}
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index 10ecc4f..080a0cb 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -187,6 +187,10 @@
* @return the container if shown or null.
*/
public static PopupContainerWithArrow showForIcon(BubbleTextView icon) {
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "PopupContainerWithArrow.showForIcon");
+ }
Launcher launcher = Launcher.getLauncher(icon.getContext());
if (getOpen(launcher) != null) {
// There is already an items container open, so don't open this one.
diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
index c125c10..0274de3 100644
--- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
+++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
@@ -20,7 +20,7 @@
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.LauncherStateManager.ANIM_ALL;
-import static com.android.launcher3.LauncherStateManager.ATOMIC_COMPONENT;
+import static com.android.launcher3.LauncherStateManager.ATOMIC_OVERVIEW_SCALE_COMPONENT;
import static com.android.launcher3.LauncherStateManager.NON_ATOMIC_COMPONENT;
import static com.android.launcher3.Utilities.SINGLE_FRAME_MS;
import static com.android.launcher3.anim.Interpolators.scrollInterpolatorForVelocity;
@@ -38,9 +38,6 @@
import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager.AnimationComponents;
-import com.android.launcher3.LauncherStateManager.AnimationConfig;
-import com.android.launcher3.LauncherStateManager.StateHandler;
-import com.android.launcher3.TestProtocol;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.AnimationSuccessListener;
import com.android.launcher3.anim.AnimatorPlaybackController;
@@ -68,10 +65,11 @@
* Play an atomic recents animation when the progress from NORMAL to OVERVIEW reaches this.
*/
public static final float ATOMIC_OVERVIEW_ANIM_THRESHOLD = 0.5f;
- protected static final long ATOMIC_DURATION = 200;
+ protected final long ATOMIC_DURATION = getAtomicDuration();
protected final Launcher mLauncher;
protected final SwipeDetector mDetector;
+ protected final SwipeDetector.Direction mSwipeDirection;
private boolean mNoIntercept;
protected int mStartContainerType;
@@ -108,6 +106,11 @@
public AbstractStateChangeTouchController(Launcher l, SwipeDetector.Direction dir) {
mLauncher = l;
mDetector = new SwipeDetector(l, this, dir);
+ mSwipeDirection = dir;
+ }
+
+ protected long getAtomicDuration() {
+ return 200;
}
protected abstract boolean canInterceptTouch(MotionEvent ev);
@@ -214,14 +217,15 @@
}
if (mAtomicComponentsController != null) {
- animComponents &= ~ATOMIC_COMPONENT;
+ animComponents &= ~ATOMIC_OVERVIEW_SCALE_COMPONENT;
}
mProgressMultiplier = initCurrentAnimation(animComponents);
mCurrentAnimation.dispatchOnStart();
return true;
}
- private boolean goingBetweenNormalAndOverview(LauncherState fromState, LauncherState toState) {
+ protected boolean goingBetweenNormalAndOverview(LauncherState fromState,
+ LauncherState toState) {
return (fromState == NORMAL || fromState == OVERVIEW)
&& (toState == NORMAL || toState == OVERVIEW)
&& mPendingAnimation == null;
@@ -229,12 +233,17 @@
@Override
public void onDragStart(boolean start) {
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "AbstractStateChangeTouchController.onDragStart() called with: start = [" +
+ start + "]");
+ }
mStartState = mLauncher.getStateManager().getState();
if (mStartState == ALL_APPS) {
mStartContainerType = LauncherLogProto.ContainerType.ALLAPPS;
} else if (mStartState == NORMAL) {
mStartContainerType = getLogContainerTypeForNormalState();
- } else if (mStartState == OVERVIEW){
+ } else if (mStartState == OVERVIEW){
mStartContainerType = LauncherLogProto.ContainerType.TASKSWITCHER;
}
if (mCurrentAnimation == null) {
@@ -260,8 +269,14 @@
public boolean onDrag(float displacement) {
float deltaProgress = mProgressMultiplier * (displacement - mDisplacementShift);
float progress = deltaProgress + mStartProgress;
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "AbstractStateChangeTouchController.onDrag() called with: displacement = [" +
+ displacement + "], progress = [" + progress + "]");
+ }
updateProgress(progress);
- boolean isDragTowardPositive = (displacement - mDisplacementShift) < 0;
+ boolean isDragTowardPositive = mSwipeDirection.isPositive(
+ displacement - mDisplacementShift);
if (progress <= 0) {
if (reinitCurrentAnimation(false, isDragTowardPositive)) {
mDisplacementShift = displacement;
@@ -297,7 +312,7 @@
* When going between normal and overview states, see if we passed the overview threshold and
* play the appropriate atomic animation if so.
*/
- protected void maybeUpdateAtomicAnim(LauncherState fromState, LauncherState toState,
+ private void maybeUpdateAtomicAnim(LauncherState fromState, LauncherState toState,
float progress) {
if (!goingBetweenNormalAndOverview(fromState, toState)) {
return;
@@ -347,14 +362,8 @@
private AnimatorSet createAtomicAnimForState(LauncherState fromState, LauncherState targetState,
long duration) {
AnimatorSetBuilder builder = getAnimatorSetBuilderForStates(fromState, targetState);
- mLauncher.getStateManager().prepareForAtomicAnimation(fromState, targetState, builder);
- AnimationConfig config = new AnimationConfig();
- config.animComponents = ATOMIC_COMPONENT;
- config.duration = duration;
- for (StateHandler handler : mLauncher.getStateManager().getStateHandlers()) {
- handler.setStateWithAnimation(targetState, builder, config);
- }
- return builder.build();
+ return mLauncher.getStateManager().createAtomicAnimation(fromState, targetState, builder,
+ ATOMIC_OVERVIEW_SCALE_COMPONENT, duration);
}
protected AnimatorSetBuilder getAnimatorSetBuilderForStates(LauncherState fromState,
@@ -384,6 +393,12 @@
? MIN_PROGRESS_TO_ALL_APPS : SUCCESS_TRANSITION_PROGRESS;
targetState = (interpolatedProgress > successProgress) ? mToState : mFromState;
}
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "AbstractStateChangeTouchController.onDragEnd() called with: velocity = [" +
+ velocity + "], fling = [" + fling + "], target state: " +
+ targetState.getClass().getSimpleName());
+ }
final float endProgress;
final float startProgress;
@@ -434,11 +449,7 @@
mLauncher.getAppsView().addSpringFromFlingUpdateListener(anim, velocity);
}
anim.start();
- settleAtomicAnimation(endProgress, anim.getDuration());
- }
-
- protected void settleAtomicAnimation(float endProgress, long duration) {
- mAtomicAnimAutoPlayInfo = new AutoPlayAtomicAnimationInfo(endProgress, duration);
+ mAtomicAnimAutoPlayInfo = new AutoPlayAtomicAnimationInfo(endProgress, anim.getDuration());
maybeAutoPlayAtomicComponentsAnim();
}
diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java
index 3639090..3c77860 100644
--- a/src/com/android/launcher3/touch/ItemClickHandler.java
+++ b/src/com/android/launcher3/touch/ItemClickHandler.java
@@ -23,7 +23,6 @@
import static com.android.launcher3.Launcher.REQUEST_BIND_PENDING_APPWIDGET;
import static com.android.launcher3.Launcher.REQUEST_RECONFIGURE_APPWIDGET;
import static com.android.launcher3.model.AppLaunchTracker.CONTAINER_ALL_APPS;
-import static com.android.launcher3.model.AppLaunchTracker.CONTAINER_DEFAULT;
import android.app.AlertDialog;
import android.content.Intent;
@@ -33,6 +32,8 @@
import android.view.View.OnClickListener;
import android.widget.Toast;
+import androidx.annotation.Nullable;
+
import com.android.launcher3.AppInfo;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.FolderInfo;
@@ -50,8 +51,6 @@
import com.android.launcher3.widget.PendingAppWidgetHostView;
import com.android.launcher3.widget.WidgetAddFlowHandler;
-import androidx.annotation.Nullable;
-
/**
* Class for handling clicks on workspace and all-apps items
*/
@@ -67,6 +66,14 @@
}
private static void onClick(View v, String sourceContainer) {
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "onClick() called with: v = [" + v.getClass().getSimpleName() +
+ "], sourceContainer = [" +
+ (sourceContainer != null ?
+ sourceContainer.getClass().getSimpleName() : "null")
+ + "]");
+ }
// Make sure that rogue clicks don't get through while allapps is launching, or after the
// view has detached (it's possible for this to happen if the view is removed mid touch).
if (v.getWindowToken() == null) {
diff --git a/src/com/android/launcher3/touch/ItemLongClickListener.java b/src/com/android/launcher3/touch/ItemLongClickListener.java
index babbcdd..003b442 100644
--- a/src/com/android/launcher3/touch/ItemLongClickListener.java
+++ b/src/com/android/launcher3/touch/ItemLongClickListener.java
@@ -74,6 +74,10 @@
}
private static boolean onAllAppsItemLongClick(View v) {
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "onAllAppsItemLongClick");
+ }
Launcher launcher = Launcher.getLauncher(v.getContext());
if (!canStartDrag(launcher)) return false;
// When we have exited all apps or are in transition, disregard long clicks
diff --git a/src/com/android/launcher3/touch/SwipeDetector.java b/src/com/android/launcher3/touch/SwipeDetector.java
index a0a410e..e558fc7 100644
--- a/src/com/android/launcher3/touch/SwipeDetector.java
+++ b/src/com/android/launcher3/touch/SwipeDetector.java
@@ -24,6 +24,8 @@
import android.view.VelocityTracker;
import android.view.ViewConfiguration;
+import com.android.launcher3.Utilities;
+
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
@@ -64,20 +66,25 @@
public static abstract class Direction {
- abstract float getDisplacement(MotionEvent ev, int pointerIndex, PointF refPoint);
+ abstract float getDisplacement(MotionEvent ev, int pointerIndex, PointF refPoint,
+ boolean isRtl);
/**
* Distance in pixels a touch can wander before we think the user is scrolling.
*/
abstract float getActiveTouchSlop(MotionEvent ev, int pointerIndex, PointF downPos);
- abstract float getVelocity(VelocityTracker tracker);
+ abstract float getVelocity(VelocityTracker tracker, boolean isRtl);
+
+ abstract boolean isPositive(float displacement);
+
+ abstract boolean isNegative(float displacement);
}
public static final Direction VERTICAL = new Direction() {
@Override
- float getDisplacement(MotionEvent ev, int pointerIndex, PointF refPoint) {
+ float getDisplacement(MotionEvent ev, int pointerIndex, PointF refPoint, boolean isRtl) {
return ev.getY(pointerIndex) - refPoint.y;
}
@@ -87,16 +94,32 @@
}
@Override
- float getVelocity(VelocityTracker tracker) {
+ float getVelocity(VelocityTracker tracker, boolean isRtl) {
return tracker.getYVelocity();
}
+
+ @Override
+ boolean isPositive(float displacement) {
+ // Up
+ return displacement < 0;
+ }
+
+ @Override
+ boolean isNegative(float displacement) {
+ // Down
+ return displacement > 0;
+ }
};
public static final Direction HORIZONTAL = new Direction() {
@Override
- float getDisplacement(MotionEvent ev, int pointerIndex, PointF refPoint) {
- return ev.getX(pointerIndex) - refPoint.x;
+ float getDisplacement(MotionEvent ev, int pointerIndex, PointF refPoint, boolean isRtl) {
+ float displacement = ev.getX(pointerIndex) - refPoint.x;
+ if (isRtl) {
+ displacement = -displacement;
+ }
+ return displacement;
}
@Override
@@ -105,8 +128,24 @@
}
@Override
- float getVelocity(VelocityTracker tracker) {
- return tracker.getXVelocity();
+ float getVelocity(VelocityTracker tracker, boolean isRtl) {
+ float velocity = tracker.getXVelocity();
+ if (isRtl) {
+ velocity = -velocity;
+ }
+ return velocity;
+ }
+
+ @Override
+ boolean isPositive(float displacement) {
+ // Right
+ return displacement > 0;
+ }
+
+ @Override
+ boolean isNegative(float displacement) {
+ // Left
+ return displacement < 0;
}
};
@@ -159,6 +198,7 @@
private final PointF mDownPos = new PointF();
private final PointF mLastPos = new PointF();
private final Direction mDir;
+ private final boolean mIsRtl;
private final float mTouchSlop;
private final float mMaxVelocity;
@@ -183,14 +223,15 @@
}
public SwipeDetector(@NonNull Context context, @NonNull Listener l, @NonNull Direction dir) {
- this(ViewConfiguration.get(context), l, dir);
+ this(ViewConfiguration.get(context), l, dir, Utilities.isRtl(context.getResources()));
}
@VisibleForTesting
protected SwipeDetector(@NonNull ViewConfiguration config, @NonNull Listener l,
- @NonNull Direction dir) {
+ @NonNull Direction dir, boolean isRtl) {
mListener = l;
mDir = dir;
+ mIsRtl = isRtl;
mTouchSlop = config.getScaledTouchSlop();
mMaxVelocity = config.getScaledMaximumFlingVelocity();
}
@@ -212,8 +253,8 @@
}
// Check if the client is interested in scroll in current direction.
- if (((mScrollConditions & DIRECTION_NEGATIVE) > 0 && mDisplacement > 0) ||
- ((mScrollConditions & DIRECTION_POSITIVE) > 0 && mDisplacement < 0)) {
+ if (((mScrollConditions & DIRECTION_NEGATIVE) > 0 && mDir.isNegative(mDisplacement)) ||
+ ((mScrollConditions & DIRECTION_POSITIVE) > 0 && mDir.isPositive(mDisplacement))) {
return true;
}
return false;
@@ -259,7 +300,7 @@
if (pointerIndex == INVALID_POINTER_ID) {
break;
}
- mDisplacement = mDir.getDisplacement(ev, pointerIndex, mDownPos);
+ mDisplacement = mDir.getDisplacement(ev, pointerIndex, mDownPos, mIsRtl);
// handle state and listener calls.
if (mState != ScrollState.DRAGGING && shouldScrollStart(ev, pointerIndex)) {
@@ -315,7 +356,7 @@
* @see #DIRECTION_BOTH
*/
public boolean wasInitialTouchPositive() {
- return mSubtractDisplacement < 0;
+ return mDir.isPositive(mSubtractDisplacement);
}
private boolean reportDragging() {
@@ -332,7 +373,7 @@
private void reportDragEnd() {
mVelocityTracker.computeCurrentVelocity(1000, mMaxVelocity);
- float velocity = mDir.getVelocity(mVelocityTracker) / 1000;
+ float velocity = mDir.getVelocity(mVelocityTracker, mIsRtl) / 1000;
if (DBG) {
Log.d(TAG, String.format("onScrollEnd disp=%.1f, velocity=%.1f",
mDisplacement, velocity));
diff --git a/src/com/android/launcher3/util/InstantAppResolver.java b/src/com/android/launcher3/util/InstantAppResolver.java
index 5dc7af8..031a40d 100644
--- a/src/com/android/launcher3/util/InstantAppResolver.java
+++ b/src/com/android/launcher3/util/InstantAppResolver.java
@@ -24,9 +24,6 @@
import com.android.launcher3.AppInfo;
import com.android.launcher3.R;
-import java.util.Collections;
-import java.util.List;
-
/**
* A wrapper class to access instant app related APIs.
*/
@@ -55,8 +52,4 @@
}
return false;
}
-
- public List<ApplicationInfo> getInstantApps() {
- return Collections.emptyList();
- }
}
diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java
index 4545a1e..bd6bfd6 100644
--- a/src/com/android/launcher3/views/BaseDragLayer.java
+++ b/src/com/android/launcher3/views/BaseDragLayer.java
@@ -114,16 +114,28 @@
}
protected boolean findActiveController(MotionEvent ev) {
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "mActiveController = null");
+ }
mActiveController = null;
AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(mActivity);
if (topView != null && topView.onControllerInterceptTouchEvent(ev)) {
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "setting controller1: " + topView.getClass().getSimpleName());
+ }
mActiveController = topView;
return true;
}
for (TouchController controller : mControllers) {
if (controller.onControllerInterceptTouchEvent(ev)) {
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "setting controller1: " + controller.getClass().getSimpleName());
+ }
mActiveController = controller;
return true;
}
@@ -193,8 +205,17 @@
}
if (mActiveController != null) {
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "BaseDragLayer before onControllerTouchEvent " +
+ mActiveController.getClass().getSimpleName());
+ }
return mActiveController.onControllerTouchEvent(ev);
} else {
+ if (com.android.launcher3.TestProtocol.sDebugTracing) {
+ android.util.Log.d(com.android.launcher3.TestProtocol.NO_DRAG_TAG,
+ "BaseDragLayer no controller");
+ }
// In case no child view handled the touch event, we may not get onIntercept anymore
return findActiveController(ev);
}
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index d1e2c88..5889468 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -15,6 +15,7 @@
*/
package com.android.launcher3.views;
+import static com.android.launcher3.anim.Interpolators.LINEAR;
import static com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM;
import android.animation.Animator;
@@ -47,7 +48,6 @@
import com.android.launcher3.LauncherModel;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
-import com.android.launcher3.anim.Interpolators;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.dragndrop.FolderAdaptiveIcon;
import com.android.launcher3.folder.FolderIcon;
@@ -60,18 +60,20 @@
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
+import static com.android.launcher3.Utilities.mapToRange;
+
/**
* A view that is created to look like another view with the purpose of creating fluid animations.
*/
public class FloatingIconView extends View implements Animator.AnimatorListener, ClipPathView {
+ public static final float SHAPE_PROGRESS_DURATION = 0.15f;
+
private static final Rect sTmpRect = new Rect();
- private Runnable mStartRunnable;
private Runnable mEndRunnable;
- private int mOriginalHeight;
private final int mBlurSizeOutline;
private boolean mIsAdaptiveIcon = false;
@@ -82,30 +84,28 @@
private final Rect mStartRevealRect = new Rect();
private final Rect mEndRevealRect = new Rect();
private Path mClipPath;
- protected final Rect mOutline = new Rect();
- private final float mTaskCornerRadius;
+ private float mTaskCornerRadius;
private final Rect mFinalDrawableBounds = new Rect();
private final Rect mBgDrawableBounds = new Rect();
private float mBgDrawableStartScale = 1f;
+ private float mBgDrawableEndScale = 1f;
private FloatingIconView(Context context) {
super(context);
-
mBlurSizeOutline = context.getResources().getDimensionPixelSize(
R.dimen.blur_size_medium_outline);
-
- mTaskCornerRadius = 0; // TODO
}
/**
* Positions this view to match the size and location of {@param rect}.
- *
* @param alpha The alpha to set this view.
* @param progress A value from [0, 1] that represents the animation progress.
- * @param windowAlphaThreshold The value at which the window alpha is 0.
+ * @param shapeProgressStart The progress value at which to start the shape reveal.
+ * @param cornerRadius The corner radius of {@param rect}.
*/
- public void update(RectF rect, float alpha, float progress, float windowAlphaThreshold) {
+ public void update(RectF rect, float alpha, float progress, float shapeProgressStart,
+ float cornerRadius, boolean isOpening) {
setAlpha(alpha);
LayoutParams lp = (LayoutParams) getLayoutParams();
@@ -116,49 +116,42 @@
float scaleX = rect.width() / (float) lp.width;
float scaleY = rect.height() / (float) lp.height;
- float scale = mIsAdaptiveIcon ? Math.max(scaleX, scaleY) : Math.min(scaleX, scaleY);
+ float scale = mIsAdaptiveIcon && !isOpening ? Math.max(scaleX, scaleY)
+ : Math.min(scaleX, scaleY);
+ scale = Math.max(1f, scale);
+
setPivotX(0);
setPivotY(0);
setScaleX(scale);
setScaleY(scale);
- // Wait until the window is no longer visible before morphing the icon into its final shape.
- float shapeRevealProgress = Utilities.mapToRange(Math.max(windowAlphaThreshold, progress),
- windowAlphaThreshold, 1f, 0f, 1, Interpolators.LINEAR);
- if (mIsAdaptiveIcon && shapeRevealProgress > 0) {
+ // shapeRevealProgress = 1 when progress = shapeProgressStart + SHAPE_PROGRESS_DURATION
+ float toMax = isOpening ? 1 / SHAPE_PROGRESS_DURATION : 1f;
+ float shapeRevealProgress = Utilities.boundToRange(mapToRange(
+ Math.max(shapeProgressStart, progress), shapeProgressStart, 1f, 0, toMax,
+ LINEAR), 0, 1);
+
+ mTaskCornerRadius = cornerRadius;
+ if (mIsAdaptiveIcon && shapeRevealProgress >= 0) {
if (mRevealAnimator == null) {
- mEndRevealRect.set(mOutline);
- // We play the reveal animation in reverse so that we end with the icon shape.
mRevealAnimator = (ValueAnimator) FolderShape.getShape().createRevealAnimator(this,
- mStartRevealRect, mEndRevealRect, mTaskCornerRadius / scale, true);
- mRevealAnimator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- mRevealAnimator = null;
- }
- });
+ mStartRevealRect, mEndRevealRect, mTaskCornerRadius / scale, !isOpening);
mRevealAnimator.start();
// We pause here so we can set the current fraction ourselves.
mRevealAnimator.pause();
}
- float bgScale = shapeRevealProgress + mBgDrawableStartScale * (1 - shapeRevealProgress);
- setBackgroundDrawableBounds(bgScale);
-
mRevealAnimator.setCurrentFraction(shapeRevealProgress);
+
+ float bgScale = (mBgDrawableEndScale * shapeRevealProgress) + mBgDrawableStartScale
+ * (1 - shapeRevealProgress);
+ setBackgroundDrawableBounds(bgScale);
}
invalidate();
invalidateOutline();
}
@Override
- public void onAnimationStart(Animator animator) {
- if (mStartRunnable != null) {
- mStartRunnable.run();
- }
- }
-
- @Override
public void onAnimationEnd(Animator animator) {
if (mEndRunnable != null) {
mEndRunnable.run();
@@ -180,7 +173,6 @@
Utilities.getLocationBoundsForView(launcher, v, positionOut);
final LayoutParams lp = new LayoutParams(positionOut.width(), positionOut.height());
lp.ignoreInsets = true;
- mOriginalHeight = lp.height;
// Position the floating view exactly on top of the original
lp.leftMargin = positionOut.left;
@@ -193,11 +185,11 @@
}
@WorkerThread
- private void getIcon(Launcher launcher, View v, ItemInfo info, boolean useDrawableAsIs,
- float aspectRatio) {
+ private void getIcon(Launcher launcher, View v, ItemInfo info, boolean isOpening,
+ Runnable onIconLoadedRunnable) {
final LayoutParams lp = (LayoutParams) getLayoutParams();
Drawable drawable = null;
- boolean supportsAdaptiveIcons = ADAPTIVE_ICON_WINDOW_ANIM.get() && !useDrawableAsIs
+ boolean supportsAdaptiveIcons = ADAPTIVE_ICON_WINDOW_ANIM.get()
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
if (!supportsAdaptiveIcons && v instanceof BubbleTextView) {
// Similar to DragView, we simply use the BubbleTextView icon here.
@@ -214,7 +206,7 @@
}
if (drawable == null) {
drawable = Utilities.getFullDrawable(launcher, info, lp.width, lp.height,
- useDrawableAsIs, new Object[1]);
+ false, new Object[1]);
}
Drawable finalDrawable = drawable == null ? null
@@ -247,35 +239,50 @@
sbd.setShiftY(sbd.getShiftY() - sTmpRect.top);
}
+ final int originalHeight = lp.height;
+ final int originalWidth = lp.width;
+
int blurMargin = mBlurSizeOutline / 2;
- mFinalDrawableBounds.set(0, 0, lp.width, mOriginalHeight);
+ mFinalDrawableBounds.set(0, 0, originalWidth, originalHeight);
if (!isFolderIcon) {
mFinalDrawableBounds.inset(iconOffset - blurMargin, iconOffset - blurMargin);
}
mForeground.setBounds(mFinalDrawableBounds);
mBackground.setBounds(mFinalDrawableBounds);
- if (isFolderIcon) {
- mStartRevealRect.set(0, 0, lp.width, mOriginalHeight);
+ mStartRevealRect.set(0, 0, originalWidth, originalHeight);
+
+ if (!isFolderIcon) {
+ mStartRevealRect.inset(mBlurSizeOutline, mBlurSizeOutline);
+ }
+
+ float aspectRatio = launcher.getDeviceProfile().aspectRatio;
+ if (launcher.getDeviceProfile().isVerticalBarLayout()) {
+ lp.width = (int) Math.max(lp.width, lp.height * aspectRatio);
} else {
- mStartRevealRect.set(mBlurSizeOutline, mBlurSizeOutline,
- lp.width - mBlurSizeOutline, mOriginalHeight - mBlurSizeOutline);
- }
-
- if (aspectRatio > 0) {
lp.height = (int) Math.max(lp.height, lp.width * aspectRatio);
- layout(lp.leftMargin, lp.topMargin, lp.leftMargin + lp.width, lp.topMargin
- + lp.height);
}
- mBgDrawableStartScale = (float) lp.height / mOriginalHeight;
- setBackgroundDrawableBounds(mBgDrawableStartScale);
+ layout(lp.leftMargin, lp.topMargin, lp.leftMargin + lp.width, lp.topMargin
+ + lp.height);
- // Set up outline
- mOutline.set(0, 0, lp.width, lp.height);
+ Rect rectOutline = new Rect();
+ float scale = Math.max((float) lp.height / originalHeight,
+ (float) lp.width / originalWidth);
+ if (isOpening) {
+ mBgDrawableStartScale = 1f;
+ mBgDrawableEndScale = scale;
+ rectOutline.set(0, 0, originalWidth, originalHeight);
+ } else {
+ mBgDrawableStartScale = scale;
+ mBgDrawableEndScale = 1f;
+ rectOutline.set(0, 0, lp.width, lp.height);
+ }
+ mEndRevealRect.set(0, 0, lp.width, lp.height);
+ setBackgroundDrawableBounds(mBgDrawableStartScale);
setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
- outline.setRoundRect(mOutline, mTaskCornerRadius);
+ outline.setRoundRect(rectOutline, mTaskCornerRadius);
}
});
setClipToOutline(true);
@@ -283,6 +290,7 @@
setBackground(finalDrawable);
}
+ onIconLoadedRunnable.run();
invalidate();
invalidateOutline();
});
@@ -350,6 +358,9 @@
}
@Override
+ public void onAnimationStart(Animator animator) {}
+
+ @Override
public void onAnimationCancel(Animator animator) {}
@Override
@@ -357,17 +368,16 @@
/**
* Creates a floating icon view for {@param originalView}.
- *
* @param originalView The view to copy
* @param hideOriginal If true, it will hide {@param originalView} while this view is visible.
- * @param useDrawableAsIs If true, we do not separate the foreground/background of adaptive
- * icons. TODO(b/122843905): We can remove this once app opening uses new animation.
- * @param aspectRatio If >= 0, we will use this aspect ratio for the initial adaptive icon size.
* @param positionOut Rect that will hold the size and position of v.
+ * @param isOpening True if this view replaces the icon for app open animation.
*/
public static FloatingIconView getFloatingIconView(Launcher launcher, View originalView,
- boolean hideOriginal, boolean useDrawableAsIs, float aspectRatio, Rect positionOut,
- FloatingIconView recycle) {
+ boolean hideOriginal, Rect positionOut, boolean isOpening, FloatingIconView recycle) {
+ if (recycle != null) {
+ recycle.recycle();
+ }
FloatingIconView view = recycle != null ? recycle : new FloatingIconView(launcher);
// Match the position of the original view.
@@ -376,9 +386,16 @@
// Get the drawable on the background thread
// Must be called after matchPositionOf so that we know what size to load.
if (originalView.getTag() instanceof ItemInfo) {
+ Runnable onIconLoaded = () -> {
+ // Delay swapping views until the icon is loaded to prevent a flash.
+ view.setVisibility(VISIBLE);
+ if (hideOriginal) {
+ originalView.setVisibility(INVISIBLE);
+ }
+ };
new Handler(LauncherModel.getWorkerLooper()).postAtFrontOfQueue(() -> {
- view.getIcon(launcher, originalView, (ItemInfo) originalView.getTag(),
- useDrawableAsIs, aspectRatio);
+ view.getIcon(launcher, originalView, (ItemInfo) originalView.getTag(), isOpening,
+ onIconLoaded);
});
}
@@ -387,12 +404,6 @@
view.setVisibility(INVISIBLE);
((ViewGroup) dragLayer.getParent()).getOverlay().add(view);
- view.mStartRunnable = () -> {
- view.setVisibility(VISIBLE);
- if (hideOriginal) {
- originalView.setVisibility(INVISIBLE);
- }
- };
if (hideOriginal) {
view.mEndRunnable = () -> {
AnimatorSet fade = new AnimatorSet();
@@ -427,7 +438,9 @@
public void onAnimationEnd(Animator animation) {
folderIcon.setBackgroundVisible(true);
folderIcon.animateBgShadowAndStroke();
- folderIcon.animateDotScale(0, 1f);
+ if (folderIcon.hasDot()) {
+ folderIcon.animateDotScale(0, 1f);
+ }
}
});
} else {
@@ -440,4 +453,24 @@
}
return view;
}
+
+ private void recycle() {
+ setTranslationX(0);
+ setTranslationY(0);
+ setScaleX(1);
+ setScaleY(1);
+ setAlpha(1);
+ setBackground(null);
+ mEndRunnable = null;
+ mIsAdaptiveIcon = false;
+ mForeground = null;
+ mBackground = null;
+ mClipPath = null;
+ mFinalDrawableBounds.setEmpty();
+ mBgDrawableBounds.setEmpty();;
+ if (mRevealAnimator != null) {
+ mRevealAnimator.cancel();
+ }
+ mRevealAnimator = null;
+ }
}
diff --git a/src/com/android/launcher3/widget/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/WidgetsRecyclerView.java
index 641183a..c15557b 100644
--- a/src/com/android/launcher3/widget/WidgetsRecyclerView.java
+++ b/src/com/android/launcher3/widget/WidgetsRecyclerView.java
@@ -56,11 +56,6 @@
addOnItemTouchListener(this);
}
- public WidgetsRecyclerView(Context context, AttributeSet attrs, int defStyleAttr,
- int defStyleRes) {
- this(context, attrs, defStyleAttr);
- }
-
@Override
protected void onFinishInflate() {
super.onFinishInflate();
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/BackgroundAppState.java b/src_ui_overrides/com/android/launcher3/uioverrides/BackgroundAppState.java
deleted file mode 100644
index 9133b07..0000000
--- a/src_ui_overrides/com/android/launcher3/uioverrides/BackgroundAppState.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.launcher3.uioverrides;
-
-/**
- * A dummy background app state
- */
-public class BackgroundAppState extends OverviewState {
-
- public BackgroundAppState(int id) {
- super(id);
- }
-}
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
index 0d727fd..9939c25 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
@@ -22,6 +22,7 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherStateManager.StateHandler;
+import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.util.TouchController;
import java.io.PrintWriter;
@@ -33,7 +34,9 @@
launcher.getDragController(), new AllAppsSwipeController(launcher)};
}
- public static void setOnTouchControllersChangedListener(Context context, Runnable listener) { }
+ public static Runnable enableLiveTouchControllerChanges(DragLayer dl) {
+ return null;
+ }
public static StateHandler[] getStateHandler(Launcher launcher) {
return new StateHandler[] {
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java b/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java
similarity index 97%
rename from src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java
rename to src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java
index bca335d..7006d77 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.launcher3.uioverrides;
+package com.android.launcher3.uioverrides.states;
import static com.android.launcher3.LauncherAnimUtils.ALL_APPS_TRANSITION_MS;
import static com.android.launcher3.allapps.DiscoveryBounce.HOME_BOUNCE_SEEN;
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewState.java b/src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java
similarity index 74%
rename from src_ui_overrides/com/android/launcher3/uioverrides/OverviewState.java
rename to src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java
index 8def0d3..aeba788 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewState.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/states/OverviewState.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.android.launcher3.uioverrides;
+package com.android.launcher3.uioverrides.states;
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
@@ -28,4 +28,16 @@
public OverviewState(int id) {
super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, FLAG_DISABLE_RESTORE);
}
+
+ public static OverviewState newBackgroundState(int id) {
+ return new OverviewState(id);
+ }
+
+ public static OverviewState newPeekState(int id) {
+ return new OverviewState(id);
+ }
+
+ public static OverviewState newSwitchState(int id) {
+ return new OverviewState(id);
+ }
}
diff --git a/tests/Android.mk b/tests/Android.mk
index ca7395a..080c98b 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -30,7 +30,6 @@
LOCAL_STATIC_JAVA_LIBRARIES += libSharedSystemUI
LOCAL_SRC_FILES := $(call all-java-files-under, tapl) \
- ../quickstep/src/com/android/quickstep/SwipeUpSetting.java \
../src/com/android/launcher3/util/SecureSettingsObserver.java \
../src/com/android/launcher3/TestProtocol.java
endif
diff --git a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java b/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java
index b600473..4ebf54c 100644
--- a/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java
+++ b/tests/src/com/android/launcher3/touch/SwipeDetectorTest.java
@@ -15,9 +15,12 @@
*/
package com.android.launcher3.touch;
-import androidx.test.InstrumentationRegistry;
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyFloat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
import android.util.Log;
import android.view.ViewConfiguration;
@@ -29,11 +32,9 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Matchers.anyFloat;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
@SmallTest
@RunWith(AndroidJUnit4.class)
@@ -63,7 +64,7 @@
doReturn(orgConfig.getScaledMaximumFlingVelocity()).when(mMockConfig)
.getScaledMaximumFlingVelocity();
- mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.VERTICAL);
+ mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.VERTICAL, false);
mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_BOTH, false);
mTouchSlop = orgConfig.getScaledTouchSlop();
doReturn(mTouchSlop).when(mMockConfig).getScaledTouchSlop();
@@ -72,7 +73,19 @@
}
@Test
- public void testDragStart_vertical() {
+ public void testDragStart_verticalPositive() {
+ mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.VERTICAL, false);
+ mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, false);
+ mGenerator.put(0, 100, 100);
+ mGenerator.move(0, 100, 100 - mTouchSlop);
+ // TODO: actually calculate the following parameters and do exact value checks.
+ verify(mMockListener).onDragStart(anyBoolean());
+ }
+
+ @Test
+ public void testDragStart_verticalNegative() {
+ mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.VERTICAL, false);
+ mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_NEGATIVE, false);
mGenerator.put(0, 100, 100);
mGenerator.move(0, 100, 100 + mTouchSlop);
// TODO: actually calculate the following parameters and do exact value checks.
@@ -88,9 +101,42 @@
}
@Test
- public void testDragStart_horizontal() {
- mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL);
- mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_BOTH, false);
+ public void testDragStart_horizontalPositive() {
+ mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, false);
+ mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, false);
+
+ mGenerator.put(0, 100, 100);
+ mGenerator.move(0, 100 + mTouchSlop, 100);
+ // TODO: actually calculate the following parameters and do exact value checks.
+ verify(mMockListener).onDragStart(anyBoolean());
+ }
+
+ @Test
+ public void testDragStart_horizontalNegative() {
+ mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, false);
+ mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_NEGATIVE, false);
+
+ mGenerator.put(0, 100, 100);
+ mGenerator.move(0, 100 - mTouchSlop, 100);
+ // TODO: actually calculate the following parameters and do exact value checks.
+ verify(mMockListener).onDragStart(anyBoolean());
+ }
+
+ @Test
+ public void testDragStart_horizontalRtlPositive() {
+ mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, true);
+ mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_POSITIVE, false);
+
+ mGenerator.put(0, 100, 100);
+ mGenerator.move(0, 100 - mTouchSlop, 100);
+ // TODO: actually calculate the following parameters and do exact value checks.
+ verify(mMockListener).onDragStart(anyBoolean());
+ }
+
+ @Test
+ public void testDragStart_horizontalRtlNegative() {
+ mDetector = new SwipeDetector(mMockConfig, mMockListener, SwipeDetector.HORIZONTAL, true);
+ mDetector.setDetectableScrollConditions(SwipeDetector.DIRECTION_NEGATIVE, false);
mGenerator.put(0, 100, 100);
mGenerator.move(0, 100 + mTouchSlop, 100);
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index 6f2f280..91ebd9b 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -34,6 +34,7 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherState;
+import com.android.launcher3.TestProtocol;
import com.android.launcher3.popup.ArrowPopup;
import com.android.launcher3.tapl.AllApps;
import com.android.launcher3.tapl.AppIcon;
@@ -327,18 +328,23 @@
@Test
@PortraitLandscape
public void testDragAppIcon() throws Throwable {
- LauncherActivityInfo settingsApp = getSettingsApp();
+ try {
+ TestProtocol.sDebugTracing = true;
+ LauncherActivityInfo settingsApp = getSettingsApp();
- final String appName = settingsApp.getLabel().toString();
- // 1. Open all apps and wait for load complete.
- // 2. Drag icon to homescreen.
- // 3. Verify that the icon works on homescreen.
- mLauncher.getWorkspace().
- switchToAllApps().
- getAppIcon(appName).
- dragToWorkspace().
- getWorkspaceAppIcon(appName).
- launch(settingsApp.getComponentName().getPackageName());
+ final String appName = settingsApp.getLabel().toString();
+ // 1. Open all apps and wait for load complete.
+ // 2. Drag icon to homescreen.
+ // 3. Verify that the icon works on homescreen.
+ mLauncher.getWorkspace().
+ switchToAllApps().
+ getAppIcon(appName).
+ dragToWorkspace().
+ getWorkspaceAppIcon(appName).
+ launch(settingsApp.getComponentName().getPackageName());
+ } finally {
+ TestProtocol.sDebugTracing = false;
+ }
}
@Test
diff --git a/tests/tapl/com/android/launcher3/tapl/AllApps.java b/tests/tapl/com/android/launcher3/tapl/AllApps.java
index e4dced5..98fb07f 100644
--- a/tests/tapl/com/android/launcher3/tapl/AllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/AllApps.java
@@ -64,7 +64,7 @@
"want to get app icon on all apps")) {
final UiObject2 allAppsContainer = verifyActiveContainer();
final UiObject2 navBar = mLauncher.waitForSystemUiObject("navigation_bar_frame");
- allAppsContainer.setGestureMargins(0, 0, 0, navBar.getVisibleBounds().height());
+ allAppsContainer.setGestureMargins(0, 0, 0, navBar.getVisibleBounds().height() + 1);
final BySelector appIconSelector = AppIcon.getAppIconSelector(appName, mLauncher);
if (!hasClickableIcon(allAppsContainer, appIconSelector)) {
scrollBackToBeginning();
@@ -141,8 +141,8 @@
* Flings forward (down) and waits the fling's end.
*/
public void flingForward() {
- try(LauncherInstrumentation.Closable c =
- mLauncher.addContextLayer("want to fling forward in all apps")) {
+ try (LauncherInstrumentation.Closable c =
+ mLauncher.addContextLayer("want to fling forward in all apps")) {
final UiObject2 allAppsContainer = verifyActiveContainer();
// Start the gesture in the center to avoid starting at elements near the top.
allAppsContainer.setGestureMargins(0, 0, 0, mHeight / 2);
@@ -156,8 +156,8 @@
* Flings backward (up) and waits the fling's end.
*/
public void flingBackward() {
- try(LauncherInstrumentation.Closable c =
- mLauncher.addContextLayer("want to fling backward in all apps")) {
+ try (LauncherInstrumentation.Closable c =
+ mLauncher.addContextLayer("want to fling backward in all apps")) {
final UiObject2 allAppsContainer = verifyActiveContainer();
// Start the gesture in the center, for symmetry with forward.
allAppsContainer.setGestureMargins(0, mHeight / 2, 0, 0);
diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java
index 26c0ca4..358d5e9 100644
--- a/tests/tapl/com/android/launcher3/tapl/Background.java
+++ b/tests/tapl/com/android/launcher3/tapl/Background.java
@@ -20,8 +20,6 @@
import static com.android.launcher3.tapl.LauncherInstrumentation.WAIT_TIME_MS;
import static com.android.launcher3.tapl.TestHelpers.getOverviewPackageName;
-import static org.junit.Assert.assertTrue;
-
import android.graphics.Point;
import android.os.SystemClock;
import android.view.MotionEvent;
@@ -61,7 +59,7 @@
"want to switch from background to overview")) {
verifyActiveContainer();
goToOverviewUnchecked(BACKGROUND_APP_STATE_ORDINAL);
- assertTrue("Overview not visible", mLauncher.getDevice().wait(
+ mLauncher.assertTrue("Overview not visible", mLauncher.getDevice().wait(
Until.hasObject(By.pkg(getOverviewPackageName())), WAIT_TIME_MS));
return new BaseOverview(mLauncher);
}
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 125deaf..a4b4171 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -16,27 +16,26 @@
package com.android.launcher3.tapl;
-import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL;
-
import android.app.ActivityManager;
import android.app.Instrumentation;
import android.app.UiAutomation;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.content.res.Resources;
import android.graphics.Point;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.SystemClock;
+import android.text.TextUtils;
import android.util.Log;
import android.view.InputDevice;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityEvent;
-
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.test.uiautomator.By;
@@ -45,18 +44,15 @@
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;
-
import com.android.launcher3.TestProtocol;
import com.android.systemui.shared.system.QuickStepContract;
-
-import org.junit.Assert;
-
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeoutException;
+import org.junit.Assert;
/**
* The main tapl object. The only object that can be explicitly constructed by the using code. It
@@ -65,6 +61,8 @@
public final class LauncherInstrumentation {
private static final String TAG = "Tapl";
+ private static final String NAV_BAR_INTERACTION_MODE_RES_NAME =
+ "config_navBarInteractionMode";
private static final int ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME = 20;
// Types for launcher containers that the user is interacting with. "Background" is a
@@ -166,23 +164,28 @@
}
public NavigationModel getNavigationModel() {
- return isSwipeUpEnabled() ? NavigationModel.TWO_BUTTON : NavigationModel.THREE_BUTTON;
- }
-
- static boolean needSlowGestures() {
- return Build.MODEL.contains("Cuttlefish");
- }
-
- private boolean isSwipeUpEnabled() {
final Context baseContext = mInstrumentation.getTargetContext();
try {
// Workaround, use constructed context because both the instrumentation context and the
// app context are not constructed with resources that take overlays into account
- Context ctx = baseContext.createPackageContext(getLauncherPackageName(), 0);
- return !QuickStepContract.isLegacyMode(ctx);
+ final Context ctx = baseContext.createPackageContext("android", 0);
+ if (isGesturalMode(ctx)) {
+ return NavigationModel.ZERO_BUTTON;
+ } else if (isSwipeUpMode(ctx)) {
+ return NavigationModel.TWO_BUTTON;
+ } else if (isLegacyMode(ctx)) {
+ return NavigationModel.THREE_BUTTON;
+ } else {
+ fail("Can't detect navigation mode");
+ }
} catch (PackageManager.NameNotFoundException e) {
- return false;
+ fail(e.toString());
}
+ return NavigationModel.THREE_BUTTON;
+ }
+
+ static boolean needSlowGestures() {
+ return Build.MODEL.contains("Cuttlefish");
}
static void log(String message) {
@@ -220,6 +223,12 @@
}
}
+ private void assertEquals(String message, String expected, String actual) {
+ if (!TextUtils.equals(expected, actual)) {
+ fail(message + " expected: '" + expected + "' but was: '" + actual + "'");
+ }
+ }
+
void assertNotEquals(String message, int unexpected, int actual) {
if (unexpected == actual) {
failEquals(message, actual);
@@ -233,9 +242,13 @@
private UiObject2 verifyContainerType(ContainerType containerType) {
assertEquals("Unexpected display rotation",
mExpectedRotation, mDevice.getDisplayRotation());
- assertTrue("Presence of recents button doesn't match isSwipeUpEnabled()",
- isSwipeUpEnabled() ==
- (mDevice.findObject(By.res(SYSTEMUI_PACKAGE, "recent_apps")) == null));
+ final NavigationModel navigationModel = getNavigationModel();
+ assertTrue("Presence of recents button doesn't match the interaction mode",
+ (navigationModel == NavigationModel.THREE_BUTTON) ==
+ mDevice.hasObject(By.res(SYSTEMUI_PACKAGE, "recent_apps")));
+ assertTrue("Presence of home button doesn't match the interaction mode",
+ (navigationModel != NavigationModel.ZERO_BUTTON) ==
+ mDevice.hasObject(By.res(SYSTEMUI_PACKAGE, "home")));
log("verifyContainerType: " + containerType);
try (Closable c = addContextLayer(
@@ -338,12 +351,7 @@
log(action = "0-button: from another app");
assertTrue("Launcher is visible, don't know how to go home",
!mDevice.hasObject(By.pkg(getLauncherPackageName())));
- final UiObject2 navBar = waitForSystemUiObject("navigation_bar_frame");
-
- swipe(
- navBar.getVisibleBounds().centerX(), navBar.getVisibleBounds().centerY(),
- navBar.getVisibleBounds().centerX(), 0,
- BACKGROUND_APP_STATE_ORDINAL, ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME);
+ mDevice.pressHome();
}
} else {
log(action = "clicking home button");
@@ -535,8 +543,9 @@
event -> TestProtocol.SWITCHED_TO_STATE_MESSAGE.equals(event.getClassName()),
"Swipe failed to receive an event for the swipe end: " + startX + ", " + startY
+ ", " + endX + ", " + endY);
- assertEquals("Swipe switched launcher to a wrong state",
- expectedState, parcel.getInt(TestProtocol.STATE_FIELD));
+ assertEquals("Swipe switched launcher to a wrong state;",
+ TestProtocol.stateOrdinalToString(expectedState),
+ TestProtocol.stateOrdinalToString(parcel.getInt(TestProtocol.STATE_FIELD)));
}
void waitForIdle() {
@@ -591,6 +600,33 @@
}
}
+ public static boolean isGesturalMode(Context context) {
+ return QuickStepContract.isGesturalMode(
+ getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME));
+ }
+
+ public static boolean isSwipeUpMode(Context context) {
+ return QuickStepContract.isSwipeUpMode(
+ getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME));
+ }
+
+ public static boolean isLegacyMode(Context context) {
+ return QuickStepContract.isLegacyMode(
+ getSystemIntegerRes(context, NAV_BAR_INTERACTION_MODE_RES_NAME));
+ }
+
+ private static int getSystemIntegerRes(Context context, String resName) {
+ Resources res = context.getResources();
+ int resId = res.getIdentifier(resName, "integer", "android");
+
+ if (resId != 0) {
+ return res.getInteger(resId);
+ } else {
+ Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
+ return -1;
+ }
+ }
+
static void sleep(int duration) {
try {
Thread.sleep(duration);
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 9979f50..22b5564 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -136,7 +136,9 @@
static void dragIconToWorkspace(LauncherInstrumentation launcher, Launchable launchable,
Point dest, int icon_drag_speed) {
+ LauncherInstrumentation.log("dragIconToWorkspace: begin");
launchable.getObject().drag(dest, icon_drag_speed);
+ LauncherInstrumentation.log("dragIconToWorkspace: end");
launcher.waitUntilGone("drop_target_bar");
}