Meshtastic-Android icon indicating copy to clipboard operation
Meshtastic-Android copied to clipboard

Port “Compass view” bottom sheet from Meshtastic-Apple PR #1504

Open jakevis opened this issue 3 weeks ago • 20 comments

This ports the “Compass view” from Meshtastic-Apple PR pull/1504 (thanks @RCGV1) to Android. It keeps the phone’s location as origin and guides you to the selected node via a modal bottom sheet on Node Detail → Position → “Open Compass.”

What changed

  • Add localized strings for compass title/action, distance/bearing display, and sensor/permission/location warnings.
  • New providers: CompassHeadingProvider (rotation vector with accel+mag fallback) and PhoneLocationProvider (LocationManager flow with permission/provider state).
  • CompassViewModel/CompassUiState combine heading + phone location with the target node, computing distance, bearing, alignment, and elapsed “last position update.”
  • Compose CompassSheetContent: dial ~2/3 width, red north reference, black target bearing, larger cardinal labels + quarter/eighth ticks, distance/bearing rows, elapsed time, and warnings with CTAs (request permission, open location settings, request position).
  • Node Detail integration: Position section gets “Open Compass”; sheet starts/stops providers with visibility, caches target node, and includes “Request Position” inside the sheet.

Why Per the iOS PR: adds a compass view to quickly navigate to a node—useful off-grid when locating a friend, dog, or tracker.

Testing

  • Built and ran on Android emulator (API 35); opened Node Detail → Position → Open Compass; verified sheet renders and warnings appear when sensors/permissions are missing. (No automated tests run in this PR.)

jakevis avatar Dec 03 '25 23:12 jakevis

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Dec 03 '25 23:12 CLAassistant

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Dec 03 '25 23:12 CLAassistant

Screenshots of the changes:

Screenshot_1764802949 Screenshot_1764802956 Screenshot_1764802954

jakevis avatar Dec 03 '25 23:12 jakevis

Why lines not a compass rose? And why are there 3 lines for a single bearing?

DaneEvans avatar Dec 03 '25 23:12 DaneEvans

Why lines not a compass rose? And why are there 3 lines for a single bearing?

Personal preference and re-using some old code I had from another project. Red is fixed line on the N marker; the thin under it is a heading line. Align the black lines and your walking directly to the node (accessibility feature mostly from the old project).

Orignal code and design I was playing with had support for multiple nodes on the rose (and that might a future PR - with a rose accessible from somewhere else). Totem Compass style - show where you stared nodes are both distance and direction from you.

For the moment; happy to drop the heading and red lines if folks prefer.

jakevis avatar Dec 04 '25 17:12 jakevis

Should there perhaps be a message displayed when the target node has a high degree of precision bits? So we don't send the users on a wild goosechase

mdecourcy avatar Dec 04 '25 17:12 mdecourcy

Should there perhaps be a message displayed when the target node has a high degree of precision bits? So we don't send the users on a wild goosechase

Let me see how hard it would be to tell the user the degree of error on the screen.. if its communicated somewhere..

jakevis avatar Dec 04 '25 17:12 jakevis

@DaneEvans @mdecourcy - ok simplified the rose and did implement an accuracy cone-

  • Data source: We use gps_accuracy (mm) and DOP (PDOP, or HDOP/VDOP fallback) from the node’s Position. If these are missing, uncertainty is “unknown.”
  • Visual: A translucent blue wedge around the bearing shows ±angular error (error radius vs. your distance). Close range + poor accuracy = wide wedge; good accuracy or long distance = narrow wedge.
  • Messaging (beneath the dial, next to distance/bearing):
    • Known: “Estimated area: ±X (±Y°)” — rendered from compass_uncertainty.
    • Unknown: “Estimated area: unknown accuracy” — rendered from compass_uncertainty_unknown.

I need to test this on some more physical devices though- only tested this in the emulator right now- but would love feedback.

Screenshot_1764870764

jakevis avatar Dec 04 '25 18:12 jakevis

Converting to draft pending physical device testing of the error cone.

jakevis avatar Dec 04 '25 22:12 jakevis

@jakevis I made a pr into your fork repo to improve the view of the compass.

RCGV1 avatar Dec 07 '25 07:12 RCGV1

@jakevis I made a pr into your fork repo to improve the view of the compass.

Looks amazing! Thank you!

jakevis avatar Dec 07 '25 09:12 jakevis

How y'all feeling about this, @jakevis @RCGV1 ?

Should we let copilot do a review pass?

