Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve selecting shapes/traces #5463

Merged
merged 9 commits into from
Mar 8, 2023
Merged

Conversation

seadowg
Copy link
Member

@seadowg seadowg commented Feb 24, 2023

Closes #5447

As well as improving the zoom behaviour on selection and fixing Mapbox, this PR fixes a bug we hadn't found that would only crop up in cases where traces and shapes were interleaved in the data.

What has been done to verify that this works as intended?

New tests and verified manually.

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?

As well as the changes described in the issue, it'd be good to test select one from map with both points and traces/shapes in a single question. There were some problems we hadn't caught in this scenario if the points and traces are interleaved in the form data set or the GeoJSON file that this PR should address.

Before submitting this PR, please make sure you have:

  • run ./gradlew checkAll and confirmed all checks still pass OR confirm CircleCI build passes and run ./gradlew connectedDebugAndroidTest locally.
  • 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

markers.add(markerDescription.point)
markerIcons.add(markerDescription.iconDescription)
return markers.size - 1
val featureId = generateFeatureId()
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 want to generate random IDs to prevent our tests from allowing implementations that rely on sequential ones.


private lateinit var map: MapFragment
private lateinit var summarySheetBehavior: BottomSheetBehavior<*>
private lateinit var summarySheet: SelectionSummarySheet
private lateinit var bottomSheetCallback: BottomSheetCallback

private val itemsByFeatureId: MutableMap<Int, MappableSelectItem> = mutableMapOf()
private val featureIdsByItemId: MutableMap<Long, Int> = mutableMapOf()
Copy link
Member Author

Choose a reason for hiding this comment

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

It maybe feels excessive to have two Map indexes here, but otherwise we'd need to do linear searches on several click events, and we build these maps in a loop we're already performing.

map.zoomToPoint(MapPoint(point.latitude, point.longitude), map.zoom, true)
if (!skipSummary) {
if (item.points.size > 1) {
map.zoomToBoundingBox(item.points, 0.8, true)
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're doing a "zoom to fit" when selecting a shape/trace rather than maintaining the user zoom. I think that addresses some of the feedback around it being hard to see which item is selected (without having to deal with color/shape changes), but as @lognaturel has pointed out to me, it isn't great in situations where the user taps on the wrong item and then loses context.

@srujner
Copy link

srujner commented Mar 7, 2023

There is possibility to cover one of the points in a trace by the Select Point window in Google and OSM map source. For Mapbox zoom works correctly but after rotating the screen almost 50% of the trace is covered by Select Window.
Is it ok?

XRecorder_07032023_130807.1.mp4

Rotated screen:

Screenshot_20230307-131734

@seadowg
Copy link
Member Author

seadowg commented Mar 7, 2023

@srujner yeah, I think this is fine.

@dbemke
Copy link

dbemke commented Mar 8, 2023

Tested with Success!

Verified on Android 10

Verified Cases:

  • zooming to points, shapes and traces in forms xml, xlsx forms and csv, geojson files attached
  • clicking on points and lines in Google Maps, OSM, Mapbox
  • offline layers
  • don’t keep activities enabled/disabled
  • rotating, minimizing, locking the screen
  • quick checks in Geo widgets

@srujner
Copy link

srujner commented Mar 8, 2023

Tested with Success!

Verified on Android 13

@grzesiek2010 grzesiek2010 merged commit d977cb9 into getodk:master Mar 8, 2023
@seadowg seadowg mentioned this pull request Mar 8, 2023
3 tasks
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.

Improve Select One From Map trace/shape selection behaviour
4 participants