From a66d4f26ea22fd4c1655df409921b20cec1405ea Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Mon, 13 Mar 2023 22:35:55 +0100 Subject: [PATCH] Fix circle outline pattern not un-setting when removed --- .../src/main/kotlin/org/microg/gms/maps/mapbox/Pattern.kt | 8 ++++---- .../kotlin/org/microg/gms/maps/mapbox/model/Circle.kt | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/Pattern.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/Pattern.kt index 646a0906a..9cfd084a7 100644 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/Pattern.kt +++ b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/Pattern.kt @@ -18,7 +18,7 @@ fun PatternItem.getName(): String = when (this) { /** * Name of pattern, to identify it after it is added to map */ -fun MutableList.getName(color: Int, strokeWidth: Float) = joinToString("-") { +fun List.getName(color: Int, strokeWidth: Float) = joinToString("-") { it.getName() } + "-${color}-width${strokeWidth}" @@ -37,15 +37,15 @@ fun PatternItem.getWidth(strokeWidth: Float): Float = when (this) { * Gets width that a bitmap for this pattern would have if it were to be drawn * with respect to aspect ratio onto a canvas with height 1. */ -fun MutableList.getWidth(strokeWidth: Float) = map { it.getWidth(strokeWidth) }.sum() +fun List.getWidth(strokeWidth: Float) = map { it.getWidth(strokeWidth) }.sum() -fun MutableList.makeBitmap(color: Int, strokeWidth: Float): Bitmap = makeBitmap(Paint().apply { +fun List.makeBitmap(color: Int, strokeWidth: Float): Bitmap = makeBitmap(Paint().apply { setColor(color) style = Paint.Style.FILL }, strokeWidth) -fun MutableList.makeBitmap(paint: Paint, strokeWidth: Float): Bitmap { +fun List.makeBitmap(paint: Paint, strokeWidth: Float): Bitmap { // Pattern aspect ratio is not respected by renderer val width = getWidth(strokeWidth).toInt() diff --git a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Circle.kt b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Circle.kt index 2ff823667..93f3c1d32 100644 --- a/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Circle.kt +++ b/play-services-maps-core-mapbox/src/main/kotlin/org/microg/gms/maps/mapbox/model/Circle.kt @@ -21,6 +21,7 @@ import android.util.Log import com.google.android.gms.dynamic.IObjectWrapper import com.google.android.gms.dynamic.ObjectWrapper import com.google.android.gms.dynamic.unwrap +import com.google.android.gms.maps.model.Dash import com.google.android.gms.maps.model.LatLng import com.google.android.gms.maps.model.PatternItem import com.google.android.gms.maps.model.internal.ICircleDelegate @@ -284,8 +285,7 @@ class CircleImpl(private val map: GoogleMapImpl, private val id: String, options it.lineWidth = strokeWidth / map.dpiFactor - line.annotation?.linePattern = null - strokePattern?.let { pattern -> + (strokePattern ?: listOf(Dash(1f))).let { pattern -> val bitmapName = pattern.getName(strokeColor, strokeWidth) map.addBitmap(bitmapName, pattern.makeBitmap(strokeColor, strokeWidth)) line.annotation?.linePattern = bitmapName -- GitLab