summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
diff options
context:
space:
mode:
authorHyunyoung Song <hyunyoungs@google.com>2016-03-01 11:57:44 -0800
committerHyunyoung Song <hyunyoungs@google.com>2016-03-01 11:57:44 -0800
commit3e840f4343086ed78a8ae44fd543a9863d868dc9 (patch)
tree3defaae7a71a3e6ecede428de464ffbf2660066b /src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
parent2cb92eb2bbfbd6ae4331657d3446f3f771aabd4b (diff)
downloadandroid_packages_apps_Trebuchet-3e840f4343086ed78a8ae44fd543a9863d868dc9.tar.gz
android_packages_apps_Trebuchet-3e840f4343086ed78a8ae44fd543a9863d868dc9.tar.bz2
android_packages_apps_Trebuchet-3e840f4343086ed78a8ae44fd543a9863d868dc9.zip
Prevent work profile widget DnD crash
b/26079469 Change-Id: I3d49ac498bbaaef8ca8a3051f5ab4b35ef771410
Diffstat (limited to 'src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java')
-rw-r--r--src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java b/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
index b3c5cc2a3..3bc3d0d80 100644
--- a/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
+++ b/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
@@ -107,18 +107,24 @@ class AppWidgetManagerCompatVL extends AppWidgetManagerCompat {
@Override
public Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap,
- int imageHeight) {
+ int imageWidth, 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 badgeMinTop = res.getDimensionPixelSize(R.dimen.profile_badge_minimum_top);
+
+ // choose min between badge size defined for widget tray versus width, height of the image.
+ // Width, height of the image can be smaller than widget tray badge size when being dropped
+ // to the workspace.
+ final int badgeSize = Math.min(res.getDimensionPixelSize(R.dimen.profile_badge_size),
+ Math.min(imageWidth, imageHeight - badgeMinTop));
final Rect badgeLocation = new Rect(0, 0, badgeSize, badgeSize);
final int top = Math.max(imageHeight - badgeSize, badgeMinTop);
+
if (res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) {
badgeLocation.offset(0, top);
} else {