jamesarich avatar Dec 07 '25 23:12 jamesarich

The only thing I have not fully tested is the uncertainty feature, also I did not figure out how to localize distance since right now it only shows km

RCGV1 avatar Dec 07 '25 23:12 RCGV1

I have a todo item tomorrow to test this on a couple physical devices now I'm back from the weekend. I want to check the uncertainty cone some more- it's a tad hard to do in the emulator.

I have ran codex-max over it before I pushed to my branch; but yes - I would certainly say copilot should triple check 😀 - I can ask codex to take a pass at the localization as well.

jakevis avatar Dec 08 '25 02:12 jakevis

4E68B13F-F422-4D48-B9AD-132394896253_1_102_o EAEAD6AD-A1CF-4AA7-9E30-6A827387F94C_1_102_o

jakevis avatar Dec 09 '25 21:12 jakevis

@jakevis you'll need to run ./gradlew spotlessApply detekt and clean up any errors

jamesarich avatar Dec 09 '25 22:12 jamesarich

🤦‍♂️ Will do, sorry about that.

jakevis avatar Dec 09 '25 23:12 jakevis

🤦‍♂️ Will do, sorry about that.

no worries, it's a common gotcha most new contribs miss - so much so that we thought about scripting an action to remind folks when detekt or spotless fail on ci 😂

jamesarich avatar Dec 09 '25 23:12 jamesarich

@jakevis you'll need to run ./gradlew spotlessApply detekt and clean up any errors

Ok - we should be set here; and I think all the copilot fixes are implemented

jakevis avatar Dec 12 '25 07:12 jakevis

@jakevis Instead of suppressing the Detekt warnings, let's actually clean up the code.

The errors are pretty descriptive of what needs to happen.

jamesarich avatar Dec 12 '25 11:12 jamesarich

@jakevis Instead of suppressing the Detekt warnings, let's actually clean up the code.

The errors are pretty descriptive of what needs to happen.

I usually try to let a dev resolve their own PR feedback as they are able - but def reach out if you need a hand.

jamesarich avatar Dec 12 '25 14:12 jamesarich

Yes let me take another look - sorry be another day or two. I think I know what happened.. I gave codex some leeway and for it to do a code review, it refactored some stuff and broke it, I reverted; but my prompt now has "always run and fix" before commit - so apparently that's how it likes to fix things..... time to do it by hand.

jakevis avatar Dec 12 '25 17:12 jakevis

so apparently that's how it likes to fix things

dang ol' robots

jamesarich avatar Dec 12 '25 17:12 jamesarich

If you don't mind I might take a whack at it this afternoon - @RCGV1 is begging me to get an internal build up for his :balloon: launch this weekend.

jamesarich avatar Dec 12 '25 17:12 jamesarich

Go for it 😀 - if I get a break here before then, I'll certainly try; but don't block on me- please feel free to fix away.

jakevis avatar Dec 12 '25 17:12 jakevis

Codecov Report

:x: Patch coverage is 0% with 515 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 0.51%. Comparing base (1a78745) to head (a3c51cf). :warning: Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
...astic/feature/node/component/CompassBottomSheet.kt 0.00% 225 Missing :warning:
...eshtastic/feature/node/compass/CompassViewModel.kt 0.00% 117 Missing :warning:
...g/meshtastic/feature/node/detail/NodeDetailList.kt 0.00% 55 Missing :warning:
...stic/feature/node/compass/PhoneLocationProvider.kt 0.00% 48 Missing :warning:
...tic/feature/node/compass/CompassHeadingProvider.kt 0.00% 42 Missing :warning:
.../meshtastic/feature/node/compass/CompassUiState.kt 0.00% 19 Missing :warning:
...shtastic/feature/node/component/PositionSection.kt 0.00% 7 Missing :warning:
...meshtastic/feature/node/detail/NodeDetailScreen.kt 0.00% 1 Missing :warning:
.../meshtastic/feature/node/model/NodeDetailAction.kt 0.00% 1 Missing :warning:
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #3896      +/-   ##
========================================
- Coverage   0.52%   0.51%   -0.02%     
========================================
  Files        395     400       +5     
  Lines      23172   23682     +510     
  Branches    2944    3042      +98     
========================================
  Hits         122     122              
- Misses     23029   23539     +510     
  Partials      21      21              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Dec 12 '25 18:12 codecov[bot]

This is good enough to get in and try out, we can iterate from here. Thanks for the :compass: @jakevis !

jamesarich avatar Dec 12 '25 18:12 jamesarich