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

Commit 228877d3 authored by Jon Miranda's avatar Jon Miranda
Browse files

Add border spacing and fixed cell height to grid.

- Border spacing is the spacing between the cells.
- Workspace cell height is now fixed, and we allocate
  all the "extra" space to three different variable height
  areas.

* Built behind ENABLE_FOUR_COLUMNS flag because it hinders the
default grid.

Bug: 175329686
Test: - set border spacing to 0 and confirm matches prior layout
      - test drag and drop still worked
      - test reordering
      - test widgets
      - test folders
      - test multiwindow

Change-Id: Ic6f3dff577d28ff214bda4b0a787ec7fd08c108b
parent 6cd63cb4
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -135,6 +135,16 @@
        <attr name="demoModeLayoutId" format="reference" />
    </declare-styleable>

    <declare-styleable name="DevicePadding">
        <attr name="maxEmptySpace" format="dimension" />
    </declare-styleable>

    <declare-styleable name="DevicePaddingFormula">
        <attr name="a" format="float|dimension" />
        <attr name="b" format="float|dimension" />
        <attr name="c" format="float|dimension" />
    </declare-styleable>

    <declare-styleable name="ProfileDisplayOption">
        <attr name="name" />
        <attr name="minWidthDps" format="float" />
+3 −1
Original line number Diff line number Diff line
@@ -20,12 +20,14 @@

    <!-- Dynamic Grid -->
    <dimen name="dynamic_grid_edge_margin">8dp</dimen>
    <dimen name="dynamic_grid_icon_drawable_padding">8dp</dimen>
    <dimen name="dynamic_grid_icon_drawable_padding">7dp</dimen>
    <!-- Minimum space between workspace and hotseat in spring loaded mode -->
    <dimen name="dynamic_grid_min_spring_loaded_space">8dp</dimen>

    <dimen name="dynamic_grid_cell_border_spacing">16dp</dimen>
    <dimen name="dynamic_grid_cell_layout_padding">5.5dp</dimen>
    <dimen name="dynamic_grid_cell_padding_x">8dp</dimen>
    <dimen name="dynamic_grid_cell_padding_y">7dp</dimen>

    <!-- Hotseat -->
    <dimen name="dynamic_grid_hotseat_top_padding">8dp</dimen>
+75 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2021 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<device-paddings xmlns:launcher="http://schemas.android.com/apk/res-auto" >

    <device-padding
        launcher:maxEmptySpace="88dp">
        <workspaceTopPadding
            launcher:a="0"
            launcher:b="0"/>
        <workspaceBottomPadding
            launcher:a="0.52"
            launcher:b="0"/>
        <hotseatBottomPadding
            launcher:a="0.48"
            launcher:b="0"/>
    </device-padding>

    <device-padding
        launcher:maxEmptySpace="97dp">
        <workspaceTopPadding
            launcher:a="0"
            launcher:b="16dp"/>
        <workspaceBottomPadding
            launcher:a="0.50"
            launcher:b="0"
            launcher:c="-16dp"/>
        <hotseatBottomPadding
            launcher:a="0.50"
            launcher:b="0"
            launcher:c="16dp"/>
    </device-padding>

    <device-padding
        launcher:maxEmptySpace="107dp">
        <workspaceTopPadding
            launcher:a="0"
            launcher:b="16dp"/>
        <workspaceBottomPadding
            launcher:a="0"
            launcher:b="36dp"/>
        <hotseatBottomPadding
            launcher:a="1"
            launcher:b="0"
            launcher:c="52dp"/>
    </device-padding>

    <device-padding
        launcher:maxEmptySpace="9999dp">
        <workspaceTopPadding
            launcher:a="0.38"
            launcher:c="36dp"/>
        <workspaceBottomPadding
            launcher:a="0.62"
            launcher:c="36dp"/>
        <hotseatBottomPadding
            launcher:a="0"
            launcher:b="36dp"/>
    </device-padding>

</device-paddings>
 No newline at end of file
