88package de.afarber.openmapview
99
1010import android.content.Context
11+ import android.graphics.BlurMaskFilter
1112import android.graphics.Canvas
1213import android.graphics.Color
1314import android.graphics.Paint
@@ -26,21 +27,33 @@ class AttributionOverlay(
2627 private var attributionText = " © OpenStreetMap contributors"
2728 private var attributionUrl = " https://www.openstreetmap.org/copyright"
2829
30+ private val density = context.resources.displayMetrics.density
31+
2932 private val textPaint =
3033 TextPaint ().apply {
3134 color = Color .BLACK
32- textSize = 12f * context.resources.displayMetrics. density
35+ textSize = 12f * density
3336 isAntiAlias = true
3437 }
3538
39+ private val glowPaint =
40+ TextPaint ().apply {
41+ color = Color .WHITE
42+ textSize = 12f * density
43+ isAntiAlias = true
44+ maskFilter = BlurMaskFilter (5f * density, BlurMaskFilter .Blur .NORMAL )
45+ }
46+
3647 private val backgroundPaint =
3748 Paint ().apply {
3849 color = Color .argb(180 , 255 , 255 , 255 )
3950 style = Paint .Style .FILL
4051 }
4152
4253 private var textBounds = Rect ()
43- private val padding = (4 * context.resources.displayMetrics.density).toInt()
54+ private val padding = (4 * density).toInt()
55+
56+ var isGlowEnabled: Boolean = true
4457
4558 var onAttributionClickListener: (() -> Unit )? = null
4659
@@ -96,6 +109,9 @@ class AttributionOverlay(
96109 val textX = viewWidth - textWidth - padding
97110 val textY = viewHeight - padding
98111
112+ if (isGlowEnabled) {
113+ canvas.drawText(attributionText, textX.toFloat(), textY.toFloat(), glowPaint)
114+ }
99115 canvas.drawText(attributionText, textX.toFloat(), textY.toFloat(), textPaint)
100116 }
101117
0 commit comments