mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 02:38:20 +00:00
Adds 'move from center' animation for taskbar icons when unfolding foldable devices. Moves unfold transition progress provider from quickstep launcher activity to TouchInteractionService to widen the scope when this provider is available to cover both launcher activity and taskbar. Launcher activity and taskbar get their own instances of unfold transition progress provider using ScopedUnfoldTransitionProgressProvider wrapper. This wrapper allows to get transition progress provider that emits events only when clients are ready to handle them. Bug: 193794563 Test: manual Change-Id: I27581bd4e145a74f526bf60f2a545e56ded322f9
88 lines
3.5 KiB
Java
88 lines
3.5 KiB
Java
/*
|
|
* Copyright (C) 2021 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
package com.android.launcher3.taskbar;
|
|
|
|
import android.view.View;
|
|
import android.view.WindowManager;
|
|
|
|
import com.android.quickstep.util.LauncherViewsMoveFromCenterTranslationApplier;
|
|
import com.android.quickstep.util.ScopedUnfoldTransitionProgressProvider;
|
|
import com.android.systemui.shared.animation.UnfoldMoveFromCenterAnimator;
|
|
import com.android.systemui.unfold.UnfoldTransitionProgressProvider.TransitionProgressListener;
|
|
|
|
/**
|
|
* Controls animation of taskbar icons when unfolding foldable devices
|
|
*/
|
|
public class TaskbarUnfoldAnimationController {
|
|
|
|
private final ScopedUnfoldTransitionProgressProvider mUnfoldTransitionProgressProvider;
|
|
private final UnfoldMoveFromCenterAnimator mMoveFromCenterAnimator;
|
|
private final TransitionListener mTransitionListener = new TransitionListener();
|
|
private TaskbarViewController mTaskbarViewController;
|
|
|
|
public TaskbarUnfoldAnimationController(ScopedUnfoldTransitionProgressProvider
|
|
unfoldTransitionProgressProvider, WindowManager windowManager) {
|
|
mUnfoldTransitionProgressProvider = unfoldTransitionProgressProvider;
|
|
mMoveFromCenterAnimator = new UnfoldMoveFromCenterAnimator(windowManager,
|
|
new LauncherViewsMoveFromCenterTranslationApplier());
|
|
}
|
|
|
|
/**
|
|
* Initializes the controller
|
|
* @param taskbarControllers references to all other taskbar controllers
|
|
*/
|
|
public void init(TaskbarControllers taskbarControllers) {
|
|
mTaskbarViewController = taskbarControllers.taskbarViewController;
|
|
mTaskbarViewController.addOneTimePreDrawListener(() ->
|
|
mUnfoldTransitionProgressProvider.setReadyToHandleTransition(true));
|
|
mUnfoldTransitionProgressProvider.addCallback(mTransitionListener);
|
|
}
|
|
|
|
/**
|
|
* Destroys the controller
|
|
*/
|
|
public void onDestroy() {
|
|
mUnfoldTransitionProgressProvider.setReadyToHandleTransition(false);
|
|
mUnfoldTransitionProgressProvider.removeCallback(mTransitionListener);
|
|
}
|
|
|
|
private class TransitionListener implements TransitionProgressListener {
|
|
|
|
@Override
|
|
public void onTransitionStarted() {
|
|
mMoveFromCenterAnimator.updateDisplayProperties();
|
|
View[] icons = mTaskbarViewController.getIconViews();
|
|
for (View icon : icons) {
|
|
// TODO(b/193794563) we should re-register views if they are re-bound/re-inflated
|
|
// during the animation
|
|
mMoveFromCenterAnimator.registerViewForAnimation(icon);
|
|
}
|
|
|
|
mMoveFromCenterAnimator.onTransitionStarted();
|
|
}
|
|
|
|
@Override
|
|
public void onTransitionFinished() {
|
|
mMoveFromCenterAnimator.onTransitionFinished();
|
|
}
|
|
|
|
@Override
|
|
public void onTransitionProgress(float progress) {
|
|
mMoveFromCenterAnimator.onTransitionProgress(progress);
|
|
}
|
|
}
|
|
}
|