Skip to content

Commit

Permalink
Fix crash when viewing line/polygons with no form style
Browse files Browse the repository at this point in the history
* Return event default style or app default style for lines and polygons when parsing from form.
  • Loading branch information
newmanw committed Jul 31, 2022
1 parent 6779971 commit cf43fb1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ Adheres to [Semantic Versioning](http://semver.org/).

##### Bug Fixes

## [7.1.6](https://github.com/ngageoint/mage-android/releases/tag/7.1.6)

##### Features

##### Bug Fixes
* Return event default style or app default style for lines and polygons when parsing from form.

## [7.1.5](https://github.com/ngageoint/mage-android/releases/tag/7.1.5)

##### Features
Expand Down
2 changes: 1 addition & 1 deletion mage/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
}

group 'mil.nga.giat.mage'
version '7.1.5'
version '7.1.6'
ext {
sourceRefspec = Grgit.open(currentDir: project.rootDir).head().id

Expand Down
2 changes: 1 addition & 1 deletion mage/src/main/java/mil/nga/giat/mage/form/FormJson.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Form(
@SerializedName("primaryFeedField") val primaryFeedField: String?,
@SerializedName("secondaryFeedField") val secondaryFeedField: String?,
@SerializedName("fields") val fields: List<FormField<Any>>,
@SerializedName("style") val style: JsonObject
@SerializedName("style") val style: JsonObject?
) {
companion object {
private val gson = GsonBuilder()
Expand Down
17 changes: 13 additions & 4 deletions mage/src/main/java/mil/nga/giat/mage/map/annotation/ShapeStyle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ShapeStyle: AnnotationStyle {
context.resources.getValue(R.dimen.fill_default_stroke_width, defaultStrokeWidth, true)
strokeWidth = defaultStrokeWidth.float * (context.resources.displayMetrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT)

this.strokeColor = 0
this.strokeColor = Color.BLACK
this.fillColor = 0
}

Expand Down Expand Up @@ -141,7 +141,7 @@ class ShapeStyle: AnnotationStyle {
}

fun fromForm(formState: FormState?, context: Context): ShapeStyle {
val style = ShapeStyle(context)
var style = ShapeStyle(context)

// Check for a style
if (formState != null) {
Expand All @@ -167,7 +167,7 @@ class ShapeStyle: AnnotationStyle {
}
if (primaryValue != null) {
// Check for a type within the style
val primaryElement = jsonStyle[primaryValue.text]
val primaryElement = jsonStyle?.get(primaryValue.text)
if (primaryElement != null && !primaryElement.isJsonNull) {

// Found the type level style
Expand All @@ -183,9 +183,18 @@ class ShapeStyle: AnnotationStyle {
}
}

return fromJson(jsonStyle, context)
if (jsonStyle != null) {
style = fromJson(jsonStyle, context)
} else {
EventHelper.getInstance(context).read(formState.eventId)?.style?.let { jsonStyle ->
JsonParser.parseString(jsonStyle)?.asJsonObjectOrNull()?.let { jsonObject ->
style = fromJson(jsonObject, context)
}
}
}
}


return style
}

Expand Down

0 comments on commit cf43fb1

Please sign in to comment.