summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/compat
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-01-14 13:40:15 -0800
committerSunny Goyal <sunnygoyal@google.com>2017-01-19 14:00:40 -0800
commita2441e88ff862714d823d6c786b2d563047f75fc (patch)
tree4d610a211c2f32f8dd788965096718d9c9597568 /src/com/android/launcher3/compat
parent278359539c02ca160caf1df54ce96053a2a2ef59 (diff)
downloadandroid_packages_apps_Trebuchet-a2441e88ff862714d823d6c786b2d563047f75fc.tar.gz
android_packages_apps_Trebuchet-a2441e88ff862714d823d6c786b2d563047f75fc.tar.bz2
android_packages_apps_Trebuchet-a2441e88ff862714d823d6c786b2d563047f75fc.zip
Updating widget preview generation to not embed any badge.
Instead drawing badge in the view directly. This will allow us to reuse the same preview when we do not want to draw badges. This also simplified badging of shortcut config activities. Change-Id: I9c07c33bf9c2b8ef81a00026b1d42587868c906f
Diffstat (limited to 'src/com/android/launcher3/compat')
-rw-r--r--src/com/android/launcher3/compat/AppWidgetManagerCompat.java3
-rw-r--r--src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java49
2 files changed, 0 insertions, 52 deletions
diff --git a/src/com/android/launcher3/compat/AppWidgetManagerCompat.java b/src/com/android/launcher3/compat/AppWidgetManagerCompat.java
index af43c02a7..7911bb213 100644
--- a/src/com/android/launcher3/compat/AppWidgetManagerCompat.java
+++ b/src/com/android/launcher3/compat/AppWidgetManagerCompat.java
@@ -71,9 +71,6 @@ public abstract class AppWidgetManagerCompat {
public abstract void startConfigActivity(AppWidgetProviderInfo info, int widgetId,
Activity activity, AppWidgetHost host, int requestCode);
- public abstract Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap,
- int imageWidth, int imageHeight);
-
public abstract LauncherAppWidgetProviderInfo findProvider(
ComponentName provider, UserHandle user);
diff --git a/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java b/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
index 56a7f46c0..61dd1a5b7 100644
--- a/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
+++ b/src/com/android/launcher3/compat/AppWidgetManagerCompatVL.java
@@ -23,17 +23,9 @@ import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Rect;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
-import android.view.View;
import android.widget.Toast;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
@@ -82,47 +74,6 @@ class AppWidgetManagerCompatVL extends AppWidgetManagerCompat {
}
@Override
- public Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap,
- 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 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 {
- badgeLocation.offset(bitmap.getWidth() - badgeSize, top);
- }
-
- Drawable drawable = mPm.getUserBadgedDrawableForDensity(
- new BitmapDrawable(res, bitmap), info.getProfile(), badgeLocation, 0);
-
- if (drawable instanceof BitmapDrawable) {
- return ((BitmapDrawable) drawable).getBitmap();
- }
-
- bitmap.eraseColor(Color.TRANSPARENT);
- Canvas c = new Canvas(bitmap);
- drawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
- drawable.draw(c);
- c.setBitmap(null);
- return bitmap;
- }
-
- @Override
public LauncherAppWidgetProviderInfo findProvider(ComponentName provider, UserHandle user) {
for (AppWidgetProviderInfo info : mAppWidgetManager
.getInstalledProvidersForProfile(user)) {