Merge "Shorten and center TaskMenuView for landscape" into sc-v2-dev am: 5dded93a72
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15857414 Change-Id: Iab80cdbf68e75a16b64f4b8e9bae9a8602866cc6
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
<dimen name="task_menu_corner_radius">22dp</dimen>
|
||||
<dimen name="task_menu_item_corner_radius">4dp</dimen>
|
||||
<dimen name="task_menu_spacing">2dp</dimen>
|
||||
<dimen name="task_menu_width_grid">200dp</dimen>
|
||||
<dimen name="overview_proactive_row_height">48dp</dimen>
|
||||
<dimen name="overview_proactive_row_bottom_margin">16dp</dimen>
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -324,7 +324,7 @@
|
||||
<!-- Size of the maximum radius for the enforced rounded rectangles. -->
|
||||
<dimen name="enforced_rounded_corner_max_radius">16dp</dimen>
|
||||
|
||||
<!-- Overview placeholder to compile in Launcer3 without Quickstep -->
|
||||
<!-- Overview placeholder to compile in Launcher3 without Quickstep -->
|
||||
<dimen name="task_thumbnail_icon_size">0dp</dimen>
|
||||
<dimen name="task_thumbnail_icon_drawable_size">0dp</dimen>
|
||||
<dimen name="task_thumbnail_icon_drawable_size_grid">0dp</dimen>
|
||||
@@ -342,6 +342,8 @@
|
||||
<dimen name="recents_page_spacing">0dp</dimen>
|
||||
<dimen name="recents_page_spacing_grid">0dp</dimen>
|
||||
<dimen name="split_placeholder_size">110dp</dimen>
|
||||
<dimen name="task_menu_width_grid">200dp</dimen>
|
||||
|
||||
|
||||
<!-- Workspace grid visualization parameters -->
|
||||
<dimen name="grid_visualization_rounding_radius">22dp</dimen>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user