From b39cf0bb33b0f9c1ba42b4e9f02af4fe2c32cf3e Mon Sep 17 00:00:00 2001 From: "sfufa@google.com" Date: Sun, 19 Sep 2021 12:37:31 -0700 Subject: [PATCH] [Hotseat] Remove stale predictions when AppIcon is removed Bug: 200088725 Test: Install work profile clock app, verify it is visible in the hotseat, launch (which should remove the icon from AllApps). Go home and verify icon is removed from the hotseat. Change-Id: I5915f5469fd4f90da0471dc177ef0965e99d07c7 --- .../hybridhotseat/HotseatPredictionController.java | 13 +++++++++++++ .../launcher3/uioverrides/QuickstepLauncher.java | 13 ++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java index 13baf5677a..86562c4374 100644 --- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java +++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java @@ -55,6 +55,7 @@ import com.android.launcher3.popup.SystemShortcut; import com.android.launcher3.touch.ItemLongClickListener; import com.android.launcher3.uioverrides.PredictedAppIcon; import com.android.launcher3.uioverrides.QuickstepLauncher; +import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.OnboardingPrefs; import com.android.launcher3.views.ArrowTipView; import com.android.launcher3.views.Snackbar; @@ -497,6 +498,18 @@ public class HotseatPredictionController implements DragController.DragListener, .log(LAUNCHER_HOTSEAT_RANKED); } + /** + * Called when app/shortcut icon is removed by system. This is used to prune visible stale + * predictions while while waiting for AppAPrediction service to send new batch of predictions. + * + * @param matcher filter matching items that have been removed + */ + public void onModelItemsRemoved(ItemInfoMatcher matcher) { + if (mPredictedItems.removeIf(matcher::matchesInfo)) { + fillGapsWithPrediction(true); + } + } + private class PinPrediction extends SystemShortcut { private PinPrediction(QuickstepLauncher target, ItemInfo itemInfo) { diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 2009cd75d9..df642652b6 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -66,6 +66,7 @@ import com.android.launcher3.uioverrides.touchcontrollers.StatusBarTouchControll import com.android.launcher3.uioverrides.touchcontrollers.TaskViewTouchController; import com.android.launcher3.uioverrides.touchcontrollers.TransposedQuickSwitchTouchController; import com.android.launcher3.uioverrides.touchcontrollers.TwoButtonNavbarTouchController; +import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.OnboardingPrefs; import com.android.launcher3.util.TouchController; import com.android.launcher3.util.UiThreadHelper; @@ -163,7 +164,11 @@ public class QuickstepLauncher extends BaseQuickstepLauncher { public boolean startActivitySafely(View v, Intent intent, ItemInfo item) { // Only pause is taskbar controller is not present mHotseatPredictionController.setPauseUIUpdate(getTaskbarUIController() == null); - return super.startActivitySafely(v, intent, item); + boolean started = super.startActivitySafely(v, intent, item); + if (getTaskbarUIController() == null && !started) { + mHotseatPredictionController.setPauseUIUpdate(false); + } + return started; } @Override @@ -227,6 +232,12 @@ public class QuickstepLauncher extends BaseQuickstepLauncher { } } + @Override + public void bindWorkspaceComponentsRemoved(ItemInfoMatcher matcher) { + super.bindWorkspaceComponentsRemoved(matcher); + mHotseatPredictionController.onModelItemsRemoved(matcher); + } + @Override public void onDestroy() { super.onDestroy();