Icon left side badging

Test: Manual
Bug:138947443
Change-Id: I8a7ce6e1cccfbfd6c2c6fad96768ab64cfdb41b1
This commit is contained in:
Samuel Fufa
2019-11-13 13:55:38 -08:00
parent a318b75cbd
commit a4431f8abe

View File

@@ -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);
badge.setBounds(mIconBitmapSize - badgeSize, mIconBitmapSize - badgeSize,
mIconBitmapSize, mIconBitmapSize);
if (mBadgeOnLeft) {
badge.setBounds(0, mIconBitmapSize - badgeSize, badgeSize, mIconBitmapSize);
} else {
badge.setBounds(mIconBitmapSize - badgeSize, mIconBitmapSize - badgeSize,
mIconBitmapSize, mIconBitmapSize);
}
badge.draw(target);
}