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:
@@ -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()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user