Work profile badge alignment

b/21336417

Change-Id: Icd54320fa0d0976cac0ae66d180cc2c99ddd0c1c
This commit is contained in:
Hyunyoung Song
2015-06-15 12:26:54 -07:00
parent 90429e11e7
commit 41e3369d5f
4 changed files with 14 additions and 11 deletions

View File

@@ -64,7 +64,7 @@ public class WidgetPreviewLoader {
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;
@@ -76,7 +76,8 @@ public class WidgetPreviewLoader {
mUserManager = UserManagerCompat.getInstance(context);
mDb = new CacheDb(context);
mWorkerHandler = new Handler(LauncherModel.getWorkerLooper());
mDeviceProfile = inv;
mProfileBadgeMargin = context.getResources()
.getDimensionPixelSize(R.dimen.profile_badge_margin);
}
/**
@@ -401,7 +402,7 @@ public class WidgetPreviewLoader {
}
// 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);
@@ -445,7 +446,8 @@ public class WidgetPreviewLoader {
} 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(