Loading res/values/dimens.xml +4 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,10 @@ also happens to equal 19dp--> <dimen name="deep_shortcuts_arrow_horizontal_offset">19dp</dimen> <!-- Icon badges (with notification counts) --> <dimen name="badge_size">24dp</dimen> <dimen name="badge_text_size">12dp</dimen> <!-- Other --> <!-- Approximates the system status bar height. Not guaranteed to be always be correct. --> <dimen name="status_bar_height">24dp</dimen> Loading src/com/android/launcher3/BubbleTextView.java +13 −4 Original line number Diff line number Diff line Loading @@ -39,6 +39,8 @@ import android.widget.TextView; import com.android.launcher3.IconCache.IconLoadRequest; import com.android.launcher3.IconCache.ItemInfoUpdateReceiver; import com.android.launcher3.badge.BadgeRenderer; import com.android.launcher3.badge.BadgeInfo; import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.graphics.DrawableFactory; import com.android.launcher3.graphics.HolographicOutlineHelper; Loading Loading @@ -164,7 +166,7 @@ public class BubbleTextView extends TextView applyIconAndLabel(info.iconBitmap, info); setTag(info); if (promiseStateChanged || info.isPromise()) { applyState(promiseStateChanged); applyPromiseState(promiseStateChanged); } } Loading Loading @@ -470,7 +472,7 @@ public class BubbleTextView extends TextView mLongPressHelper.cancelLongPress(); } public void applyState(boolean promiseStateChanged) { public void applyPromiseState(boolean promiseStateChanged) { if (getTag() instanceof ShortcutInfo) { ShortcutInfo info = (ShortcutInfo) getTag(); final boolean isPromise = info.isPromise(); Loading Loading @@ -500,6 +502,13 @@ public class BubbleTextView extends TextView } } public void applyBadgeState(BadgeInfo badgeInfo) { if (mIcon instanceof FastBitmapDrawable) { BadgeRenderer badgeRenderer = mLauncher.getDeviceProfile().mBadgeRenderer; ((FastBitmapDrawable) mIcon).applyIconBadge(badgeInfo, badgeRenderer); } } private Theme getPreloaderTheme() { Object tag = getTag(); int style = ((tag != null) && (tag instanceof ShortcutInfo) && Loading src/com/android/launcher3/DeviceProfile.java +8 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ import android.view.ViewGroup.LayoutParams; import android.widget.FrameLayout; import com.android.launcher3.CellLayout.ContainerType; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.badge.BadgeRenderer; import java.util.ArrayList; Loading Loading @@ -136,6 +136,9 @@ public class DeviceProfile { // Listeners private ArrayList<LauncherLayoutChangeListener> mListeners = new ArrayList<>(); // Icon badges public BadgeRenderer mBadgeRenderer; public DeviceProfile(Context context, InvariantDeviceProfile inv, Point minSize, Point maxSize, int width, int height, boolean isLandscape) { Loading Loading @@ -193,6 +196,10 @@ public class DeviceProfile { hotseatBarBottomPaddingPx = 0; hotseatLandGutterPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_gutter_width); int badgeSize = res.getDimensionPixelSize(R.dimen.badge_size); int badgeTextSize = res.getDimensionPixelSize(R.dimen.badge_text_size); mBadgeRenderer = new BadgeRenderer(badgeSize, badgeTextSize); // Determine sizes. widthPx = width; heightPx = height; Loading src/com/android/launcher3/FastBitmapDrawable.java +30 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,10 @@ import android.graphics.drawable.Drawable; import android.util.SparseArray; import android.view.animation.DecelerateInterpolator; import com.android.launcher3.graphics.IconPalette; import com.android.launcher3.badge.BadgeRenderer; import com.android.launcher3.badge.BadgeInfo; public class FastBitmapDrawable extends Drawable { private static final float DISABLED_DESATURATION = 1f; private static final float DISABLED_BRIGHTNESS = 0.5f; Loading Loading @@ -99,6 +103,10 @@ public class FastBitmapDrawable extends Drawable { private State mState = State.NORMAL; private boolean mIsDisabled; private BadgeInfo mBadgeInfo; private BadgeRenderer mBadgeRenderer; private IconPalette mIconPalette; // The saturation and brightness are values that are mapped to REDUCED_FILTER_VALUE_SPACE and // as a result, can be used to compose the key for the cached ColorMatrixColorFilters private int mDesaturation = 0; Loading @@ -114,9 +122,21 @@ public class FastBitmapDrawable extends Drawable { setBounds(0, 0, b.getWidth(), b.getHeight()); } public void applyIconBadge(BadgeInfo badgeInfo, BadgeRenderer badgeRenderer) { mBadgeInfo = badgeInfo; mBadgeRenderer = badgeRenderer; if (mIconPalette == null) { mIconPalette = IconPalette.fromDominantColor(Utilities .findDominantColorByHue(mBitmap, 20)); } invalidateSelf(); } @Override public void draw(Canvas canvas) { drawInternal(canvas); // Draw the icon badge in the top right corner. drawBadgeIfNecessary(canvas); } public void drawWithBrightness(Canvas canvas, float brightness) { Loading @@ -130,6 +150,16 @@ public class FastBitmapDrawable extends Drawable { canvas.drawBitmap(mBitmap, null, getBounds(), mPaint); } protected void drawBadgeIfNecessary(Canvas canvas) { if (hasBadge()) { mBadgeRenderer.draw(canvas, mIconPalette, mBadgeInfo, getBounds()); } } private boolean hasBadge() { return mBadgeInfo != null && mBadgeInfo.getNotificationCount() != null; } @Override public void setColorFilter(ColorFilter cf) { // No op Loading src/com/android/launcher3/Utilities.java +1 −1 Original line number Diff line number Diff line Loading @@ -306,7 +306,7 @@ public final class Utilities { * @param bitmap The bitmap to scan * @param samples The approximate max number of samples to use. */ static int findDominantColorByHue(Bitmap bitmap, int samples) { public static int findDominantColorByHue(Bitmap bitmap, int samples) { final int height = bitmap.getHeight(); final int width = bitmap.getWidth(); int sampleStride = (int) Math.sqrt((height * width) / samples); Loading Loading
res/values/dimens.xml +4 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,10 @@ also happens to equal 19dp--> <dimen name="deep_shortcuts_arrow_horizontal_offset">19dp</dimen> <!-- Icon badges (with notification counts) --> <dimen name="badge_size">24dp</dimen> <dimen name="badge_text_size">12dp</dimen> <!-- Other --> <!-- Approximates the system status bar height. Not guaranteed to be always be correct. --> <dimen name="status_bar_height">24dp</dimen> Loading
src/com/android/launcher3/BubbleTextView.java +13 −4 Original line number Diff line number Diff line Loading @@ -39,6 +39,8 @@ import android.widget.TextView; import com.android.launcher3.IconCache.IconLoadRequest; import com.android.launcher3.IconCache.ItemInfoUpdateReceiver; import com.android.launcher3.badge.BadgeRenderer; import com.android.launcher3.badge.BadgeInfo; import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.graphics.DrawableFactory; import com.android.launcher3.graphics.HolographicOutlineHelper; Loading Loading @@ -164,7 +166,7 @@ public class BubbleTextView extends TextView applyIconAndLabel(info.iconBitmap, info); setTag(info); if (promiseStateChanged || info.isPromise()) { applyState(promiseStateChanged); applyPromiseState(promiseStateChanged); } } Loading Loading @@ -470,7 +472,7 @@ public class BubbleTextView extends TextView mLongPressHelper.cancelLongPress(); } public void applyState(boolean promiseStateChanged) { public void applyPromiseState(boolean promiseStateChanged) { if (getTag() instanceof ShortcutInfo) { ShortcutInfo info = (ShortcutInfo) getTag(); final boolean isPromise = info.isPromise(); Loading Loading @@ -500,6 +502,13 @@ public class BubbleTextView extends TextView } } public void applyBadgeState(BadgeInfo badgeInfo) { if (mIcon instanceof FastBitmapDrawable) { BadgeRenderer badgeRenderer = mLauncher.getDeviceProfile().mBadgeRenderer; ((FastBitmapDrawable) mIcon).applyIconBadge(badgeInfo, badgeRenderer); } } private Theme getPreloaderTheme() { Object tag = getTag(); int style = ((tag != null) && (tag instanceof ShortcutInfo) && Loading
src/com/android/launcher3/DeviceProfile.java +8 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ import android.view.ViewGroup.LayoutParams; import android.widget.FrameLayout; import com.android.launcher3.CellLayout.ContainerType; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.badge.BadgeRenderer; import java.util.ArrayList; Loading Loading @@ -136,6 +136,9 @@ public class DeviceProfile { // Listeners private ArrayList<LauncherLayoutChangeListener> mListeners = new ArrayList<>(); // Icon badges public BadgeRenderer mBadgeRenderer; public DeviceProfile(Context context, InvariantDeviceProfile inv, Point minSize, Point maxSize, int width, int height, boolean isLandscape) { Loading Loading @@ -193,6 +196,10 @@ public class DeviceProfile { hotseatBarBottomPaddingPx = 0; hotseatLandGutterPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_gutter_width); int badgeSize = res.getDimensionPixelSize(R.dimen.badge_size); int badgeTextSize = res.getDimensionPixelSize(R.dimen.badge_text_size); mBadgeRenderer = new BadgeRenderer(badgeSize, badgeTextSize); // Determine sizes. widthPx = width; heightPx = height; Loading
src/com/android/launcher3/FastBitmapDrawable.java +30 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,10 @@ import android.graphics.drawable.Drawable; import android.util.SparseArray; import android.view.animation.DecelerateInterpolator; import com.android.launcher3.graphics.IconPalette; import com.android.launcher3.badge.BadgeRenderer; import com.android.launcher3.badge.BadgeInfo; public class FastBitmapDrawable extends Drawable { private static final float DISABLED_DESATURATION = 1f; private static final float DISABLED_BRIGHTNESS = 0.5f; Loading Loading @@ -99,6 +103,10 @@ public class FastBitmapDrawable extends Drawable { private State mState = State.NORMAL; private boolean mIsDisabled; private BadgeInfo mBadgeInfo; private BadgeRenderer mBadgeRenderer; private IconPalette mIconPalette; // The saturation and brightness are values that are mapped to REDUCED_FILTER_VALUE_SPACE and // as a result, can be used to compose the key for the cached ColorMatrixColorFilters private int mDesaturation = 0; Loading @@ -114,9 +122,21 @@ public class FastBitmapDrawable extends Drawable { setBounds(0, 0, b.getWidth(), b.getHeight()); } public void applyIconBadge(BadgeInfo badgeInfo, BadgeRenderer badgeRenderer) { mBadgeInfo = badgeInfo; mBadgeRenderer = badgeRenderer; if (mIconPalette == null) { mIconPalette = IconPalette.fromDominantColor(Utilities .findDominantColorByHue(mBitmap, 20)); } invalidateSelf(); } @Override public void draw(Canvas canvas) { drawInternal(canvas); // Draw the icon badge in the top right corner. drawBadgeIfNecessary(canvas); } public void drawWithBrightness(Canvas canvas, float brightness) { Loading @@ -130,6 +150,16 @@ public class FastBitmapDrawable extends Drawable { canvas.drawBitmap(mBitmap, null, getBounds(), mPaint); } protected void drawBadgeIfNecessary(Canvas canvas) { if (hasBadge()) { mBadgeRenderer.draw(canvas, mIconPalette, mBadgeInfo, getBounds()); } } private boolean hasBadge() { return mBadgeInfo != null && mBadgeInfo.getNotificationCount() != null; } @Override public void setColorFilter(ColorFilter cf) { // No op Loading
src/com/android/launcher3/Utilities.java +1 −1 Original line number Diff line number Diff line Loading @@ -306,7 +306,7 @@ public final class Utilities { * @param bitmap The bitmap to scan * @param samples The approximate max number of samples to use. */ static int findDominantColorByHue(Bitmap bitmap, int samples) { public static int findDominantColorByHue(Bitmap bitmap, int samples) { final int height = bitmap.getHeight(); final int width = bitmap.getWidth(); int sampleStride = (int) Math.sqrt((height * width) / samples); Loading