mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 01:46:49 +00:00
Use WidgetSizes to estimate widget size instead of custom calculation
Also fix 2 bugs in WidgetCell
1. preview layout: padding is added to the AppWidgetHostView rather
than the preview container. We shouldn't add padding to the size
of the preview container.
2. widget_preview_shortcut_padding is a padding added to shortcuts but
not widgets.
Test: Open full widgets picker and observe widgets are rendered
correctly in the widgets recommendation table. Also, observe
the generated bitmap images are correctly rendered.
Run AddWidgetTest.
Bug: 189975670
Change-Id: I00db3200e0b61dc5e82f3c4bfdf34e197ea20314
This commit is contained in:
@@ -27,10 +27,10 @@ import android.os.AsyncTask;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.util.LongSparseArray;
|
||||
import android.util.Pair;
|
||||
import android.util.Size;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
@@ -50,6 +50,7 @@ import com.android.launcher3.util.Thunk;
|
||||
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
|
||||
import com.android.launcher3.widget.WidgetCell;
|
||||
import com.android.launcher3.widget.WidgetManagerHelper;
|
||||
import com.android.launcher3.widget.util.WidgetSizes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -79,9 +80,6 @@ public class WidgetPreviewLoader {
|
||||
private final UserCache mUserCache;
|
||||
private final CacheDb mDb;
|
||||
|
||||
private final UserHandle mMyUser = Process.myUserHandle();
|
||||
private final ArrayMap<UserHandle, Bitmap> mUserBadges = new ArrayMap<>();
|
||||
|
||||
public WidgetPreviewLoader(Context context, IconCache iconCache) {
|
||||
mContext = context;
|
||||
mIconCache = iconCache;
|
||||
@@ -366,9 +364,9 @@ public class WidgetPreviewLoader {
|
||||
previewHeight = drawable.getIntrinsicHeight();
|
||||
} else {
|
||||
DeviceProfile dp = launcher.getDeviceProfile();
|
||||
int tileSize = Math.min(dp.cellWidthPx, dp.cellHeightPx);
|
||||
previewWidth = tileSize * spanX;
|
||||
previewHeight = tileSize * spanY;
|
||||
Size widgetSize = WidgetSizes.getWidgetSizePx(dp, spanX, spanY);
|
||||
previewWidth = widgetSize.getWidth();
|
||||
previewHeight = widgetSize.getHeight();
|
||||
}
|
||||
|
||||
// Scale to fit width only - let the widget preview be clipped in the
|
||||
|
||||
Reference in New Issue
Block a user