mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 01:16:49 +00:00
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:
@@ -25,7 +25,6 @@ import android.view.View;
|
||||
import android.view.ViewDebug;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Reorderable;
|
||||
import com.android.launcher3.dragndrop.DraggableView;
|
||||
import com.android.launcher3.util.MultiTranslateDelegate;
|
||||
@@ -48,13 +47,13 @@ public abstract class NavigableAppWidgetHostView extends AppWidgetHostView
|
||||
|
||||
private float mScaleForReorderBounce = 1f;
|
||||
|
||||
private final Rect mTempRect = new Rect();
|
||||
|
||||
@ViewDebug.ExportedProperty(category = "launcher")
|
||||
private boolean mChildrenFocused;
|
||||
|
||||
protected final ActivityContext mActivity;
|
||||
|
||||
private boolean mDisableSetPadding = false;
|
||||
|
||||
public NavigableAppWidgetHostView(Context context) {
|
||||
super(context);
|
||||
mActivity = ActivityContext.lookupContext(context);
|
||||
@@ -146,6 +145,22 @@ public abstract class NavigableAppWidgetHostView extends AppWidgetHostView
|
||||
dispatchChildFocus(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAppWidget(int appWidgetId, AppWidgetProviderInfo info) {
|
||||
// Prevent default padding being set on the view based on provider info. Launcher manages
|
||||
// its own widget spacing
|
||||
mDisableSetPadding = true;
|
||||
super.setAppWidget(appWidgetId, info);
|
||||
mDisableSetPadding = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPadding(int left, int top, int right, int bottom) {
|
||||
if (!mDisableSetPadding) {
|
||||
super.setPadding(left, top, right, bottom);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchUnhandledMove(View focused, int direction) {
|
||||
return mChildrenFocused;
|
||||
@@ -195,26 +210,6 @@ public abstract class NavigableAppWidgetHostView extends AppWidgetHostView
|
||||
public void getWorkspaceVisualDragBounds(Rect bounds) {
|
||||
int width = (int) (getMeasuredWidth() * mScaleToFit);
|
||||
int height = (int) (getMeasuredHeight() * mScaleToFit);
|
||||
|
||||
getWidgetInset(mActivity.getDeviceProfile(), mTempRect);
|
||||
bounds.set(mTempRect.left, mTempRect.top, width - mTempRect.right,
|
||||
height - mTempRect.bottom);
|
||||
}
|
||||
|
||||
/**
|
||||
* Widgets have padding added by the system. We may choose to inset this padding if the grid
|
||||
* supports it.
|
||||
*/
|
||||
public void getWidgetInset(DeviceProfile grid, Rect out) {
|
||||
if (!grid.shouldInsetWidgets()) {
|
||||
out.setEmpty();
|
||||
return;
|
||||
}
|
||||
AppWidgetProviderInfo info = getAppWidgetInfo();
|
||||
if (info == null) {
|
||||
out.set(grid.inv.defaultWidgetPadding);
|
||||
} else {
|
||||
AppWidgetHostView.getDefaultPaddingForWidget(getContext(), info.provider, out);
|
||||
}
|
||||
bounds.set(0, 0, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user