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

Commit 9162f818 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Better handling transparent activities

> Only hiding the task associated with the current task, instead of hiding all tasks
> Maintaining a state for hidden task so that it does not get reset when alpha is changed due
  to some other reason.

Bug: 77830202
Change-Id: I202e99b153c6f9e3a8d9c68d6844672b3bff41e9
parent 4107c431
Loading
Loading
Loading
Loading
+7 B (120 KiB)

File changed.

No diff preview for this file type.

+5 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.view.MotionEvent.ACTION_UP;
import static android.view.MotionEvent.INVALID_POINTER_ID;

import static com.android.systemui.shared.system.NavigationBarCompat.QUICK_STEP_DRAG_SLOP_PX;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;

import android.annotation.TargetApi;
import android.app.ActivityManager.RunningTaskInfo;
@@ -45,6 +46,7 @@ import android.view.WindowManager;

import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.util.TraceHelper;
import com.android.quickstep.util.RemoteAnimationTargetSet;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.shared.system.AssistDataReceiver;
import com.android.systemui.shared.system.BackgroundExecutor;
@@ -229,8 +231,9 @@ public class OtherActivityTouchConsumer extends ContextWrapper implements TouchC
                            Rect minimizedHomeBounds) {
                        if (mInteractionHandler == handler) {
                            TraceHelper.partitionSection("RecentsController", "Received");
                            handler.onRecentsAnimationStart(controller, apps, homeContentInsets,
                                    minimizedHomeBounds);
                            handler.onRecentsAnimationStart(controller,
                                    new RemoteAnimationTargetSet(apps, MODE_CLOSING),
                                    homeContentInsets, minimizedHomeBounds);
                        } else {
                            TraceHelper.endSection("RecentsController", "Finishing no handler");
                            controller.finish(false /* toHome */);
+10 −13
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import com.android.quickstep.ActivityControlHelper.FallbackActivityControllerHel
import com.android.quickstep.ActivityControlHelper.LauncherActivityControllerHelper;
import com.android.quickstep.util.ClipAnimationHelper;
import com.android.quickstep.util.RemoteAnimationProvider;
import com.android.quickstep.util.RemoteAnimationTargetSet;
import com.android.quickstep.util.SysuiEventLogger;
import com.android.quickstep.views.RecentsView;
import com.android.systemui.shared.system.ActivityManagerWrapper;
@@ -279,15 +280,13 @@ public class OverviewCommandHelper {
                return anim;
            }

            RemoteAnimationTargetCompat closingTarget = null;
            RemoteAnimationTargetSet targetSet =
                    new RemoteAnimationTargetSet(targetCompats, MODE_CLOSING);


            // Use the top closing app to determine the insets for the animation
            for (RemoteAnimationTargetCompat target : targetCompats) {
                if (target.mode == MODE_CLOSING) {
                    closingTarget = target;
                    break;
                }
            }
            if (closingTarget == null) {
            RemoteAnimationTargetCompat runningTaskTarget = targetSet.findTask(mRunningTaskId);
            if (runningTaskTarget == null) {
                Log.e(TAG, "No closing app");
                anim.play(ValueAnimator.ofInt(0, 1).setDuration(100));
                return anim;
@@ -302,20 +301,18 @@ public class OverviewCommandHelper {
            rootView.getLocationOnScreen(loc);
            Rect homeBounds = new Rect(loc[0], loc[1],
                    loc[0] + rootView.getWidth(), loc[1] + rootView.getHeight());
            clipHelper.updateSource(homeBounds, closingTarget);
            clipHelper.updateSource(homeBounds, runningTaskTarget);

            Rect targetRect = new Rect();
            mHelper.getSwipeUpDestinationAndLength(
                    mActivity.getDeviceProfile(), mActivity, targetRect);
            clipHelper.updateTargetRect(targetRect);


            ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
            valueAnimator.setDuration(RECENTS_LAUNCH_DURATION);
            valueAnimator.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
            valueAnimator.addUpdateListener((v) -> {
                clipHelper.applyTransform(targetCompats, (float) v.getAnimatedValue());
            });
            valueAnimator.addUpdateListener((v) ->
                clipHelper.applyTransform(targetSet, (float) v.getAnimatedValue()));
            anim.play(valueAnimator);
            return anim;
        }
+4 −4
Original line number Diff line number Diff line
@@ -16,9 +16,9 @@
package com.android.quickstep;

import com.android.launcher3.util.TraceHelper;
import com.android.quickstep.util.RemoteAnimationTargetSet;
import com.android.systemui.shared.system.BackgroundExecutor;
import com.android.systemui.shared.system.RecentsAnimationControllerCompat;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;

/**
 * Wrapper around RecentsAnimationController to help with some synchronization
@@ -26,17 +26,17 @@ import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
public class RecentsAnimationWrapper {

    public RecentsAnimationControllerCompat controller;
    public RemoteAnimationTargetCompat[] targets;
    public RemoteAnimationTargetSet targetSet;

    private boolean mInputConsumerEnabled = false;
    private boolean mBehindSystemBars = true;
    private boolean mSplitScreenMinimized = false;

    public synchronized void setController(
            RecentsAnimationControllerCompat controller, RemoteAnimationTargetCompat[] targets) {
            RecentsAnimationControllerCompat controller, RemoteAnimationTargetSet targetSet) {
        TraceHelper.partitionSection("RecentsController", "Set controller " + controller);
        this.controller = controller;
        this.targets = targets;
        this.targetSet = targetSet;

        if (mInputConsumerEnabled) {
            enableInputConsumer();
+50 −54
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import static com.android.quickstep.TouchConsumer.INTERACTION_QUICK_SCRUB;
import static com.android.systemui.shared.recents.utilities.Utilities
        .postAtFrontOfQueueAsynchronously;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS;
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING;

import android.animation.Animator;
import android.animation.ObjectAnimator;
@@ -48,9 +47,9 @@ import android.view.ViewTreeObserver.OnDrawListener;
import android.view.animation.Interpolator;

import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseActivity;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.MainThreadExecutor;
import com.android.launcher3.R;
@@ -67,6 +66,7 @@ import com.android.quickstep.ActivityControlHelper.ActivityInitListener;
import com.android.quickstep.ActivityControlHelper.LayoutListener;
import com.android.quickstep.TouchConsumer.InteractionType;
import com.android.quickstep.util.ClipAnimationHelper;
import com.android.quickstep.util.RemoteAnimationTargetSet;
import com.android.quickstep.util.SysuiEventLogger;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
@@ -76,7 +76,6 @@ import com.android.systemui.shared.system.InputConsumerController;
import com.android.systemui.shared.system.LatencyTrackerCompat;
import com.android.systemui.shared.system.RecentsAnimationControllerCompat;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
import com.android.systemui.shared.system.TransactionCompat;
import com.android.systemui.shared.system.WindowCallbacksCompat;
import com.android.systemui.shared.system.WindowManagerWrapper;

@@ -347,6 +346,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
        }

        mRecentsView.showTask(mRunningTaskId);
        mRecentsView.setRunningTaskHidden(true);
        mRecentsView.setFirstTaskIconScaledDown(true /* isScaledDown */, false /* animate */);
        mLayoutListener.open();
        mStateCallback.setState(STATE_LAUNCHER_STARTED);
@@ -436,7 +436,8 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
                Interpolator interpolator = mInteractionType == INTERACTION_QUICK_SCRUB
                        ? ACCEL_2 : LINEAR;
                float interpolated = interpolator.getInterpolation(shift);
                mClipAnimationHelper.applyTransform(mRecentsAnimationWrapper.targets, interpolated);
                mClipAnimationHelper.applyTransform(
                        mRecentsAnimationWrapper.targetSet, interpolated);
            }
        }

@@ -478,17 +479,17 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
    }

    public void onRecentsAnimationStart(RecentsAnimationControllerCompat controller,
            RemoteAnimationTargetCompat[] apps, Rect homeContentInsets, Rect minimizedHomeBounds) {
        if (apps != null) {
            // Use the top closing app to determine the insets for the animation
            for (RemoteAnimationTargetCompat target : apps) {
                if (target.mode == MODE_CLOSING) {
                    DeviceProfile dp = LauncherAppState.getIDP(mContext).getDeviceProfile(mContext);
            RemoteAnimationTargetSet targets, Rect homeContentInsets, Rect minimizedHomeBounds) {
        LauncherAppState appState = LauncherAppState.getInstanceNoCreate();
        InvariantDeviceProfile idp = appState == null ?
                new InvariantDeviceProfile(mContext) : appState.getInvariantDeviceProfile();
        DeviceProfile dp = idp.getDeviceProfile(mContext);
        final Rect overviewStackBounds;
        RemoteAnimationTargetCompat runningTaskTarget = targets.findTask(mRunningTaskId);

                    if (minimizedHomeBounds != null) {
        if (minimizedHomeBounds != null && runningTaskTarget != null) {
            overviewStackBounds = mActivityControlHelper
                                .getOverviewWindowBounds(minimizedHomeBounds, target);
                    .getOverviewWindowBounds(minimizedHomeBounds, runningTaskTarget);
            dp = dp.getMultiWindowProfile(mContext,
                    new Point(minimizedHomeBounds.width(), minimizedHomeBounds.height()));
            dp.updateInsets(homeContentInsets);
@@ -502,12 +503,13 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
            dp.updateInsets(insets);
        }

                    mClipAnimationHelper.updateSource(overviewStackBounds, target);
                    initTransitionEndpoints(dp);
                }
            }
        if (runningTaskTarget != null) {
            mClipAnimationHelper.updateSource(overviewStackBounds, runningTaskTarget);
        }
        mRecentsAnimationWrapper.setController(controller, apps);
        initTransitionEndpoints(dp);


        mRecentsAnimationWrapper.setController(controller, targets);
        setStateOnUiThread(STATE_APP_CONTROLLER_RECEIVED);
    }

@@ -641,6 +643,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
        mLauncherTransitionController = null;
        mLayoutListener.finish();

        mRecentsView.setRunningTaskHidden(false);
        mRecentsView.setFirstTaskIconScaledDown(false /* isScaledDown */, false /* animate */);
    }

@@ -666,16 +669,12 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {

        synchronized (mRecentsAnimationWrapper) {
            if (mRecentsAnimationWrapper.controller != null) {
                for (RemoteAnimationTargetCompat app : mRecentsAnimationWrapper.targets) {
                    if (app.mode == MODE_CLOSING) {
                // Update the screenshot of the task
                ThumbnailData thumbnail =
                                mRecentsAnimationWrapper.controller.screenshotTask(app.taskId);
                        final TaskView taskView =
                                mRecentsView.updateThumbnail(app.taskId, thumbnail);
                        mRecentsAnimationWrapper.controller.screenshotTask(mRunningTaskId);
                final TaskView taskView = mRecentsView.updateThumbnail(mRunningTaskId, thumbnail);
                mRecentsView.setRunningTaskHidden(false);
                if (taskView != null) {
                            taskView.setAlpha(1);

                    // Defer finishing the animation until the next launcher frame with the
                    // new thumbnail
                    finishTransitionPosted = new WindowCallbacksCompat(taskView) {
@@ -686,9 +685,6 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
                            detach();
                        }
                    }.attach();
                            break;
                        }
                    }
                }
            }
        }
Loading