Restyle geoshape/geotrace#7017
Conversation
|
@alyblenkin I've updated the style for OSM. Take a look and let me know if the behaviour/style is as expected, and then I can get working on making it work in Google Maps/Mapbox. |
|
@dbemke @srujner @WKobus are you able to have a quick play with traces/shapes? They should look inconsistent right now, but I've made some changes to simplify how they work, and I'm interested to see if it has any performance drawbacks. I'm going to have a go as well. I can end a Google Maps APK if you need it! |
|
Absolutely! Not a priority, just something to check before I finish the PR off. |
|
Noting down a few things from my chat with Callum:
|
Can you give us a hint where to look for the performance issues - adding points, saving points etc? |
Adding and removing points with shapes/traces mainly! |
| } | ||
| } | ||
|
|
||
| private val viewModel: GeoPolyViewModel by viewModels { |
There was a problem hiding this comment.
We can probably move a bunch more of the Fragment's state in to this (or another) ViewModel, but I think this is a good start for now: we can continue improving this as part of #6970.
| */ | ||
| fun hasCenter(): Boolean | ||
|
|
||
| fun supportsDraggablePolygon(): Boolean { |
There was a problem hiding this comment.
This lets us implement in just OSM while not completely breaking other engines. I think we should follow up with Mapbox/Google Maps implementations as that allows us to keep the change sets small and do the work in parallel if we can.
| * If there are no vertices, does nothing. | ||
| */ | ||
| fun removePolyLineLastPoint(featureId: Int) | ||
| fun updatePolygon(featureId: Int, polygonDescription: PolygonDescription) |
There was a problem hiding this comment.
For the moment, updatePolyLine and updatePolygon aren't optimized at all, but I thought it would be good to have it set up so we can work on optimizations within the map engine code without risk of merge conflicts with work happening in GeoPolyFragment.
| private val strokeColor: String? = null, | ||
| val draggable: Boolean = false, | ||
| val closed: Boolean = false | ||
| @Deprecated("Use PolygonDescription instead") val closed: Boolean = false |
There was a problem hiding this comment.
Our line/polygon API for MapFragment was in a weird state where you could add draggable or static lines, static polygons and draggale or static closed lines. We got away with the latter because we didn't need to fill them, but now we do they need to be proper polygons under the hood.
| private var accuracyThreshold: Int = 0 | ||
|
|
||
| init { | ||
| viewModelScope.launch { |
There was a problem hiding this comment.
We've talked off and on about whether to use coroutines directly like this (as opposed to through our Scheduler interface) - especially with ViewModels as it gives us viewModelScope. I can't immediately think of a benefit to using Scheduler here as this work is dispatched on the UI thread, so there's no need to integrate with IdlingResource for Espresso. That said, as far as I can tell, there are no tests for the automatic location recording. I'll backfill those as a follow up and see how this fits in.
I can't reproduce. Could you double-check the steps? Is the point you see always in the same place? |
| object MapConsts { | ||
| const val DEFAULT_STROKE_COLOR = -65536 // color-int representation of #ffff0000 | ||
| @JvmField | ||
| val DEFAULT_STROKE_COLOR = Color.parseColor("#3e9fcc") |
There was a problem hiding this comment.
There is a nice toColorInt ext fun which you can use here and below: Color.parseColor("#3e9fcc") -> #3e9fcc".toColorInt().
There was a problem hiding this comment.
That function returns Int? rather than Int - I'm guessing it's for dealing with user input rather than static strings.
There was a problem hiding this comment.
That function returns Int? rather than Int
No, it returns Int:
@ColorInt public inline fun String.toColorInt(): Int = Color.parseColor(this)
and under the hood it does the same thing.
There was a problem hiding this comment.
I've added that change in #7024 so that merging this pr is not blocked.
There was a problem hiding this comment.
Ah looks like we've shadowed it:
I can rename that.
osmdroid/src/main/java/org/odk/collect/osmdroid/OsmDroidMapFragment.java
Outdated
Show resolved
Hide resolved
osmdroid/src/main/java/org/odk/collect/osmdroid/OsmDroidMapFragment.java
Outdated
Show resolved
Hide resolved
maps/src/main/java/org/odk/collect/maps/markers/MarkerIconCreator.kt
Outdated
Show resolved
Hide resolved
maps/src/main/java/org/odk/collect/maps/markers/MarkerIconDescription.kt
Outdated
Show resolved
Hide resolved
| val interval = intent.getLongExtra(EXTRA_UPDATE_INTERVAL, -1) | ||
| locationClient.setUpdateIntervals( | ||
| interval, | ||
| interval / 2 |
There was a problem hiding this comment.
Should we simplify #setUpdateIntervals as now we alwasy pass the same values?
There was a problem hiding this comment.
I can follow up with that as I'd like to investigate white it was the way it was.
mapbox/src/main/java/org/odk/collect/mapbox/MapboxMapFragment.kt
Outdated
Show resolved
Hide resolved
geo/src/main/java/org/odk/collect/geo/geopoly/GeoPolyViewModel.kt
Outdated
Show resolved
Hide resolved
geo/src/main/java/org/odk/collect/geo/geopoly/GeoPolyViewModel.kt
Outdated
Show resolved
Hide resolved
geo/src/main/java/org/odk/collect/geo/geopoly/GeoPolyViewModel.kt
Outdated
Show resolved
Hide resolved
Yes it was adding a point in the center of the map. I've solved it in #7016 so just rebase. |
osmdroid/src/main/java/org/odk/collect/osmdroid/OsmDroidMapFragment.java
Outdated
Show resolved
Hide resolved
It always the same place. I reproduced it also in All widgets form. Steps are on OSM and I edit one step to leave one point. |
|
@dbemke I've rebased so that issue should be fixed now! |
|
Tested with Success! Verified on devices with Android 10 Verified cases:
|
|
Tested with Success! Verified on devices with Android 16 |


Work towards #6962
Closes #6999
Closes #7019
This restyles traces and shapes in OSM. I also fixed a crash that could happen on rotate (#6999) as it fitted in to some work I needed to do anyway (@grzesiek2010 discussed that in #7019).
Why is this the best possible solution? Were any other approaches considered?
Comments inline.
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?
Do we need any specific form for testing your changes? If so, please attach one.
It's worth playing with all map engines to see if there are any performance regressions with adding/removing points with shapes/traces as how they are rendered has been changed across the board. Other than that (and the fixed issue), the style changes are isolated to OSM - Google Maps and Mapbox look a little wonky, but we'll be fixing that in follow-ups. It might be worth just doing a quick pass of things for now as we'll be making further changes to the maps with #6970.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest(or./gradlew testLab) and confirmed all checks still passDateFormatsTest