diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java index 9ee7b0e5a5..537d2c66ab 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsSlideInView.java @@ -23,6 +23,7 @@ import android.graphics.Canvas; import android.graphics.Rect; import android.util.AttributeSet; import android.view.MotionEvent; +import android.view.View; import android.view.animation.Interpolator; import android.window.OnBackInvokedDispatcher; @@ -30,6 +31,7 @@ import com.android.launcher3.DeviceProfile; import com.android.launcher3.Insettable; import com.android.launcher3.R; import com.android.launcher3.anim.AnimatorListeners; +import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.taskbar.allapps.TaskbarAllAppsViewController.TaskbarAllAppsCallbacks; import com.android.launcher3.taskbar.overlay.TaskbarOverlayContext; @@ -64,19 +66,45 @@ public class TaskbarAllAppsSlideInView extends AbstractSlideInView mAllAppsCallbacks.onAllAppsTransitionEnd(true))); - animator.start(); - } else { - mTranslationShift = TRANSLATION_SHIFT_OPENED; + addOnAttachStateChangeListener(new OnAttachStateChangeListener() { + @Override + public void onViewAttachedToWindow(View v) { + removeOnAttachStateChangeListener(this); + // Wait for view and its descendants to be fully attached before starting open. + post(() -> showOnFullyAttachedToWindow(animate)); + } + + @Override + public void onViewDetachedFromWindow(View v) { + removeOnAttachStateChangeListener(this); + } + }); + } + + private void showOnFullyAttachedToWindow(boolean animate) { + mAllAppsCallbacks.onAllAppsTransitionStart(true); + if (!animate) { mAllAppsCallbacks.onAllAppsTransitionEnd(true); + mTranslationShift = TRANSLATION_SHIFT_OPENED; + return; } + + setUpOpenAnimation(mAllAppsCallbacks.getOpenDuration()); + Animator animator = mOpenCloseAnimation.getAnimationPlayer(); + animator.setInterpolator(EMPHASIZED); + animator.addListener(AnimatorListeners.forEndCallback(() -> { + if (mIsOpen) { + mAllAppsCallbacks.onAllAppsTransitionEnd(true); + } + })); + animator.start(); + } + + @Override + protected void onOpenCloseAnimationPending(PendingAnimation animation) { + mAllAppsCallbacks.onAllAppsAnimationPending( + animation, mToTranslationShift == TRANSLATION_SHIFT_OPENED); } /** The apps container inside this view. */ diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java index f43169b498..85633e9037 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsViewController.java @@ -20,6 +20,7 @@ import static com.android.launcher3.util.OnboardingPrefs.ALL_APPS_VISITED_COUNT; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.allapps.AllAppsTransitionListener; +import com.android.launcher3.anim.PendingAnimation; import com.android.launcher3.appprediction.AppsDividerView; import com.android.launcher3.taskbar.NavbarButtonsViewController; import com.android.launcher3.taskbar.TaskbarControllers; @@ -125,5 +126,9 @@ final class TaskbarAllAppsViewController { boolean handleSearchBackInvoked() { return mSearchSessionController.handleBackInvoked(); } + + void onAllAppsAnimationPending(PendingAnimation animation, boolean toAllApps) { + mSearchSessionController.onAllAppsAnimationPending(animation, toAllApps); + } } } diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarSearchSessionController.kt b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarSearchSessionController.kt index c26977f7ac..8a2041fc34 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarSearchSessionController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarSearchSessionController.kt @@ -20,6 +20,7 @@ import android.content.Context import android.view.View import com.android.launcher3.R import com.android.launcher3.allapps.AllAppsTransitionListener +import com.android.launcher3.anim.PendingAnimation import com.android.launcher3.config.FeatureFlags import com.android.launcher3.dragndrop.DragOptions.PreDragCondition import com.android.launcher3.model.data.ItemInfo @@ -50,6 +51,8 @@ open class TaskbarSearchSessionController : ResourceBasedOverride, AllAppsTransi open fun handleBackInvoked(): Boolean = false + open fun onAllAppsAnimationPending(animation: PendingAnimation, toAllApps: Boolean) = Unit + companion object { @JvmStatic fun newInstance(context: Context): TaskbarSearchSessionController {