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

Commit c35507dc authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Set thumbnails for GroupedTaskView based on split layout bounds

Bug: 181704764
Test: Go to stage split in landscape w/
home rotation on/off, swipe up.
Thumbnails aren't perfectly overlaid, polish needed

Change-Id: I54e39cc5a18f527e80a664d60aca72dfd706ebdc
parent 8b78c138
Loading
Loading
Loading
Loading
+11 −28
Original line number Original line Diff line number Diff line
package com.android.quickstep.views;
package com.android.quickstep.views;


import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;

import android.content.Context;
import android.content.Context;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.ViewGroup;


import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.R;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.RecentsModel;
import com.android.quickstep.TaskThumbnailCache;
import com.android.quickstep.TaskThumbnailCache;
import com.android.quickstep.util.CancellableTask;
import com.android.quickstep.util.CancellableTask;
@@ -48,13 +45,14 @@ public class GroupedTaskView extends TaskView {
        mSnapshotView2 = findViewById(R.id.bottomright_snapshot);
        mSnapshotView2 = findViewById(R.id.bottomright_snapshot);
    }
    }


    public void bind(Task primary, Task secondary, RecentsOrientedState orientedState) {
    public void bind(Task primary, Task secondary, RecentsOrientedState orientedState,
            SplitConfigurationOptions.StagedSplitBounds splitBoundsConfig) {
        super.bind(primary, orientedState);
        super.bind(primary, orientedState);
        mSecondaryTask = secondary;
        mSecondaryTask = secondary;
        mTaskIdContainer[1] = secondary.key.id;
        mTaskIdContainer[1] = secondary.key.id;
        mTaskIdAttributeContainer[1] = new TaskIdAttributeContainer(secondary, mSnapshotView2);
        mTaskIdAttributeContainer[1] = new TaskIdAttributeContainer(secondary, mSnapshotView2);
        mSnapshotView2.bind(secondary);
        mSnapshotView2.bind(secondary);
        adjustThumbnailBoundsForSplit();
        adjustThumbnailBoundsForSplit(splitBoundsConfig, orientedState);
    }
    }


    @Override
    @Override
