Pass device profile as constructor arg to DatabaseWidgetPreviewLoader

This is so, we can use it with compose, and let caller pass the needed
dependencies. May also convert to dagger in
 followup

Bug: 408283627
Flag: EXEMPT BUGFIX
Test: N/A
Change-Id: I9b04011ec2592df3bd02bd74ec4889eb05928e7f
This commit is contained in:
Shamali P authored and Shamali Patwa committed 2025-05-16 11:47:18 -07:00
1 parent a098f6a855
commit 4cb6ff3838
4 files changed
+20 -12

No files matched your search

@@ -68,8 +68,11 @@ public class DatabaseWidgetPreviewLoader {
private final Context mContext;
public DatabaseWidgetPreviewLoader(Context context) {
private final DeviceProfile mDeviceProfile;
public DatabaseWidgetPreviewLoader(Context context, DeviceProfile deviceProfile) {
mContext = context;
mDeviceProfile = deviceProfile;
}
/**
@@ -182,14 +185,12 @@ public class DatabaseWidgetPreviewLoader {
int previewWidth;
int previewHeight;
DeviceProfile dp = ActivityContext.lookupContext(mContext).getDeviceProfile();
if (widgetPreviewExists && drawable.getIntrinsicWidth() > 0
&& drawable.getIntrinsicHeight() > 0) {
previewWidth = drawable.getIntrinsicWidth();
previewHeight = drawable.getIntrinsicHeight();
} else {
Size widgetSize = WidgetSizes.getWidgetSizePx(dp, spanX, spanY);
Size widgetSize = WidgetSizes.getWidgetSizePx(mDeviceProfile, spanX, spanY);
previewWidth = widgetSize.getWidth();
previewHeight = widgetSize.getHeight();
}
@@ -253,7 +254,7 @@ public class DatabaseWidgetPreviewLoader {
Drawable icon = info.getFullResIcon(
LauncherAppState.getInstance(mContext).getIconCache());
if (icon != null) {
int appIconSize = dp.iconSizePx;
int appIconSize = mDeviceProfile.iconSizePx;
int iconSize = (int) Math.min(appIconSize * scale,
Math.min(boxRect.width(), boxRect.height()));