Remove work profile badge from widget previews

Test: Check work profile badge no longer shown on work widget in the
      full and bottom widgets pickers.
Bug: 177675123
Change-Id: I0e5e32e18df832c1919749404094d68805c30556
This commit is contained in:
Steven Ng
2021-05-19 21:34:06 +01:00
parent a79cd20147
commit f735c738ea
3 changed files with 0 additions and 71 deletions

View File

@@ -21,9 +21,7 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.CancellationSignal;
@@ -35,9 +33,7 @@ import android.util.LongSparseArray;
import android.util.Pair;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import com.android.launcher3.icons.FastBitmapDrawable;
import com.android.launcher3.icons.GraphicsUtils;
import com.android.launcher3.icons.IconCache;
import com.android.launcher3.icons.LauncherIcons;
@@ -93,51 +89,6 @@ public class WidgetPreviewLoader {
mDb = new CacheDb(context);
}
/**
* Returns a drawable that can be used as a badge for the user or null.
*/
@UiThread
public Drawable getBadgeForUser(UserHandle user, int badgeSize) {
if (mMyUser.equals(user)) {
return null;
}
Bitmap badgeBitmap = getUserBadge(user, badgeSize);
FastBitmapDrawable d = new FastBitmapDrawable(badgeBitmap);
d.setFilterBitmap(true);
d.setBounds(0, 0, badgeBitmap.getWidth(), badgeBitmap.getHeight());
return d;
}
private Bitmap getUserBadge(UserHandle user, int badgeSize) {
synchronized (mUserBadges) {
Bitmap badgeBitmap = mUserBadges.get(user);
if (badgeBitmap != null) {
return badgeBitmap;
}
final Resources res = mContext.getResources();
badgeBitmap = Bitmap.createBitmap(badgeSize, badgeSize, Bitmap.Config.ARGB_8888);
Drawable drawable = mContext.getPackageManager().getUserBadgedDrawableForDensity(
new BitmapDrawable(res, badgeBitmap), user,
new Rect(0, 0, badgeSize, badgeSize),
0);
if (drawable instanceof BitmapDrawable) {
badgeBitmap = ((BitmapDrawable) drawable).getBitmap();
} else {
badgeBitmap.eraseColor(Color.TRANSPARENT);
Canvas c = new Canvas(badgeBitmap);
drawable.setBounds(0, 0, badgeSize, badgeSize);
drawable.draw(c);
c.setBitmap(null);
}
mUserBadges.put(user, badgeBitmap);
return badgeBitmap;
}
}
/**
* Generates the widget preview on {@link AsyncTask#THREAD_POOL_EXECUTOR}. Must be
* called on UI thread