Merge "Work profile badge alignment b/21336417" into ub-launcher3-burnaby
This commit is contained in:
committed by
Android (Google) Code Review
commit
0fc56db04f
@@ -117,7 +117,7 @@
|
|||||||
|
|
||||||
<!-- Sizes for managed profile badges -->
|
<!-- Sizes for managed profile badges -->
|
||||||
<dimen name="profile_badge_size">24dp</dimen>
|
<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>
|
<dimen name="profile_badge_minimum_top">2dp</dimen>
|
||||||
|
|
||||||
<!-- Shadows and outlines -->
|
<!-- Shadows and outlines -->
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class WidgetPreviewLoader {
|
|||||||
private final UserManagerCompat mUserManager;
|
private final UserManagerCompat mUserManager;
|
||||||
private final AppWidgetManagerCompat mManager;
|
private final AppWidgetManagerCompat mManager;
|
||||||
private final CacheDb mDb;
|
private final CacheDb mDb;
|
||||||
private final InvariantDeviceProfile mDeviceProfile;
|
private final int mProfileBadgeMargin;
|
||||||
|
|
||||||
private final MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor();
|
private final MainThreadExecutor mMainThreadExecutor = new MainThreadExecutor();
|
||||||
@Thunk final Handler mWorkerHandler;
|
@Thunk final Handler mWorkerHandler;
|
||||||
@@ -76,7 +76,8 @@ public class WidgetPreviewLoader {
|
|||||||
mUserManager = UserManagerCompat.getInstance(context);
|
mUserManager = UserManagerCompat.getInstance(context);
|
||||||
mDb = new CacheDb(context);
|
mDb = new CacheDb(context);
|
||||||
mWorkerHandler = new Handler(LauncherModel.getWorkerLooper());
|
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
|
// Draw the scaled preview into the final bitmap
|
||||||
int x = (preview.getWidth() - previewWidth) / 2;
|
int x = (preview.getWidth() - previewWidth - mProfileBadgeMargin) / 2;
|
||||||
if (widgetPreviewExists) {
|
if (widgetPreviewExists) {
|
||||||
drawable.setBounds(x, 0, x + previewWidth, previewHeight);
|
drawable.setBounds(x, 0, x + previewWidth, previewHeight);
|
||||||
drawable.draw(c);
|
drawable.draw(c);
|
||||||
@@ -445,7 +446,8 @@ public class WidgetPreviewLoader {
|
|||||||
} catch (Resources.NotFoundException e) { }
|
} catch (Resources.NotFoundException e) { }
|
||||||
c.setBitmap(null);
|
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(
|
private Bitmap generateShortcutPreview(
|
||||||
|
|||||||
@@ -87,7 +87,8 @@ class AppWidgetManagerCompatV16 extends AppWidgetManagerCompat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap, int imageHeight) {
|
public Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap,
|
||||||
|
int imageHeight) {
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,7 +108,8 @@ class AppWidgetManagerCompatVL extends AppWidgetManagerCompat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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())) {
|
if (info.isCustomWidget || info.getProfile().equals(android.os.Process.myUserHandle())) {
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
@@ -116,15 +117,14 @@ class AppWidgetManagerCompatVL extends AppWidgetManagerCompat {
|
|||||||
// Add a user badge in the bottom right of the image.
|
// Add a user badge in the bottom right of the image.
|
||||||
final Resources res = mContext.getResources();
|
final Resources res = mContext.getResources();
|
||||||
final int badgeSize = res.getDimensionPixelSize(R.dimen.profile_badge_size);
|
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 int badgeMinTop = res.getDimensionPixelSize(R.dimen.profile_badge_minimum_top);
|
||||||
final Rect badgeLocation = new Rect(0, 0, badgeSize, badgeSize);
|
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) {
|
if (res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
|
||||||
badgeLocation.offset(badgeMargin, top);
|
badgeLocation.offset(0, top);
|
||||||
} else {
|
} else {
|
||||||
badgeLocation.offset(bitmap.getWidth() - badgeSize - badgeMargin, top);
|
badgeLocation.offset(bitmap.getWidth() - badgeSize, top);
|
||||||
}
|
}
|
||||||
|
|
||||||
Drawable drawable = mPm.getUserBadgedDrawableForDensity(
|
Drawable drawable = mPm.getUserBadgedDrawableForDensity(
|
||||||
|
|||||||
Reference in New Issue
Block a user