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