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

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

Using the split screen secondory bounds returned by SystemUIProxy

Bug: 77281732
Change-Id: I0ae75528ec2fae006a11833b06383369ba593365
parent 23f83a8b
Loading
Loading
Loading
Loading
+39 −21
Original line number Diff line number Diff line
@@ -24,14 +24,17 @@ import android.graphics.Matrix.ScaleToFit;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.RemoteException;

import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.views.BaseDragLayer;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskThumbnailView;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.recents.utilities.RectFEvaluator;
import com.android.systemui.shared.system.RemoteAnimationTargetCompat;
import com.android.systemui.shared.system.TransactionCompat;
@@ -156,7 +159,36 @@ public class ClipAnimationHelper {
        mHomeStackBounds.offset(pos[0], pos[1]);

        if (rv.shouldUseMultiWindowTaskSizeStrategy()) {
            // TODO: Fetch multi-window target bounds from system-ui
            updateStackBoundsToMultiWindowTaskSize(activity);
        } else {
            mSourceStackBounds.set(mHomeStackBounds);
            mSourceInsets.set(activity.getDeviceProfile().getInsets());
        }

        Rect targetRect = new Rect();
        dl.getDescendantRectRelativeToSelf(ttv, targetRect);
        updateTargetRect(targetRect);

        // Transform the clip relative to the target rect.
        float scale = mTargetRect.width() / mSourceRect.width();
        mSourceWindowClipInsets.left = mSourceWindowClipInsets.left * scale;
        mSourceWindowClipInsets.top = mSourceWindowClipInsets.top * scale;
        mSourceWindowClipInsets.right = mSourceWindowClipInsets.right * scale;
        mSourceWindowClipInsets.bottom = mSourceWindowClipInsets.bottom * scale;
    }

    private void updateStackBoundsToMultiWindowTaskSize(BaseDraggingActivity activity) {
        ISystemUiProxy sysUiProxy = RecentsModel.getInstance(activity).getSystemUiProxy();
        if (sysUiProxy != null) {
            try {
                mSourceStackBounds.set(sysUiProxy.getNonMinimizedSplitScreenSecondaryBounds());
                return;
            } catch (RemoteException e) {
                // Use half screen size
            }
        }

        // Assume that the task size is half screen size (minus the insets and the divider size)
        DeviceProfile fullDp = activity.getDeviceProfile().getFullScreenProfile();
        // Use availableWidthPx and availableHeightPx instead of widthPx and heightPx to
        // account for system insets
@@ -177,22 +209,8 @@ public class ClipAnimationHelper {
        // Align the task to bottom right (probably not true for seascape).
        mSourceStackBounds.offset(insets.left + fullDp.availableWidthPx - taskWidth,
                insets.top + fullDp.availableHeightPx - taskHeight);
        } else {
            mSourceStackBounds.set(mHomeStackBounds);
            mSourceInsets.set(activity.getDeviceProfile().getInsets());
    }

        Rect targetRect = new Rect();
        dl.getDescendantRectRelativeToSelf(ttv, targetRect);
        updateTargetRect(targetRect);

        // Transform the clip relative to the target rect.
        float scale = mTargetRect.width() / mSourceRect.width();
        mSourceWindowClipInsets.left = mSourceWindowClipInsets.left * scale;
        mSourceWindowClipInsets.top = mSourceWindowClipInsets.top * scale;
        mSourceWindowClipInsets.right = mSourceWindowClipInsets.right * scale;
        mSourceWindowClipInsets.bottom = mSourceWindowClipInsets.bottom * scale;
    }

    public void drawForProgress(TaskThumbnailView ttv, Canvas canvas, float progress) {
        RectF currentRect =  mRectFEvaluator.evaluate(progress, mSourceRect, mTargetRect);