Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2467275 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Registering app transition animations with the internal stateManager,

so that the animation is reset when we start a state animation from
launcher

Bug: 74975768
Bug: 75290288
Change-Id: If7f71f087d7bb64fb25c085c476a6fcbc86518e2
parent 9d69c8da
Loading
Loading
Loading
Loading
+73 −8
Original line number Diff line number Diff line
@@ -15,27 +15,92 @@
 */
package com.android.launcher3;

import static com.android.systemui.shared.recents.utilities.Utilities
        .postAtFrontOfQueueAsynchronously;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Handler;
import android.support.annotation.BinderThread;
import android.support.annotation.UiThread;

import com.android.systemui.shared.system.RemoteAnimationRunnerCompat;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;

@TargetApi(Build.VERSION_CODES.P)
public abstract class LauncherAnimationRunner extends AnimatorListenerAdapter
        implements RemoteAnimationRunnerCompat {

    private static final int REFRESH_RATE_MS = 16;

    private final Handler mHandler;

    private Runnable mSysFinishRunnable;

    private AnimatorSet mAnimator;

    public LauncherAnimationRunner(Handler handler) {
        mHandler = handler;
    }

    @BinderThread
    @Override
    public void onAnimationStart(RemoteAnimationTargetCompat[] targetCompats, Runnable runnable) {
        postAtFrontOfQueueAsynchronously(mHandler, () -> {
            // Finish any previous animation
            finishSystemAnimation();

import static com.android.systemui.shared.recents.utilities.Utilities.postAtFrontOfQueueAsynchronously;
            mSysFinishRunnable = runnable;
            mAnimator = getAnimator(targetCompats);
            if (mAnimator == null) {
                finishSystemAnimation();
                return;
            }
            mAnimator.addListener(this);
            mAnimator.start();
            // Because t=0 has the app icon in its original spot, we can skip the
            // first frame and have the same movement one frame earlier.
            mAnimator.setCurrentPlayTime(REFRESH_RATE_MS);

public abstract class LauncherAnimationRunner implements RemoteAnimationRunnerCompat {
        });
    }

    AnimatorSet mAnimator;
    private Launcher mLauncher;

    LauncherAnimationRunner(Launcher launcher) {
        mLauncher = launcher;
    @UiThread
    public abstract AnimatorSet getAnimator(RemoteAnimationTargetCompat[] targetCompats);

    @UiThread
    @Override
    public void onAnimationEnd(Animator animation) {
        if (animation == mAnimator) {
            mAnimator = null;
            finishSystemAnimation();
        }
    }

    /**
     * Called by the system
     */
    @BinderThread
    @Override
    public void onAnimationCancelled() {
        postAtFrontOfQueueAsynchronously(mLauncher.getWindow().getDecorView().getHandler(), () -> {
        postAtFrontOfQueueAsynchronously(mHandler, () -> {
            if (mAnimator != null) {
                mAnimator.cancel();
                mAnimator.removeListener(this);
                mAnimator.end();
                mAnimator = null;
            }
        });
    }

    @UiThread
    private void finishSystemAnimation() {
        if (mSysFinishRunnable != null) {
            mSysFinishRunnable.run();
            mSysFinishRunnable = null;
        }
    }
}
 No newline at end of file
+107 −156

File changed.

Preview size limit exceeded, changes collapsed.

+0 −75

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −25
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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;

public class MutableBoolean {
    public boolean value;

    public MutableBoolean(boolean value) {
        this.value = value;
    }
}
+5 −5
Original line number Diff line number Diff line
@@ -400,10 +400,6 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, L
        return mStateManager;
    }

    public LauncherAppTransitionManager getAppTransitionManager() {
        return mAppTransitionManager;
    }

    protected void overrideTheme(boolean isDark, boolean supportsDarkText) {
        if (isDark) {
            setTheme(R.style.LauncherThemeDark);
@@ -1254,7 +1250,11 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, L
                // In all these cases, only animate if we're already on home
                AbstractFloatingView.closeAllOpenViews(this, isStarted());

                if (!isInState(NORMAL)) {
                    // Only change state, if not already the same. This prevents cancelling any
                    // animations running as part of resume
                    mStateManager.goToState(NORMAL);
                }

                // Reset the apps view
                if (!alreadyOnHome && mAppsView != null) {
Loading