Skip to content

Commit 2db6c8c

Browse files
Add language property to w3wmarker and update parcel serialization
# Conflicts: # lib-compose/src/main/java/com/what3words/components/compose/maps/models/W3WMarker.kt
1 parent 2a959b9 commit 2db6c8c

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

lib-compose/src/main/java/com/what3words/components/compose/maps/mapper/DomainModelConverter.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ fun W3WAddress.toW3WMarker(makerColor: W3WMarkerColor = MARKER_COLOR_DEFAULT): W
2121
words = this.words,
2222
square = this.square!!,
2323
color = makerColor,
24-
center = this.center!!
24+
center = this.center!!,
25+
language = this.language,
2526
)
2627
}
2728

lib-compose/src/main/java/com/what3words/components/compose/maps/models/W3WMarker.kt

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,8 @@ import androidx.compose.ui.graphics.Color
77
import androidx.compose.ui.graphics.toArgb
88
import com.what3words.core.types.geometry.W3WCoordinates
99
import com.what3words.core.types.geometry.W3WRectangle
10-
import kotlinx.serialization.KSerializer
11-
import kotlinx.serialization.Serializable
12-
import kotlinx.serialization.descriptors.PrimitiveKind
13-
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
14-
import kotlinx.serialization.descriptors.SerialDescriptor
15-
import kotlinx.serialization.encoding.Decoder
16-
import kotlinx.serialization.encoding.Encoder
10+
import com.what3words.core.types.language.W3WLanguage
11+
import com.what3words.core.types.language.W3WProprietaryLanguage
1712

1813
/**
1914
* Represents a marker on a map, associated with a what3words address.
@@ -31,6 +26,7 @@ data class W3WMarker(
3126
val square: W3WRectangle,
3227
val color: W3WMarkerColor,
3328
val center: W3WCoordinates,
29+
val language: W3WLanguage,
3430
val title: String? = null,
3531
val snippet: String? = null,
3632
val zoomOutScale: Float = 1f,
@@ -56,6 +52,7 @@ data class W3WMarker(
5652
parcel.readDouble(),
5753
parcel.readDouble()
5854
),
55+
W3WProprietaryLanguage(parcel.readString()!!, parcel.readString(), null, null),
5956
parcel.readString(),
6057
parcel.readString()
6158
)
@@ -96,12 +93,9 @@ data class W3WMarker(
9693
* @property slash The color of the slash in the marker.
9794
* @property id A unique identifier generated from the combination of background and slash colors.
9895
*/
99-
@Serializable
10096
@Immutable
10197
data class W3WMarkerColor(
102-
@Serializable(with = ColorSerializer::class)
10398
val background: Color,
104-
@Serializable(with = ColorSerializer::class)
10599
val slash: Color
106100
) {
107101
val id: Long
@@ -110,16 +104,4 @@ data class W3WMarkerColor(
110104
val slashLong = slash.toArgb().toLong() and 0xFFFFFFFFL
111105
return (backgroundLong shl 32) or slashLong
112106
}
113-
}
114-
115-
object ColorSerializer : KSerializer<Color> {
116-
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor("Color", PrimitiveKind.LONG)
117-
118-
override fun serialize(encoder: Encoder, value: Color) {
119-
encoder.encodeLong(value.value.toLong())
120-
}
121-
122-
override fun deserialize(decoder: Decoder): Color {
123-
return Color(decoder.decodeLong().toULong())
124-
}
125107
}

0 commit comments

Comments
 (0)