Always insetting the widget by a minimum of 6dp

Removing default widget padding logic. Also widget padding it applied
at ShortcutAndWidgetContainer so that the widgetView always has the
correct size.

Bug: 274826296
Bug: 257589413
Test: Verified using screenshots
Flags: N/A
Change-Id: Id4b5e94db6ec7b2aa3dca87b1e9ccc831b608cac
This commit is contained in:
Sunny Goyal
2023-04-10 12:03:04 -07:00
parent c4e2508681
commit 6c304b157d
15 changed files with 105 additions and 205 deletions

View File

@@ -1,7 +1,5 @@
package com.android.launcher3;
import static android.appwidget.AppWidgetHostView.getDefaultPaddingForWidget;
import static com.android.launcher3.CellLayout.SPRING_LOADED_PROGRESS;
import static com.android.launcher3.LauncherAnimUtils.LAYOUT_HEIGHT;
import static com.android.launcher3.LauncherAnimUtils.LAYOUT_WIDTH;
@@ -77,8 +75,6 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
private DragLayer mDragLayer;
private ImageButton mReconfigureButton;
private Rect mWidgetPadding;
private final int mBackgroundPadding;
private final int mTouchTargetWidth;
@@ -218,9 +214,6 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
mMaxHSpan = info.maxSpanX;
mMaxVSpan = info.maxSpanY;
mWidgetPadding = getDefaultPaddingForWidget(getContext(),
widgetView.getAppWidgetInfo().provider, null);
// Only show resize handles for the directions in which resizing is possible.
InvariantDeviceProfile idp = LauncherAppState.getIDP(cellLayout.getContext());
mVerticalResizeActive = (info.resizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0
@@ -517,16 +510,12 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O
*/
private void getSnappedRectRelativeToDragLayer(Rect out) {
float scale = mWidgetView.getScaleToFit();
mDragLayer.getViewRectRelativeToSelf(mWidgetView, out);
int width = 2 * mBackgroundPadding
+ (int) (scale * (out.width() - mWidgetPadding.left - mWidgetPadding.right));
int height = 2 * mBackgroundPadding
+ (int) (scale * (out.height() - mWidgetPadding.top - mWidgetPadding.bottom));
int x = (int) (out.left - mBackgroundPadding + scale * mWidgetPadding.left);
int y = (int) (out.top - mBackgroundPadding + scale * mWidgetPadding.top);
int width = 2 * mBackgroundPadding + Math.round(scale * out.width());
int height = 2 * mBackgroundPadding + Math.round(scale * out.height());
int x = out.left - mBackgroundPadding;
int y = out.top - mBackgroundPadding;
out.left = x;
out.top = y;