Support customizing open-close PendingAnimation for Taskbar search.

Test: Manual
Bug: 289290185
Flag: No
Change-Id: I9f076875c4bd13c98a3ace8c02d512defa013fdf
This commit is contained in:
Brian Isganitis
2023-07-28 19:33:56 +00:00
parent 0a036e9c15
commit a7ee532d47
3 changed files with 46 additions and 10 deletions

View File

@@ -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<TaskbarOverla
}
mIsOpen = true;
attachToContainer();
mAllAppsCallbacks.onAllAppsTransitionStart(true);
if (animate) {
setUpOpenAnimation(mAllAppsCallbacks.getOpenDuration());
Animator animator = mOpenCloseAnimation.getAnimationPlayer();
animator.setInterpolator(EMPHASIZED);
animator.addListener(AnimatorListeners.forEndCallback(
() -> 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. */