Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e6a642d authored by Vinit Nayak's avatar Vinit Nayak
Browse files

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
parent e37b51b3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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>

+12 −5
Original line number Diff line number Diff line
@@ -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);
        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()) - (2 * padding);
                    .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);
    }

+3 −1
Original line number Diff line number Diff line
@@ -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>
+12 −12
Original line number Diff line number Diff line
@@ -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
+9 −2
Original line number Diff line number Diff line
@@ -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.
Loading