From 81c97986fe49f97bb9053ff6ba81f4eb281480d9 Mon Sep 17 00:00:00 2001 From: John Seagull <149725024+thecreeper3326@users.noreply.github.com> Date: Sun, 20 Sep 2026 16:07:10 -0400 Subject: [PATCH 1/2] Title and author text is now ellipsized to prevent drawing outside of the island --- .../essentials/utils/IslandOverlayView.kt | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/sameerasw/essentials/utils/IslandOverlayView.kt b/app/src/main/java/com/sameerasw/essentials/utils/IslandOverlayView.kt index 2d58de4b5..4ad89457d 100644 --- a/app/src/main/java/com/sameerasw/essentials/utils/IslandOverlayView.kt +++ b/app/src/main/java/com/sameerasw/essentials/utils/IslandOverlayView.kt @@ -512,12 +512,12 @@ class IslandOverlayView(context: Context) : View(context) { } } - private val notificationSenderPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { + private val notificationSenderPaint = TextPaint(Paint.ANTI_ALIAS_FLAG).apply { color = Color.WHITE typeface = googleSansFlexTypeface ?: Typeface.create("sans-serif-medium", Typeface.NORMAL) } - private val notificationBodyPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { + private val notificationBodyPaint = TextPaint(Paint.ANTI_ALIAS_FLAG).apply { color = Color.WHITE typeface = googleSansFlexTypeface ?: Typeface.create("sans-serif", Typeface.NORMAL) } @@ -2682,20 +2682,34 @@ class IslandOverlayView(context: Context) : View(context) { canvas.restore() } + val maxWidth = (expandedWidthDp - 20) * density; notificationBodyPaint.alpha = contentAlpha notificationBodyPaint.textSize = m.titleTextSize notificationBodyPaint.textAlign = Paint.Align.CENTER val titleY = artRect.bottom + m.titleGap + m.titleTextSize - canvas.drawText(mediaTitle, pillCenterX, titleY, notificationBodyPaint) + val clippedTitle = TextUtils.ellipsize( + mediaTitle, + notificationBodyPaint, + maxWidth, + TextUtils.TruncateAt.END + ).toString() + canvas.drawText(clippedTitle, pillCenterX, titleY, notificationBodyPaint) notificationBodyPaint.textAlign = Paint.Align.LEFT notificationSenderPaint.alpha = contentAlpha notificationSenderPaint.textSize = m.artistTextSize notificationSenderPaint.textAlign = Paint.Align.CENTER val artistY = titleY + m.artistTextSize + m.artistGap - canvas.drawText(mediaArtist, pillCenterX, artistY, notificationSenderPaint) + val clippedArtist = TextUtils.ellipsize( + mediaArtist, + notificationSenderPaint, + maxWidth, + TextUtils.TruncateAt.END + ).toString() + canvas.drawText(clippedArtist, pillCenterX, artistY, notificationSenderPaint) notificationSenderPaint.textAlign = Paint.Align.LEFT + val progressY = artistY + m.progressGap wavyProgress.draw(canvas, pillLeft + 16f * density, progressY, pillRight - 16f * density, mediaProgressFraction, contentAlpha, playerAccentColor()) From 79bfbd6d8499aac8490b2fd5d23e4109d01ceaff Mon Sep 17 00:00:00 2001 From: John Seagull <149725024+thecreeper3326@users.noreply.github.com> Date: Mon, 21 Sep 2026 13:18:04 -0400 Subject: [PATCH 2/2] use marquee text instead of ellipses --- .../essentials/utils/IslandOverlayView.kt | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/sameerasw/essentials/utils/IslandOverlayView.kt b/app/src/main/java/com/sameerasw/essentials/utils/IslandOverlayView.kt index 4ad89457d..ad6a4b865 100644 --- a/app/src/main/java/com/sameerasw/essentials/utils/IslandOverlayView.kt +++ b/app/src/main/java/com/sameerasw/essentials/utils/IslandOverlayView.kt @@ -387,6 +387,8 @@ class IslandOverlayView(context: Context) : View(context) { private val leftMarquee = MarqueeController() private val rightMarquee = MarqueeController() + private val titleMarquee = MarqueeController() + private val artistMarquee = MarqueeController() private val marqueeFadePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { xfermode = PorterDuffXfermode(PorterDuff.Mode.DST_IN) } @@ -2683,31 +2685,20 @@ class IslandOverlayView(context: Context) : View(context) { } val maxWidth = (expandedWidthDp - 20) * density; + val mediaRevealFraction = mediaFraction * (1f - mediaCompactFraction); + val left = cameraCenterX - maxWidth/2; + val right = cameraCenterX + maxWidth/2; notificationBodyPaint.alpha = contentAlpha notificationBodyPaint.textSize = m.titleTextSize - notificationBodyPaint.textAlign = Paint.Align.CENTER val titleY = artRect.bottom + m.titleGap + m.titleTextSize - val clippedTitle = TextUtils.ellipsize( - mediaTitle, - notificationBodyPaint, - maxWidth, - TextUtils.TruncateAt.END - ).toString() - canvas.drawText(clippedTitle, pillCenterX, titleY, notificationBodyPaint) - notificationBodyPaint.textAlign = Paint.Align.LEFT + drawMarqueeText(canvas, mediaTitle, notificationBodyPaint, titleMarquee, left, right, mediaPillRect.top, mediaPillRect.bottom, false, height / 2f, mediaRevealFraction, alignTextToCenter = true) + notificationSenderPaint.alpha = contentAlpha notificationSenderPaint.textSize = m.artistTextSize - notificationSenderPaint.textAlign = Paint.Align.CENTER val artistY = titleY + m.artistTextSize + m.artistGap - val clippedArtist = TextUtils.ellipsize( - mediaArtist, - notificationSenderPaint, - maxWidth, - TextUtils.TruncateAt.END - ).toString() - canvas.drawText(clippedArtist, pillCenterX, artistY, notificationSenderPaint) - notificationSenderPaint.textAlign = Paint.Align.LEFT + drawMarqueeText(canvas, mediaArtist, notificationSenderPaint, artistMarquee, left, right, mediaPillRect.top + m.artistTextSize + m.artistGap, mediaPillRect.bottom + m.artistTextSize + m.artistGap, false, height / 2f, mediaRevealFraction, alignTextToCenter = true) + val progressY = artistY + m.progressGap @@ -3346,6 +3337,7 @@ class IslandOverlayView(context: Context) : View(context) { cornerRadius: Float, revealFraction: Float = animatedNotificationFraction, alignTextToEnd: Boolean = false, + alignTextToCenter : Boolean = false ) { val availableWidth = (clipRight - clipLeft).coerceAtLeast(10f * density) if (revealFraction >= 0.98f) { @@ -3409,7 +3401,9 @@ class IslandOverlayView(context: Context) : View(context) { canvas.save() val textClipRect = RectF(clipLeft, currentTop, clipRight, currentBottom) canvas.clipRect(textClipRect) - val textX = if (alignTextToEnd) (clipRight - paint.measureText(text) - 8f * density).coerceAtLeast(clipLeft) else clipLeft + var textX = if (alignTextToEnd) (clipRight - paint.measureText(text) - 8f * density).coerceAtLeast(clipLeft) else clipLeft + + if (alignTextToCenter) textX = clipLeft + ((availableWidth - paint.measureText(text)) / 2f).coerceAtLeast(0f) canvas.drawText(text, textX, textY, paint) canvas.restore() }