Merge "Move app => overview anim out of OverviewCommandHelper" into ub-launcher3-master
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 4df1b37..af25355 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java
@@ -272,7 +272,8 @@
Consumer<AnimatorPlaybackController> callback) {
LauncherState endState = interactionType == INTERACTION_QUICK_SCRUB
? FAST_OVERVIEW : OVERVIEW;
- if (wasVisible) {
+ if (wasVisible && fromState != BACKGROUND_APP) {
+ // If a translucent app was launched fom launcher, animate launcher states.
DeviceProfile dp = activity.getDeviceProfile();
long accuracy = 2 * Math.max(dp.widthPx, dp.heightPx);
callback.accept(activity.getStateManager()
@@ -330,14 +331,17 @@
}
// Setup the clip animation helper source/target rects in the final transformed state
- // of the recents view (a scale may be applied prior to this animation starting to
- // line up the side pages during swipe up)
+ // of the recents view (a scale/translationY may be applied prior to this animation
+ // starting to line up the side pages during swipe up)
float prevRvScale = recentsView.getScaleX();
+ float prevRvTransY = recentsView.getTranslationY();
float targetRvScale = endState.getOverviewScaleAndTranslationYFactor(launcher)[0];
SCALE_PROPERTY.set(recentsView, targetRvScale);
+ recentsView.setTranslationY(0);
ClipAnimationHelper clipHelper = new ClipAnimationHelper(launcher);
clipHelper.fromTaskThumbnailView(v.getThumbnail(), (RecentsView) v.getParent(), null);
SCALE_PROPERTY.set(recentsView, prevRvScale);
+ recentsView.setTranslationY(prevRvTransY);
if (!clipHelper.getSourceRect().isEmpty() && !clipHelper.getTargetRect().isEmpty()) {
float fromScale = clipHelper.getSourceRect().width()
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index a99fc0f..c1417dd 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -1164,11 +1164,18 @@
@UiThread
private void startNewTask() {
// Launch the task user scrolled to (mRecentsView.getNextPage()).
- mRecentsAnimationWrapper.finish(true /* toRecents */, () -> {
+ if (ENABLE_QUICKSTEP_LIVE_TILE.get()) {
+ // We finish recents animation inside launchTask() when live tile is enabled.
mRecentsView.getTaskViewAt(mRecentsView.getNextPage()).launchTask(false,
result -> setStateOnUiThread(STATE_HANDLER_INVALIDATED),
mMainThreadHandler);
- });
+ } else {
+ mRecentsAnimationWrapper.finish(true /* toRecents */, () -> {
+ mRecentsView.getTaskViewAt(mRecentsView.getNextPage()).launchTask(false,
+ result -> setStateOnUiThread(STATE_HANDLER_INVALIDATED),
+ mMainThreadHandler);
+ });
+ }
mTouchInteractionLog.finishRecentsAnimation(false);
doLogGesture(NEW_TASK);
}
diff --git a/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java b/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java
index c612b05..57400bd 100644
--- a/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java
+++ b/quickstep/src/com/android/quickstep/util/ClipAnimationHelper.java
@@ -32,7 +32,6 @@
import android.os.Build;
import android.os.RemoteException;
import android.view.animation.Interpolator;
-
import androidx.annotation.Nullable;
import com.android.launcher3.BaseDraggingActivity;
@@ -277,7 +276,8 @@
updateStackBoundsToMultiWindowTaskSize(activity);
} else {
mSourceStackBounds.set(mHomeStackBounds);
- mSourceInsets.set(ttv.getInsets());
+ Rect fallback = dl.getInsets();
+ mSourceInsets.set(ttv.getInsets(fallback));
}
TransformedRect targetRect = new TransformedRect();
diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
index d0289d0..90604ef 100644
--- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -169,11 +169,11 @@
return mDimAlpha;
}
- public Rect getInsets() {
+ public Rect getInsets(Rect fallback) {
if (mThumbnailData != null) {
return mThumbnailData.insets;
}
- return new Rect();
+ return fallback;
}
public int getSysUiStatusNavFlags() {
diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java
index 5b9b172..ff9dd13 100644
--- a/src/com/android/launcher3/BaseDraggingActivity.java
+++ b/src/com/android/launcher3/BaseDraggingActivity.java
@@ -44,10 +44,6 @@
private static final String TAG = "BaseDraggingActivity";
- // The Intent extra that defines whether to ignore the launch animation
- public static final String INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION =
- "com.android.launcher3.intent.extra.shortcut.INGORE_LAUNCH_ANIMATION";
-
// When starting an action mode, setting this tag will cause the action mode to be cancelled
// automatically when user interacts with the launcher.
public static final Object AUTO_CANCEL_ACTION_MODE = new Object();
@@ -158,14 +154,7 @@
return false;
}
- // Only launch using the new animation if the shortcut has not opted out (this is a
- // private contract between launcher and may be ignored in the future).
- boolean useLaunchAnimation = (v != null) &&
- !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
- Bundle optsBundle = useLaunchAnimation
- ? getActivityLaunchOptionsAsBundle(v)
- : null;
-
+ Bundle optsBundle = (v != null) ? getActivityLaunchOptionsAsBundle(v) : null;
UserHandle user = item == null ? null : item.user;
// Prepare intent
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index ea59fff..5c5f5e4 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -57,6 +57,7 @@
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -172,7 +173,7 @@
Log.d(TAG, "APPS_PENDING_INSTALL: " + strings
+ ", removing packages: " + packageNames);
}
- if (Utilities.isEmpty(strings)) {
+ if (strings == null || ((Collection) strings).isEmpty()) {
return;
}
Set<String> newStrings = new HashSet<>(strings);
@@ -268,7 +269,7 @@
HashSet<ShortcutKey> result = new HashSet<>();
Set<String> strings = Utilities.getPrefs(context).getStringSet(APPS_PENDING_INSTALL, null);
- if (Utilities.isEmpty(strings)) {
+ if (strings == null || ((Collection) strings).isEmpty()) {
return result;
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index fc3af7e..73fba4e 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -146,6 +146,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.function.Predicate;
import androidx.annotation.Nullable;
@@ -1118,7 +1119,7 @@
}
};
- public void updateNotificationDots(final Set<PackageUserKey> updatedDots) {
+ public void updateNotificationDots(Predicate<PackageUserKey> updatedDots) {
mWorkspace.updateNotificationDots(updatedDots);
mAppsView.getAppsStore().updateNotificationDots(updatedDots);
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index c847120..60dfbb7 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -57,8 +57,6 @@
import java.io.Closeable;
import java.io.IOException;
import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.HashSet;
import java.util.Locale;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
@@ -514,47 +512,12 @@
}
}
- /**
- * Returns true if {@param original} contains all entries defined in {@param updates} and
- * have the same value.
- * The comparison uses {@link Object#equals(Object)} to compare the values.
- */
- public static boolean containsAll(Bundle original, Bundle updates) {
- for (String key : updates.keySet()) {
- Object value1 = updates.get(key);
- Object value2 = original.get(key);
- if (value1 == null) {
- if (value2 != null) {
- return false;
- }
- } else if (!value1.equals(value2)) {
- return false;
- }
- }
- return true;
- }
-
- /** Returns whether the collection is null or empty. */
- public static boolean isEmpty(Collection c) {
- return c == null || c.isEmpty();
- }
-
public static boolean isBinderSizeError(Exception e) {
return e.getCause() instanceof TransactionTooLargeException
|| e.getCause() instanceof DeadObjectException;
}
/**
- * Returns a HashSet with a single element. We use this instead of Collections.singleton()
- * because HashSet ensures all operations, such as remove, are supported.
- */
- public static <T> HashSet<T> singletonHashSet(T elem) {
- HashSet<T> hashSet = new HashSet<>(1);
- hashSet.add(elem);
- return hashSet;
- }
-
- /**
* Utility method to post a runnable on the handler, skipping the synchronization barriers.
*/
public static void postAsyncCallback(Handler handler, Runnable callback) {
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 3438a26..2db6cd9 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -98,6 +98,7 @@
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
+import java.util.function.Predicate;
/**
* The workspace is a wide area with a wallpaper and a finite number of pages.
@@ -3059,7 +3060,7 @@
});
}
- public void updateNotificationDots(final Set<PackageUserKey> updatedDots) {
+ public void updateNotificationDots(Predicate<PackageUserKey> updatedDots) {
final PackageUserKey packageUserKey = new PackageUserKey(null, null);
final IntSet folderIds = new IntSet();
mapOverItems(MAP_RECURSE, new ItemOperator() {
@@ -3067,7 +3068,7 @@
public boolean evaluate(ItemInfo info, View v) {
if (info instanceof ShortcutInfo && v instanceof BubbleTextView) {
if (!packageUserKey.updateFromItemInfo(info)
- || updatedDots.contains(packageUserKey)) {
+ || updatedDots.test(packageUserKey)) {
((BubbleTextView) v).applyDotState(info, true /* animate */);
folderIds.add(info.container);
}
diff --git a/src/com/android/launcher3/allapps/AllAppsStore.java b/src/com/android/launcher3/allapps/AllAppsStore.java
index 52d7d28..8e7fec8 100644
--- a/src/com/android/launcher3/allapps/AllAppsStore.java
+++ b/src/com/android/launcher3/allapps/AllAppsStore.java
@@ -31,6 +31,7 @@
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
+import java.util.function.Predicate;
/**
* A utility class to maintain the collection of all apps.
@@ -122,11 +123,11 @@
mIconContainers.remove(container);
}
- public void updateNotificationDots(Set<PackageUserKey> updatedDots) {
+ public void updateNotificationDots(Predicate<PackageUserKey> updatedDots) {
updateAllIcons((child) -> {
if (child.getTag() instanceof ItemInfo) {
ItemInfo info = (ItemInfo) child.getTag();
- if (mTempKey.updateFromItemInfo(info) && updatedDots.contains(mTempKey)) {
+ if (mTempKey.updateFromItemInfo(info) && updatedDots.test(mTempKey)) {
child.applyDotState(info, true /* animate */);
}
}
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index 288d568..9b23f3f 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -73,6 +73,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.function.Predicate;
/**
* A container for shortcuts to deep links and notifications associated with an app.
@@ -463,10 +464,10 @@
/**
* Updates the notification header if the original icon's dot updated.
*/
- public void updateNotificationHeader(Set<PackageUserKey> updatedDots) {
+ public void updateNotificationHeader(Predicate<PackageUserKey> updatedDots) {
ItemInfo itemInfo = (ItemInfo) mOriginalIcon.getTag();
PackageUserKey packageUser = PackageUserKey.fromItemInfo(itemInfo);
- if (updatedDots.contains(packageUser)) {
+ if (updatedDots.test(packageUser)) {
updateNotificationHeader();
}
}
diff --git a/src/com/android/launcher3/popup/PopupDataProvider.java b/src/com/android/launcher3/popup/PopupDataProvider.java
index 984a03d..f4da858 100644
--- a/src/com/android/launcher3/popup/PopupDataProvider.java
+++ b/src/com/android/launcher3/popup/PopupDataProvider.java
@@ -85,7 +85,7 @@
}
}
if (dotShouldBeRefreshed) {
- mLauncher.updateNotificationDots(Utilities.singletonHashSet(postedPackageUserKey));
+ mLauncher.updateNotificationDots(t -> postedPackageUserKey.equals(t));
}
}
@@ -97,7 +97,7 @@
if (oldDotInfo.getNotificationKeys().size() == 0) {
mPackageUserToDotInfos.remove(removedPackageUserKey);
}
- mLauncher.updateNotificationDots(Utilities.singletonHashSet(removedPackageUserKey));
+ mLauncher.updateNotificationDots(t -> removedPackageUserKey.equals(t));
trimNotifications(mPackageUserToDotInfos);
}
}
@@ -133,7 +133,7 @@
}
if (!updatedDots.isEmpty()) {
- mLauncher.updateNotificationDots(updatedDots.keySet());
+ mLauncher.updateNotificationDots(updatedDots::containsKey);
}
trimNotifications(updatedDots);
}
diff --git a/src/com/android/launcher3/qsb/QsbContainerView.java b/src/com/android/launcher3/qsb/QsbContainerView.java
index 57a458b..c2bae6d 100644
--- a/src/com/android/launcher3/qsb/QsbContainerView.java
+++ b/src/com/android/launcher3/qsb/QsbContainerView.java
@@ -159,7 +159,7 @@
mQsb.setId(R.id.qsb_widget);
if (!isInPreviewMode()) {
- if (!Utilities.containsAll(AppWidgetManager.getInstance(context)
+ if (!containsAll(AppWidgetManager.getInstance(context)
.getAppWidgetOptions(widgetId), opts)) {
mQsb.updateAppWidgetOptions(opts);
}
@@ -296,4 +296,24 @@
QsbWidgetHostView newView(Context context);
}
+
+ /**
+ * Returns true if {@param original} contains all entries defined in {@param updates} and
+ * have the same value.
+ * The comparison uses {@link Object#equals(Object)} to compare the values.
+ */
+ private static boolean containsAll(Bundle original, Bundle updates) {
+ for (String key : updates.keySet()) {
+ Object value1 = updates.get(key);
+ Object value2 = original.get(key);
+ if (value1 == null) {
+ if (value2 != null) {
+ return false;
+ }
+ } else if (!value1.equals(value2)) {
+ return false;
+ }
+ }
+ return true;
+ }
}
diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java
index 6ba2f40..71bf781 100644
--- a/src/com/android/launcher3/views/OptionsPopupView.java
+++ b/src/com/android/launcher3/views/OptionsPopupView.java
@@ -15,7 +15,6 @@
*/
package com.android.launcher3.views;
-import static com.android.launcher3.BaseDraggingActivity.INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION;
import static com.android.launcher3.Utilities.EXTRA_WALLPAPER_OFFSET;
import android.content.Context;
@@ -195,16 +194,12 @@
return false;
}
Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER)
+ .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
.putExtra(EXTRA_WALLPAPER_OFFSET,
launcher.getWorkspace().getWallpaperOffsetForCenterPage());
- intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
-
String pickerPackage = launcher.getString(R.string.wallpaper_picker_package);
if (!TextUtils.isEmpty(pickerPackage)) {
intent.setPackage(pickerPackage);
- } else {
- // If there is no target package, use the default intent chooser animation
- intent.putExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION, true);
}
return launcher.startActivitySafely(v, intent, null);
}