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

Commit 2e4dcb16 authored by Vinit Nayak's avatar Vinit Nayak
Browse files

Place TaskMenuView aligned with secondary split thumbnail

* Use consistent divider calculations in
different methods

Fixes: 245610772
Fixes: 218784487

Test: Open task menu view in split pair in landscape/
seascape/portrait, real and fake.

Change-Id: If1bbc7a0d4f1767584d0fc8cf549130f35b8e4a3
parent cd854149
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
package com.android.quickstep.views;

import static com.android.launcher3.AbstractFloatingView.getAnyView;
import static com.android.launcher3.util.SplitConfigurationOptions.DEFAULT_SPLIT_RATIO;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT;
@@ -13,6 +14,7 @@ import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@@ -162,6 +164,21 @@ public class GroupedTaskView extends TaskView {
        }
    }

    @Override
    protected boolean showTaskMenuWithContainer(IconView iconView) {
        boolean showedTaskMenu = super.showTaskMenuWithContainer(iconView);
        if (iconView == mIconView2 && showedTaskMenu && !isGridTask()) {
            // Adjust the position of the secondary task's menu view (only on phones)
            TaskMenuView taskMenuView = getAnyView(mActivity, AbstractFloatingView.TYPE_TASK_MENU);
            DeviceProfile deviceProfile = mActivity.getDeviceProfile();
            getRecentsView().getPagedOrientationHandler()
                    .setSecondaryTaskMenuPosition(mSplitBoundsConfig, this,
                            deviceProfile, mTaskIdAttributeContainer[0].getThumbnailView(),
                            taskMenuView);
        }
        return showedTaskMenu;
    }

    @Nullable
    @Override
    public RunnableList launchTaskAnimated() {
+0 −19
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.quickstep.views;

import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_UNDEFINED;
import static com.android.quickstep.views.TaskThumbnailView.DIM_ALPHA;

import android.animation.Animator;
@@ -156,23 +154,6 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
                mTaskContainer.getThumbnailView(), overscrollShift, deviceProfile));
        setY(pagedOrientationHandler.getTaskMenuY(
                adjustedY, mTaskContainer.getThumbnailView(), overscrollShift));

        // TODO(b/193432925) temporary menu placement for split screen task menus
        TaskIdAttributeContainer[] taskIdAttributeContainers =
                mTaskView.getTaskIdAttributeContainers();
        if (taskIdAttributeContainers[0].getStagePosition() != STAGE_POSITION_UNDEFINED) {
            if (mTaskContainer.getStagePosition() != STAGE_POSITION_BOTTOM_OR_RIGHT) {
                return;
            }
            Rect r = new Rect();
            mTaskContainer.getThumbnailView().getBoundsOnScreen(r);
            if (deviceProfile.isLandscape) {
                setX(r.left);
            } else {
                setY(r.top);

            }
        }
    }

    public void onRotationChanged() {
+15 −2
Original line number Diff line number Diff line
@@ -376,6 +376,19 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
        return isRtl ? 1 : -1;
    }

    @Override
    public void setSecondaryTaskMenuPosition(SplitBounds splitBounds, View taskView,
            DeviceProfile deviceProfile, View primarySnaphotView, View taskMenuView) {
        float topLeftTaskPlusDividerPercent = splitBounds.appsStackedVertically
                ? (splitBounds.topTaskPercent + splitBounds.dividerHeightPercent)
                : (splitBounds.leftTaskPercent + splitBounds.dividerWidthPercent);
        FrameLayout.LayoutParams snapshotParams =
                (FrameLayout.LayoutParams) primarySnaphotView.getLayoutParams();
        float additionalOffset = (taskView.getHeight() - snapshotParams.topMargin)
                * topLeftTaskPlusDividerPercent;
        taskMenuView.setY(taskMenuView.getY() + additionalOffset);
    }

    /* -------------------- */

    @Override
@@ -492,8 +505,8 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
        int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
        int totalThumbnailHeight = parentHeight - spaceAboveSnapshot;
        int dividerBar = splitBoundsConfig.appsStackedVertically
                ? splitBoundsConfig.visualDividerBounds.height()
                : splitBoundsConfig.visualDividerBounds.width();
                ? (int) (splitBoundsConfig.dividerHeightPercent * parentHeight)
                : (int) (splitBoundsConfig.dividerWidthPercent * parentWidth);
        int primarySnapshotHeight;
        int primarySnapshotWidth;
        int secondarySnapshotHeight;
+8 −0
Original line number Diff line number Diff line
@@ -230,6 +230,14 @@ public interface PagedOrientationHandler {
    /** @return Either 1 or -1, a factor to multiply by so the animation goes the correct way. */
    int getTaskDragDisplacementFactor(boolean isRtl);

    /**
     * Calls the corresponding {@link View#setX(float)} or {@link View#setY(float)}
     * on {@param taskMenuView} by taking the space needed by {@param primarySnapshotView} into
     * account.
     * This is expected to only be called for secondary (bottom/right) tasks.
     */
    void setSecondaryTaskMenuPosition(SplitBounds splitBounds, View taskView,
            DeviceProfile deviceProfile, View primarySnaphotView, View taskMenuView);
    /**
     * Maps the velocity from the coordinate plane of the foreground app to that
     * of Launcher's (which now will always be portrait)
+20 −0
Original line number Diff line number Diff line
@@ -315,6 +315,26 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
        return new PointF(0, 0);
    }

    @Override
    public void setSecondaryTaskMenuPosition(SplitBounds splitBounds, View taskView,
            DeviceProfile deviceProfile, View primarySnaphotView, View taskMenuView) {
        float topLeftTaskPlusDividerPercent = splitBounds.appsStackedVertically
                ? (splitBounds.topTaskPercent + splitBounds.dividerHeightPercent)
                : (splitBounds.leftTaskPercent + splitBounds.dividerWidthPercent);
        FrameLayout.LayoutParams snapshotParams =
                (FrameLayout.LayoutParams) primarySnaphotView.getLayoutParams();
        float additionalOffset;
        if (deviceProfile.isLandscape) {
            additionalOffset = (taskView.getWidth() - snapshotParams.leftMargin)
                    * topLeftTaskPlusDividerPercent;
            taskMenuView.setX(taskMenuView.getX() + additionalOffset);
        } else {
            additionalOffset = (taskView.getHeight() - snapshotParams.topMargin)
                    * topLeftTaskPlusDividerPercent;
            taskMenuView.setY(taskMenuView.getY() + additionalOffset);
        }
    }

    @Override
    public Pair<Float, Float> getDwbLayoutTranslations(int taskViewWidth,
            int taskViewHeight, SplitBounds splitBounds, DeviceProfile deviceProfile,