diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml
index c6490827d8..34cd1c21e7 100644
--- a/quickstep/res/values/dimens.xml
+++ b/quickstep/res/values/dimens.xml
@@ -27,6 +27,7 @@
22dp
4dp
2dp
+ 200dp
48dp
16dp
diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
index 5ddbf87cfd..2cf447f9e5 100644
--- a/quickstep/src/com/android/quickstep/views/TaskMenuView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.java
@@ -151,7 +151,7 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
}
setRotation(pagedOrientationHandler.getDegreesRotated());
setX(pagedOrientationHandler.getTaskMenuX(adjustedX,
- mTaskContainer.getThumbnailView(), overscrollShift));
+ mTaskContainer.getThumbnailView(), overscrollShift, deviceProfile));
setY(pagedOrientationHandler.getTaskMenuY(
adjustedY, mTaskContainer.getThumbnailView(), overscrollShift));
@@ -229,7 +229,6 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
private void addMenuOptions(TaskIdAttributeContainer taskContainer) {
mTaskName.setText(TaskUtils.getTitle(getContext(), taskContainer.getTask()));
mTaskName.setOnClickListener(v -> close(true));
-
TaskOverlayFactory.getEnabledShortcuts(mTaskView, mActivity.getDeviceProfile(),
taskContainer)
.forEach(this::addMenuOption);
@@ -256,13 +255,21 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
orientationHandler.setTaskMenuAroundTaskView(this, mTaskInsetMargin);
// Get Position
+ DeviceProfile deviceProfile = mActivity.getDeviceProfile();
mActivity.getDragLayer().getDescendantRectRelativeToSelf(mTaskView, sTempRect);
Rect insets = mActivity.getDragLayer().getInsets();
BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams();
int padding = getResources()
.getDimensionPixelSize(R.dimen.task_menu_vertical_padding);
- params.width = orientationHandler
- .getTaskMenuWidth(taskContainer.getThumbnailView()) - (2 * padding);
+ if (deviceProfile.overviewShowAsGrid) {
+ // TODO(b/193432925) temporary so it doesn't look terrible on large screen
+ params.width =
+ getContext().getResources().getDimensionPixelSize(R.dimen.task_menu_width_grid);
+ } else {
+ params.width = orientationHandler
+ .getTaskMenuWidth(taskContainer.getThumbnailView(),
+ deviceProfile) - (2 * padding);
+ }
// Gravity set to Left instead of Start as sTempRect.left measures Left distance not Start
params.gravity = Gravity.LEFT;
setLayoutParams(params);
@@ -276,7 +283,7 @@ public class TaskMenuView extends AbstractFloatingView implements OnScrollChange
mOptionLayout.setShowDividers(SHOW_DIVIDER_MIDDLE);
orientationHandler.setTaskOptionsMenuLayoutOrientation(
- mActivity.getDeviceProfile(), mOptionLayout, dividerSpacing, divider);
+ deviceProfile, mOptionLayout, dividerSpacing, divider);
setPosition(sTempRect.left - insets.left, sTempRect.top - insets.top, 0);
}
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index bc232a6534..baf4c15c69 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -324,7 +324,7 @@
16dp
-
+
0dp
0dp
0dp
@@ -342,6 +342,8 @@
0dp
0dp
110dp
+ 200dp
+
22dp
diff --git a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
index 0c3ad1d045..3ac25f2e02 100644
--- a/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
+++ b/src/com/android/launcher3/touch/LandscapePagedViewHandler.java
@@ -20,7 +20,8 @@ import static android.view.Gravity.CENTER_VERTICAL;
import static android.view.Gravity.END;
import static android.view.Gravity.START;
import static android.view.Gravity.TOP;
-import static android.widget.ListPopupWindow.WRAP_CONTENT;
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
@@ -257,26 +258,28 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
}
@Override
- public float getTaskMenuX(float x, View thumbnailView, int overScroll) {
+ public float getTaskMenuX(float x, View thumbnailView, int overScroll,
+ DeviceProfile deviceProfile) {
return thumbnailView.getMeasuredWidth() + x;
}
@Override
public float getTaskMenuY(float y, View thumbnailView, int overScroll) {
- return y + overScroll;
+ return y + overScroll +
+ (thumbnailView.getMeasuredHeight() - thumbnailView.getMeasuredWidth()) / 2f;
}
@Override
- public int getTaskMenuWidth(View view) {
- return view.getMeasuredHeight();
+ public int getTaskMenuWidth(View view, DeviceProfile deviceProfile) {
+ return view.getMeasuredWidth();
}
@Override
public void setTaskOptionsMenuLayoutOrientation(DeviceProfile deviceProfile,
LinearLayout taskMenuLayout, int dividerSpacing,
ShapeDrawable dividerDrawable) {
- taskMenuLayout.setOrientation(LinearLayout.HORIZONTAL);
- dividerDrawable.setIntrinsicWidth(dividerSpacing);
+ taskMenuLayout.setOrientation(LinearLayout.VERTICAL);
+ dividerDrawable.setIntrinsicHeight(dividerSpacing);
taskMenuLayout.setDividerDrawable(dividerDrawable);
}
@@ -284,12 +287,9 @@ public class LandscapePagedViewHandler implements PagedOrientationHandler {
public void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp,
LinearLayout viewGroup, DeviceProfile deviceProfile) {
// Phone fake landscape
- viewGroup.setOrientation(LinearLayout.VERTICAL);
- lp.width = 0;
+ viewGroup.setOrientation(LinearLayout.HORIZONTAL);
+ lp.width = MATCH_PARENT;
lp.height = WRAP_CONTENT;
- lp.weight = 1;
- Utilities.setStartMarginForView(viewGroup.findViewById(R.id.text), 0);
- Utilities.setStartMarginForView(viewGroup.findViewById(R.id.icon), 0);
}
@Override
diff --git a/src/com/android/launcher3/touch/PagedOrientationHandler.java b/src/com/android/launcher3/touch/PagedOrientationHandler.java
index 494fe22c73..19d73a88ac 100644
--- a/src/com/android/launcher3/touch/PagedOrientationHandler.java
+++ b/src/com/android/launcher3/touch/PagedOrientationHandler.java
@@ -171,9 +171,16 @@ public interface PagedOrientationHandler {
void setSplitIconParams(View primaryIconView, View secondaryIconView,
int taskIconHeight, Rect primarySnapshotBounds, Rect secondarySnapshotBounds,
boolean isRtl, DeviceProfile deviceProfile, StagedSplitBounds splitConfig);
- float getTaskMenuX(float x, View thumbnailView, int overScroll);
+
+ /*
+ * The following two methods try to center the TaskMenuView in landscape by finding the center
+ * of the thumbnail view and then subtracting half of the taskMenu width. In this case, the
+ * taskMenu width is the same size as the thumbnail width (what got set below in
+ * getTaskMenuWidth()), so we directly use that in the calculations.
+ */
+ float getTaskMenuX(float x, View thumbnailView, int overScroll, DeviceProfile deviceProfile);
float getTaskMenuY(float y, View thumbnailView, int overScroll);
- int getTaskMenuWidth(View view);
+ int getTaskMenuWidth(View view, DeviceProfile deviceProfile);
/**
* Sets linear layout orientation for {@link com.android.launcher3.popup.SystemShortcut} items
* inside task menu view.
diff --git a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
index a453cae436..1b8ebd8b3c 100644
--- a/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
+++ b/src/com/android/launcher3/touch/PortraitPagedViewHandler.java
@@ -20,6 +20,7 @@ import static android.view.Gravity.BOTTOM;
import static android.view.Gravity.CENTER_HORIZONTAL;
import static android.view.Gravity.START;
import static android.view.Gravity.TOP;
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
@@ -264,8 +265,14 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
}
@Override
- public float getTaskMenuX(float x, View thumbnailView, int overScroll) {
- return x + overScroll;
+ public float getTaskMenuX(float x, View thumbnailView, int overScroll,
+ DeviceProfile deviceProfile) {
+ if (deviceProfile.isLandscape) {
+ return x + overScroll
+ + (thumbnailView.getMeasuredWidth() - thumbnailView.getMeasuredHeight()) / 2f;
+ } else {
+ return x + overScroll;
+ }
}
@Override
@@ -274,43 +281,27 @@ public class PortraitPagedViewHandler implements PagedOrientationHandler {
}
@Override
- public int getTaskMenuWidth(View view) {
- return view.getMeasuredWidth();
+ public int getTaskMenuWidth(View view, DeviceProfile deviceProfile) {
+ return deviceProfile.isLandscape && !deviceProfile.overviewShowAsGrid ?
+ view.getMeasuredHeight() :
+ view.getMeasuredWidth();
}
@Override
public void setTaskOptionsMenuLayoutOrientation(DeviceProfile deviceProfile,
LinearLayout taskMenuLayout, int dividerSpacing,
ShapeDrawable dividerDrawable) {
- if (deviceProfile.isLandscape && !deviceProfile.isTablet) {
- // Phone landscape
- taskMenuLayout.setOrientation(LinearLayout.HORIZONTAL);
- dividerDrawable.setIntrinsicWidth(dividerSpacing);
- } else {
- // Phone Portrait, LargeScreen Landscape/Portrait
- taskMenuLayout.setOrientation(LinearLayout.VERTICAL);
- dividerDrawable.setIntrinsicHeight(dividerSpacing);
- }
+ taskMenuLayout.setOrientation(LinearLayout.VERTICAL);
+ dividerDrawable.setIntrinsicHeight(dividerSpacing);
taskMenuLayout.setDividerDrawable(dividerDrawable);
}
@Override
public void setLayoutParamsForTaskMenuOptionItem(LinearLayout.LayoutParams lp,
LinearLayout viewGroup, DeviceProfile deviceProfile) {
- if (deviceProfile.isLandscape && !deviceProfile.isTablet) {
- // Phone landscape
- viewGroup.setOrientation(LinearLayout.VERTICAL);
- lp.width = 0;
- lp.weight = 1;
- Utilities.setStartMarginForView(viewGroup.findViewById(R.id.text), 0);
- Utilities.setStartMarginForView(viewGroup.findViewById(R.id.icon), 0);
- } else {
- // Phone Portrait, LargeScreen Landscape/Portrait
- viewGroup.setOrientation(LinearLayout.HORIZONTAL);
- lp.width = LinearLayout.LayoutParams.MATCH_PARENT;
- }
-
- lp.height = LinearLayout.LayoutParams.WRAP_CONTENT;
+ viewGroup.setOrientation(LinearLayout.HORIZONTAL);
+ lp.width = LinearLayout.LayoutParams.MATCH_PARENT;
+ lp.height = WRAP_CONTENT;
}
@Override
diff --git a/src/com/android/launcher3/touch/SeascapePagedViewHandler.java b/src/com/android/launcher3/touch/SeascapePagedViewHandler.java
index 4f33ff04bc..d5851c8074 100644
--- a/src/com/android/launcher3/touch/SeascapePagedViewHandler.java
+++ b/src/com/android/launcher3/touch/SeascapePagedViewHandler.java
@@ -81,13 +81,15 @@ public class SeascapePagedViewHandler extends LandscapePagedViewHandler {
}
@Override
- public float getTaskMenuX(float x, View thumbnailView, int overScroll) {
+ public float getTaskMenuX(float x, View thumbnailView, int overScroll,
+ DeviceProfile deviceProfile) {
return x;
}
@Override
public float getTaskMenuY(float y, View thumbnailView, int overScroll) {
- return y + thumbnailView.getMeasuredHeight() + overScroll;
+ return y + overScroll +
+ (thumbnailView.getMeasuredHeight() + thumbnailView.getMeasuredWidth()) / 2f;
}
@Override