From b42e124f5b189eb28d7dd2694ef6dab77985aa07 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Tue, 8 Mar 2022 16:37:35 -0800 Subject: [PATCH 1/7] Never look for matching view in All Apps when swiping up to go home. The swiping up gesture will never return an app in All Apps, so we can ignore All Apps state in those cases. This fixes an edge case where user swipes up and launcher state is still in All Apps. This causes us to animate the icon to where it would be in All Apps, even though by the time the animation starts we are actually in Normal state. Bug: 222124240 Test: open app from all apps then quickly swipe up to go home Change-Id: I756a870660a397d6629aec82e4f5ec4914ed0669 --- .../com/android/launcher3/QuickstepTransitionManager.java | 4 ++-- .../src/com/android/quickstep/LauncherSwipeHandlerV2.java | 3 ++- src/com/android/launcher3/Launcher.java | 7 +++++-- src/com/android/launcher3/views/FloatingSurfaceView.java | 3 ++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index c4a3fb5572..8644a1238f 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -1288,8 +1288,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener } } - return mLauncher.getFirstMatchForAppClose(launchCookieItemId, - packageName, UserHandle.of(runningTaskTarget.taskInfo.userId)); + return mLauncher.getFirstMatchForAppClose(launchCookieItemId, packageName, + UserHandle.of(runningTaskTarget.taskInfo.userId), true /* supportsAllAppsState */); } private @NonNull RectF getDefaultWindowTargetRect() { diff --git a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java index af6cb847db..bc7a6ae449 100644 --- a/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java +++ b/quickstep/src/com/android/quickstep/LauncherSwipeHandlerV2.java @@ -233,7 +233,8 @@ public class LauncherSwipeHandlerV2 extends return mActivity.getFirstMatchForAppClose(launchCookieItemId, runningTaskView.getTask().key.getComponent().getPackageName(), - UserHandle.of(runningTaskView.getTask().key.userId)); + UserHandle.of(runningTaskView.getTask().key.userId), + false /* supportsAllAppsState */); } @Override diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 8fb2f53ec6..9bb815c823 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -2743,8 +2743,11 @@ public class Launcher extends StatefulActivity implements Launche * @param preferredItemId The id of the preferred item to match to if it exists. * @param packageName The package name of the app to match. * @param user The user of the app to match. + * @param supportsAllAppsState If true and we are in All Apps state, looks for view in All Apps. + * Else we only looks on the workspace. */ - public View getFirstMatchForAppClose(int preferredItemId, String packageName, UserHandle user) { + public View getFirstMatchForAppClose(int preferredItemId, String packageName, UserHandle user, + boolean supportsAllAppsState) { final ItemInfoMatcher preferredItem = (info, cn) -> info != null && info.id == preferredItemId; final ItemInfoMatcher packageAndUserAndApp = (info, cn) -> @@ -2755,7 +2758,7 @@ public class Launcher extends StatefulActivity implements Launche && TextUtils.equals(info.getTargetComponent().getPackageName(), packageName); - if (isInState(LauncherState.ALL_APPS)) { + if (supportsAllAppsState && isInState(LauncherState.ALL_APPS)) { return getFirstMatch(Collections.singletonList(mAppsView.getActiveRecyclerView()), preferredItem, packageAndUserAndApp); } else { diff --git a/src/com/android/launcher3/views/FloatingSurfaceView.java b/src/com/android/launcher3/views/FloatingSurfaceView.java index 7f54d6dce5..19c28b4c72 100644 --- a/src/com/android/launcher3/views/FloatingSurfaceView.java +++ b/src/com/android/launcher3/views/FloatingSurfaceView.java @@ -159,7 +159,8 @@ public class FloatingSurfaceView extends AbstractFloatingView implements return; } View icon = mLauncher.getFirstMatchForAppClose(-1, - mContract.componentName.getPackageName(), mContract.user); + mContract.componentName.getPackageName(), mContract.user, + false /* supportsAllAppsState */); boolean iconChanged = mIcon != icon; if (iconChanged) { From ede8718e63abb387bbca8b03e5f58273020cf2f2 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Wed, 9 Mar 2022 10:03:41 -0800 Subject: [PATCH 2/7] Sync hotseat/taskbar handoff + Do not allow sync during tests Bug: 223443781 Bug: 202507555 Test: open/close apps in hotseat/taskbar Change-Id: I2f434d440a26999219e785b8671768e27d0dcad3 --- Android.bp | 3 ++ .../TaskbarLauncherStateController.java | 35 +++++++++++++++++++ .../taskbar/TaskbarViewController.java | 14 ++++++-- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/Android.bp b/Android.bp index f5a38b4e6f..c980a2e50f 100644 --- a/Android.bp +++ b/Android.bp @@ -31,6 +31,7 @@ android_library { "androidx.test.uiautomator_uiautomator", "androidx.preference_preference", "SystemUISharedLib", + "SystemUIAnimationLib", ], srcs: [ "tests/tapl/**/*.java", @@ -196,6 +197,7 @@ android_library { "lottie", "SystemUISharedLib", "SystemUI-statsd", + "SystemUIAnimationLib", ], manifest: "quickstep/AndroidManifest.xml", min_sdk_version: "current", @@ -287,6 +289,7 @@ android_library { "SystemUISharedLib", "Launcher3CommonDepsLib", "QuickstepResLib", + "SystemUIAnimationLib", ], manifest: "quickstep/AndroidManifest.xml", platform_apis: true, diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java index ebe6a04611..235a156fb5 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java @@ -29,13 +29,16 @@ import androidx.annotation.NonNull; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.BaseQuickstepLauncher; +import com.android.launcher3.DeviceProfile; import com.android.launcher3.LauncherState; +import com.android.launcher3.Utilities; import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.util.MultiValueAlpha; import com.android.quickstep.AnimatedFloat; import com.android.quickstep.RecentsAnimationCallbacks; import com.android.quickstep.RecentsAnimationController; import com.android.quickstep.views.RecentsView; +import com.android.systemui.animation.ViewRootSync; import com.android.systemui.shared.recents.model.ThumbnailData; import java.util.HashMap; @@ -76,6 +79,9 @@ import java.util.function.Supplier; private boolean mShouldDelayLauncherStateAnim; + // We skip any view synchronizations during init/destroy. + private boolean mCanSyncViews; + private final StateManager.StateListener mStateListener = new StateManager.StateListener() { @@ -102,6 +108,8 @@ import java.util.function.Supplier; }; public void init(TaskbarControllers controllers, BaseQuickstepLauncher launcher) { + mCanSyncViews = false; + mControllers = controllers; mLauncher = launcher; @@ -121,9 +129,13 @@ import java.util.function.Supplier; updateStateForFlag(FLAG_RESUMED, launcher.hasBeenResumed()); mLauncherState = launcher.getStateManager().getState(); applyState(0); + + mCanSyncViews = true; } public void onDestroy() { + mCanSyncViews = false; + mIconAlignmentForResumedState.finishAnimation(); mIconAlignmentForGestureState.finishAnimation(); mIconAlignmentForLauncherState.finishAnimation(); @@ -131,6 +143,8 @@ import java.util.function.Supplier; mIconAlphaForHome.setConsumer(null); mLauncher.getHotseat().setIconsAlpha(1f); mLauncher.getStateManager().removeStateListener(mStateListener); + + mCanSyncViews = true; } public Animator createAnimToLauncher(@NonNull LauncherState toState, @@ -380,6 +394,27 @@ import java.util.function.Supplier; return; } float alignment = alignmentSupplier.get(); + float currentValue = mIconAlphaForHome.getValue(); + boolean taskbarWillBeVisible = alignment < 1; + boolean firstFrameVisChanged = (taskbarWillBeVisible && Float.compare(currentValue, 1) != 0) + || (!taskbarWillBeVisible && Float.compare(currentValue, 0) != 0); + + // Sync the first frame where we swap taskbar and hotseat. + if (firstFrameVisChanged && mCanSyncViews && !Utilities.IS_RUNNING_IN_TEST_HARNESS) { + DeviceProfile dp = mLauncher.getDeviceProfile(); + + // Do all the heavy work before the sync. + mControllers.taskbarViewController.createIconAlignmentControllerIfNotExists(dp); + + ViewRootSync.synchronizeNextDraw(mLauncher.getHotseat(), + mControllers.taskbarActivityContext.getDragLayer(), + () -> updateIconAlignment(alignment)); + } else { + updateIconAlignment(alignment); + } + } + + private void updateIconAlignment(float alignment) { mControllers.taskbarViewController.setLauncherIconAlignment( alignment, mLauncher.getDeviceProfile()); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index 6e34ee03b4..f354b2c2a8 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -191,6 +191,16 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar + mTaskbarIconTranslationYForStash.value); } + /** + * Creates the icon alignment controller if it does not already exist. + * @param launcherDp Launcher device profile. + */ + public void createIconAlignmentControllerIfNotExists(DeviceProfile launcherDp) { + if (mIconAlignControllerLazy == null) { + mIconAlignControllerLazy = createIconAlignmentController(launcherDp); + } + } + /** * Sets the taskbar icon alignment relative to Launcher hotseat icons * @param alignmentRatio [0, 1] @@ -198,9 +208,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar * 1 => fully aligned */ public void setLauncherIconAlignment(float alignmentRatio, DeviceProfile launcherDp) { - if (mIconAlignControllerLazy == null) { - mIconAlignControllerLazy = createIconAlignmentController(launcherDp); - } + createIconAlignmentControllerIfNotExists(launcherDp); mIconAlignControllerLazy.setPlayFraction(alignmentRatio); if (alignmentRatio <= 0 || alignmentRatio >= 1) { // Cleanup lazy controller so that it is created again in next animation From 79e76f4e7bca50396bd38274d8b3c35b931f1b84 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Wed, 9 Mar 2022 11:19:37 -0800 Subject: [PATCH 3/7] Update home settings subheads' style to Google Sans Text Fixes: 187671205 Test: manual Change-Id: I980b6b71900cf90934b562e9b2c313351cdb9e2c --- res/values-v31/styles.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/res/values-v31/styles.xml b/res/values-v31/styles.xml index e42d0a3371..008a77c3a8 100644 --- a/res/values-v31/styles.xml +++ b/res/values-v31/styles.xml @@ -38,6 +38,7 @@ @style/HomeSettings.PreferenceScreenStyle @style/HomeSettings.PreferenceStyle @style/HomeSettings.SwitchPreferenceStyle + google-sans-text