Shorten and center TaskMenuView for landscape

* The width of the task menu view for landscape
(both fake and real) is the same as the width
it would be in portrait.
* With the shorter width, we also center the
positioning of the TaskMenuView
* Note this is only for phone, large screen
changes TODO

Bug: 193432925
Test: Tested real/fake landscape + seascape,
view is centered. Portrait same as before.

Change-Id: Ide41e252a3c177c4a911aab544f78930fed2e76f
This commit is contained in:
Vinit Nayak
2021-09-17 16:38:31 -07:00
parent e37b51b30f
commit 9e6a642d8b
7 changed files with 59 additions and 49 deletions

View File

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