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

Commit 12655597 authored by Kshitij's avatar Kshitij
Browse files

Merge branch '2672os-t-fixtabletbadges' into 'v1-t'

fix: DotRenderer: Tune further for tablet

See merge request !14
parents 77c2cc0a 34f6e1ce
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ 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.28f;
    private static final float SIZE_PERCENTAGE_WITH_COUNT = 0.24f;

    // The max number to draw on dots
    private static final int MAX_COUNT = 999;
@@ -145,19 +145,22 @@ public class DotRenderer {

        // Ensure dot fits entirely in canvas clip bounds.
        Rect canvasBounds = canvas.getClipBounds();
        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 - (isTablet && !isTaskbar ? 15f : 0f);
        float dy = dotCenterY + offsetY - (isTablet ? 20f : 15f);

        if (numNotifications > 9 && numNotifications < 1000) {
            canvas.translate(dx - 17f, dy);
        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;
        float dx = mustNudge? mCircleRadius: dotCenterX;

        // Taskbar icons are too small and do not show the dot text.
        // We will displace the dot to the correct position.
        if (isTaskbar) {
            canvas.translate(dotCenterX - mCircleRadius, dotCenterY - mCircleRadius);
        } else if (numNotifications > 9 && numNotifications < 1000) {
            canvas.translate(dx - (mustNudge ? 12f : 17f), dotCenterY);
        } else if (numNotifications > 0) {
            canvas.translate(dx - 12f, dy);
            canvas.translate(dx - 12f, dotCenterY);
        }

        float scale = params.scale * (isTablet && !isTaskbar ? 0.75f : 1f);