From a4431f8abe9cf69acd2ce593e0e352ebd845c8f9 Mon Sep 17 00:00:00 2001 From: Samuel Fufa Date: Wed, 13 Nov 2019 13:55:38 -0800 Subject: [PATCH] Icon left side badging Test: Manual Bug:138947443 Change-Id: I8a7ce6e1cccfbfd6c2c6fad96768ab64cfdb41b1 --- .../launcher3/icons/BaseIconFactory.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java index 535c5d8296..8bd9dba1f9 100644 --- a/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java +++ b/iconloaderlib/src/com/android/launcher3/icons/BaseIconFactory.java @@ -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); }