Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba3e7c0c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Support Vectors as frames of animation drawables in PointerIcon." into main

parents f440dacc 64ac8b12
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -480,11 +480,19 @@ public final class PointerIcon implements Parcelable {
                mBitmapFrames = new Bitmap[frames - 1];
                final int width = drawable.getIntrinsicWidth();
                final int height = drawable.getIntrinsicHeight();
                final boolean isVectorAnimation = drawable instanceof VectorDrawable;
                mDrawNativeDropShadow = isVectorAnimation;
                for (int i = 1; i < frames; ++i) {
                    Drawable drawableFrame = animationDrawable.getFrame(i);
                    if (!(drawableFrame instanceof BitmapDrawable)) {
                    if (!(drawableFrame instanceof BitmapDrawable)
                            && !(drawableFrame instanceof VectorDrawable)) {
                        throw new IllegalArgumentException("Frame of an animated pointer icon "
                                + "must refer to a bitmap drawable.");
                                + "must refer to a bitmap drawable or vector drawable.");
                    }
                    if (isVectorAnimation != (drawableFrame instanceof VectorDrawable)) {
                        throw new IllegalArgumentException("The drawable of the " + i + "-th frame "
                                + "is a different type from the others. All frames should be the "
                                + "same type.");
                    }
                    if (drawableFrame.getIntrinsicWidth() != width ||
                        drawableFrame.getIntrinsicHeight() != height) {
@@ -492,8 +500,11 @@ public final class PointerIcon implements Parcelable {
                                + "is different. All frames should have the exact same size and "
                                + "share the same hotspot.");
                    }
                    BitmapDrawable bitmapDrawableFrame = (BitmapDrawable) drawableFrame;
                    mBitmapFrames[i - 1] = getBitmapFromDrawable(bitmapDrawableFrame);
                    if (isVectorAnimation) {
                        drawableFrame = getBitmapDrawableFromVectorDrawable(resources,
                                (VectorDrawable) drawableFrame);
                    }
                    mBitmapFrames[i - 1] = getBitmapFromDrawable((BitmapDrawable) drawableFrame);
                }
            }
        }