Skip to content

feat(map): Show distance, direction, and elevation diff when long-pressing a point - #3913

Merged
kylecorry31 merged 4 commits into
kylecorry31:mainfrom
Maqbool61:feature/map-selected-point-info-sheet
Jul 25, 2026
Merged

kylecorry31 merged 4 commits into
kylecorry31:mainfrom
Maqbool61:feature/map-selected-point-info-sheet

Conversation

@Maqbool61

@Maqbool61 Maqbool61 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3878

Description

When the user long-presses a point on the map, the existing share sheet
now shows distance, direction, and elevation difference from the user's
current location to the selected point — displayed as DataPointView
widgets between the toolbar and the action buttons, styled consistently
with the rest of the app. This applies to both the Map tool and the
Offline Maps (photo maps) tool.

Changes:

  • LocationDataPointView: new shared view in shared/views/ wrapping
    a horizontal row of three DataPointViews with setDistance(),
    setDirection(), and setElevationDiff() methods
  • ActionSheet: optional customView parameter inserted between the
    toolbar and action buttons
  • Share.actions: forwards customView to ActionSheet
  • MapFragment: uses LocationDataPointView and navigation.elevation
    for user elevation; subtitle restored
  • ViewPhotoMapFragment: same sheet added to long press handler using
    altimeter.altitude for user elevation
  • ToolMapTest, ToolOfflineMapsTest: added assertions to verify
    distance, direction, and elevation data points appear on long press

Testing

  1. Open the Map tool with GPS active
  2. Long-press any point on the map
  3. Verify the share sheet shows the coordinate title, elevation subtitle,
    distance/direction/elevation data points, and Beacon/Navigate/Distance buttons
  4. Repeat in the Offline Maps tool (open any photo map and long press)
  5. Verify dismissing the sheet clears the map pin in both tools

Comment thread app/src/main/java/com/kylecorry/trail_sense/tools/map/ui/MapFragment.kt Outdated
Comment thread app/src/main/java/com/kylecorry/trail_sense/tools/map/ui/MapFragment.kt Outdated
@kylecorry31

Copy link
Copy Markdown
Owner

Hi, thank you for the contribution. It is fine for this pull request, but for future pull requests can you be sure to follow the pull request description template and CONTRIBUTING.md? Thank you!

@Maqbool61

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback! I've updated the implementation to embed the data points directly inside the existing share sheet instead of creating a separate one.

The approach taken:

Added an optional customView parameter to ActionSheet that gets inserted between the toolbar and the action buttons
Added the same parameter to Share.actions to forward it through
In MapFragment, a LinearLayout with three DataPointViews (distance, direction, elevation diff) is built inline and passed as customView
Removed MapSelectedPointSheetView and its layout entirely
Restored manager.setSelectedLocation(null) on sheet dismiss

The data points now appear above the Beacon/Navigate/Distance buttons inside the single share sheet, styled consistently with the rest of the app.

@Maqbool61
Maqbool61 requested a review from kylecorry31 July 22, 2026 21:07

@kylecorry31 kylecorry31 left a comment •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This should also be present on the view photo maps fragment when the user selects a location on the map there (part of the Offline Maps tool). When you extract the component, be sure to make it part of the shared views so that offline maps doesn't reach into the map tool's package.

Once you've made the requested changes, can you also add tests to the androidTest for the map tool and offline maps tool? There are existing tests that long press the map, so just a couple of lines would be needed to verify it is displaying the correct information.

Can you also include screenshots when making the changes (you can update the description - there's a section in the template for screenshots)? It makes it easier to review since I usually only test locally if I don't have any large requested changes after reviewing the code.

Comment thread app/src/main/java/com/kylecorry/trail_sense/tools/map/ui/MapFragment.kt Outdated
Comment thread app/src/main/java/com/kylecorry/trail_sense/tools/map/ui/MapFragment.kt Outdated
@Maqbool61
Maqbool61 force-pushed the feature/map-selected-point-info-sheet branch from a4cc9be to df99061 Compare July 23, 2026 10:35
@Maqbool61

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed feedback! Here's what was updated:

Extracted the data point row into LocationDataPointView in shared/views/ with setDistance(), setDirection(), and setElevationDiff() methods — keeps display logic out of the fragments and avoids cross-package dependencies
Added the same sheet to ViewPhotoMapFragment (Offline Maps tool) using altimeter.altitude for the user's elevation
Switched to navigation.elevation instead of a second DEM lookup for the user's elevation in MapFragment
Restored the elevation subtitle
Added assertions to the existing long press tests in both ToolMapTest and ToolOfflineMapsTest to verify distance, direction, and elevation data points are displayed correctly

@Maqbool61
Maqbool61 requested a review from kylecorry31 July 23, 2026 10:40
Comment thread app/src/main/java/com/kylecorry/trail_sense/shared/views/LocationDataPointView.kt Outdated
@Maqbool61
Maqbool61 force-pushed the feature/map-selected-point-info-sheet branch from b9931c6 to 141e62c Compare July 25, 2026 05:51
@Maqbool61

Copy link
Copy Markdown
Contributor Author

Done — removed the subtitles from the data point views to match the navigation sheet style, and updated the tests accordingly. Also squashed all commits into one.
Screenshot_2026-07-25_10-50-09
Screenshot_2026-07-25_10-50-36

@Maqbool61
Maqbool61 requested a review from kylecorry31 July 25, 2026 05:54

@kylecorry31 kylecorry31 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Ideally I would like the text aligned with the icon, but to prevent further back and forth I'm going to merge this and make the change myself since that's pretty trivial. Thanks!

@kylecorry31
kylecorry31 merged commit 1cb2836 into kylecorry31:main Jul 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show distance and direction to selected point on map

2 participants