Merge "Place TaskMenuView aligned with secondary split thumbnail" into tm-qpr-dev

This commit is contained in:
Vinit Nayak
2022-09-12 18:29:22 +00:00
committed by Android (Google) Code Review
5 changed files with 60 additions and 21 deletions

View File

@@ -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() {

View File

@@ -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() {

View File

@@ -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;

View File

@@ -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)

View File

@@ -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,