Validate geopoly on changes when question has incremental param#6989
Validate geopoly on changes when question has incremental param#6989grzesiek2010 merged 31 commits intogetodk:masterfrom
Conversation
androidshared/src/main/java/org/odk/collect/androidshared/ui/AlertStore.kt
Outdated
Show resolved
Hide resolved
test-shared/src/main/java/org/odk/collect/testshared/Assertions.kt
Outdated
Show resolved
Hide resolved
test-shared/src/main/java/org/odk/collect/testshared/Assertions.kt
Outdated
Show resolved
Hide resolved
| import android.os.Bundle | ||
| import androidx.fragment.app.FragmentResultListener | ||
| import androidx.lifecycle.Lifecycle | ||
| import androidx.lifecycle.MutableLiveData |
There was a problem hiding this comment.
There is a lot of !! in kotlin version. Can we review the class and improve that?
There was a problem hiding this comment.
As far as I can see we only use !! for accessing result in FragmentResultRecorder. I'm not sure I have a better solution for asserting on nullable values (as doing something like assertNotNull won't get you smart cast and lateinit isn't really correct), but it is something that comes up in tests as a lot. Maybe we should write a helper to avoid it that asserts and casts for us? Maybe something like:
assertNotNull(result) {
assertThat(it, equalTo(GeoPolyFragment.REQUEST_GEOPOLY))
}There was a problem hiding this comment.
Sorry this comments was mant to be added in GeoPolyFragment, not in the test class.
There was a problem hiding this comment.
Ah I see! I can take a look there.
There was a problem hiding this comment.
I've removed a chunk of them, but there's still quite a few for map. I think these should really be reworked by moving the polyline state to MapViewModel so that hosts don't have to interact with a child Fragment. I can hopefully do that refactor as part of the upcoming restyle of the screen.
geo/src/main/java/org/odk/collect/geo/geopoly/GeoPolyFragment.kt
Outdated
Show resolved
Hide resolved
geo/src/main/java/org/odk/collect/geo/geopoly/GeoPolyFragment.kt
Outdated
Show resolved
Hide resolved
geo/src/test/java/org/odk/collect/geo/geopoly/GeoPolyFragmentTest.kt
Outdated
Show resolved
Hide resolved
| val geopoly = result.getString(GeoPolyFragment.RESULT_GEOPOLY) | ||
| val incremental = FormEntryPromptUtils.getBindAttribute(prompt, "incremental") | ||
|
|
||
| if (incremental == "true" && geopolyChange != null) { |
There was a problem hiding this comment.
Shouldn't we perform a case-insensitive check for true?
Maybe we should introduce getBooleanBindAttribute function?
There was a problem hiding this comment.
I don't think we need to be that permissive, but I do recall we might do that elsewhere?
There was a problem hiding this comment.
We already sanitize appearances here:
https://github.com/getodk/collect/blob/master/collect_app/src/main/java/org/odk/collect/android/utilities/Appearances.kt#L97
In theory, we could rely on pyxform, but for various reasons probably because it’s not guaranteed to be perfect, or because other tools can be used to parse XLS forms, we started doing this ourselves.
That’s why I thought we might want to do the same for bind attributes as well. If you’re not sure about this approach, we can always file a separate issue and discuss it there.
There was a problem hiding this comment.
Let's go with another issue. The current implementation fits the spec and I think doing anything else is something we need to discuss.
...ect_app/src/test/java/org/odk/collect/android/widgets/utilities/GeoPolyDialogFragmentTest.kt
Outdated
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/widgets/utilities/GeoPolyDialogFragment.kt
Outdated
Show resolved
Hide resolved
collect_app/src/main/java/org/odk/collect/android/widgets/utilities/GeoPolyDialogFragment.kt
Show resolved
Hide resolved
geo/src/main/java/org/odk/collect/geo/geopoly/GeoPolyFragment.kt
Outdated
Show resolved
Hide resolved
|
Could you check if the form I created is ok? When I try to upload it to Central there's information that Central doesn't know the incremental parameter. |
Central only allows adding xml with incremental |
Sorry should have specified this in the PR description. Yes you'll need to add |

Closes #6969
As well as adding the feature I made two other changes:
Why is this the best possible solution? Were any other approaches considered?
There's probably not a lot of surprising here after the last sets of changes made for this feature: I basically just hooked up
FormEntryViewModel'scurrentIndexandonAnswerQuestiontoGeoPolyFragmentthroughGeoPolyDialogFragmentso that the question is answered (and constraints validated) every time a point is added or removed.How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
I did convert the geopoly UI from Java to Kotlin, so outside of testing the new feature, it's worth testing the geopoly flow as a whole. Again, nothing with the actual map integration has changed, so I think it's safe to just use one engine.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest(or./gradlew testLab) and confirmed all checks still passDateFormatsTest