fix(YouTube - Swipe controls): Adjust the overlay text size (#4503)

This commit is contained in:
MarcaD 2025-02-25 15:34:37 +02:00 committed by GitHub
parent 576a8f48ab
commit 6dc4bf75e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,7 +18,7 @@ import kotlin.math.min
import kotlin.math.round import kotlin.math.round
/** /**
* Main overlay layout for displaying volume and brightness level with both circular and rectangular progress bars. * Main overlay layout for displaying volume and brightness level with both circular and horizontal progress bars.
*/ */
class SwipeControlsOverlayLayout( class SwipeControlsOverlayLayout(
context: Context, context: Context,
@ -69,7 +69,7 @@ class SwipeControlsOverlayLayout(
} }
addView(circularProgressView) addView(circularProgressView)
// Initialize rectangular progress bar // Initialize horizontal progress bar
val screenWidth = resources.displayMetrics.widthPixels val screenWidth = resources.displayMetrics.widthPixels
val layoutWidth = (screenWidth * 2 / 3).toInt() // 2/3 of screen width val layoutWidth = (screenWidth * 2 / 3).toInt() // 2/3 of screen width
horizontalProgressView = HorizontalProgressView( horizontalProgressView = HorizontalProgressView(
@ -152,10 +152,7 @@ class SwipeControlsOverlayLayout(
} }
/** /**
* Abstract base class for progress views to reduce code duplication. * Abstract base class for progress views.
*/
/**
* Abstract base class for progress views to reduce code duplication.
*/ */
abstract class AbstractProgressView( abstract class AbstractProgressView(
context: Context, context: Context,
@ -183,10 +180,9 @@ abstract class AbstractProgressView(
public val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { public val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
color = overlayTextColor color = overlayTextColor
textAlign = Paint.Align.CENTER textAlign = Paint.Align.CENTER
textSize = 30f // Can adjust based on need textSize = 40f // Can adjust based on need
} }
protected var progress = 0 protected var progress = 0
protected var maxProgress = 100 protected var maxProgress = 100
protected var displayText: String = "0" protected var displayText: String = "0"
@ -211,7 +207,7 @@ abstract class AbstractProgressView(
} }
/** /**
* Custom view for rendering a circular progress indicator with text and icon. * Custom view for rendering a circular progress indicator with icons and text.
*/ */
class CircularProgressView( class CircularProgressView(
context: Context, context: Context,
@ -235,7 +231,7 @@ class CircularProgressView(
private val rectF = RectF() private val rectF = RectF()
init { init {
textPaint.textSize = 40f // Override default text size for horizontal view textPaint.textSize = 40f // Override default text size for circular view
progressPaint.strokeWidth = 20f progressPaint.strokeWidth = 20f
fillBackgroundPaint.strokeWidth = 20f fillBackgroundPaint.strokeWidth = 20f
progressPaint.strokeCap = Paint.Cap.ROUND progressPaint.strokeCap = Paint.Cap.ROUND
@ -266,7 +262,7 @@ class CircularProgressView(
it.draw(canvas) it.draw(canvas)
} }
// If not in icon-only mode, draw the text inside the ring. // If not a minimal style mode, draw the text inside the ring.
if (!overlayShowOverlayMinimalStyle) { if (!overlayShowOverlayMinimalStyle) {
canvas.drawText(displayText, width / 2f, height / 2f + 60f, textPaint) canvas.drawText(displayText, width / 2f, height / 2f + 60f, textPaint)
} }
@ -300,7 +296,7 @@ class HorizontalProgressView(
private val padding = 40f private val padding = 40f
init { init {
textPaint.textSize = 30f // Override default text size for horizontal view textPaint.textSize = 36f // Override default text size for horizontal view
progressPaint.strokeWidth = 0f progressPaint.strokeWidth = 0f
progressPaint.strokeCap = Paint.Cap.BUTT progressPaint.strokeCap = Paint.Cap.BUTT
progressPaint.style = Paint.Style.FILL progressPaint.style = Paint.Style.FILL