Skip to content

Restyle geoshape/geotrace#7017

Merged
grzesiek2010 merged 42 commits intogetodk:masterfrom
seadowg:trace-style
Jan 19, 2026
Merged

Restyle geoshape/geotrace#7017
grzesiek2010 merged 42 commits intogetodk:masterfrom
seadowg:trace-style

Conversation

@seadowg
Copy link
Member

@seadowg seadowg commented Jan 9, 2026

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:

  • added or modified tests for any new or changed behavior
  • run ./gradlew connectedAndroidTest (or ./gradlew testLab) and confirmed all checks still pass
  • added a comment above any new strings describing it for translators
  • added any new strings with date formatting to DateFormatsTest
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

@seadowg
Copy link
Member Author

seadowg commented Jan 9, 2026

@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.

@alyblenkin
Copy link
Collaborator

Based on our conversation in slack, we want to align more closely with the designs from Web Forms.
image

https://effortless-dragon-d2ff5f.netlify.app/

@seadowg
Copy link
Member Author

seadowg commented Jan 15, 2026

@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!

@srujner
Copy link

srujner commented Jan 15, 2026

@seadowg Can it wait until Monday?
We're focusing on testing #7016 right now, and there's a lot to check there.

Google Maps APK would be helpful :)

@seadowg
Copy link
Member Author

seadowg commented Jan 15, 2026

Absolutely! Not a priority, just something to check before I finish the PR off.

@alyblenkin
Copy link
Collaborator

Noting down a few things from my chat with Callum:

  • Points size: They are currently 6×, which feels better than before. They feel appropriate while actively mapping, but appear pretty large when zoomed out. Dynamically resizing markers based on zoom would be a larger lift, so we’re planning to leave this for now.
  • Invalid state: the most recently placed point will not be highlighted when invalid, since all points will be shown in red. This may be revisited later based on feedback.
  • Select state: later we want to clearly indicate the selected point so that moving points is more discoverable, like we do with WF.

@dbemke
Copy link

dbemke commented Jan 16, 2026

I'm interested to see if it has any performance drawbacks.

Can you give us a hint where to look for the performance issues - adding points, saving points etc?

@seadowg
Copy link
Member Author

seadowg commented Jan 16, 2026

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 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dbemke
Copy link

dbemke commented Jan 16, 2026

I think I found an Easter egg !!! Hidden point in the geotrace (on all devices).
esterEgg

Steps to reproduce:

  1. Open All question types form in the demo project.
  2. Tap "get line" in geotrace.
  3. Select e.g. placement by tappping and add some point.
  4. Tap pause and remove the points except from one
  5. Tap the back button and discard changes.
  6. Open the map again - the hidden point is there ;)

The way points are entered and removed doesn't matter. I haven't found it on the master version or the store version.

private var accuracyThreshold: Int = 0

init {
viewModelScope.launch {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@seadowg
Copy link
Member Author

seadowg commented Jan 16, 2026

I think I found an Easter egg !!! Hidden point in the geotrace (on all devices).

I can't reproduce. Could you double-check the steps? Is the point you see always in the same place?

@seadowg seadowg requested a review from grzesiek2010 January 16, 2026 14:48
@seadowg seadowg marked this pull request as ready for review January 16, 2026 14:48
object MapConsts {
const val DEFAULT_STROKE_COLOR = -65536 // color-int representation of #ffff0000
@JvmField
val DEFAULT_STROKE_COLOR = Color.parseColor("#3e9fcc")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a nice toColorInt ext fun which you can use here and below: Color.parseColor("#3e9fcc") -> #3e9fcc".toColorInt().

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That function returns Int? rather than Int - I'm guessing it's for dealing with user input rather than static strings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added that change in #7024 so that merging this pr is not blocked.

Copy link
Member Author

@seadowg seadowg Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah looks like we've shadowed it:

I can rename that.

val interval = intent.getLongExtra(EXTRA_UPDATE_INTERVAL, -1)
locationClient.setUpdateIntervals(
interval,
interval / 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we simplify #setUpdateIntervals as now we alwasy pass the same values?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can follow up with that as I'd like to investigate white it was the way it was.

@grzesiek2010
Copy link
Member

I think I found an Easter egg !!! Hidden point in the geotrace (on all devices).

I can't reproduce. Could you double-check the steps? Is the point you see always in the same place?

Yes it was adding a point in the center of the map. I've solved it in #7016 so just rebase.

@dbemke
Copy link

dbemke commented Jan 19, 2026

Could you double-check the steps? Is the point you see always in the same place?

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.

@seadowg
Copy link
Member Author

seadowg commented Jan 19, 2026

@dbemke I've rebased so that issue should be fixed now!

@seadowg seadowg requested a review from grzesiek2010 January 19, 2026 14:39
@grzesiek2010 grzesiek2010 merged commit 3daae3e into getodk:master Jan 19, 2026
7 checks passed
@dbemke
Copy link

dbemke commented Jan 21, 2026

Tested with Success!

Verified on devices with Android 10

Verified cases:

@WKobus
Copy link

WKobus commented Jan 21, 2026

Tested with Success!

Verified on devices with Android 16

@seadowg seadowg deleted the trace-style branch January 21, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash after rotating the screen with automatic location recording on in geoshape and geotrace

6 participants