From 52307a46048f902c59d16e44c5805d38ca2370f6 Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Tue, 5 Apr 2022 20:35:28 +0100 Subject: [PATCH 1/8] Adjust grid cell visualizations. This is a partial revert of ag/17540098 Bug: 202971709 Test: manual Change-Id: Ia6f863701c169709053980766337b3caae6fba76 --- res/values-land/dimens.xml | 3 +++ res/values-sw600dp/dimens.xml | 3 +++ res/values/dimens.xml | 5 +++-- src/com/android/launcher3/CellLayout.java | 13 ++++++++----- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml index 58aeda4c0d..cf5b14caf4 100644 --- a/res/values-land/dimens.xml +++ b/res/values-land/dimens.xml @@ -35,4 +35,7 @@ 2dp 6dp 6dp + + + 24dp diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml index 823fc62372..834d8ee093 100644 --- a/res/values-sw600dp/dimens.xml +++ b/res/values-sw600dp/dimens.xml @@ -44,4 +44,7 @@ 16dp 16dp 56dp + + + 6dp diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 83d40d59f7..2a093f057d 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -367,8 +367,9 @@ - 22dp - 6dp + 28dp + 6dp + 6dp 48dp diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index d235180314..f7133c49dd 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -148,7 +148,8 @@ public class CellLayout extends ViewGroup { private boolean mVisualizeDropLocation = true; private RectF mVisualizeGridRect = new RectF(); private Paint mVisualizeGridPaint = new Paint(); - private int mGridVisualizationPadding; + private int mGridVisualizationPaddingX; + private int mGridVisualizationPaddingY; private int mGridVisualizationRoundingRadius; private float mGridAlpha = 0f; private int mGridColor = 0; @@ -260,8 +261,10 @@ public class CellLayout extends ViewGroup { mBackground.setAlpha(0); mGridColor = Themes.getAttrColor(getContext(), R.attr.workspaceAccentColor); - mGridVisualizationPadding = - res.getDimensionPixelSize(R.dimen.grid_visualization_cell_spacing); + mGridVisualizationPaddingX = res.getDimensionPixelSize( + R.dimen.grid_visualization_horizontal_cell_spacing); + mGridVisualizationPaddingY = res.getDimensionPixelSize( + R.dimen.grid_visualization_vertical_cell_spacing); mGridVisualizationRoundingRadius = res.getDimensionPixelSize(R.dimen.grid_visualization_rounding_radius); mReorderPreviewAnimationMagnitude = (REORDER_PREVIEW_MAGNITUDE * deviceProfile.iconSizePx); @@ -591,8 +594,8 @@ public class CellLayout extends ViewGroup { protected void visualizeGrid(Canvas canvas) { DeviceProfile dp = mActivity.getDeviceProfile(); - int paddingX = (int) Math.min((mCellWidth - dp.iconSizePx) / 2, mGridVisualizationPadding); - int paddingY = (int) Math.min((mCellHeight - dp.iconSizePx) / 2, mGridVisualizationPadding); + int paddingX = Math.min((mCellWidth - dp.iconSizePx) / 2, mGridVisualizationPaddingX); + int paddingY = Math.min((mCellHeight - dp.iconSizePx) / 2, mGridVisualizationPaddingY); mVisualizeGridRect.set(paddingX, paddingY, mCellWidth - paddingX, mCellHeight - paddingY); From e8a60abc83103abb568c33eec5872d366d2db39a Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Mon, 11 Apr 2022 18:17:31 +0100 Subject: [PATCH 2/8] Don't use double padding in DeferredAppWidgetHostView if that would result in negative width Fix: 203530620 Test: manual Change-Id: I4aeff08e4fafec74e6a1bb031dfa14ae9d59e87e --- .../widget/DeferredAppWidgetHostView.java | 29 +++++-------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/src/com/android/launcher3/widget/DeferredAppWidgetHostView.java b/src/com/android/launcher3/widget/DeferredAppWidgetHostView.java index 57f8bc7717..f42142ecf0 100644 --- a/src/com/android/launcher3/widget/DeferredAppWidgetHostView.java +++ b/src/com/android/launcher3/widget/DeferredAppWidgetHostView.java @@ -16,7 +16,6 @@ package com.android.launcher3.widget; -import android.annotation.SuppressLint; import android.appwidget.AppWidgetProviderInfo; import android.content.Context; import android.graphics.Canvas; @@ -31,9 +30,6 @@ import android.widget.RemoteViews; import com.android.launcher3.R; -import java.io.PrintWriter; -import java.io.StringWriter; - /** * A widget host views created while the host has not bind to the system service. */ @@ -73,34 +69,23 @@ public class DeferredAppWidgetHostView extends LauncherAppWidgetHostView { return; } - // Use double padding so that there is extra space between background and text + // Use double padding so that there is extra space between background and text if possible. int availableWidth = getMeasuredWidth() - 2 * (getPaddingLeft() + getPaddingRight()); + if (availableWidth <= 0) { + availableWidth = getMeasuredWidth() - (getPaddingLeft() + getPaddingRight()); + } if (mSetupTextLayout != null && mSetupTextLayout.getText().equals(info.label) && mSetupTextLayout.getWidth() == availableWidth) { return; } - try { - mSetupTextLayout = new StaticLayout(info.label, mPaint, availableWidth, - Layout.Alignment.ALIGN_CENTER, 1, 0, true); - } catch (IllegalArgumentException e) { - @SuppressLint("DrawAllocation") StringWriter stringWriter = new StringWriter(); - @SuppressLint("DrawAllocation") PrintWriter printWriter = new PrintWriter(stringWriter); - mActivity.getDeviceProfile().dump(/*prefix=*/"", printWriter); - printWriter.flush(); - String message = "b/203530620 " - + "- availableWidth: " + availableWidth - + ", getMeasuredWidth: " + getMeasuredWidth() - + ", getPaddingLeft: " + getPaddingLeft() - + ", getPaddingRight: " + getPaddingRight() - + ", deviceProfile: " + stringWriter.toString(); - throw new IllegalArgumentException(message, e); - } + mSetupTextLayout = new StaticLayout(info.label, mPaint, availableWidth, + Layout.Alignment.ALIGN_CENTER, 1, 0, true); } @Override protected void onDraw(Canvas canvas) { if (mSetupTextLayout != null) { - canvas.translate(getPaddingLeft() * 2, + canvas.translate((getWidth() - mSetupTextLayout.getWidth()) / 2, (getHeight() - mSetupTextLayout.getHeight()) / 2); mSetupTextLayout.draw(canvas); } From ba7cf0dc7d38847e38d6ae183c21d3ccd77fa7c7 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Mon, 11 Apr 2022 13:20:34 -0700 Subject: [PATCH 3/8] Fixing potential ANR when fetching for wallpaper info Bug: 214581894 Test: Manual Change-Id: I616b34b0ce6c96ed360073b2e8ff4eed81190add --- .../launcher3/util/WallpaperOffsetInterpolator.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/util/WallpaperOffsetInterpolator.java b/src/com/android/launcher3/util/WallpaperOffsetInterpolator.java index 8a7cae90bc..f1276dd3c9 100644 --- a/src/com/android/launcher3/util/WallpaperOffsetInterpolator.java +++ b/src/com/android/launcher3/util/WallpaperOffsetInterpolator.java @@ -14,6 +14,8 @@ import android.os.SystemClock; import android.util.Log; import android.view.animation.Interpolator; +import androidx.annotation.AnyThread; + import com.android.launcher3.Utilities; import com.android.launcher3.Workspace; import com.android.launcher3.anim.Interpolators; @@ -182,6 +184,7 @@ public class WallpaperOffsetInterpolator extends BroadcastReceiver { } } + @AnyThread private void updateOffset() { Message.obtain(mHandler, MSG_SET_NUM_PARALLAX, getNumPagesForWallpaperParallax(), 0, mWindowToken).sendToTarget(); @@ -206,9 +209,12 @@ public class WallpaperOffsetInterpolator extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - mWallpaperIsLiveWallpaper = - WallpaperManager.getInstance(mWorkspace.getContext()).getWallpaperInfo() != null; - updateOffset(); + UI_HELPER_EXECUTOR.execute(() -> { + // Updating the boolean on a background thread is fine as the assignments are atomic + mWallpaperIsLiveWallpaper = + WallpaperManager.getInstance(context).getWallpaperInfo() != null; + updateOffset(); + }); } private static final int MSG_START_ANIMATION = 1; From 42e30963c371399317a7c10be924fcdc2f19c16d Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Mon, 28 Mar 2022 23:58:36 -0700 Subject: [PATCH 4/8] Play icon alignment animation in live tile mode aka launcher is not resumed but recents animation is running Fixes: 210047102 Test: Go to overview in live tile mode, tap on somewhere outside any task in overview, and make sure icon alignment animation is played. Change-Id: Ic300ee296049b6fdcdf6d2595916cc84c09d95fa --- .../taskbar/TaskbarLauncherStateController.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java index eed67b62c2..6c89f534d8 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java @@ -26,6 +26,7 @@ import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.BaseQuickstepLauncher; @@ -74,6 +75,8 @@ import java.util.function.Supplier; private int mState; private LauncherState mLauncherState = LauncherState.NORMAL; + private @Nullable TaskBarRecentsAnimationListener mTaskBarRecentsAnimationListener; + private boolean mIsAnimatingToLauncherViaGesture; private boolean mIsAnimatingToLauncherViaResume; @@ -163,12 +166,11 @@ import java.util.function.Supplier; animatorSet.play(stashController.applyStateWithoutStart(duration)); animatorSet.play(applyState(duration, false)); - TaskBarRecentsAnimationListener listener = new TaskBarRecentsAnimationListener(callbacks); - callbacks.addListener(listener); + mTaskBarRecentsAnimationListener = new TaskBarRecentsAnimationListener(callbacks); + callbacks.addListener(mTaskBarRecentsAnimationListener); RecentsView recentsView = mLauncher.getOverviewPanel(); recentsView.setTaskLaunchListener(() -> { - listener.endGestureStateOverride(true); - callbacks.removeListener(listener); + mTaskBarRecentsAnimationListener.endGestureStateOverride(true); }); return animatorSet; } @@ -379,7 +381,7 @@ import java.util.function.Supplier; } private void onIconAlignmentRatioChangedForStateTransition() { - if (!isResumed()) { + if (!isResumed() && mTaskBarRecentsAnimationListener == null) { return; } onIconAlignmentRatioChanged(this::getCurrentIconAlignmentRatioForLauncherState); @@ -455,6 +457,7 @@ import java.util.function.Supplier; private void endGestureStateOverride(boolean finishedToApp) { mCallbacks.removeListener(this); + mTaskBarRecentsAnimationListener = null; // Update the resumed state immediately to ensure a seamless handoff boolean launcherResumed = !finishedToApp; From d4ed2f7717d7963640ba3f0f3564b330e8d03ad8 Mon Sep 17 00:00:00 2001 From: Tracy Zhou Date: Sat, 9 Apr 2022 17:42:53 -0700 Subject: [PATCH 5/8] Update task bar icon alignment logic when launcher is paused and resumed in Overview If launcher is paused and resumed in overview, goingToUnstashedLauncherStateChanged doesn't change, so we should not use goingToUnstashedLauncherState as a signal for the end value of mIconAlignmentForResumedState anim Bug: 223109070 Test: go to overview, use the share functionality, share to drive, and make sure task bar ends up in stashed state. Making sure that it never unstashes is out of scope for this change Change-Id: I5684be6b58279a9b41e257dd72591f7d692c2fbc --- .../launcher3/taskbar/TaskbarLauncherStateController.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java index eed67b62c2..df0eb1fba8 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java @@ -257,7 +257,10 @@ import java.util.function.Supplier; if (hasAnyFlag(changedFlags, FLAG_RESUMED) || launcherStateChangedDuringAnimToResumeAlignment) { boolean isResumed = isResumed(); - float toAlignmentForResumedState = isResumed && goingToUnstashedLauncherState() ? 1 : 0; + // If launcher is resumed, we show the icons when going to an unstashed launcher state + // or launcher state is not changed (e.g. in overview, launcher is paused and resumed). + float toAlignmentForResumedState = isResumed && (goingToUnstashedLauncherState() + || !goingToUnstashedLauncherStateChanged) ? 1 : 0; // If we're already animating to the value, just leave it be instead of restarting it. if (!mIconAlignmentForResumedState.isAnimatingToValue(toAlignmentForResumedState)) { ObjectAnimator resumeAlignAnim = mIconAlignmentForResumedState From 4ad53f12680abc50b4f10a74a7024fb322eb660e Mon Sep 17 00:00:00 2001 From: Brian Isganitis Date: Wed, 6 Apr 2022 15:58:38 -0700 Subject: [PATCH 6/8] Defer unstashing taskbar on all apps close if gesture in progress. This behavior is more consistent with how we update taskbar stashing when IME is dismissed. Test: Verified stashing behavior with gestures, 3-button, and bottom sheet dismiss. Fix: 223837786 Change-Id: Ib85ebe629f33f0bddc36bbc8d99136711105b279 --- .../taskbar/TaskbarStashController.java | 32 +++++++++++++++++-- .../allapps/TaskbarAllAppsSlideInView.java | 2 +- .../allapps/TaskbarAllAppsViewController.java | 7 ++-- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index 3521ee33b7..be67136bf0 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -33,6 +33,7 @@ import android.view.ViewConfiguration; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Utilities; +import com.android.launcher3.taskbar.allapps.TaskbarAllAppsSlideInView; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.quickstep.AnimatedFloat; @@ -518,13 +519,40 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba */ public void setSystemGestureInProgress(boolean inProgress) { mIsSystemGestureInProgress = inProgress; - // Only update FLAG_STASHED_IN_APP_IME when system gesture is not in progress. - if (!mIsSystemGestureInProgress) { + if (mIsSystemGestureInProgress) { + return; + } + + // Only update the following flags when system gesture is not in progress. + maybeResetStashedInAppAllApps(hasAnyFlag(FLAG_STASHED_IN_APP_IME) == mIsImeShowing); + if (hasAnyFlag(FLAG_STASHED_IN_APP_IME) != mIsImeShowing) { updateStateForFlag(FLAG_STASHED_IN_APP_IME, mIsImeShowing); applyState(TASKBAR_STASH_DURATION_FOR_IME, getTaskbarStashStartDelayForIme()); } } + /** + * Reset stashed in all apps only if no system gesture is in progress. + *

+ * Otherwise, the reset should be deferred until after the gesture is finished. + * + * @see #setSystemGestureInProgress + */ + public void maybeResetStashedInAppAllApps() { + maybeResetStashedInAppAllApps(true); + } + + private void maybeResetStashedInAppAllApps(boolean applyState) { + if (mIsSystemGestureInProgress) { + return; + } + + updateStateForFlag(FLAG_STASHED_IN_APP_ALL_APPS, false); + if (applyState) { + applyState(TaskbarAllAppsSlideInView.DEFAULT_CLOSE_DURATION); + } + } + /** * When hiding the IME, delay the unstash animation to align with the end of the transition. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java index 5d2d72af37..a37ebac2c3 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java @@ -34,7 +34,7 @@ import java.util.Optional; public class TaskbarAllAppsSlideInView extends AbstractSlideInView implements Insettable, DeviceProfile.OnDeviceProfileChangeListener { static final int DEFAULT_OPEN_DURATION = 500; - static final int DEFAULT_CLOSE_DURATION = 200; + public static final int DEFAULT_CLOSE_DURATION = 200; private TaskbarAllAppsContainerView mAppsView; private OnCloseListener mOnCloseBeginListener; diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java index 32ebbe822e..f19b7de2f8 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java @@ -16,7 +16,6 @@ package com.android.launcher3.taskbar.allapps; import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_STASHED_IN_APP_ALL_APPS; -import static com.android.launcher3.taskbar.allapps.TaskbarAllAppsSlideInView.DEFAULT_CLOSE_DURATION; import static com.android.launcher3.taskbar.allapps.TaskbarAllAppsSlideInView.DEFAULT_OPEN_DURATION; import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT; @@ -86,9 +85,9 @@ final class TaskbarAllAppsViewController { mSlideInView.setOnCloseBeginListener(() -> { AbstractFloatingView.closeOpenContainer( mContext, AbstractFloatingView.TYPE_ACTION_POPUP); - mTaskbarStashController.updateStateForFlag( - FLAG_STASHED_IN_APP_ALL_APPS, false); - mTaskbarStashController.applyState(DEFAULT_CLOSE_DURATION); + // Post in case view is closing due to gesture navigation. If a gesture is in progress, + // wait to unstash until after the gesture is finished. + mSlideInView.post(mTaskbarStashController::maybeResetStashedInAppAllApps); }); } } From 7013ee716d8ebb07a16a24bbacafd51c3b16245c Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Tue, 12 Apr 2022 11:50:09 +0100 Subject: [PATCH 7/8] Add drop target button overlap correction to second button only. Bug: 228311837 Bug: 228311837 Test: manual. Change-Id: Ib9256deadd58c7350143221bf98c79415aaf9bc4 --- src/com/android/launcher3/DropTargetBar.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java index b94cdbf226..54f769b421 100644 --- a/src/com/android/launcher3/DropTargetBar.java +++ b/src/com/android/launcher3/DropTargetBar.java @@ -252,8 +252,7 @@ public class DropTargetBar extends FrameLayout int overlap = start + leftButton.getMeasuredWidth() + rightButton.getMeasuredWidth() - end; if (overlap > 0) { - start -= overlap / 2; - end += overlap / 2; + end += overlap; } leftButton.layout(start, 0, start + leftButton.getMeasuredWidth(), From 29fbab4ddd664a7c36fb58940fd457c67b3bfe52 Mon Sep 17 00:00:00 2001 From: Pat Manning Date: Mon, 4 Apr 2022 16:08:52 +0100 Subject: [PATCH 8/8] Animate clear all button's alpha after last task has scrolled beyond its edge. Test: manual Fix: 208879377 Change-Id: Iad43abbe36d11317869a0c5aa6a8d59fd1fddb67 --- .../com/android/quickstep/views/ClearAllButton.java | 5 ++++- .../src/com/android/quickstep/views/RecentsView.java | 11 ++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/quickstep/views/ClearAllButton.java b/quickstep/src/com/android/quickstep/views/ClearAllButton.java index 332cbeb397..50be5ea565 100644 --- a/quickstep/src/com/android/quickstep/views/ClearAllButton.java +++ b/quickstep/src/com/android/quickstep/views/ClearAllButton.java @@ -141,7 +141,10 @@ public class ClearAllButton extends Button { } applyPrimaryTranslation(); applySecondaryTranslation(); - mScrollAlpha = 1 - shift / orientationSize; + float clearAllSpacing = + recentsView.getPageSpacing() + recentsView.getClearAllExtraPageSpacing(); + clearAllSpacing = mIsRtl ? -clearAllSpacing : clearAllSpacing; + mScrollAlpha = Math.max((clearAllScroll + clearAllSpacing - scroll) / clearAllSpacing, 0); updateAlpha(); } diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index e64e439779..3fa01690ac 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1289,10 +1289,11 @@ public abstract class RecentsView