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

Commit 10b106dc authored by Samuel Fufa's avatar Samuel Fufa Committed by Android (Google) Code Review
Browse files

Merge "Icon left side badging" into ub-launcher3-master

parents d1456473 a4431f8a
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ public class BaseIconFactory implements AutoCloseable {
    private final PackageManager mPm;
    private final ColorExtractor mColorExtractor;
    private boolean mDisableColorExtractor;
    private boolean mBadgeOnLeft = false;

    protected final int mFillResIconDpi;
    protected final int mIconBitmapSize;
@@ -77,6 +78,7 @@ public class BaseIconFactory implements AutoCloseable {
    protected void clear() {
        mWrapperBackgroundColor = DEFAULT_WRAPPER_BACKGROUND;
        mDisableColorExtractor = false;
        mBadgeOnLeft = false;
    }

    public ShadowGenerator getShadowGenerator() {
@@ -200,6 +202,13 @@ public class BaseIconFactory implements AutoCloseable {
                Math.min(scale[0], ShadowGenerator.getScaleForBounds(iconBounds)));
    }

    /**
     * Switches badging to left/right
     */
    public void setBadgeOnLeft(boolean badgeOnLeft) {
        mBadgeOnLeft = badgeOnLeft;
    }

    /**
     * Sets the background color used for wrapped adaptive icon
     */
@@ -261,8 +270,12 @@ public class BaseIconFactory implements AutoCloseable {
     */
    public void badgeWithDrawable(Canvas target, Drawable badge) {
        int badgeSize = getBadgeSizeForIconSize(mIconBitmapSize);
        if (mBadgeOnLeft) {
            badge.setBounds(0, mIconBitmapSize - badgeSize, badgeSize, mIconBitmapSize);
        } else {
            badge.setBounds(mIconBitmapSize - badgeSize, mIconBitmapSize - badgeSize,
                    mIconBitmapSize, mIconBitmapSize);
        }
        badge.draw(target);
    }