POI screen > better map camera when far away...#118
Conversation
Summary of ChangesHello @mmathieum, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the map experience on the Points of Interest (POI) screen by making the map camera more dynamic and context-aware. It ensures that the map view provides a more relevant display of surrounding POIs, vehicle locations, and the user's position, especially when the user is not immediately adjacent to the main POI. Additionally, it refines how vehicle location markers are presented and updates internal data handling for better maintainability. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request improves the map camera logic on the POI screen, particularly when the user is far from the POI, by including relevant context stops and the closest vehicle in the view. While the logic for selecting visible markers is improved, there are several concerns regarding the user experience (UX) where the camera might snap back or info windows might be forced open repeatedly during data updates. Additionally, a logic error was found in the construction of vehicle marker snippets, and the context stop inclusion logic is inconsistent between forward and backward directions.
…icleLocationExt.kt Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This pull request improves the map camera behavior on the POI (Point of Interest) screen when viewing objects that are far away. The changes enhance how the map displays markers, particularly vehicle locations, by improving camera positioning logic and simplifying the vehicle timestamp display.
Changes:
- Simplified vehicle location timestamp display to show minutes (with "+" indicator) for times >= 100 seconds, removing separate day/hour displays
- Enhanced map camera logic to include device location and additional nearby POIs in visible markers calculation
- Added ability to show info window for the closest vehicle location marker automatically
- Added option to hide map marker snippets for cleaner display
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| strings_schedule.xml (en, fr) | Removed unused time format strings and added new "minutes+" format string |
| VehicleLocationExt.kt | Simplified timestamp display logic, modified snippet to combine label and time, added hideSnippet parameter |
| GMapsExt.kt | Added Location.toLatLng() extension function |
| MapViewControllerExt.kt | Enhanced updateVehicleLocationMarkers with selectedUuid parameter and boolean return type |
| MapViewController.java | Made showMarkers public, added hideMapMarkerSnippet field, code style improvements |
| POIFragmentExt.kt | Refactored visibleMarkersLocationList to include device location and additional POIs based on distance |
| POIFragment.java | Added setupMapViewController, integrated closest vehicle selection and showMarkers call |
| POIViewModel.kt | Added distinctUntilChanged() to vehicleLocations, minor comment fix |
| DataSourceRequestManager.kt | Reordered imports alphabetically |
| POIManager.java, Module.java, POIArrayAdapter.java | Renamed getLocation() to getLocationString() for clarity |
| RDSDirectionStopsFragment.kt | Updated updateVehicleLocationMarkers call with new parameter |
Comments suppressed due to low confidence (3)
app-android/src/main/java/org/mtransit/android/ui/view/map/VehicleLocationExt.kt:40
- The logic for determining when to show minutes vs seconds is incorrect. With seconds >= 100L, this will show minutes after only 100 seconds (1 minute 40 seconds), but the previous logic showed days/hours/minutes appropriately. The threshold of 100 seconds seems arbitrary. Consider using a more meaningful threshold like 60 seconds (1 minute) if the intent is to simplify the display. Also note that the calculation
seconds / 60will be integer division, so precision may be lost.
seconds >= 100L -> context.getString(R.string.short_minutes_plus_count, seconds / 60)
app-android/src/main/java/org/mtransit/android/ui/fragment/POIFragmentExt.kt:86
- The maxVehicleDistanceInMeters calculation is overly complex and difficult to understand. The logic appears to compute the maximum of two values, where each value is constrained by the other multiplied by 3. This creates a circular dependency that makes the logic unclear. Consider simplifying to:
min(poiDistanceToNextRelevantPOIM?.times(3f) ?: Float.MAX_VALUE, poiDistanceToDeviceLocationInMeters?.times(3f) ?: Float.MAX_VALUE).takeIf { it != Float.MAX_VALUE }which would take the smaller of the two distances multiplied by 3, or a clearer expression of the intended logic.
val maxVehicleDistanceInMeters = max(
poiDistanceToNextRelevantPOIM?.times(3f)?.coerceAtMost(poiDistanceToDeviceLocationInMeters?.times(3f) ?: Float.MAX_VALUE) ?: 0f,
poiDistanceToDeviceLocationInMeters?.coerceAtMost(poiDistanceToNextRelevantPOIM?.times(3f) ?: Float.MAX_VALUE) ?: 0f
).takeIf { it > 0f }
app-android/src/main/java/org/mtransit/android/ui/fragment/POIFragmentExt.kt:92
- The change from using sortedBy().forEach() to minByOrNull() means only the single closest vehicle location will be included in visibleMarkersLocationList, instead of potentially multiple vehicles within the max distance. This is a significant behavior change that may not be intentional. If the goal is to show all vehicles within maxVehicleDistanceInMeters, use filter instead:
?.filter { it.position.distanceToInMeters(poimLatLng) <= maxVehicleDistanceInMeters }?.forEach { add(it.position) }
viewModel?.vehicleLocations?.value
?.minByOrNull { it.position.distanceToInMeters(poimLatLng) }
?.let { vehicleLocation ->
if (maxVehicleDistanceInMeters != null && vehicleLocation.position.distanceToInMeters(poimLatLng) <= maxVehicleDistanceInMeters) {
add(vehicleLocation.position)
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the map view on the POI screen to provide a better camera experience, especially when the user is far from the POI. It introduces more sophisticated logic for determining which markers to display and adjusts their sizes for better clarity. Several related refactorings and cleanups are included, such as simplifying distance calculations and improving how vehicle locations are updated and displayed. My feedback focuses on improving the readability of a complex calculation.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
TODO: