From f58db150afd1efc0ac0875faf7f8f8286db9503c Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Thu, 2 Jun 2022 16:06:37 -0700 Subject: [PATCH] Play fallback animation if icon in All Apps is covered by header. Bug: 230707341 Test: enter all apps scroll so icon is covered by header open app, swipe back to return to all apps confirm fallback animation plays repeat but scroll so icon is not covered by header confirm normal animation plays Change-Id: I56cda07f3eccc11e8909f7fb28210f65cc6e0f1d --- src/com/android/launcher3/Launcher.java | 21 ++++++++++++++++--- .../allapps/ActivityAllAppsContainerView.java | 2 +- .../allapps/BaseAllAppsContainerView.java | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 18463839b2..c8bce026e7 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -124,6 +124,7 @@ import com.android.launcher3.DropTarget.DragObject; import com.android.launcher3.accessibility.BaseAccessibilityDelegate.LauncherAction; import com.android.launcher3.accessibility.LauncherAccessibilityDelegate; import com.android.launcher3.allapps.ActivityAllAppsContainerView; +import com.android.launcher3.allapps.AllAppsRecyclerView; import com.android.launcher3.allapps.AllAppsStore; import com.android.launcher3.allapps.AllAppsTransitionController; import com.android.launcher3.allapps.BaseAllAppsContainerView; @@ -196,6 +197,7 @@ import com.android.launcher3.util.TraceHelper; import com.android.launcher3.util.UiThreadHelper; import com.android.launcher3.util.ViewOnDrawExecutor; import com.android.launcher3.views.ActivityContext; +import com.android.launcher3.views.FloatingIconView; import com.android.launcher3.views.FloatingSurfaceView; import com.android.launcher3.views.OptionsPopupView; import com.android.launcher3.views.ScrimView; @@ -2757,8 +2759,8 @@ public class Launcher extends StatefulActivity * @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, - boolean supportsAllAppsState) { + public @Nullable View getFirstMatchForAppClose(int preferredItemId, String packageName, + UserHandle user, boolean supportsAllAppsState) { final Predicate preferredItem = info -> info != null && info.id == preferredItemId; final Predicate packageAndUserAndApp = info -> @@ -2770,8 +2772,21 @@ public class Launcher extends StatefulActivity packageName); if (supportsAllAppsState && isInState(LauncherState.ALL_APPS)) { - return getFirstMatch(Collections.singletonList(mAppsView.getActiveRecyclerView()), + AllAppsRecyclerView activeRecyclerView = mAppsView.getActiveRecyclerView(); + View v = getFirstMatch(Collections.singletonList(activeRecyclerView), preferredItem, packageAndUserAndApp); + + if (activeRecyclerView.getCurrentScrollY() > 0) { + RectF locationBounds = new RectF(); + FloatingIconView.getLocationBoundsForView(this, v, false, locationBounds, + new Rect()); + if (locationBounds.top < mAppsView.getHeaderBottom()) { + // Icon is covered by scrim, return null to play fallback animation. + return null; + } + } + + return v; } else { List containers = new ArrayList<>(mWorkspace.getPanelCount() + 1); containers.add(mWorkspace.getHotseat().getShortcutsAndWidgets()); diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java index 2368cf7ce1..53a6fd7edb 100644 --- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java @@ -239,7 +239,7 @@ public class ActivityAllAppsContainerView createAdapter(AlphabeticalAppsList mAppsList, BaseAdapterProvider[] adapterProviders); - protected int getHeaderBottom() { + public int getHeaderBottom() { return (int) getTranslationY(); }