Loading iconloaderlib/src/com/android/launcher3/icons/DotRenderer.java +37 −19 Original line number Diff line number Diff line Loading @@ -42,7 +42,8 @@ public class DotRenderer { // The dot size is defined as a percentage of the app icon size. private static final float SIZE_PERCENTAGE = 0.21f; private static final float SIZE_PERCENTAGE_WITH_COUNT = 0.24f; private static final float SIZE_PERCENTAGE_WITH_COUNT = 0.28f; private static final float SIZE_PERCENTAGE_WITH_COUNT_TABLET = 0.24f; // The max number to draw on dots private static final int MAX_COUNT = 999; Loading @@ -65,12 +66,12 @@ public class DotRenderer { private final boolean mDisplayCount; public DotRenderer(int iconSizePx, Path iconShapePath, int pathSize) { this(iconSizePx, iconShapePath, pathSize, false, null); this(iconSizePx, iconShapePath, pathSize, false, null, false); } public DotRenderer(int iconSizePx, Path iconShapePath, int pathSize, Boolean displayCount, Typeface typeface) { public DotRenderer(int iconSizePx, Path iconShapePath, int pathSize, Boolean displayCount, Typeface typeface, boolean isTablet) { mDisplayCount = displayCount; int size = Math.round((displayCount ? SIZE_PERCENTAGE_WITH_COUNT : SIZE_PERCENTAGE) * iconSizePx); int size = Math.round((displayCount ? (isTablet ? SIZE_PERCENTAGE_WITH_COUNT_TABLET : SIZE_PERCENTAGE_WITH_COUNT) : SIZE_PERCENTAGE) * iconSizePx); if (size <= 0) { size = MIN_DOT_SIZE; } Loading Loading @@ -146,11 +147,12 @@ public class DotRenderer { // Ensure dot fits entirely in canvas clip bounds. Rect canvasBounds = canvas.getClipBounds(); if (isTablet) { // We draw the dot relative to its center. float availableWidth = (float) (canvasBounds.width() - iconBounds.width()) / 2; // We check if the dot is too close to the edge of the screen and nudge it if necessary. boolean mustNudge = isTablet && availableWidth < mCircleRadius; boolean mustNudge = availableWidth < mCircleRadius; float dx = mustNudge ? mCircleRadius : dotCenterX; // Taskbar icons are too small and do not show the dot text. Loading @@ -162,6 +164,22 @@ public class DotRenderer { } else if (numNotifications > 0) { canvas.translate(dx - 12f, dotCenterY); } } else { float offsetX = params.leftAlign ? Math.max(0, canvasBounds.left - (dotCenterX + mBitmapOffset)) : Math.min(0, canvasBounds.right - (dotCenterX - mBitmapOffset)); float offsetY = Math.max(0, canvasBounds.top - (dotCenterY + mBitmapOffset)); // We draw the dot relative to its center. float dx = dotCenterX + offsetX; float dy = dotCenterY + offsetY - 15f; if (numNotifications > 9 && numNotifications < 1000) { canvas.translate(dx - 17f, dy); } else if (numNotifications > 0) { canvas.translate(dx - 12f, dy); } } float scale = params.scale * (isTablet && !isTaskbar ? 0.75f : 1f); canvas.scale(scale, scale); Loading Loading
iconloaderlib/src/com/android/launcher3/icons/DotRenderer.java +37 −19 Original line number Diff line number Diff line Loading @@ -42,7 +42,8 @@ public class DotRenderer { // The dot size is defined as a percentage of the app icon size. private static final float SIZE_PERCENTAGE = 0.21f; private static final float SIZE_PERCENTAGE_WITH_COUNT = 0.24f; private static final float SIZE_PERCENTAGE_WITH_COUNT = 0.28f; private static final float SIZE_PERCENTAGE_WITH_COUNT_TABLET = 0.24f; // The max number to draw on dots private static final int MAX_COUNT = 999; Loading @@ -65,12 +66,12 @@ public class DotRenderer { private final boolean mDisplayCount; public DotRenderer(int iconSizePx, Path iconShapePath, int pathSize) { this(iconSizePx, iconShapePath, pathSize, false, null); this(iconSizePx, iconShapePath, pathSize, false, null, false); } public DotRenderer(int iconSizePx, Path iconShapePath, int pathSize, Boolean displayCount, Typeface typeface) { public DotRenderer(int iconSizePx, Path iconShapePath, int pathSize, Boolean displayCount, Typeface typeface, boolean isTablet) { mDisplayCount = displayCount; int size = Math.round((displayCount ? SIZE_PERCENTAGE_WITH_COUNT : SIZE_PERCENTAGE) * iconSizePx); int size = Math.round((displayCount ? (isTablet ? SIZE_PERCENTAGE_WITH_COUNT_TABLET : SIZE_PERCENTAGE_WITH_COUNT) : SIZE_PERCENTAGE) * iconSizePx); if (size <= 0) { size = MIN_DOT_SIZE; } Loading Loading @@ -146,11 +147,12 @@ public class DotRenderer { // Ensure dot fits entirely in canvas clip bounds. Rect canvasBounds = canvas.getClipBounds(); if (isTablet) { // We draw the dot relative to its center. float availableWidth = (float) (canvasBounds.width() - iconBounds.width()) / 2; // We check if the dot is too close to the edge of the screen and nudge it if necessary. boolean mustNudge = isTablet && availableWidth < mCircleRadius; boolean mustNudge = availableWidth < mCircleRadius; float dx = mustNudge ? mCircleRadius : dotCenterX; // Taskbar icons are too small and do not show the dot text. Loading @@ -162,6 +164,22 @@ public class DotRenderer { } else if (numNotifications > 0) { canvas.translate(dx - 12f, dotCenterY); } } else { float offsetX = params.leftAlign ? Math.max(0, canvasBounds.left - (dotCenterX + mBitmapOffset)) : Math.min(0, canvasBounds.right - (dotCenterX - mBitmapOffset)); float offsetY = Math.max(0, canvasBounds.top - (dotCenterY + mBitmapOffset)); // We draw the dot relative to its center. float dx = dotCenterX + offsetX; float dy = dotCenterY + offsetY - 15f; if (numNotifications > 9 && numNotifications < 1000) { canvas.translate(dx - 17f, dy); } else if (numNotifications > 0) { canvas.translate(dx - 12f, dy); } } float scale = params.scale * (isTablet && !isTaskbar ? 0.75f : 1f); canvas.scale(scale, scale); Loading