summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2015-06-15 20:03:53 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-15 20:04:07 +0000
commit0fc56db04fa7dde3150b02862d6a3ab3374d89bc (patch)
tree91b50375df5a06fae3fbb62dd656857905f9bed9
parentbe9c52fff17760dc83fd156bb0730a645e836aeb (diff)
parent41e3369d5fffb2e8dfa33bfcb14386ad339b0f2f (diff)
downloadandroid_packages_apps_Trebuchet-0fc56db04fa7dde3150b02862d6a3ab3374d89bc.tar.gz
android_packages_apps_Trebuchet-0fc56db04fa7dde3150b02862d6a3ab3374d89bc.tar.bz2
android_packages_apps_Trebuchet-0fc56db04fa7dde3150b02862d6a3ab3374d89bc.zip
Merge "Work profile badge alignment b/21336417" into ub-launcher3-burnaby
-rw-r--r--res/values/dimens.xml2
-rw-r--r--src/com/android/launcher3/WidgetPreviewLoader.java10
-rw-r--r--src/com/android/launcher3/compat/AppWidgetManagerCompatV16.java3
-rw-r--r--src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java10
4 files changed, 14 insertions, 11 deletions
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 2184eadb3..370b31200 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -117,7 +117,7 @@
<!-- 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 -->
diff --git a/src/com/android/launcher3/WidgetPreviewLoader.java b/src/com/android/launcher3/WidgetPreviewLoader.java
index cfeced2df..75952d1a6 100644
--- a/src/com/android/launcher3/WidgetPreviewLoader.java
+++ b/src/com/android/launcher3/WidgetPreviewLoader.java
@@ -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(
diff --git a/src/com/android/launcher3/compat/AppWidgetManagerCompatV16.java b/src/com/android/launcher3/compat/AppWidgetManagerCompatV16.java
index a64c70535..f7f4b7e4f 100644
--- a/src/com/android/launcher3/compat/AppWidgetManagerCompatV16.java
+++ b/src/com/android/launcher3/compat/AppWidgetManagerCompatV16.java
@@ -87,7 +87,8 @@ class AppWidgetManagerCompatV16 extends AppWidgetManagerCompat {
}
@Override
- public Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap, int imageHeight) {
+ public Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap,
+ int imageHeight) {
return bitmap;
}
}
diff --git a/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java b/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
index 96ace8477..13712d8c7 100644
--- a/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
+++ b/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
@@ -108,7 +108,8 @@ class AppWidgetManagerCompatVL extends AppWidgetManagerCompat {
}
@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;
}
@@ -116,15 +117,14 @@ class AppWidgetManagerCompatVL extends AppWidgetManagerCompat {
// 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(