Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a66d4f26 authored by Fynn Godau's avatar Fynn Godau
Browse files

Fix circle outline pattern not un-setting when removed

parent 2776aee0
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ fun PatternItem.getName(): String = when (this) {
/**
 * Name of pattern, to identify it after it is added to map
 */
fun MutableList<PatternItem>.getName(color: Int, strokeWidth: Float) = joinToString("-") {
fun List<PatternItem>.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<PatternItem>.getWidth(strokeWidth: Float) = map { it.getWidth(strokeWidth) }.sum()
fun List<PatternItem>.getWidth(strokeWidth: Float) = map { it.getWidth(strokeWidth) }.sum()

fun MutableList<PatternItem>.makeBitmap(color: Int, strokeWidth: Float): Bitmap = makeBitmap(Paint().apply {
fun List<PatternItem>.makeBitmap(color: Int, strokeWidth: Float): Bitmap = makeBitmap(Paint().apply {
    setColor(color)
    style = Paint.Style.FILL
}, strokeWidth)


fun MutableList<PatternItem>.makeBitmap(paint: Paint, strokeWidth: Float): Bitmap {
fun List<PatternItem>.makeBitmap(paint: Paint, strokeWidth: Float): Bitmap {

    // Pattern aspect ratio is not respected by renderer
    val width = getWidth(strokeWidth).toInt()
+2 −2
Original line number Diff line number Diff line
@@ -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