+15 −8
Original line number Diff line number Diff line
@@ -279,8 +279,9 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
     *  Based on the current deltas, we determine if and how to resize the widget.
     */
    private void resizeWidgetIfNeeded(boolean onDismiss) {
        float xThreshold = mCellLayout.getCellWidth();
        float yThreshold = mCellLayout.getCellHeight();
        DeviceProfile dp = mLauncher.getDeviceProfile();
        float xThreshold = mCellLayout.getCellWidth() + dp.cellLayoutBorderSpacingPx;
        float yThreshold = mCellLayout.getCellHeight() + dp.cellLayoutBorderSpacingPx;

        int hSpanInc = getSpanIncrement((mDeltaX + mDeltaXAddOn) / xThreshold - mRunningHInc);
        int vSpanInc = getSpanIncrement((mDeltaY + mDeltaYAddOn) / yThreshold - mRunningVInc);
@@ -364,13 +365,18 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
        final float density = context.getResources().getDisplayMetrics().density;
        final Point[] cellSize = CELL_SIZE.get(context);

        final int borderSpacing = context.getResources()
                .getDimensionPixelSize(R.dimen.dynamic_grid_cell_border_spacing);
        final float hBorderSpacing = (spanX - 1) * borderSpacing;
        final float vBorderSpacing = (spanY - 1) * borderSpacing;

        // Compute landscape size
        int landWidth = (int) ((spanX * cellSize[0].x) / density);
        int landHeight = (int) ((spanY * cellSize[0].y) / density);
        int landWidth = (int) (((spanX * cellSize[0].x) + hBorderSpacing) / density);
        int landHeight = (int) (((spanY * cellSize[0].y) + vBorderSpacing) / density);

        // Compute portrait size
        int portWidth = (int) ((spanX * cellSize[1].x) / density);
        int portHeight = (int) ((spanY * cellSize[1].y) / density);
        int portWidth = (int) (((spanX * cellSize[1].x) + hBorderSpacing) / density);
        int portHeight = (int) (((spanY * cellSize[1].y) + vBorderSpacing) / density);
        rect.set(portWidth, landHeight, landWidth, portHeight);
        return rect;
    }
@@ -384,8 +390,9 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
    }

    private void onTouchUp() {
        int xThreshold = mCellLayout.getCellWidth();
        int yThreshold = mCellLayout.getCellHeight();
        DeviceProfile dp = mLauncher.getDeviceProfile();
        int xThreshold = mCellLayout.getCellWidth() + dp.cellLayoutBorderSpacingPx;
        int yThreshold = mCellLayout.getCellHeight() + dp.cellLayoutBorderSpacingPx;

        mDeltaXAddOn = mRunningHInc * xThreshold;
        mDeltaYAddOn = mRunningVInc * yThreshold;
+10 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.launcher3;

import static com.android.launcher3.FastBitmapDrawable.newIcon;
import static com.android.launcher3.config.FeatureFlags.ENABLE_FOUR_COLUMNS;
import static com.android.launcher3.graphics.IconShape.getShape;
import static com.android.launcher3.graphics.PreloadIconDrawable.newPendingIcon;
import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;
@@ -198,6 +199,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
            setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx);
            setCompoundDrawablePadding(grid.iconDrawablePaddingPx);
            defaultIconSize = grid.iconSizePx;
            setCenterVertically(ENABLE_FOUR_COLUMNS.get());
        } else if (mDisplay == DISPLAY_ALL_APPS) {
            setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx);
            setCompoundDrawablePadding(grid.allAppsIconDrawablePaddingPx);
@@ -232,7 +234,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
        int shadowSize = context.getResources().getDimensionPixelSize(
                R.dimen.blur_size_click_shadow);
        mHighlightShadowFilter = new BlurMaskFilter(shadowSize, BlurMaskFilter.Blur.INNER);

    }

    @Override
@@ -554,6 +555,14 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
        outBounds.set(left, top, right, bottom);
    }


    /**
     * Sets whether to vertically center the content.
     */
    public void setCenterVertically(boolean centerVertically) {
        mCenterVertically = centerVertically;
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (mCenterVertically) {
Loading