Adding support for dynamic calendar and clock icons

Change-Id: Icdba34340a27a4f6dff7310d0bf9fd29aef1330c
This commit is contained in:
Sunny Goyal
2019-10-24 15:59:49 -07:00
parent 70d7860eae
commit 14168431bd
32 changed files with 1021 additions and 306 deletions

View File

@@ -20,6 +20,7 @@ import static com.android.launcher3.anim.Interpolators.ACCEL;
import static com.android.launcher3.anim.Interpolators.DEACCEL;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
@@ -35,6 +36,7 @@ import android.graphics.drawable.Drawable;
import android.util.Property;
import android.util.SparseArray;
import com.android.launcher3.graphics.PlaceHolderIconDrawable;
import com.android.launcher3.icons.BitmapInfo;
public class FastBitmapDrawable extends Drawable {
@@ -361,7 +363,7 @@ public class FastBitmapDrawable extends Drawable {
}
@Override
public Drawable newDrawable() {
public FastBitmapDrawable newDrawable() {
return new FastBitmapDrawable(mBitmap, mIconColor, mIsDisabled);
}
@@ -370,4 +372,37 @@ public class FastBitmapDrawable extends Drawable {
return 0;
}
}
/**
* Interface to be implemented by custom {@link BitmapInfo} to handle drawable construction
*/
public interface Factory {
/**
* Called to create a new drawable
*/
FastBitmapDrawable newDrawable();
}
/**
* Returns a FastBitmapDrawable with the icon.
*/
public static FastBitmapDrawable newIcon(Context context, ItemInfoWithIcon info) {
FastBitmapDrawable drawable = newIcon(context, info.bitmap);
drawable.setIsDisabled(info.isDisabled());
return drawable;
}
/**
* Creates a drawable for the provided BitmapInfo
*/
public static FastBitmapDrawable newIcon(Context context, BitmapInfo info) {
if (info instanceof Factory) {
return ((Factory) info).newDrawable();
} else if (info.isLowRes()) {
return new PlaceHolderIconDrawable(info, context);
} else {
return new FastBitmapDrawable(info);
}
}
}