diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java index 0bed51dac4..3920c56cde 100644 --- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.java +++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.java @@ -1,5 +1,6 @@ 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() { diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java index c1711d137f..681574573e 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java +++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java @@ -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() { diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java index 9ac1c0e4f9..89c300dd2c 100644 --- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java +++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java @@ -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; diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java index 1a8d355ffc..cbcb70013a 100644 --- a/src/com/android/launcher3/touch/PagedOrientationHandler.java +++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java @@ -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) diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java index 07d183953b..450205d61b 100644 --- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java +++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java @@ -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 getDwbLayoutTranslations(int taskViewWidth, int taskViewHeight, SplitBounds splitBounds, DeviceProfile deviceProfile,