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

Commit 6c76501e authored by Xiaowen Lei's avatar Xiaowen Lei
Browse files

Don't add padding for Smartspace (actual and preview).

As demonstrated in ag/27287153, the actual Smartspace doesn't have any
top padding, but the qsb_preview does.
  - Turns out, ShortcutAndWidgetContainer sets padding on its children.
  - The actual Smartspace has padding removed by overriding the
    `setPadding` method in SmartspaceViewContainer. (See ag/13562740.)

This CL updates ShortcutAndWidgetContainer.java to not add padding for
either the actual or the preview Smartspace. It makes use of
`R.id.search_container_workspace` to identify the applicable cases,
rather than checking class types or names. This way, there is no
Pixel-specific logic added.

Before: https://hsv.googleplex.com/6335187293044736?node=18
After: https://hsv.googleplex.com/5450651931770880?node=18
Actual Smartspace, for reference:
  - https://hsv.googleplex.com/6083634648842240?node=14

Note the `isChildQsb` also returns true for the QsbContainerView. Since
that class already has the same `setPadding` override:
  - https://cs.android.com/android/platform/superproject/main/+/main:packages/apps/Launcher3/src/com/android/launcher3/qsb/QsbContainerView.java;l=147-150;drc=e58aaf1802e43f73bbd417658c1c4c42e2fe28fd
This CL does't affect its padding.

Flag: EXEMPT bugfix
Bug: 338601960
Test: Go to Wallpaper & style preview for Home screen.
Change-Id: I5b6f7752cfee556b815c83e9df85f9e74f23ab4b
parent 348ac13c
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -158,6 +158,11 @@ public class ShortcutAndWidgetContainer extends ViewGroup implements FolderIcon.
            final PointF appWidgetScale = dp.getAppWidgetScale((ItemInfo) child.getTag());
            lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX, mCountY,
                    appWidgetScale.x, appWidgetScale.y, mBorderSpace, dp.widgetPadding);
        } else if (isChildQsb(child)) {
            lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX, mCountY,
                    mBorderSpace);
            // No need to add padding for Qsb, which is either Smartspace (actual or preview), or
            // QsbContainerView.
        } else {
            lp.setup(mCellWidth, mCellHeight, invertLayoutHorizontally(), mCountX, mCountY,
                    mBorderSpace);
@@ -185,6 +190,10 @@ public class ShortcutAndWidgetContainer extends ViewGroup implements FolderIcon.
        child.measure(childWidthMeasureSpec, childheightMeasureSpec);
    }

    private boolean isChildQsb(View child) {
        return child.getId() == R.id.search_container_workspace;
    }

    public boolean invertLayoutHorizontally() {
        return mInvertIfRtl && Utilities.isRtl(getResources());
    }