@@ -108,30 +106,15 @@ public class GroupedTaskView extends TaskView {
        mSnapshotView2.setOverlayEnabled(overlayEnabled);
        mSnapshotView2.setOverlayEnabled(overlayEnabled);
    }
    }


    private void adjustThumbnailBoundsForSplit() {
    private void adjustThumbnailBoundsForSplit(
        DeviceProfile deviceProfile = mActivity.getDeviceProfile();
            SplitConfigurationOptions.StagedSplitBounds splitBoundsConfig,
        ViewGroup.LayoutParams primaryLp = mSnapshotView.getLayoutParams();
            RecentsOrientedState orientedState) {
        primaryLp.width = mSecondaryTask == null ?
        if (splitBoundsConfig == null) {
                MATCH_PARENT :
                getWidth();
        int spaceAboveSnapshot = deviceProfile.overviewTaskThumbnailTopMarginPx;
        // TODO get divider height
        int dividerBar = 20;
        primaryLp.height = mSecondaryTask == null ?
                MATCH_PARENT :
                (getHeight() - spaceAboveSnapshot - dividerBar) / 2;
        mSnapshotView.setLayoutParams(primaryLp);

        if (mSecondaryTask == null) {
            mSnapshotView2.setVisibility(GONE);
            return;
            return;
        }
        }


        mSnapshotView2.setVisibility(VISIBLE);
        orientedState.getOrientationHandler().setGroupedTaskViewThumbnailBounds(
        ViewGroup.LayoutParams secondaryLp = mSnapshotView2.getLayoutParams();
                mSnapshotView, mSnapshotView2, this, splitBoundsConfig,
        secondaryLp.width = getWidth();
                mActivity.getDeviceProfile());
        secondaryLp.height = primaryLp.height;
        mSnapshotView2.setLayoutParams(secondaryLp);
        mSnapshotView2.setTranslationY(primaryLp.height + spaceAboveSnapshot + dividerBar);
    }
    }
}
}
+12 −6
Original line number Original line Diff line number Diff line
@@ -575,6 +575,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
     */
     */
    private TaskView mSplitHiddenTaskView;
    private TaskView mSplitHiddenTaskView;
    private TaskView mSecondSplitHiddenTaskView;
    private TaskView mSecondSplitHiddenTaskView;
    private SplitConfigurationOptions.StagedSplitBounds mSplitBoundsConfig;


    /**
    /**
     * Keeps track of the index of the TaskView that split screen was initialized with so we know
     * Keeps track of the index of the TaskView that split screen was initialized with so we know
@@ -1314,7 +1315,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
                    taskDataIndex--;
                    taskDataIndex--;
                    leftTop = tasks.get(taskDataIndex);
                    leftTop = tasks.get(taskDataIndex);
                }
                }
                ((GroupedTaskView) taskView).bind(leftTop, rightBottom, mOrientationState);
                ((GroupedTaskView) taskView).bind(leftTop, rightBottom, mOrientationState,
                        mSplitBoundsConfig);
            } else {
            } else {
                taskView.bind(task, mOrientationState);
                taskView.bind(task, mOrientationState);
            }
            }
@@ -2087,8 +2089,11 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
                        Task.from(new TaskKey(secondaryTaskInfo), secondaryTaskInfo, false)
                        Task.from(new TaskKey(secondaryTaskInfo), secondaryTaskInfo, false)
                };
                };
                addView(taskView, mTaskViewStartIndex);
                addView(taskView, mTaskViewStartIndex);
                // When we create a placeholder task view mSplitBoundsConfig will be null, but with
                // the actual app running we won't need to show the thumbnail until all the tasks
                // load later anyways
                ((GroupedTaskView)taskView).bind(mTmpRunningTasks[0], mTmpRunningTasks[1],
                ((GroupedTaskView)taskView).bind(mTmpRunningTasks[0], mTmpRunningTasks[1],
                        mOrientationState);
                        mOrientationState, mSplitBoundsConfig);
            } else {
            } else {
                taskView = getTaskViewFromPool(false);
                taskView = getTaskViewFromPool(false);
                addView(taskView, mTaskViewStartIndex);
                addView(taskView, mTaskViewStartIndex);
@@ -4038,12 +4043,13 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
                    recentsAnimationTargets.getNonAppTargetOfType(TYPE_DOCK_DIVIDER);
                    recentsAnimationTargets.getNonAppTargetOfType(TYPE_DOCK_DIVIDER);
            RemoteAnimationTargetCompat primaryTaskTarget = recentsAnimationTargets.apps[0];
            RemoteAnimationTargetCompat primaryTaskTarget = recentsAnimationTargets.apps[0];
            RemoteAnimationTargetCompat secondaryTaskTarget = recentsAnimationTargets.apps[1];
            RemoteAnimationTargetCompat secondaryTaskTarget = recentsAnimationTargets.apps[1];
            SplitConfigurationOptions.StagedSplitBounds
            mSplitBoundsConfig = new SplitConfigurationOptions.StagedSplitBounds(
                    info = new SplitConfigurationOptions.StagedSplitBounds(
                    primaryTaskTarget.screenSpaceBounds,
                    primaryTaskTarget.screenSpaceBounds,
                    secondaryTaskTarget.screenSpaceBounds, dividerTarget.screenSpaceBounds);
                    secondaryTaskTarget.screenSpaceBounds, dividerTarget.screenSpaceBounds);
            mRemoteTargetHandles[0].mTaskViewSimulator.setPreview(primaryTaskTarget, info);
            mRemoteTargetHandles[0].mTaskViewSimulator.setPreview(primaryTaskTarget,
            mRemoteTargetHandles[1].mTaskViewSimulator.setPreview(secondaryTaskTarget, info);
                    mSplitBoundsConfig);
            mRemoteTargetHandles[1].mTaskViewSimulator.setPreview(secondaryTaskTarget,
                    mSplitBoundsConfig);
            RemoteAnimationTargets rats = new RemoteAnimationTargets(
            RemoteAnimationTargets rats = new RemoteAnimationTargets(
                    new RemoteAnimationTargetCompat[]{primaryTaskTarget},
                    new RemoteAnimationTargetCompat[]{primaryTaskTarget},
                    recentsAnimationTargets.wallpapers, recentsAnimationTargets.nonApps,
                    recentsAnimationTargets.wallpapers, recentsAnimationTargets.nonApps,
+20 −0
Original line number Original line Diff line number Diff line
@@ -36,6 +36,7 @@ import android.view.MotionEvent;
import android.view.Surface;
import android.view.Surface;
import android.view.VelocityTracker;
import android.view.VelocityTracker;
import android.view.View;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityEvent;
import android.widget.LinearLayout;
import android.widget.LinearLayout;


@@ -405,6 +406,25 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
        }
        }
    }
    }


    @Override
    public void setGroupedTaskViewThumbnailBounds(View mSnapshotView, View mSnapshotView2,
            View taskParent, SplitConfigurationOptions.StagedSplitBounds splitBoundsConfig,
            DeviceProfile dp) {
        int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
        int totalThumbnailHeight = taskParent.getHeight() - spaceAboveSnapshot;
        int totalThumbnailWidth = taskParent.getWidth();
        int dividerBar = splitBoundsConfig.mDividerBounds.width() / 2;
        ViewGroup.LayoutParams primaryLp = mSnapshotView.getLayoutParams();
        ViewGroup.LayoutParams secondaryLp = mSnapshotView2.getLayoutParams();

        primaryLp.width = totalThumbnailWidth;
        primaryLp.height = (int)(totalThumbnailHeight * splitBoundsConfig.mLeftTaskPercent);

        secondaryLp.width = totalThumbnailWidth;
        secondaryLp.height = totalThumbnailHeight - primaryLp.height - dividerBar;
        mSnapshotView2.setTranslationY(primaryLp.height + spaceAboveSnapshot + dividerBar);
    }

    @Override
    @Override
    public FloatProperty getSplitSelectTaskOffset(FloatProperty primary, FloatProperty secondary,
    public FloatProperty getSplitSelectTaskOffset(FloatProperty primary, FloatProperty secondary,
            DeviceProfile deviceProfile) {
            DeviceProfile deviceProfile) {
+3 −0
Original line number Original line Diff line number Diff line
@@ -160,6 +160,9 @@ public interface PagedOrientationHandler {
            SplitConfigurationOptions.StagedSplitBounds splitInfo,
            SplitConfigurationOptions.StagedSplitBounds splitInfo,
            @SplitConfigurationOptions.StagePosition int desiredStagePosition);
            @SplitConfigurationOptions.StagePosition int desiredStagePosition);


    void setGroupedTaskViewThumbnailBounds(View mSnapshot1, View mSnapshot2, View taskParent,
            SplitConfigurationOptions.StagedSplitBounds splitBoundsConfig, DeviceProfile dp);

    // Overview TaskMenuView methods
    // Overview TaskMenuView methods
    float getTaskMenuX(float x, View thumbnailView, int overScroll);
    float getTaskMenuX(float x, View thumbnailView, int overScroll);
    float getTaskMenuY(float y, View thumbnailView, int overScroll);
    float getTaskMenuY(float y, View thumbnailView, int overScroll);
+34 −0
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ import android.view.MotionEvent;
import android.view.Surface;
import android.view.Surface;
import android.view.VelocityTracker;
import android.view.VelocityTracker;
import android.view.View;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityEvent;
import android.widget.LinearLayout;
import android.widget.LinearLayout;


@@ -507,6 +508,39 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
        }
        }
    }
    }


    @Override
    public void setGroupedTaskViewThumbnailBounds(View mSnapshotView, View mSnapshotView2,
            View taskParent, SplitConfigurationOptions.StagedSplitBounds splitBoundsConfig,
            DeviceProfile dp) {
        int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
        int totalThumbnailHeight = taskParent.getHeight() - spaceAboveSnapshot;
        int totalThumbnailWidth = taskParent.getWidth();
        int dividerBar = (dp.isLandscape ?
                splitBoundsConfig.mDividerBounds.width() :
                splitBoundsConfig.mDividerBounds.height())
                / 2;
        ViewGroup.LayoutParams primaryLp = mSnapshotView.getLayoutParams();
        ViewGroup.LayoutParams secondaryLp = mSnapshotView2.getLayoutParams();

        if (dp.isLandscape) {
            primaryLp.height = totalThumbnailHeight;
            primaryLp.width = (int)(totalThumbnailWidth * splitBoundsConfig.mLeftTaskPercent);

            secondaryLp.height = totalThumbnailHeight;
            secondaryLp.width = totalThumbnailWidth - primaryLp.width - dividerBar;
            mSnapshotView2.setTranslationX(primaryLp.width + dividerBar);
            mSnapshotView2.setTranslationY(spaceAboveSnapshot);
        } else {
            primaryLp.width = totalThumbnailWidth;
            primaryLp.height = (int)(totalThumbnailHeight * splitBoundsConfig.mTopTaskPercent);

            secondaryLp.width = totalThumbnailWidth;
            secondaryLp.height = totalThumbnailHeight - primaryLp.height - dividerBar;
            mSnapshotView2.setTranslationY(primaryLp.height + spaceAboveSnapshot + dividerBar);
            mSnapshotView2.setTranslationX(0);
        }
    }

    @Override
    @Override
    public FloatProperty getSplitSelectTaskOffset(FloatProperty primary, FloatProperty secondary,
    public FloatProperty getSplitSelectTaskOffset(FloatProperty primary, FloatProperty secondary,
            DeviceProfile dp) {
            DeviceProfile dp) {