mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-01 08:16:49 +00:00
resolve merge conflicts of 39b700fcc5 to ub-launcher3-master.
Change-Id: I394258be0c75289cab2f5141c0fb765504527420
This commit is contained in:
@@ -62,6 +62,7 @@ import android.widget.Toast;
|
||||
|
||||
import com.android.launcher3.compat.UserHandleCompat;
|
||||
import com.android.launcher3.config.ProviderConfig;
|
||||
import com.android.launcher3.util.IconNormalizer;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -209,12 +210,15 @@ public final class Utilities {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a bitmap suitable for the all apps view. The icon is badged for {@param user}
|
||||
* Returns a bitmap suitable for the all apps view. The icon is badged for {@param user}.
|
||||
* The bitmap is also visually normalized with other icons.
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public static Bitmap createBadgedIconBitmap(
|
||||
Drawable icon, UserHandleCompat user, Context context) {
|
||||
Bitmap bitmap = createIconBitmap(icon, context);
|
||||
float scale = ProviderConfig.IS_DOGFOOD_BUILD ?
|
||||
IconNormalizer.getInstance().getScale(icon) : 1;
|
||||
Bitmap bitmap = createIconBitmap(icon, context, scale);
|
||||
if (Utilities.ATLEAST_LOLLIPOP && user != null
|
||||
&& !UserHandleCompat.myUserHandle().equals(user)) {
|
||||
BitmapDrawable drawable = new BitmapDrawable(context.getResources(), bitmap);
|
||||
@@ -234,6 +238,13 @@ public final class Utilities {
|
||||
* Returns a bitmap suitable for the all apps view.
|
||||
*/
|
||||
public static Bitmap createIconBitmap(Drawable icon, Context context) {
|
||||
return createIconBitmap(icon, context, 1.0f /* scale */);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scale the scale to apply before drawing {@param icon} on the canvas
|
||||
*/
|
||||
public static Bitmap createIconBitmap(Drawable icon, Context context, float scale) {
|
||||
synchronized (sCanvas) {
|
||||
final int iconBitmapSize = getIconBitmapSize();
|
||||
|
||||
@@ -289,7 +300,10 @@ public final class Utilities {
|
||||
|
||||
sOldBounds.set(icon.getBounds());
|
||||
icon.setBounds(left, top, left+width, top+height);
|
||||
canvas.save(Canvas.MATRIX_SAVE_FLAG);
|
||||
canvas.scale(scale, scale, textureWidth / 2, textureHeight / 2);
|
||||
icon.draw(canvas);
|
||||
canvas.restore();
|
||||
icon.setBounds(sOldBounds);
|
||||
canvas.setBitmap(null);
|
||||
|
||||
@@ -346,7 +360,7 @@ public final class Utilities {
|
||||
}
|
||||
|
||||
/**
|
||||
* Inverse of {@link #getDescendantCoordRelativeToSelf(View, int[])}.
|
||||
* Inverse of {@link #getDescendantCoordRelativeToParent(View, View, int[], boolean)}.
|
||||
*/
|
||||
public static float mapCoordInSelfToDescendent(View descendant, View root,
|
||||
int[] coord) {
|
||||
|
||||
Reference in New Issue
Block a user