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..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) } @@ -512,12 +514,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,19 +2684,22 @@ class IslandOverlayView(context: Context) : View(context) { canvas.restore() } + 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 - canvas.drawText(mediaTitle, 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 - canvas.drawText(mediaArtist, 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 wavyProgress.draw(canvas, pillLeft + 16f * density, progressY, pillRight - 16f * density, mediaProgressFraction, contentAlpha, playerAccentColor()) @@ -3332,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) { @@ -3395,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() }