<!-- Sizes for managed profile badges -->
<dimen name="profile_badge_size">24dp</dimen>
- <dimen name="profile_badge_margin">4dp</dimen>
+ <dimen name="profile_badge_margin">5dp</dimen>
<dimen name="profile_badge_minimum_top">2dp</dimen>
<!-- Shadows and outlines -->
private final UserManagerCompat mUserManager;
private final AppWidgetManagerCompat mManager;
private final CacheDb mDb;
- private final InvariantDeviceProfile mDeviceProfile;
+ private final int mProfileBadgeMargin;
private final MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor();
@Thunk final Handler mWorkerHandler;
mUserManager = UserManagerCompat.getInstance(context);
mDb = new CacheDb(context);
mWorkerHandler = new Handler(LauncherModel.getWorkerLooper());
- mDeviceProfile = inv;
+ mProfileBadgeMargin = context.getResources()
+ .getDimensionPixelSize(R.dimen.profile_badge_margin);
}
/**
}
// Draw the scaled preview into the final bitmap
- int x = (preview.getWidth() - previewWidth) / 2;
+ int x = (preview.getWidth() - previewWidth - mProfileBadgeMargin) / 2;
if (widgetPreviewExists) {
drawable.setBounds(x, 0, x + previewWidth, previewHeight);
drawable.draw(c);
} catch (Resources.NotFoundException e) { }
c.setBitmap(null);
}
- return mManager.getBadgeBitmap(info, preview, Math.min(preview.getHeight(), previewHeight));
+ int imageHeight = Math.min(preview.getHeight(), previewHeight + mProfileBadgeMargin);
+ return mManager.getBadgeBitmap(info, preview, imageHeight);
}
private Bitmap generateShortcutPreview(
}
@Override
- public Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap, int imageHeight) {
+ public Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap,
+ int imageHeight) {
return bitmap;
}
}
}
@Override
- public Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap, int imageHeight) {
+ public Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap,
+ int imageHeight) {
if (info.isCustomWidget || info.getProfile().equals(android.os.Process.myUserHandle())) {
return bitmap;
}
// Add a user badge in the bottom right of the image.
final Resources res = mContext.getResources();
final int badgeSize = res.getDimensionPixelSize(R.dimen.profile_badge_size);
- final int badgeMargin = res.getDimensionPixelSize(R.dimen.profile_badge_margin);
final int badgeMinTop = res.getDimensionPixelSize(R.dimen.profile_badge_minimum_top);
final Rect badgeLocation = new Rect(0, 0, badgeSize, badgeSize);
- final int top = Math.max(imageHeight - badgeSize - badgeMargin, badgeMinTop);
+ final int top = Math.max(imageHeight - badgeSize, badgeMinTop);
if (res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
- badgeLocation.offset(badgeMargin, top);
+ badgeLocation.offset(0, top);
} else {
- badgeLocation.offset(bitmap.getWidth() - badgeSize - badgeMargin, top);
+ badgeLocation.offset(bitmap.getWidth() - badgeSize, top);
}
Drawable drawable = mPm.getUserBadgedDrawableForDensity(