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

Commit 1d146b22 authored by Android Build Merger (Role)'s avatar Android Build Merger (Role)
Browse files

[automerger] Fixing launcher going to a different state when dragging an icon...

[automerger] Fixing launcher going to a different state when dragging an icon from different activity am: 4dcda065

Change-Id: Ifcb89488c351ba866026cfbdf3645b4358eeac8f
parents 1b905daf 4dcda065
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.CancellationSignal;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
@@ -236,8 +237,14 @@ public class LauncherAppTransitionManagerImpl extends LauncherAppTransitionManag
        return bounds;
    }

    public void setRemoteAnimationProvider(RemoteAnimationProvider animationProvider) {
    public void setRemoteAnimationProvider(final RemoteAnimationProvider animationProvider,
            CancellationSignal cancellationSignal) {
        mRemoteAnimationProvider = animationProvider;
        cancellationSignal.setOnCancelListener(() -> {
            if (animationProvider == mRemoteAnimationProvider) {
                mRemoteAnimationProvider = null;
            }
        });
    }

    /**
+4 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Handler;

import com.android.launcher3.states.InternalStateHandler;
@@ -48,10 +49,11 @@ public class LauncherInitListener extends InternalStateHandler implements Activi

            // Set a one-time animation provider. After the first call, this will get cleared.
            // TODO: Probably also check the intended target id.
            CancellationSignal cancellationSignal = new CancellationSignal();
            appTransitionManager.setRemoteAnimationProvider((targets) -> {

                // On the first call clear the reference.
                appTransitionManager.setRemoteAnimationProvider(null);
                cancellationSignal.cancel();
                RemoteAnimationProvider provider = mRemoteAnimationProvider;
                mRemoteAnimationProvider = null;

@@ -59,7 +61,7 @@ public class LauncherInitListener extends InternalStateHandler implements Activi
                    return provider.createWindowAnimation(targets);
                }
                return null;
            });
            }, cancellationSignal);
        }
        OverviewCallbacks.get(launcher).onInitOverviewTransition();
        return mOnInitListener.test(launcher, alreadyOnHome);
+24 −0
Original line number Diff line number Diff line
@@ -25,14 +25,19 @@ import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import static com.android.launcher3.allapps.DiscoveryBounce.HOME_BOUNCE_SEEN;
import static com.android.launcher3.allapps.DiscoveryBounce.SHELF_BOUNCE_SEEN;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;

import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.Context;
import android.os.CancellationSignal;
import android.util.Base64;

import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppTransitionManagerImpl;
import com.android.launcher3.LauncherState;
import com.android.launcher3.LauncherStateManager;
import com.android.launcher3.LauncherStateManager.StateHandler;
@@ -41,6 +46,8 @@ import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.util.TouchController;
import com.android.quickstep.OverviewInteractionState;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.util.RemoteAnimationTargetSet;
import com.android.quickstep.util.RemoteFadeOutAnimationListener;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.system.ActivityCompat;
import com.android.systemui.shared.system.WindowManagerWrapper;
@@ -179,6 +186,23 @@ public class UiFactory {
        }
    }

    public static void useFadeOutAnimationForLauncherStart(Launcher launcher,
            CancellationSignal cancellationSignal) {
        LauncherAppTransitionManagerImpl appTransitionManager =
                (LauncherAppTransitionManagerImpl) launcher.getAppTransitionManager();
        appTransitionManager.setRemoteAnimationProvider((targets) -> {

            // On the first call clear the reference.
            cancellationSignal.cancel();

            ValueAnimator fadeAnimation = ValueAnimator.ofFloat(1, 0);
            fadeAnimation.addUpdateListener(new RemoteFadeOutAnimationListener(targets));
            AnimatorSet anim = new AnimatorSet();
            anim.play(fadeAnimation);
            return anim;
        }, cancellationSignal);
    }

    public static boolean dumpActivity(Activity activity, PrintWriter writer) {
        if (!Utilities.IS_DEBUG_DEVICE) {
            return false;
+53 −0
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.quickstep.util;

import static com.android.quickstep.util.RemoteAnimationProvider.prepareTargetsForFirstFrame;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;

import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;

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

/**
 * Animation listener which fades out the closing targets
 */
public class RemoteFadeOutAnimationListener implements AnimatorUpdateListener {

    private final RemoteAnimationTargetSet mTarget;
    private boolean mFirstFrame = true;

    public RemoteFadeOutAnimationListener(RemoteAnimationTargetCompat[] targets) {
        mTarget = new RemoteAnimationTargetSet(targets, MODE_CLOSING);
    }

    @Override
    public void onAnimationUpdate(ValueAnimator valueAnimator) {
        TransactionCompat t = new TransactionCompat();
        if (mFirstFrame) {
            prepareTargetsForFirstFrame(mTarget.unfilteredApps, t, MODE_CLOSING);
            mFirstFrame = false;
        }

        float alpha = 1 - valueAnimator.getAnimatedFraction();
        for (RemoteAnimationTargetCompat app : mTarget.apps) {
            t.setAlpha(app.leash, alpha);
        }
        t.apply();
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ public abstract class BaseItemDragListener extends InternalStateHandler implemen
        postCleanup();
    }

    private void postCleanup() {
    protected void postCleanup() {
        clearReference();
        if (mLauncher != null) {
            // Remove any drag params from the launcher intent since the drag operation is complete.
Loading