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

Commit 0225efac authored by Jonathan Miranda's avatar Jonathan Miranda Committed by Android (Google) Code Review
Browse files

Merge "Update FloatingIconView to display PreloadIconDrawables during swipe...

Merge "Update FloatingIconView to display PreloadIconDrawables during swipe home animations." into sc-dev
parents 83cdd1e8 b40b98db
Loading
Loading
Loading
Loading
+54 −34
Original line number Diff line number Diff line
@@ -301,7 +301,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
        verifyHighRes();

        if ((info.runtimeStatusFlags & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) {
            applyProgressLevel(info.getProgressLevel());
            applyProgressLevel();
        }
        applyDotState(info, false /* animate */);
    }
@@ -603,21 +603,20 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
     * with the total download progress.
     */
    public void applyLoadingState(boolean promiseStateChanged) {
        if (getTag() instanceof WorkspaceItemInfo) {
        if (getTag() instanceof ItemInfoWithIcon) {
            WorkspaceItemInfo info = (WorkspaceItemInfo) getTag();
            int progressLevel = info.getProgressLevel();
            if ((info.runtimeStatusFlags & ItemInfoWithIcon.FLAG_INCREMENTAL_DOWNLOAD_ACTIVE)
                    != 0) {
                updateProgressBarUi(progressLevel, progressLevel == 100);
                updateProgressBarUi(info.getProgressLevel() == 100);
            } else if (info.hasPromiseIconUi() || (info.runtimeStatusFlags
                        & ItemInfoWithIcon.FLAG_INSTALL_SESSION_ACTIVE) != 0) {
                updateProgressBarUi(progressLevel, promiseStateChanged);
                updateProgressBarUi(promiseStateChanged);
            }
        }
    }

    private void updateProgressBarUi(int progressLevel, boolean maybePerformFinishedAnimation) {
        PreloadIconDrawable preloadDrawable = applyProgressLevel(progressLevel);
    private void updateProgressBarUi(boolean maybePerformFinishedAnimation) {
        PreloadIconDrawable preloadDrawable = applyProgressLevel();
        if (preloadDrawable != null && maybePerformFinishedAnimation) {
            preloadDrawable.maybePerformFinishedAnimation();
        }
@@ -625,9 +624,13 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,

    /** Applies the given progress level to the this icon's progress bar. */
    @Nullable
    public PreloadIconDrawable applyProgressLevel(int progressLevel) {
        if (getTag() instanceof ItemInfoWithIcon) {
    public PreloadIconDrawable applyProgressLevel() {
        if (!(getTag() instanceof ItemInfoWithIcon)) {
            return null;
        }

        ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
        int progressLevel = info.getProgressLevel();
        if (progressLevel >= 100) {
            setContentDescription(info.contentDescription != null
                    ? info.contentDescription : "");
@@ -640,23 +643,40 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
                    .getString(R.string.app_waiting_download_title, info.title));
        }
        if (mIcon != null) {
                final PreloadIconDrawable preloadDrawable;
            PreloadIconDrawable preloadIconDrawable;
            if (mIcon instanceof PreloadIconDrawable) {
                    preloadDrawable = (PreloadIconDrawable) mIcon;
                    preloadDrawable.setLevel(progressLevel);
                    preloadDrawable.setIsDisabled(!info.isAppStartable());
                preloadIconDrawable = (PreloadIconDrawable) mIcon;
                preloadIconDrawable.setLevel(progressLevel);
                preloadIconDrawable.setIsDisabled(!info.isAppStartable());
            } else {
                    preloadDrawable = newPendingIcon(getContext(), info);
                    preloadDrawable.setLevel(progressLevel);
                    preloadDrawable.setIsDisabled(!info.isAppStartable());
                    setIcon(preloadDrawable);
                preloadIconDrawable = makePreloadIcon();
                setIcon(preloadIconDrawable);
            }
                return preloadDrawable;
            return preloadIconDrawable;
        }
        return null;
    }

    /**
     * Creates a PreloadIconDrawable with the appropriate progress level without mutating this
     * object.
     */
    @Nullable
    public PreloadIconDrawable makePreloadIcon() {
        if (!(getTag() instanceof ItemInfoWithIcon)) {
            return null;
        }

        ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
        int progressLevel = info.getProgressLevel();
        final PreloadIconDrawable preloadDrawable = newPendingIcon(getContext(), info);

        preloadDrawable.setLevel(progressLevel);
        preloadDrawable.setIsDisabled(!info.isAppStartable());

        return preloadDrawable;
    }

    public void applyDotState(ItemInfo itemInfo, boolean animate) {
        if (mIcon instanceof FastBitmapDrawable) {
            boolean wasDotted = mDotInfo != null;
+3 −3
Original line number Diff line number Diff line
@@ -276,15 +276,15 @@ public class FastBitmapDrawable extends Drawable {

    @Override
    public ConstantState getConstantState() {
        return new MyConstantState(mBitmap, mIconColor, mIsDisabled);
        return new FastBitmapConstantState(mBitmap, mIconColor, mIsDisabled);
    }

    protected static class MyConstantState extends ConstantState {
    protected static class FastBitmapConstantState extends ConstantState {
        protected final Bitmap mBitmap;
        protected final int mIconColor;
        protected final boolean mIsDisabled;

        public MyConstantState(Bitmap bitmap, int color, boolean isDisabled) {
        public FastBitmapConstantState(Bitmap bitmap, int color, boolean isDisabled) {
            mBitmap = bitmap;
            mIconColor = color;
            mIsDisabled = isDisabled;
+1 −1
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ public class AllAppsStore {
    public void updateProgressBar(AppInfo app) {
        updateAllIcons((child) -> {
            if (child.getTag() == app) {
                child.applyProgressLevel(app.getProgressLevel());
                child.applyProgressLevel();
            }
        });
    }
+43 −1
Original line number Diff line number Diff line
@@ -105,6 +105,10 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
    private ObjectAnimator mCurrentAnim;

    public PreloadIconDrawable(ItemInfoWithIcon info, Context context) {
        this(info, IconPalette.getPreloadProgressColor(context, info.bitmap.color));
    }

    public PreloadIconDrawable(ItemInfoWithIcon info, int indicatorColor) {
        super(info.bitmap);
        mItem = info;
        mShapePath = getShapePath();
@@ -114,7 +118,7 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
        mProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
        mProgressPaint.setStyle(Paint.Style.STROKE);
        mProgressPaint.setStrokeCap(Paint.Cap.ROUND);
        mIndicatorColor = IconPalette.getPreloadProgressColor(context, mIconColor);
        mIndicatorColor = indicatorColor;

        setInternalProgress(0);

@@ -297,4 +301,42 @@ public class PreloadIconDrawable extends FastBitmapDrawable {
    public static PreloadIconDrawable newPendingIcon(Context context, ItemInfoWithIcon info) {
        return new PreloadIconDrawable(info, context);
    }

    @Override
    public ConstantState getConstantState() {
        return new PreloadIconConstantState(
                mBitmap, mIconColor, !mItem.isAppStartable(), mItem, mIndicatorColor);
    }

    protected static class PreloadIconConstantState extends FastBitmapConstantState {

        protected final ItemInfoWithIcon mInfo;
        protected final int mIndicatorColor;
        protected final int mLevel;

        public PreloadIconConstantState(
                Bitmap bitmap,
                int iconColor,
                boolean isDisabled,
                ItemInfoWithIcon info,
                int indicatorcolor) {
            super(bitmap, iconColor, isDisabled);
            mInfo = info;
            mIndicatorColor = indicatorcolor;
            mLevel = info.getProgressLevel();
        }

        @Override
        public PreloadIconDrawable newDrawable() {
            PreloadIconDrawable drawable = new PreloadIconDrawable(mInfo, mIndicatorColor);
            drawable.setLevel(mLevel);
            drawable.setIsDisabled(mIsDisabled);
            return drawable;
        }

        @Override
        public int getChangingConfigurations() {
            return 0;
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -308,7 +308,7 @@ public class ClockDrawableWrapper extends AdaptiveIconDrawable implements Bitmap
            return new ClockConstantState(mInfo, isDisabled());
        }

        private static class ClockConstantState extends MyConstantState {
        private static class ClockConstantState extends FastBitmapConstantState {

            private final ClockBitmapInfo mInfo;

Loading