Merge changes from topic "am-a3d615af-02aa-451c-b89c-c1f59300b566" into ub-launcher3-master
* changes:
[automerger] Fix bug where add to folder fails even when folder creation animation runs. am: 36f6359c21
Fix bug where add to folder fails even when folder creation animation runs.
diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
index 6ee4cdb..13530b2 100644
--- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
@@ -92,8 +92,16 @@
implements OnDeviceProfileChangeListener {
private static final String TAG = "LauncherTransition";
+
+ /** Duration of status bar animations. */
public static final int STATUS_BAR_TRANSITION_DURATION = 120;
+ /**
+ * Since our animations decelerate heavily when finishing, we want to start status bar animations
+ * x ms before the ending.
+ */
+ public static final int STATUS_BAR_TRANSITION_PRE_DELAY = 96;
+
private static final String CONTROL_REMOTE_APP_TRANSITION_PERMISSION =
"android.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS";
@@ -210,9 +218,14 @@
}
};
- int duration = findTaskViewToLaunch(launcher, v, null) != null
- ? RECENTS_LAUNCH_DURATION : APP_LAUNCH_DURATION;
- int statusBarTransitionDelay = duration - STATUS_BAR_TRANSITION_DURATION;
+ boolean fromRecents = mLauncher.getStateManager().getState().overviewUi
+ && findTaskViewToLaunch(launcher, v, null) != null;
+ int duration = fromRecents
+ ? RECENTS_LAUNCH_DURATION
+ : APP_LAUNCH_DURATION;
+
+ int statusBarTransitionDelay = duration - STATUS_BAR_TRANSITION_DURATION
+ - STATUS_BAR_TRANSITION_PRE_DELAY;
return ActivityOptionsCompat.makeRemoteAnimation(new RemoteAnimationAdapterCompat(
runner, duration, statusBarTransitionDelay));
}
diff --git a/quickstep/src/com/android/quickstep/ActivityControlHelper.java b/quickstep/src/com/android/quickstep/ActivityControlHelper.java
index 3197532..275075f 100644
--- a/quickstep/src/com/android/quickstep/ActivityControlHelper.java
+++ b/quickstep/src/com/android/quickstep/ActivityControlHelper.java
@@ -185,7 +185,7 @@
if (dp.isVerticalBarLayout()) {
Rect targetInsets = dp.getInsets();
int hotseatInset = dp.isSeascape() ? targetInsets.left : targetInsets.right;
- return dp.hotseatBarSizePx + dp.hotseatBarSidePaddingPx + hotseatInset;
+ return dp.hotseatBarSizePx + hotseatInset;
} else {
int shelfHeight = dp.hotseatBarSizePx + dp.getInsets().bottom;
// Track slightly below the top of the shelf (between top and content).
@@ -448,7 +448,7 @@
if (dp.isVerticalBarLayout()) {
Rect targetInsets = dp.getInsets();
int hotseatInset = dp.isSeascape() ? targetInsets.left : targetInsets.right;
- return dp.hotseatBarSizePx + dp.hotseatBarSidePaddingPx + hotseatInset;
+ return dp.hotseatBarSizePx + hotseatInset;
} else {
return dp.heightPx - outRect.rect.bottom;
}
diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java
index a5fbba7..ed8b4d2 100644
--- a/quickstep/src/com/android/quickstep/RecentsActivity.java
+++ b/quickstep/src/com/android/quickstep/RecentsActivity.java
@@ -20,6 +20,7 @@
import static com.android.launcher3.LauncherAppTransitionManagerImpl.RECENTS_LAUNCH_DURATION;
import static com.android.launcher3.LauncherAppTransitionManagerImpl.STATUS_BAR_TRANSITION_DURATION;
+import static com.android.launcher3.LauncherAppTransitionManagerImpl.STATUS_BAR_TRANSITION_PRE_DELAY;
import static com.android.quickstep.TaskUtils.getRecentsWindowAnimator;
import static com.android.quickstep.TaskUtils.taskIsATargetWithMode;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;
@@ -186,7 +187,8 @@
};
return ActivityOptionsCompat.makeRemoteAnimation(new RemoteAnimationAdapterCompat(
runner, RECENTS_LAUNCH_DURATION,
- RECENTS_LAUNCH_DURATION - STATUS_BAR_TRANSITION_DURATION));
+ RECENTS_LAUNCH_DURATION - STATUS_BAR_TRANSITION_DURATION
+ - STATUS_BAR_TRANSITION_PRE_DELAY));
}
/**
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index 532699e..703ea2e 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -24,6 +24,7 @@
import static com.android.quickstep.QuickScrubController.QUICK_SCRUB_FROM_APP_START_DURATION;
import static com.android.quickstep.TouchConsumer.INTERACTION_NORMAL;
import static com.android.quickstep.TouchConsumer.INTERACTION_QUICK_SCRUB;
+import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -560,8 +561,7 @@
? mSyncTransactionApplier
: null);
- // TODO: This logic is spartanic!
- boolean passedThreshold = shift > 0.12f;
+ boolean passedThreshold = shift > 1 - UPDATE_SYSUI_FLAGS_THRESHOLD;
mRecentsAnimationWrapper.setAnimationTargetsBehindSystemBars(!passedThreshold);
if (mActivityControlHelper.shouldMinimizeSplitScreen()) {
mRecentsAnimationWrapper.setSplitScreenMinimizedForTransaction(passedThreshold);
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 6ce6693..f7f496f 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -117,7 +117,7 @@
private static final int DISMISS_TASK_DURATION = 300;
// The threshold at which we update the SystemUI flags when animating from the task into the app
- private static final float UPDATE_SYSUI_FLAGS_THRESHOLD = 0.6f;
+ public static final float UPDATE_SYSUI_FLAGS_THRESHOLD = 0.85f;
private static final float[] sTempFloatArray = new float[3];
diff --git a/res/values/config.xml b/res/values/config.xml
index d5bb131..f2d6c21 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -149,4 +149,5 @@
<integer name="config_recentsMaxThumbnailCacheSize">6</integer>
<integer name="config_recentsMaxIconCacheSize">12</integer>
+ <item name="workspace_page_container" type="id" />
</resources>
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 2f47728..20c4a5f 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -102,7 +102,9 @@
public int hotseatBarSizePx;
public final int hotseatBarTopPaddingPx;
public final int hotseatBarBottomPaddingPx;
- public final int hotseatBarSidePaddingPx;
+ // Start is the side next to the nav bar, end is the side next to the workspace
+ public final int hotseatBarSidePaddingStartPx;
+ public final int hotseatBarSidePaddingEndPx;
// All apps
public int allAppsCellHeightPx;
@@ -178,10 +180,14 @@
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding);
hotseatBarBottomPaddingPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_bottom_padding);
- hotseatBarSidePaddingPx =
+ hotseatBarSidePaddingEndPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);
+ // Add a bit of space between nav bar and hotseat in multi-window vertical bar layout.
+ hotseatBarSidePaddingStartPx = isMultiWindowMode && isVerticalBarLayout()
+ ? edgeMarginPx : 0;
hotseatBarSizePx = isVerticalBarLayout()
- ? Utilities.pxFromDp(inv.iconSize, dm)
+ ? Utilities.pxFromDp(inv.iconSize, dm) + hotseatBarSidePaddingStartPx
+ + hotseatBarSidePaddingEndPx
: res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_size)
+ hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx;
@@ -326,7 +332,8 @@
// Hotseat
if (isVerticalLayout) {
- hotseatBarSizePx = iconSizePx;
+ hotseatBarSizePx = iconSizePx + hotseatBarSidePaddingStartPx
+ + hotseatBarSidePaddingEndPx;
}
hotseatCellHeightPx = iconSizePx;
@@ -425,14 +432,12 @@
if (isVerticalBarLayout()) {
padding.top = 0;
padding.bottom = edgeMarginPx;
- padding.left = hotseatBarSidePaddingPx;
- padding.right = hotseatBarSidePaddingPx;
if (isSeascape()) {
- padding.left += hotseatBarSizePx;
- padding.right += verticalDragHandleSizePx;
+ padding.left = hotseatBarSizePx;
+ padding.right = verticalDragHandleSizePx;
} else {
- padding.left += verticalDragHandleSizePx;
- padding.right += hotseatBarSizePx;
+ padding.left = verticalDragHandleSizePx;
+ padding.right = hotseatBarSizePx;
}
} else {
int paddingBottom = hotseatBarSizePx + verticalDragHandleSizePx;
@@ -462,11 +467,11 @@
public Rect getHotseatLayoutPadding() {
if (isVerticalBarLayout()) {
if (isSeascape()) {
- mHotseatPadding.set(
- mInsets.left, mInsets.top, hotseatBarSidePaddingPx, mInsets.bottom);
+ mHotseatPadding.set(mInsets.left + hotseatBarSidePaddingStartPx,
+ mInsets.top, hotseatBarSidePaddingEndPx, mInsets.bottom);
} else {
- mHotseatPadding.set(
- hotseatBarSidePaddingPx, mInsets.top, mInsets.right, mInsets.bottom);
+ mHotseatPadding.set(hotseatBarSidePaddingEndPx, mInsets.top,
+ mInsets.right + hotseatBarSidePaddingStartPx, mInsets.bottom);
}
} else {
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index ee4b113..6668f2c 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -157,10 +157,10 @@
lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
if (grid.isSeascape()) {
lp.gravity = Gravity.LEFT;
- lp.width = grid.hotseatBarSizePx + insets.left + grid.hotseatBarSidePaddingPx;
+ lp.width = grid.hotseatBarSizePx + insets.left;
} else {
lp.gravity = Gravity.RIGHT;
- lp.width = grid.hotseatBarSizePx + insets.right + grid.hotseatBarSidePaddingPx;
+ lp.width = grid.hotseatBarSizePx + insets.right;
}
} else {
lp.gravity = Gravity.BOTTOM;
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index aaeeb63..3a8679e 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2328,6 +2328,8 @@
if (isInState(NORMAL)) {
shortcutInfos.add(new KeyboardShortcutInfo(getString(R.string.all_apps_button_label),
KeyEvent.KEYCODE_A, KeyEvent.META_CTRL_ON));
+ shortcutInfos.add(new KeyboardShortcutInfo(getString(R.string.widget_button_text),
+ KeyEvent.KEYCODE_W, KeyEvent.META_CTRL_ON));
}
final View currentFocus = getCurrentFocus();
if (currentFocus != null) {
@@ -2376,6 +2378,12 @@
return true;
}
break;
+ case KeyEvent.KEYCODE_W:
+ if (isInState(NORMAL)) {
+ OptionsPopupView.openWidgets(this);
+ return true;
+ }
+ break;
}
}
return super.onKeyShortcut(keyCode, event);
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index eafdecc..abba9c4 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -547,6 +547,7 @@
// created CellLayout.
CellLayout newScreen = (CellLayout) LayoutInflater.from(getContext()).inflate(
R.layout.workspace_screen, this, false /* attachToRoot */);
+ newScreen.getShortcutsAndWidgets().setId(R.id.workspace_page_container);
int paddingLeftRight = mLauncher.getDeviceProfile().cellLayoutPaddingLeftRightPx;
int paddingBottom = mLauncher.getDeviceProfile().cellLayoutBottomPaddingPx;
newScreen.setPadding(paddingLeftRight, 0, paddingLeftRight, paddingBottom);
diff --git a/src/com/android/launcher3/notification/NotificationMainView.java b/src/com/android/launcher3/notification/NotificationMainView.java
index 33caded..5c0e259 100644
--- a/src/com/android/launcher3/notification/NotificationMainView.java
+++ b/src/com/android/launcher3/notification/NotificationMainView.java
@@ -116,6 +116,10 @@
*/
public void applyNotificationInfo(NotificationInfo mainNotification, boolean animate) {
mNotificationInfo = mainNotification;
+ NotificationListener listener = NotificationListener.getInstanceIfConnected();
+ if (listener != null) {
+ listener.setNotificationsShown(new String[] {mNotificationInfo.notificationKey});
+ }
CharSequence title = mNotificationInfo.title;
CharSequence text = mNotificationInfo.text;
if (!TextUtils.isEmpty(title) && !TextUtils.isEmpty(text)) {
diff --git a/src/com/android/launcher3/popup/ArrowPopup.java b/src/com/android/launcher3/popup/ArrowPopup.java
index 9098777..be666a6 100644
--- a/src/com/android/launcher3/popup/ArrowPopup.java
+++ b/src/com/android/launcher3/popup/ArrowPopup.java
@@ -266,11 +266,7 @@
}
// Insets are added later, so subtract them now.
- if (mIsRtl) {
- x += insets.right;
- } else {
- x -= insets.left;
- }
+ x -= insets.left;
y -= insets.top;
mGravity = 0;
diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
index b1fef02..955177a 100644
--- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
+++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
@@ -29,6 +29,7 @@
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
+import android.os.SystemClock;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
@@ -88,6 +89,7 @@
private AnimatorSet mAtomicAnim;
// True if we want to resume playing atomic components when mAtomicAnim completes.
private boolean mScheduleResumeAtomicComponent;
+ private AutoPlayAtomicAnimationInfo mAtomicAnimAutoPlayInfo;
private boolean mPassedOverviewAtomicThreshold;
// mAtomicAnim plays the atomic components of the state animations when we pass the threshold.
@@ -235,12 +237,17 @@
if (mCurrentAnimation == null) {
mFromState = mStartState;
mToState = null;
- mAtomicComponentsController = null;
+ cancelAnimationControllers();
reinitCurrentAnimation(false, mDetector.wasInitialTouchPositive());
mDisplacementShift = 0;
} else {
mCurrentAnimation.pause();
mStartProgress = mCurrentAnimation.getProgressFraction();
+
+ mAtomicAnimAutoPlayInfo = null;
+ if (mAtomicComponentsController != null) {
+ mAtomicComponentsController.pause();
+ }
}
mCanBlockFling = mFromState == NORMAL;
mFlingBlockCheck.unblockFling();
@@ -315,6 +322,7 @@
return;
}
cancelAtomicComponentsController();
+
if (mCurrentAnimation != null) {
mAtomicComponentsStartProgress = mCurrentAnimation.getProgressFraction();
long duration = (long) (getShiftRange() * 2);
@@ -322,6 +330,7 @@
createAtomicAnimForState(mFromState, mToState, duration), duration);
mAtomicComponentsController.dispatchOnStart();
mAtomicComponentsTargetState = mToState;
+ maybeAutoPlayAtomicComponentsAnim();
}
}
});
@@ -416,16 +425,8 @@
mLauncher.getAppsView().addSpringFromFlingUpdateListener(anim, velocity);
}
anim.start();
- if (mAtomicAnim == null) {
- startAtomicComponentsAnim(endProgress, anim.getDuration());
- } else {
- mAtomicAnim.addListener(new AnimationSuccessListener() {
- @Override
- public void onAnimationSuccess(Animator animator) {
- startAtomicComponentsAnim(endProgress, anim.getDuration());
- }
- });
- }
+ mAtomicAnimAutoPlayInfo = new AutoPlayAtomicAnimationInfo(endProgress, anim.getDuration());
+ maybeAutoPlayAtomicComponentsAnim();
}
/**
@@ -435,18 +436,32 @@
* the non-atomic components, which only happens if we reinit before the atomic animation
* finishes.
*/
- private void startAtomicComponentsAnim(float toProgress, long duration) {
- if (mAtomicComponentsController != null) {
- ValueAnimator atomicAnim = mAtomicComponentsController.getAnimationPlayer();
- atomicAnim.setFloatValues(mAtomicComponentsController.getProgressFraction(), toProgress);
- atomicAnim.setDuration(duration);
+ private void maybeAutoPlayAtomicComponentsAnim() {
+ if (mAtomicComponentsController == null || mAtomicAnimAutoPlayInfo == null) {
+ return;
+ }
+
+ final AnimatorPlaybackController controller = mAtomicComponentsController;
+ ValueAnimator atomicAnim = controller.getAnimationPlayer();
+ atomicAnim.setFloatValues(controller.getProgressFraction(),
+ mAtomicAnimAutoPlayInfo.toProgress);
+ long duration = mAtomicAnimAutoPlayInfo.endTime - SystemClock.elapsedRealtime();
+ mAtomicAnimAutoPlayInfo = null;
+ if (duration <= 0) {
atomicAnim.start();
+ atomicAnim.end();
+ mAtomicComponentsController = null;
+ } else {
+ atomicAnim.setDuration(duration);
atomicAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
- mAtomicComponentsController = null;
+ if (mAtomicComponentsController == controller) {
+ mAtomicComponentsController = null;
+ }
}
});
+ atomicAnim.start();
}
}
@@ -476,6 +491,10 @@
}
protected void onSwipeInteractionCompleted(LauncherState targetState, int logAction) {
+ if (mAtomicComponentsController != null) {
+ mAtomicComponentsController.getAnimationPlayer().end();
+ mAtomicComponentsController = null;
+ }
cancelAnimationControllers();
boolean shouldGoToTargetState = true;
if (mPendingAnimation != null) {
@@ -523,5 +542,17 @@
mAtomicComponentsController.getAnimationPlayer().cancel();
mAtomicComponentsController = null;
}
+ mAtomicAnimAutoPlayInfo = null;
+ }
+
+ private static class AutoPlayAtomicAnimationInfo {
+
+ public final float toProgress;
+ public final long endTime;
+
+ AutoPlayAtomicAnimationInfo(float toProgress, long duration) {
+ this.toProgress = toProgress;
+ this.endTime = duration + SystemClock.elapsedRealtime();
+ }
}
}
diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java
index c17857f..db4c492 100644
--- a/src/com/android/launcher3/views/OptionsPopupView.java
+++ b/src/com/android/launcher3/views/OptionsPopupView.java
@@ -153,7 +153,10 @@
}
public static boolean onWidgetsClicked(View view) {
- Launcher launcher = Launcher.getLauncher(view.getContext());
+ return openWidgets(Launcher.getLauncher(view.getContext()));
+ }
+
+ public static boolean openWidgets(Launcher launcher) {
if (launcher.getPackageManager().isSafeMode()) {
Toast.makeText(launcher, R.string.safemode_widget_error, Toast.LENGTH_SHORT).show();
return false;
diff --git a/tests/Android.mk b/tests/Android.mk
index e8797a7..f6f02fe 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -22,7 +22,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_FULL_LIBS_MANIFEST_FILES := $(LOCAL_PATH)/AndroidManifest-common.xml
-LOCAL_SDK_VERSION := current
+LOCAL_SDK_VERSION := 28
LOCAL_MIN_SDK_VERSION := 21
LOCAL_PACKAGE_NAME := Launcher3Tests