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

Commit dc48fc4f authored by Becky Qiu's avatar Becky Qiu
Browse files

[Overview Actions] Adjust the select mode taskview UI.

It will have a 30dp horizontal paddings and vertically in the middle of the screen.

Test: local
Bug: 155444014

Change-Id: I4f3d627008b2c114cc4921bf683919c6044926e4
parent 65381300
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.graphics.Rect;

import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
import com.android.quickstep.views.RecentsView;

@@ -64,10 +63,10 @@ public class OverviewModalTaskState extends OverviewState {
        Rect out = new Rect();
        activity.<RecentsView>getOverviewPanel().getTaskSize(out);
        int taskHeight = out.height();
        float topMargin = res.getDimension(R.dimen.task_thumbnail_top_margin);
        float bottomMargin = res.getDimension(R.dimen.overview_actions_top_margin);
        float newHeight = taskHeight + topMargin + bottomMargin;
        float scale = newHeight / taskHeight;
        activity.<RecentsView>getOverviewPanel().getModalTaskSize(out);
        int newHeight = out.height();

        float scale = (float) newHeight / taskHeight;

        return new float[] {scale, NO_OFFSET};
    }
+1 −3
Original line number Diff line number Diff line
@@ -145,8 +145,6 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo

    /** Updates vertical margins for different navigation mode. */
    public void updateVerticalMarginForNavModeChange(Mode mode) {
        int topMargin = getResources()
                .getDimensionPixelSize(R.dimen.overview_actions_top_margin);
        int bottomMargin = 0;
        if (mode == Mode.THREE_BUTTONS) {
            bottomMargin = getResources()
@@ -157,6 +155,6 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
        }
        LayoutParams params = (LayoutParams) getLayoutParams();
        params.setMargins(
                params.leftMargin, topMargin, params.rightMargin, bottomMargin);
                params.leftMargin, params.topMargin, params.rightMargin, bottomMargin);
    }
}
+5 −12
Original line number Diff line number Diff line
@@ -839,6 +839,11 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        mSizeStrategy.calculateTaskSize(mActivity, mActivity.getDeviceProfile(), outRect);
    }

    /** Gets the task size for modal state. */
    public void getModalTaskSize(Rect outRect) {
        mSizeStrategy.calculateModalTaskSize(mActivity, mActivity.getDeviceProfile(), outRect);
    }

    @Override
    protected boolean computeScrollHelper() {
        boolean scrolling = super.computeScrollHelper();
@@ -2155,18 +2160,6 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
        updatePageOffsets();
        if (getCurrentPageTaskView() != null) {
            getCurrentPageTaskView().setModalness(modalness);
            TaskView tv = getCurrentPageTaskView();

            // Move the task view up as it scales...
            // ...the icon on taskview is hidden in modal state, so consider the top of the task
            mTempFloatPoint[0] = 0;
            mTempFloatPoint[1] = tv.getTop() + mTaskTopMargin;
            // ...find the top after the transformation
            getMatrix().mapPoints(mTempFloatPoint);

            // ...make it match the top inset
            float calcOffset = (mInsets.top - mTempFloatPoint[1]) * mTaskModalness;
            tv.setTranslationY(calcOffset);
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@

    <!-- Overrideable in overlay that provides the Overview Actions. -->
    <dimen name="overview_actions_height">66dp</dimen>
    <dimen name="overview_actions_top_margin">44dp</dimen>
    <dimen name="overview_actions_bottom_margin_gesture">16dp</dimen>
    <dimen name="overview_actions_bottom_margin_three_button">8dp</dimen>
    <dimen name="overview_actions_horizontal_margin">16dp</dimen>
@@ -64,6 +63,7 @@
    <dimen name="task_card_menu_horizontal_padding">0dp</dimen>
    <dimen name="portrait_task_card_horz_space">136dp</dimen>
    <dimen name="portrait_task_card_horz_space_big_overview">96dp</dimen>
    <dimen name="portrait_modal_task_card_horz_space">60dp</dimen>
    <dimen name="landscape_task_card_horz_space">200dp</dimen>
    <dimen name="multi_window_task_card_horz_space">100dp</dimen>
    <!-- Copied from framework resource:
+63 −11
Original line number Diff line number Diff line
@@ -109,6 +109,68 @@ public abstract class WindowSizeStrategy {
                Math.round(x) + Math.round(outWidth), Math.round(y) + Math.round(outHeight));
    }

    /**
     * Calculates the modal taskView size for the provided device configuration
     */
    public void calculateModalTaskSize(Context context, DeviceProfile dp, Rect outRect) {
        float taskWidth, taskHeight, paddingHorz;
        Resources res = context.getResources();
        Rect insets = dp.getInsets();

        if (dp.isMultiWindowMode) {
            getMultiWindowSize(context, dp, mTempPoint);
            taskWidth = mTempPoint.x;
            taskHeight = mTempPoint.y;
            paddingHorz = res.getDimension(R.dimen.multi_window_task_card_horz_space);
        } else {
            taskWidth = dp.availableWidthPx;
            taskHeight = dp.availableHeightPx;

            final int paddingResId;
            if (dp.isVerticalBarLayout()) {
                paddingResId = R.dimen.landscape_task_card_horz_space;
            } else {
                paddingResId = R.dimen.portrait_modal_task_card_horz_space;
            }
            paddingHorz = res.getDimension(paddingResId);
        }

        // Note this should be same as dp.availableWidthPx and dp.availableHeightPx unless
        // we override the insets ourselves.
        int launcherVisibleWidth = dp.widthPx - insets.left - insets.right;
        int launcherVisibleHeight = dp.heightPx - insets.top - insets.bottom;

        // Calculate for the overview height.
        float overviewActionsHeight = getOverviewActionsHeight(context);
        float availableHeight = launcherVisibleHeight - overviewActionsHeight;
        float availableWidth = launcherVisibleWidth - paddingHorz;

        float scale = Math.min(availableWidth / taskWidth, availableHeight / taskHeight);
        float outWidth = scale * taskWidth;
        float outHeight = scale * taskHeight;

        // Center in the visible space
        float x = insets.left + (launcherVisibleWidth - outWidth) / 2;
        float y = insets.top + (launcherVisibleHeight - overviewActionsHeight - outHeight) / 2;
        outRect.set(Math.round(x), Math.round(y),
                Math.round(x) + Math.round(outWidth), Math.round(y) + Math.round(outHeight));
    }

    /** Gets the space that the overview actions will take, including margins. */
    public float getOverviewActionsHeight(Context context) {
        Resources res = context.getResources();
        float actionsBottomMargin = 0;
        if (getMode(context) == Mode.THREE_BUTTONS) {
            actionsBottomMargin = res.getDimensionPixelSize(
                R.dimen.overview_actions_bottom_margin_three_button);
        } else {
            actionsBottomMargin = res.getDimensionPixelSize(
                R.dimen.overview_actions_bottom_margin_gesture);
        }
        float overviewActionsHeight = actionsBottomMargin
                + res.getDimensionPixelSize(R.dimen.overview_actions_height);
        return overviewActionsHeight;
    }

    public static final WindowSizeStrategy LAUNCHER_ACTIVITY_SIZE_STRATEGY =
            new WindowSizeStrategy(true) {
@@ -138,17 +200,7 @@ public abstract class WindowSizeStrategy {
                if (showOverviewActions(context)) {
                    //TODO: this needs to account for the swipe gesture height and accessibility
                    // UI when shown.
                    float actionsBottomMargin = 0;
                    if (getMode(context) == Mode.THREE_BUTTONS) {
                        actionsBottomMargin = res.getDimensionPixelSize(
                                R.dimen.overview_actions_bottom_margin_three_button);
                    } else {
                        actionsBottomMargin = res.getDimensionPixelSize(
                                R.dimen.overview_actions_bottom_margin_gesture);
                    }
                    float actionsHeight = actionsBottomMargin
                            + res.getDimensionPixelSize(R.dimen.overview_actions_height);
                    return actionsHeight;
                    return getOverviewActionsHeight(context);
                } else {
                    return getDefaultSwipeHeight(context, dp) + dp.workspacePageIndicatorHeight
                            + res.getDimensionPixelSize(