diff --git a/ChoiceSDK/build.gradle b/ChoiceSDK/build.gradle index 0b28983..4078078 100644 --- a/ChoiceSDK/build.gradle +++ b/ChoiceSDK/build.gradle @@ -8,9 +8,9 @@ buildscript { } project.ext.buildNumber = buildNumber - project.ext.sdkVersionName = "0.1.5" + project.ext.sdkVersionName = "0.1.6" project.ext.appVersionName = "${project.sdkVersionName}.${project.buildNumber}" - project.ext.versionCode = 6 + project.ext.versionCode = 7 project.ext.groupId = "at.bluesource.choicesdk" ext.kotlin_version = "1.4.32" diff --git a/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/map/MapActivity.kt b/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/map/MapActivity.kt index ef3fa85..fa4c2c0 100644 --- a/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/map/MapActivity.kt +++ b/ChoiceSDK/choicesdk-app/src/main/java/com/bluesource/choicesdk_app/map/MapActivity.kt @@ -1,6 +1,7 @@ package com.bluesource.choicesdk_app.map import android.Manifest +import android.annotation.SuppressLint import android.content.Context import android.content.pm.PackageManager import android.graphics.Color @@ -28,18 +29,9 @@ import io.reactivex.rxjava3.observers.DisposableObserver class MapActivity : AppCompatActivity() { - private val TAG = "Test" private lateinit var mapDisposable: Disposable private lateinit var mapFragment: MapFragment - private val PERMISSIONS = arrayOf( - Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.ACCESS_COARSE_LOCATION, - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.INTERNET - ) - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_map) @@ -51,7 +43,7 @@ class MapActivity : AppCompatActivity() { fragmentTransaction.add(R.id.mapContainer, mapFragment) fragmentTransaction.commit() - if (!hasPermissions(this, PERMISSIONS)) { + if (!hasPermissions(this)) { ActivityCompat.requestPermissions(this, PERMISSIONS, 3) } else { testMap() @@ -75,9 +67,9 @@ class MapActivity : AppCompatActivity() { } } - private fun hasPermissions(context: Context, permissions: Array): Boolean { + private fun hasPermissions(context: Context): Boolean { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - for (permission in permissions) { + for (permission in PERMISSIONS) { if (ActivityCompat.checkSelfPermission( context, permission @@ -168,7 +160,7 @@ class MapActivity : AppCompatActivity() { ) map.addCircle( - Circle.CircleOptions() + CircleOptions() .center(location) .radius(100.0) .fillColor(Color.YELLOW) @@ -185,7 +177,7 @@ class MapActivity : AppCompatActivity() { map.addPolyline( PolylineOptions() .add(location2, location3) - .strokeWidth(15f) + .width(15f) .startCap(Cap.RoundCap()) .endCap( Cap.CustomCap( @@ -204,7 +196,6 @@ class MapActivity : AppCompatActivity() { .fillColor(Color.RED) .strokeColor(Color.GREEN) .strokeWidth(3f) - .addHole(listOf(locationHole1, location6)) ) map.addMarker( @@ -311,6 +302,7 @@ class MapActivity : AppCompatActivity() { return null } + @SuppressLint("SetTextI18n") override fun getInfoWindow(marker: Marker?): View { val view: View = layoutInflater.inflate(R.layout.infow_window_layout, null) @@ -331,4 +323,16 @@ class MapActivity : AppCompatActivity() { super.onDestroy() mapDisposable.dispose() } + + companion object { + private const val TAG = "MapActivity" + + private val PERMISSIONS = arrayOf( + Manifest.permission.WRITE_EXTERNAL_STORAGE, + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.ACCESS_FINE_LOCATION, + Manifest.permission.INTERNET + ) + } } \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/Map.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/Map.kt index 3be2f42..39dfd07 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/Map.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/Map.kt @@ -62,7 +62,7 @@ interface Map { * Other */ @Throws(ApiException::class) - fun addCircle(options: Circle.CircleOptions): Circle + fun addCircle(options: CircleOptions): Circle fun addGroundOverlay(options: GroundOverlayOptions) fun addMarker(options: MarkerOptions): Marker fun addPolygon(options: PolygonOptions): Polygon diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/PatternItem.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/PatternItem.kt index 7ae3d62..ad96321 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/PatternItem.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/PatternItem.kt @@ -37,11 +37,11 @@ sealed class PatternItem { */ class Dot : PatternItem() { companion object { - internal fun toGmsDot(): com.google.android.gms.maps.model.Dot { + internal fun Dot.toGmsDot(): com.google.android.gms.maps.model.Dot { return com.google.android.gms.maps.model.Dot() } - internal fun toHmsDot(): com.huawei.hms.maps.model.Dot { + internal fun Dot.toHmsDot(): com.huawei.hms.maps.model.Dot { return com.huawei.hms.maps.model.Dot() } } @@ -75,10 +75,19 @@ sealed class PatternItem { } } + internal fun com.huawei.hms.maps.model.PatternItem.toChoice(): PatternItem { + return when (this) { + is com.huawei.hms.maps.model.Dash -> Dash(length = this.length) + is com.huawei.hms.maps.model.Dot -> Dot() + is com.huawei.hms.maps.model.Gap -> Gap(length = this.length) + else -> throw IllegalArgumentException("No implementation provided for PatternItem of type: ${this.javaClass}") + } + } + internal fun PatternItem.toGmsPatternItem(): com.google.android.gms.maps.model.PatternItem { return when (this) { is Dash -> this.toGmsDash() - is Dot -> toGmsDot() + is Dot -> this.toGmsDot() is Gap -> this.toGmsGap() } } @@ -86,7 +95,7 @@ sealed class PatternItem { internal fun PatternItem.toHmsPatternItem(): com.huawei.hms.maps.model.PatternItem { return when (this) { is Dash -> this.toHmsDash() - is Dot -> toHmsDot() + is Dot -> this.toHmsDot() is Gap -> this.toHmsGap() } } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/Circle.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/Circle.kt index 74c6291..2c01723 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/Circle.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/Circle.kt @@ -3,111 +3,27 @@ package at.bluesource.choicesdk.maps.common.shape import at.bluesource.choicesdk.maps.common.LatLng -import at.bluesource.choicesdk.maps.common.LatLng.Companion.toGmsLatLng -import at.bluesource.choicesdk.maps.common.LatLng.Companion.toHmsLatLng import at.bluesource.choicesdk.maps.common.PatternItem -import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toGmsPatternItem -import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toHmsPatternItem import at.bluesource.choicesdk.maps.gms.shape.GmsCircle import at.bluesource.choicesdk.maps.hms.shape.HmsCircle /** * A circle on the earth's surface (spherical cap). */ -interface Circle : Shape { +interface Circle { + val id: String var center: LatLng - var radius: Double + var clickable: Boolean var fillColor: Int - - /** - * Defines options for a [Circle]. - * Use this Builder to add a circle to the map. - */ - class CircleOptions : ShapeOptions() { - private var center: LatLng = LatLng(0.0, 0.0) - private var fillColor: Int = 0x00000000 // transparent - private var radius = 1.0 - private var pattern: List = listOf() - - fun center(center: LatLng): CircleOptions { - this.center = center - return this - } - - fun fillColor(color: Int): CircleOptions { - fillColor = color - return this - } - - fun radius(radius: Double): CircleOptions { - this.radius = radius - return this - } - - fun strokePattern(pattern: List): CircleOptions { - this.pattern = pattern - return this - } - - override fun clickable(clickable: Boolean): CircleOptions { - super.clickable(clickable) - return this - } - - override fun strokeColor(color: Int): CircleOptions { - super.strokeColor(color) - return this - } - - override fun strokeWidth(widthInPx: Float): CircleOptions { - super.strokeWidth(widthInPx) - return this - } - - override fun visible(visible: Boolean): CircleOptions { - super.visible(visible) - return this - } - - override fun zIndex(zIndex: Float): CircleOptions { - super.zIndex(zIndex) - return this - } - - companion object { - internal fun CircleOptions.toGmsCircleOptions(): com.google.android.gms.maps.model.CircleOptions { - val co = com.google.android.gms.maps.model.CircleOptions() - .center(center.toGmsLatLng()) - .clickable(clickable) - .fillColor(fillColor) - .radius(radius) - .strokeColor(strokeColor) - .strokeWidth(strokeWidthInPx) - .visible(visible) - .zIndex(zIndex) - .strokePattern(pattern.map { it.toGmsPatternItem() }) - - // special case since gms does not draw anything if the list is empty - if (pattern.isNotEmpty()) { - co.strokePattern(pattern.map { it.toGmsPatternItem() }) - } - return co - } - - internal fun CircleOptions.toHmsCircleOptions(): com.huawei.hms.maps.model.CircleOptions { - return com.huawei.hms.maps.model.CircleOptions() - .center(center.toHmsLatLng()) - .clickable(clickable) - .fillColor(fillColor) - .radius(radius) - .strokeColor(strokeColor) - .strokeWidth(strokeWidthInPx) - .visible(visible) - .zIndex(zIndex) - .strokePattern(pattern.map { it.toHmsPatternItem() }) - } - } - } + var radius: Double + var strokeColor: Int + var strokePattern: List + var strokeWidth: Float + var tag: Any? + var visible: Boolean + var zIndex: Float + + fun remove() companion object { internal fun com.google.android.gms.maps.model.Circle.toChoiceCircle(): Circle { diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/CircleOptions.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/CircleOptions.kt new file mode 100644 index 0000000..61bddba --- /dev/null +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/CircleOptions.kt @@ -0,0 +1,102 @@ +package at.bluesource.choicesdk.maps.common.shape + +import at.bluesource.choicesdk.maps.common.LatLng +import at.bluesource.choicesdk.maps.common.LatLng.Companion.toGmsLatLng +import at.bluesource.choicesdk.maps.common.LatLng.Companion.toHmsLatLng +import at.bluesource.choicesdk.maps.common.PatternItem +import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toGmsPatternItem +import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toHmsPatternItem + +/** + * Defines options for a [Circle]. + * Use this Builder to add a circle to the map. + */ +class CircleOptions { + private var center: LatLng = LatLng(0.0, 0.0) + private var clickable = false + private var fillColor: Int = 0x00000000 // transparent + private var radius = 1.0 + private var strokeColor: Int = 0xff000000.toInt() // black, also toInt workaround for compiler issue: https://youtrack.jetbrains.com/issue/KT-4749 + private var strokePattern: List = listOf() + private var strokeWidth: Float = 10f + private var visible = true + private var zIndex: Float = 0f + + fun center(center: LatLng): CircleOptions { + this.center = center + return this + } + + fun clickable(clickable: Boolean): CircleOptions { + this.clickable = clickable + return this + } + + fun fillColor(color: Int): CircleOptions { + this.fillColor = color + return this + } + + fun radius(radius: Double): CircleOptions { + this.radius = radius + return this + } + + fun strokeColor(color: Int): CircleOptions { + this.strokeColor = color + return this + } + + fun strokePattern(pattern: List): CircleOptions { + this.strokePattern = pattern + return this + } + + fun strokeWidth(width: Float): CircleOptions { + this.strokeWidth = width + return this + } + + fun visible(visible: Boolean): CircleOptions { + this.visible = visible + return this + } + + fun zIndex(zIndex: Float): CircleOptions { + this.zIndex = zIndex + return this + } + + companion object { + internal fun CircleOptions.toGmsCircleOptions(): com.google.android.gms.maps.model.CircleOptions { + val co = com.google.android.gms.maps.model.CircleOptions() + .center(center.toGmsLatLng()) + .clickable(clickable) + .fillColor(fillColor) + .radius(radius) + .strokeColor(strokeColor) + .strokeWidth(strokeWidth) + .visible(visible) + .zIndex(zIndex) + + // special case since gms does not draw anything if the list is empty + if (strokePattern.isNotEmpty()) { + co.strokePattern(strokePattern.map { it.toGmsPatternItem() }) + } + return co + } + + internal fun CircleOptions.toHmsCircleOptions(): com.huawei.hms.maps.model.CircleOptions { + return com.huawei.hms.maps.model.CircleOptions() + .center(center.toHmsLatLng()) + .clickable(clickable) + .fillColor(fillColor) + .radius(radius) + .strokeColor(strokeColor) + .strokeWidth(strokeWidth) + .visible(visible) + .zIndex(zIndex) + .strokePattern(strokePattern.map { it.toHmsPatternItem() }) + } + } +} \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/Polygon.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/Polygon.kt index c602af0..9f06955 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/Polygon.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/Polygon.kt @@ -3,6 +3,7 @@ package at.bluesource.choicesdk.maps.common.shape import at.bluesource.choicesdk.maps.common.LatLng +import at.bluesource.choicesdk.maps.common.PatternItem import at.bluesource.choicesdk.maps.gms.shape.GmsPolygon import at.bluesource.choicesdk.maps.hms.shape.HmsPolygon @@ -10,13 +11,20 @@ import at.bluesource.choicesdk.maps.hms.shape.HmsPolygon * A polygon on the earth's surface. A polygon can be convex or concave, it may span the * 180 meridian and it can have holes that are not filled in. */ -interface Polygon : Shape { - - val linePoints: List - val lineHoles: List> +interface Polygon { + val id: String + var clickable: Boolean var fillColor: Int var geodesic: Boolean + var holes: List> + var points: List + var strokeColor: Int var strokeJointType: Int + var strokePattern: List + var strokeWidth: Float + var tag: Any? + var visible: Boolean + var zIndex: Float fun remove() diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/PolygonOptions.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/PolygonOptions.kt index 298d832..08baecf 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/PolygonOptions.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/PolygonOptions.kt @@ -13,54 +13,56 @@ import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toHmsPatternIte * Defines options for a [Polygon]. * Use this Builder to add a polygon to the map. */ -class PolygonOptions : ShapeOptions() { - private val linePoints: MutableList = mutableListOf() - internal val lineHoles: MutableList = mutableListOf() +class PolygonOptions { + private val holes: MutableList = mutableListOf() + private val points: MutableList = mutableListOf() + private var clickable = false private var fillColor: Int = 0x00000000 // transparent - var isGeodesic: Boolean = false - private set + private var geodesic: Boolean = false + private var strokeColor: Int = 0xff000000.toInt() // black, also toInt workaround for compiler issue: https://youtrack.jetbrains.com/issue/KT-4749 private var strokeJointType: Int = Polygon.DEFAULT - private var pattern: List = listOf() + private var strokePattern: List = listOf() + private var strokeWidth: Float = 10f + private var visible = true + private var zIndex: Float = 0f fun add(vararg points: LatLng): PolygonOptions { - linePoints.addAll(points) + this.points.addAll(points) return this } fun add(point: LatLng): PolygonOptions { - linePoints.add(point) + this.points.add(point) return this } fun addAll(points: Iterable): PolygonOptions { - linePoints.addAll(points) + this.points.addAll(points) return this } fun addHole(points: Iterable): PolygonOptions { - lineHoles.addAll(points) + this.holes.addAll(points) return this } - fun fillColor(color: Int): PolygonOptions { - fillColor = color + fun clickable(clickable: Boolean): PolygonOptions { + this.clickable = clickable return this } - fun geodesic(geodesic: Boolean): PolygonOptions { - this.isGeodesic = geodesic + fun fillColor(color: Int): PolygonOptions { + this.fillColor = color return this } - fun strokeType(type: Int): PolygonOptions { - when (type) { - in listOf(Polygon.BEVEL, Polygon.DEFAULT, Polygon.ROUND) -> strokeJointType = type - } + fun geodesic(geodesic: Boolean): PolygonOptions { + this.geodesic = geodesic return this } - fun strokePattern(pattern: List): PolygonOptions { - this.pattern = pattern + fun strokeColor(color: Int): PolygonOptions { + this.strokeColor = color return this } @@ -69,33 +71,35 @@ class PolygonOptions : ShapeOptions() { return this } - fun getPointsForGms(): List { - return linePoints.map { it.toGmsLatLng() } + fun strokePattern(pattern: List): PolygonOptions { + this.strokePattern = pattern + return this } - override fun clickable(clickable: Boolean): PolygonOptions { - super.clickable(clickable) + fun strokeWidth(width: Float): PolygonOptions { + this.strokeWidth = width return this } - override fun strokeColor(color: Int): PolygonOptions { - super.strokeColor(color) + fun visible(visible: Boolean): PolygonOptions { + this.visible = visible return this } - override fun strokeWidth(widthInPx: Float): PolygonOptions { - super.strokeWidth(widthInPx) + fun zIndex(zIndex: Float): PolygonOptions { + this.zIndex = zIndex return this } - override fun visible(visible: Boolean): PolygonOptions { - super.visible(visible) + fun strokeType(type: Int): PolygonOptions { + when (type) { + in listOf(Polygon.BEVEL, Polygon.DEFAULT, Polygon.ROUND) -> strokeJointType = type + } return this } - override fun zIndex(zIndex: Float): PolygonOptions { - super.zIndex(zIndex) - return this + fun getPointsForGms(): List { + return points.map { it.toGmsLatLng() } } companion object { @@ -103,65 +107,63 @@ class PolygonOptions : ShapeOptions() { @JvmStatic fun com.google.android.gms.maps.model.PolygonOptions.toChoice(): PolygonOptions { - val linePoints: List = this.points.map { it.toChoiceLatLng() } - val pattern: List = this.strokePattern.orEmpty().map { it.toChoice() } - val mappedHoles: List> = this.holes.map { hole -> hole.map { it.toChoiceLatLng() } } + val holes: List> = this.holes.map { hole -> hole.map { it.toChoiceLatLng() } } val options = PolygonOptions() - .clickable(isClickable) - .fillColor(fillColor) - .strokeColor(strokeColor) - .strokeWidth(strokeWidth) - .visible(isVisible) - .zIndex(zIndex) - .addAll(linePoints) - .geodesic(isGeodesic) - .strokeJointType(strokeJointType) - .strokePattern(pattern) - - mappedHoles.forEach { hole -> options.addHole(hole) } + .clickable(isClickable) + .fillColor(fillColor) + .geodesic(isGeodesic) + .strokeColor(strokeColor) + .strokeJointType(strokeJointType) + .strokePattern(strokePattern.orEmpty().map { it.toChoice() }) + .strokeWidth(strokeWidth) + .visible(isVisible) + .zIndex(zIndex) + + options.addAll(points.map { it.toChoiceLatLng() }) + holes.forEach { hole -> options.addHole(hole) } return options } internal fun PolygonOptions.toGmsPolygonOptions(): com.google.android.gms.maps.model.PolygonOptions { val po = com.google.android.gms.maps.model.PolygonOptions() - .clickable(clickable) - .fillColor(fillColor) - .strokeColor(strokeColor) - .strokeWidth(strokeWidthInPx) - .visible(visible) - .zIndex(zIndex) - .addAll(linePoints.map { it.toGmsLatLng() }) - .geodesic(isGeodesic) - .strokeJointType(strokeJointType) + .clickable(clickable) + .fillColor(fillColor) + .geodesic(geodesic) + .strokeColor(strokeColor) + .strokeJointType(strokeJointType) + .strokeWidth(strokeWidth) + .visible(visible) + .zIndex(zIndex) + po.addAll(points.map { it.toGmsLatLng() }) // special case since gms adds an empty hole if list is empty // which leads to an ApiException - if (lineHoles.size > 0) { - po.addHole(lineHoles.map { it.toGmsLatLng() }) + if (holes.size > 0) { + po.addHole(holes.map { it.toGmsLatLng() }) } - - if (pattern.isNotEmpty()) { - po.strokePattern(pattern.map { it.toGmsPatternItem() }) + if (strokePattern.isNotEmpty()) { + po.strokePattern(strokePattern.map { it.toGmsPatternItem() }) } + return po } internal fun PolygonOptions.toHmsPolygonOptions(): com.huawei.hms.maps.model.PolygonOptions { return com.huawei.hms.maps.model.PolygonOptions() - .clickable(clickable) - .fillColor(fillColor) - .strokeColor(strokeColor) - .strokeWidth(strokeWidthInPx) - .visible(visible) - .zIndex(zIndex) - .addAll(linePoints.map { it.toHmsLatLng() }) - .addHole(lineHoles.map { it.toHmsLatLng() }) - .geodesic(isGeodesic) - .strokeJointType(strokeJointType) - .strokePattern(pattern.map { it.toHmsPatternItem() }) + .clickable(clickable) + .fillColor(fillColor) + .geodesic(geodesic) + .strokeColor(strokeColor) + .strokeJointType(strokeJointType) + .strokePattern(strokePattern.map { it.toHmsPatternItem() }) + .strokeWidth(strokeWidth) + .visible(visible) + .zIndex(zIndex) + .addAll(points.map { it.toHmsLatLng() }) + .addHole(holes.map { it.toHmsLatLng() }) } } } \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/Polyline.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/Polyline.kt index b261a83..8f55605 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/Polyline.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/Polyline.kt @@ -3,6 +3,7 @@ package at.bluesource.choicesdk.maps.common.shape import at.bluesource.choicesdk.maps.common.LatLng +import at.bluesource.choicesdk.maps.common.PatternItem import at.bluesource.choicesdk.maps.gms.shape.GmsPolyline import at.bluesource.choicesdk.maps.hms.shape.HmsPolyline @@ -11,11 +12,20 @@ import at.bluesource.choicesdk.maps.hms.shape.HmsPolyline * When a polyline is returned, the custom start and end cap bitmap id's are always -1 * In order to set a new cap use the designated get/set methods of polyline caps to set a new CustomCap */ -interface Polyline : Shape { - val linePoints: List +interface Polyline { + val id: String + var clickable: Boolean + var color: Int + var endCap: Cap var geodesic: Boolean + var jointType: Int + var pattern: List + var points: List var startCap: Cap - var endCap: Cap + var tag: Any? + var visible: Boolean + var width: Float + var zIndex: Float fun remove() diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/PolylineOptions.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/PolylineOptions.kt index 5035484..e010b3a 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/PolylineOptions.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/PolylineOptions.kt @@ -16,15 +16,19 @@ import at.bluesource.choicesdk.maps.common.shape.Cap.Companion.toHmsCap * Defines options for a [Polyline]. * Use this Builder to add a polyline to the map. */ -class PolylineOptions : ShapeOptions() { +class PolylineOptions { - val points: MutableList = mutableListOf() - var isGeodesic: Boolean = false - private set - - private var startCap: Cap = Cap.ButtCap() + private var clickable: Boolean = false + private var color: Int = 0xff000000.toInt() // black, also toInt workaround for compiler issue: https://youtrack.jetbrains.com/issue/KT-4749 private var endCap: Cap = Cap.ButtCap() + private var geodesic: Boolean = false + private var jointType: Int = Polygon.DEFAULT private var pattern: List = listOf() + private val points: MutableList = mutableListOf() + private var startCap: Cap = Cap.ButtCap() + private var visible = true + private var width: Float = 10f + private var zIndex: Float = 0f fun add(vararg points: LatLng): PolylineOptions { this.points.addAll(points) @@ -41,88 +45,90 @@ class PolylineOptions : ShapeOptions() { return this } - fun geodesic(geodesic: Boolean): PolylineOptions { - this.isGeodesic = geodesic + fun clickable(clickable: Boolean): PolylineOptions { + this.clickable = clickable return this } - fun startCap(cap: Cap): PolylineOptions { - startCap = cap + fun color(color: Int): PolylineOptions { + this.color = color return this } fun endCap(cap: Cap): PolylineOptions { - endCap = cap + this.endCap = cap return this } - fun strokePattern(pattern: List): PolylineOptions { - this.pattern = pattern + fun geodesic(geodesic: Boolean): PolylineOptions { + this.geodesic = geodesic return this } - fun getPointsForGms(): List { - return points.map { it.toGmsLatLng() } + fun jointType(jointType: Int): PolylineOptions { + this.jointType = jointType + return this } - override fun clickable(clickable: Boolean): PolylineOptions { - super.clickable(clickable) + fun pattern(pattern: List): PolylineOptions { + this.pattern = pattern return this } - override fun strokeColor(color: Int): PolylineOptions { - super.strokeColor(color) + fun startCap(cap: Cap): PolylineOptions { + this.startCap = cap return this } - override fun strokeWidth(widthInPx: Float): PolylineOptions { - super.strokeWidth(widthInPx) + fun visible(visible: Boolean): PolylineOptions { + this.visible = visible return this } - override fun visible(visible: Boolean): PolylineOptions { - super.visible(visible) + fun width(width: Float): PolylineOptions { + this.width = width return this } - override fun zIndex(zIndex: Float): PolylineOptions { - super.zIndex(zIndex) + fun zIndex(zIndex: Float): PolylineOptions { + this.zIndex = zIndex return this } + fun getPointsForGms(): List { + return points.map { it.toGmsLatLng() } + } + companion object { @JvmStatic fun com.google.android.gms.maps.model.PolylineOptions.toChoice(): PolylineOptions { - - val linePoints: List = points.map { it.toChoiceLatLng() } - val mappedPattern = pattern.orEmpty().map { it.toChoice() } - return PolylineOptions() - .clickable(isClickable) - .strokeColor(color) - .strokeWidth(width) - .visible(isVisible) - .zIndex(zIndex) - .addAll(linePoints) - .geodesic(isGeodesic) - .startCap(startCap.toChoiceCap()) - .endCap(endCap.toChoiceCap()) - .strokePattern(mappedPattern) - + .clickable(isClickable) + .color(color) + .endCap(endCap.toChoiceCap()) + .geodesic(isGeodesic) + .jointType(jointType) + .pattern(pattern.orEmpty().map { it.toChoice() }) + .startCap(startCap.toChoiceCap()) + .visible(isVisible) + .width(width) + .zIndex(zIndex) + .addAll(points.map { it.toChoiceLatLng() }) } internal fun PolylineOptions.toGmsPolylineOptions(): com.google.android.gms.maps.model.PolylineOptions { val po = com.google.android.gms.maps.model.PolylineOptions() - .clickable(clickable) - .color(strokeColor) - .width(strokeWidthInPx) - .visible(visible) - .zIndex(zIndex) - .addAll(points.map { it.toGmsLatLng() }) - .geodesic(isGeodesic) - .startCap(startCap.toGmsCap()) - .endCap(endCap.toGmsCap()) + .clickable(clickable) + .color(color) + .endCap(endCap.toGmsCap()) + .geodesic(geodesic) + .jointType(jointType) + .startCap(startCap.toGmsCap()) + .visible(visible) + .width(width) + .zIndex(zIndex) + .addAll(points.map { it.toGmsLatLng() }) // special case since gms does not draw anything if the list is empty if (pattern.isNotEmpty()) { @@ -133,16 +139,17 @@ class PolylineOptions : ShapeOptions() { internal fun PolylineOptions.toHmsPolylineOptions(): com.huawei.hms.maps.model.PolylineOptions { return com.huawei.hms.maps.model.PolylineOptions() - .clickable(clickable) - .color(strokeColor) - .width(strokeWidthInPx) - .visible(visible) - .zIndex(zIndex) - .addAll(points.map { it.toHmsLatLng() }) - .geodesic(isGeodesic) - .startCap(startCap.toHmsCap()) - .endCap(endCap.toHmsCap()) - .pattern(pattern.map { it.toHmsPatternItem() }) + .clickable(clickable) + .color(color) + .endCap(endCap.toHmsCap()) + .geodesic(geodesic) + .jointType(jointType) + .pattern(pattern.map { it.toHmsPatternItem() }) + .startCap(startCap.toHmsCap()) + .visible(visible) + .width(width) + .zIndex(zIndex) + .addAll(points.map { it.toHmsLatLng() }) } } } \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/Shape.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/Shape.kt deleted file mode 100644 index bf1da8a..0000000 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/Shape.kt +++ /dev/null @@ -1,13 +0,0 @@ -package at.bluesource.choicesdk.maps.common.shape - -/** - * Base interface for shapes - */ -interface Shape { - var clickable: Boolean - var strokeColor: Int - var strokeWidth: Float - var visible: Boolean - var zIndex: Float - var tag: Any? -} \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/ShapeOptions.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/ShapeOptions.kt deleted file mode 100644 index 0009cb1..0000000 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/common/shape/ShapeOptions.kt +++ /dev/null @@ -1,39 +0,0 @@ -package at.bluesource.choicesdk.maps.common.shape - -/** - * Base class for shape options - */ -@Suppress("unused") -abstract class ShapeOptions { - var clickable = false - var strokeColor: Int = - 0xff000000.toInt() // black, also toInt workaround for compiler issue: https://youtrack.jetbrains.com/issue/KT-4749 - var strokeWidthInPx: Float = 10f - var visible = true - var zIndex: Float = 0f - - open fun clickable(clickable: Boolean): ShapeOptions { - this.clickable = clickable - return this - } - - open fun strokeColor(color: Int): ShapeOptions { - strokeColor = color - return this - } - - open fun strokeWidth(widthInPx: Float): ShapeOptions { - strokeWidthInPx = widthInPx - return this - } - - open fun visible(visible: Boolean): ShapeOptions { - this.visible = visible - return this - } - - open fun zIndex(zIndex: Float): ShapeOptions { - this.zIndex = zIndex - return this - } -} \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMap.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMap.kt index 87c217d..34b67b1 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMap.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/GmsMap.kt @@ -22,8 +22,8 @@ import at.bluesource.choicesdk.maps.common.options.TileOverlay import at.bluesource.choicesdk.maps.common.options.TileOverlayOptions import at.bluesource.choicesdk.maps.common.options.TileOverlayOptions.Companion.toGmsTileOverlayOptions import at.bluesource.choicesdk.maps.common.shape.* -import at.bluesource.choicesdk.maps.common.shape.Circle.CircleOptions.Companion.toGmsCircleOptions import at.bluesource.choicesdk.maps.common.shape.Circle.Companion.toChoiceCircle +import at.bluesource.choicesdk.maps.common.shape.CircleOptions.Companion.toGmsCircleOptions import at.bluesource.choicesdk.maps.common.shape.Polygon.Companion.toChoicePolygon import at.bluesource.choicesdk.maps.common.shape.PolygonOptions.Companion.toGmsPolygonOptions import at.bluesource.choicesdk.maps.common.shape.Polyline.Companion.toChoicePolyline @@ -218,7 +218,7 @@ internal class GmsMap(private val map: GoogleMap) : Map { return GmsMarker(map.addMarker(options.toGmsMarkerOptions())) } - override fun addCircle(options: Circle.CircleOptions): Circle { + override fun addCircle(options: CircleOptions): Circle { return map.addCircle(options.toGmsCircleOptions()).toChoiceCircle() } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/shape/GmsCircle.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/shape/GmsCircle.kt index 61870fa..a2db57d 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/shape/GmsCircle.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/shape/GmsCircle.kt @@ -3,6 +3,9 @@ package at.bluesource.choicesdk.maps.gms.shape import at.bluesource.choicesdk.maps.common.LatLng import at.bluesource.choicesdk.maps.common.LatLng.Companion.toChoiceLatLng import at.bluesource.choicesdk.maps.common.LatLng.Companion.toGmsLatLng +import at.bluesource.choicesdk.maps.common.PatternItem +import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toChoice +import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toGmsPatternItem import at.bluesource.choicesdk.maps.common.shape.Circle /** @@ -12,49 +15,72 @@ import at.bluesource.choicesdk.maps.common.shape.Circle * @see com.google.android.gms.maps.model.Circle */ internal class GmsCircle(private var circle: com.google.android.gms.maps.model.Circle) : Circle { + + override val id: String + get() = circle.id + override var center: LatLng get() = circle.center.toChoiceLatLng() set(value) { circle.center = value.toGmsLatLng() } + override var clickable: Boolean get() = circle.isClickable set(value) { circle.isClickable = value } + override var fillColor: Int get() = circle.fillColor set(value) { circle.fillColor = value } + override var radius: Double get() = circle.radius set(value) { circle.radius = value } + override var strokeColor: Int get() = circle.strokeColor set(value) { circle.strokeColor = value } + + override var strokePattern: List + get() = circle.strokePattern.orEmpty().map { it.toChoice() } + set(value) { + circle.strokePattern = value.map { it.toGmsPatternItem() } + } + override var strokeWidth: Float get() = circle.strokeWidth set(value) { circle.strokeWidth = value } + override var visible: Boolean get() = circle.isVisible set(value) { circle.isVisible = value } + override var zIndex: Float get() = circle.zIndex set(value) { circle.zIndex = value } + override var tag: Any? get() = circle.tag set(value) { circle.tag = value } + + override fun remove() { + circle.remove() + } + } \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/shape/GmsPolygon.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/shape/GmsPolygon.kt index 2da4bc6..92bc64b 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/shape/GmsPolygon.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/shape/GmsPolygon.kt @@ -2,7 +2,11 @@ package at.bluesource.choicesdk.maps.gms.shape import at.bluesource.choicesdk.maps.common.LatLng import at.bluesource.choicesdk.maps.common.LatLng.Companion.toChoiceLatLng -import com.google.android.gms.maps.model.Polygon +import at.bluesource.choicesdk.maps.common.LatLng.Companion.toGmsLatLng +import at.bluesource.choicesdk.maps.common.PatternItem +import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toChoice +import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toGmsPatternItem +import at.bluesource.choicesdk.maps.common.shape.Polygon /** * Wrapper class for gms polygon version @@ -10,54 +14,77 @@ import com.google.android.gms.maps.model.Polygon * @property polygon gms Polyline instance * @see com.google.android.gms.maps.model.Polygon */ -internal class GmsPolygon(private var polygon: Polygon) : - at.bluesource.choicesdk.maps.common.shape.Polygon { - override val linePoints: List +internal class GmsPolygon(private var polygon: com.google.android.gms.maps.model.Polygon) : Polygon { + + override val id: String + get() = polygon.id + + override var points: List get() = polygon.points.map { it.toChoiceLatLng() } + set(value) { + polygon.points = value.map { it.toGmsLatLng() } + } - override val lineHoles: List> + override var holes: List> get() = polygon.holes.map { list -> list.map { it.toChoiceLatLng() } } + set(value) { + polygon.holes = value.map { it.map { latLng -> latLng.toGmsLatLng() } } + } override var fillColor: Int get() = polygon.fillColor set(value) { polygon.fillColor = value } + override var geodesic: Boolean get() = polygon.isGeodesic set(value) { polygon.isGeodesic = value } + override var strokeJointType: Int get() = polygon.strokeJointType set(value) { polygon.strokeJointType = value } + + override var strokePattern: List + get() = polygon.strokePattern.orEmpty().map { it.toChoice() } + set(value) { + polygon.strokePattern = value.map { it.toGmsPatternItem() } + } + override var clickable: Boolean get() = polygon.isClickable set(value) { polygon.isClickable = value } + override var strokeColor: Int get() = polygon.strokeColor set(value) { polygon.strokeColor = value } + override var strokeWidth: Float get() = polygon.strokeWidth set(value) { polygon.strokeWidth = value } + override var visible: Boolean get() = polygon.isVisible set(value) { polygon.isVisible = value } + override var zIndex: Float get() = polygon.zIndex set(value) { polygon.zIndex = value } + override var tag: Any? get() = polygon.tag set(value) { diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/shape/GmsPolyline.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/shape/GmsPolyline.kt index da3fead..b673ab4 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/shape/GmsPolyline.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/gms/shape/GmsPolyline.kt @@ -2,6 +2,10 @@ package at.bluesource.choicesdk.maps.gms.shape import at.bluesource.choicesdk.maps.common.LatLng import at.bluesource.choicesdk.maps.common.LatLng.Companion.toChoiceLatLng +import at.bluesource.choicesdk.maps.common.LatLng.Companion.toGmsLatLng +import at.bluesource.choicesdk.maps.common.PatternItem +import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toChoice +import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toGmsPatternItem import at.bluesource.choicesdk.maps.common.shape.Cap import at.bluesource.choicesdk.maps.common.shape.Cap.Companion.toChoiceCap import at.bluesource.choicesdk.maps.common.shape.Cap.Companion.toGmsCap @@ -10,60 +14,87 @@ import at.bluesource.choicesdk.maps.common.shape.Polyline /** * Wrapper class for gms polyline version * - * @property polyLine gms Polyline instance + * @property polyline gms Polyline instance * @see com.google.android.gms.maps.model.Polyline */ -internal class GmsPolyline(private val polyLine: com.google.android.gms.maps.model.Polyline) : Polyline { - override val linePoints: List - get() = polyLine.points.map { it.toChoiceLatLng() } +internal class GmsPolyline(private val polyline: com.google.android.gms.maps.model.Polyline) : Polyline { + + override val id: String + get() = polyline.id + + override var points: List + get() = polyline.points.map { it.toChoiceLatLng() } + set(value) { + polyline.points = value.map { it.toGmsLatLng() } + } override var geodesic: Boolean - get() = polyLine.isGeodesic + get() = polyline.isGeodesic + set(value) { + polyline.isGeodesic = value + } + + override var jointType: Int + get() = polyline.jointType + set(value) { + polyline.jointType = value + } + + override var pattern: List + get() = polyline.pattern.orEmpty().map { it.toChoice() } set(value) { - polyLine.isGeodesic = value + polyline.pattern = value.map { it.toGmsPatternItem() } } + override var startCap: Cap - get() = polyLine.startCap.toChoiceCap() + get() = polyline.startCap.toChoiceCap() set(value) { - polyLine.startCap = value.toGmsCap() + polyline.startCap = value.toGmsCap() } + override var endCap: Cap - get() = polyLine.endCap.toChoiceCap() + get() = polyline.endCap.toChoiceCap() set(value) { - polyLine.endCap = value.toGmsCap() + polyline.endCap = value.toGmsCap() } + override var clickable: Boolean - get() = polyLine.isClickable + get() = polyline.isClickable set(value) { - polyLine.isClickable = value + polyline.isClickable = value } - override var strokeColor: Int - get() = polyLine.color + + override var color: Int + get() = polyline.color set(value) { - polyLine.color = value + polyline.color = value } - override var strokeWidth: Float - get() = polyLine.width + + override var width: Float + get() = polyline.width set(value) { - polyLine.width = value + polyline.width = value } + override var visible: Boolean - get() = polyLine.isVisible + get() = polyline.isVisible set(value) { - polyLine.isVisible = value + polyline.isVisible = value } + override var zIndex: Float - get() = polyLine.zIndex + get() = polyline.zIndex set(value) { - polyLine.zIndex = value + polyline.zIndex = value } + override var tag: Any? - get() = polyLine.tag + get() = polyline.tag set(value) { - polyLine.tag = value + polyline.tag = value } override fun remove() { - polyLine.remove() + polyline.remove() } } \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsMap.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsMap.kt index 3edd238..4bb9cc4 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsMap.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/HmsMap.kt @@ -23,8 +23,8 @@ import at.bluesource.choicesdk.maps.common.options.TileOverlay import at.bluesource.choicesdk.maps.common.options.TileOverlayOptions import at.bluesource.choicesdk.maps.common.options.TileOverlayOptions.Companion.toHmsTileOverlayOptions import at.bluesource.choicesdk.maps.common.shape.* -import at.bluesource.choicesdk.maps.common.shape.Circle.CircleOptions.Companion.toHmsCircleOptions import at.bluesource.choicesdk.maps.common.shape.Circle.Companion.toChoiceCircle +import at.bluesource.choicesdk.maps.common.shape.CircleOptions.Companion.toHmsCircleOptions import at.bluesource.choicesdk.maps.common.shape.Polygon.Companion.toChoicePolygon import at.bluesource.choicesdk.maps.common.shape.PolygonOptions.Companion.toHmsPolygonOptions import at.bluesource.choicesdk.maps.common.shape.Polyline.Companion.toChoicePolyline @@ -219,7 +219,7 @@ internal class HmsMap(private var map: HuaweiMap) : Map { return HmsMarker(map.addMarker(options.toHmsMarkerOptions())) } - override fun addCircle(options: Circle.CircleOptions): Circle { + override fun addCircle(options: CircleOptions): Circle { return map.addCircle(options.toHmsCircleOptions()).toChoiceCircle() } diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/shape/HmsCircle.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/shape/HmsCircle.kt index 0a96072..8f783b8 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/shape/HmsCircle.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/shape/HmsCircle.kt @@ -3,6 +3,9 @@ package at.bluesource.choicesdk.maps.hms.shape import at.bluesource.choicesdk.maps.common.LatLng import at.bluesource.choicesdk.maps.common.LatLng.Companion.toChoiceLatLng import at.bluesource.choicesdk.maps.common.LatLng.Companion.toHmsLatLng +import at.bluesource.choicesdk.maps.common.PatternItem +import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toChoice +import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toHmsPatternItem import at.bluesource.choicesdk.maps.common.shape.Circle /** @@ -12,49 +15,71 @@ import at.bluesource.choicesdk.maps.common.shape.Circle * @see com.huawei.hms.maps.model.Circle */ internal class HmsCircle(private var circle: com.huawei.hms.maps.model.Circle) : Circle { + + override val id: String + get() = circle.id + override var center: LatLng get() = circle.center.toChoiceLatLng() set(value) { circle.center = value.toHmsLatLng() } + override var clickable: Boolean get() = circle.isClickable set(value) { circle.isClickable = value } + override var fillColor: Int get() = circle.fillColor set(value) { circle.fillColor = value } + override var radius: Double get() = circle.radius set(value) { circle.radius = value } + override var strokeColor: Int get() = circle.strokeColor set(value) { circle.strokeColor = value } + + override var strokePattern: List + get() = circle.strokePattern.orEmpty().map { it.toChoice() } + set(value) { + circle.strokePattern = value.map { it.toHmsPatternItem() } + } + override var strokeWidth: Float get() = circle.strokeWidth set(value) { circle.strokeWidth = value } + override var visible: Boolean get() = circle.isVisible set(value) { circle.isVisible = value } + override var zIndex: Float get() = circle.zIndex set(value) { circle.zIndex = value } + override var tag: Any? get() = circle.tag set(value) { circle.setTag(value) } + + override fun remove() { + circle.remove() + } } \ No newline at end of file diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/shape/HmsPolygon.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/shape/HmsPolygon.kt index 110b6ce..157705e 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/shape/HmsPolygon.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/shape/HmsPolygon.kt @@ -2,7 +2,11 @@ package at.bluesource.choicesdk.maps.hms.shape import at.bluesource.choicesdk.maps.common.LatLng import at.bluesource.choicesdk.maps.common.LatLng.Companion.toChoiceLatLng -import com.huawei.hms.maps.model.Polygon +import at.bluesource.choicesdk.maps.common.LatLng.Companion.toHmsLatLng +import at.bluesource.choicesdk.maps.common.PatternItem +import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toChoice +import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toHmsPatternItem +import at.bluesource.choicesdk.maps.common.shape.Polygon /** * Wrapper class for hms polygon version @@ -10,54 +14,77 @@ import com.huawei.hms.maps.model.Polygon * @property polygon hms Polygon instance * @see com.huawei.hms.maps.model.Polygon */ -internal class HmsPolygon(private var polygon: Polygon) : - at.bluesource.choicesdk.maps.common.shape.Polygon { - override val linePoints: List +internal class HmsPolygon(private var polygon: com.huawei.hms.maps.model.Polygon) : Polygon { + + override val id: String + get() = polygon.id + + override var points: List get() = polygon.points.map { it.toChoiceLatLng() } + set(value) { + polygon.points = value.map { it.toHmsLatLng() } + } - override val lineHoles: List> + override var holes: List> get() = polygon.holes.map { list -> list.map { it.toChoiceLatLng() } } + set(value) { + polygon.holes = value.map { it.map { latLng -> latLng.toHmsLatLng() } } + } override var fillColor: Int get() = polygon.fillColor set(value) { polygon.fillColor = value } + override var geodesic: Boolean get() = polygon.isGeodesic set(value) { polygon.isGeodesic = value } + override var strokeJointType: Int get() = polygon.strokeJointType set(value) { polygon.strokeJointType = value } + + override var strokePattern: List + get() = polygon.strokePattern.orEmpty().map { it.toChoice() } + set(value) { + polygon.strokePattern = value.map { it.toHmsPatternItem() } + } + override var clickable: Boolean get() = polygon.isClickable set(value) { polygon.isClickable = value } + override var strokeColor: Int get() = polygon.strokeColor set(value) { polygon.strokeColor = value } + override var strokeWidth: Float get() = polygon.strokeWidth set(value) { polygon.strokeWidth = value } + override var visible: Boolean get() = polygon.isVisible set(value) { polygon.isVisible = value } + override var zIndex: Float get() = polygon.zIndex set(value) { polygon.zIndex = value } + override var tag: Any? get() = polygon.tag set(value) { diff --git a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/shape/HmsPolyline.kt b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/shape/HmsPolyline.kt index 4c6c2f0..ee6fd0a 100644 --- a/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/shape/HmsPolyline.kt +++ b/ChoiceSDK/choicesdk-maps/src/main/java/at/bluesource/choicesdk/maps/hms/shape/HmsPolyline.kt @@ -2,6 +2,10 @@ package at.bluesource.choicesdk.maps.hms.shape import at.bluesource.choicesdk.maps.common.LatLng import at.bluesource.choicesdk.maps.common.LatLng.Companion.toChoiceLatLng +import at.bluesource.choicesdk.maps.common.LatLng.Companion.toHmsLatLng +import at.bluesource.choicesdk.maps.common.PatternItem +import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toChoice +import at.bluesource.choicesdk.maps.common.PatternItem.Companion.toHmsPatternItem import at.bluesource.choicesdk.maps.common.shape.Cap import at.bluesource.choicesdk.maps.common.shape.Cap.Companion.toChoiceCap import at.bluesource.choicesdk.maps.common.shape.Cap.Companion.toHmsCap @@ -10,60 +14,87 @@ import at.bluesource.choicesdk.maps.common.shape.Polyline /** * Wrapper class for hms polyline version * - * @property polyLine hms Polyline instance + * @property polyline hms Polyline instance * @see com.huawei.hms.maps.model.Polyline */ -internal class HmsPolyline(private val polyLine: com.huawei.hms.maps.model.Polyline) : Polyline { - override val linePoints: List - get() = polyLine.points.map { it.toChoiceLatLng() } +internal class HmsPolyline(private val polyline: com.huawei.hms.maps.model.Polyline) : Polyline { + + override val id: String + get() = polyline.id + + override var points: List + get() = polyline.points.map { it.toChoiceLatLng() } + set(value) { + polyline.points = value.map { it.toHmsLatLng() } + } override var geodesic: Boolean - get() = polyLine.isGeodesic + get() = polyline.isGeodesic + set(value) { + polyline.isGeodesic = value + } + + override var jointType: Int + get() = polyline.jointType + set(value) { + polyline.jointType = value + } + + override var pattern: List + get() = polyline.pattern.orEmpty().map { it.toChoice() } set(value) { - polyLine.isGeodesic = value + polyline.pattern = value.map { it.toHmsPatternItem() } } + override var startCap: Cap - get() = polyLine.startCap.toChoiceCap() + get() = polyline.startCap.toChoiceCap() set(value) { - polyLine.startCap = value.toHmsCap() + polyline.startCap = value.toHmsCap() } + override var endCap: Cap - get() = polyLine.endCap.toChoiceCap() + get() = polyline.endCap.toChoiceCap() set(value) { - polyLine.endCap = value.toHmsCap() + polyline.endCap = value.toHmsCap() } + override var clickable: Boolean - get() = polyLine.isClickable + get() = polyline.isClickable set(value) { - polyLine.isClickable = value + polyline.isClickable = value } - override var strokeColor: Int - get() = polyLine.color + + override var color: Int + get() = polyline.color set(value) { - polyLine.color = value + polyline.color = value } - override var strokeWidth: Float - get() = polyLine.width + + override var width: Float + get() = polyline.width set(value) { - polyLine.width = value + polyline.width = value } + override var visible: Boolean - get() = polyLine.isVisible + get() = polyline.isVisible set(value) { - polyLine.isVisible = value + polyline.isVisible = value } + override var zIndex: Float - get() = polyLine.zIndex + get() = polyline.zIndex set(value) { - polyLine.zIndex = value + polyline.zIndex = value } + override var tag: Any? - get() = polyLine.tag + get() = polyline.tag set(value) { - polyLine.tag = value + polyline.tag = value } override fun remove() { - polyLine.remove() + polyline.remove() } } \ No newline at end of file diff --git a/README.md b/README.md index 56b9205..be1537e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

-A SDK that aims to wrap similar functionalities from HMS and GMS services to one common interface. This is the launchpad for app providers expanding from GMS (Google Mobile Services) to HMS (Huawei Mobile Services) without having another codebranch to be setup, published and maintained. Choice SDK is already in use in multiple commercial, public and privat operated apps. The goal is to save development, maintainance and security issues now and in future. +A SDK that aims to wrap similar functionalities from HMS and GMS services to one common interface. This is the launchpad for app providers expanding from GMS (Google Mobile Services) to HMS (Huawei Mobile Services) without having another codebranch to be setup, published and maintained. Choice SDK is already in use in multiple commercial, public and private operated apps. The goal is to save development, maintainance and security issues now and in future. ## Contents - [Features](#features) @@ -69,11 +69,12 @@ apply plugin: 'com.huawei.agconnect' Add the following dependencies as required to your app. GMS, Firebase and HMS dependencies are included, so they do not need to be declared in your app. ```gradle dependencies { - implementation 'at.bluesource.choicesdk:choicesdk-analytics:0.1.5' - implementation 'at.bluesource.choicesdk:choicesdk-location:0.1.5' - implementation 'at.bluesource.choicesdk:choicesdk-maps:0.1.5' - implementation 'at.bluesource.choicesdk:choicesdk-messaging:0.1.5' - implementation 'at.bluesource.choicesdk:choicesdk-signin:0.1.5' + def choicesdk_version = '0.1.6' + implementation "at.bluesource.choicesdk:choicesdk-analytics:$choicesdk_version" + implementation "at.bluesource.choicesdk:choicesdk-location:$choicesdk_version" + implementation "at.bluesource.choicesdk:choicesdk-maps:$choicesdk_version" + implementation "at.bluesource.choicesdk:choicesdk-messaging:$choicesdk_version" + implementation "at.bluesource.choicesdk:choicesdk-signin:$choicesdk_version" } ``` diff --git a/documentation/map.md b/documentation/map.md index 7fd226b..4e3cdb7 100644 --- a/documentation/map.md +++ b/documentation/map.md @@ -74,7 +74,7 @@ map.addMarker( Adding a circle: ```kotlin map.addCircle( - Circle.CircleOptions() + CircleOptions() .center(location) .radius(100.0) .fillColor(Color.YELLOW) @@ -103,7 +103,7 @@ Adding a polyline: map.addPolyline( PolylineOptions() .add(location1, location2) - .strokeWidth(15f) + .width(15f) .startCap(Cap.RoundCap()) .endCap(Cap.SquareCap()) .zIndex(2f)