trilium/apps/mobile/android
Elian Doran 8b10c77c86
feat(geomap): show the device's location with MapLibre's locate button
Adds MapLibre's own GeolocateControl to the geo map, in the bottom-right
corner above the camera group, in tracking mode: the first press asks the
browser for the device's position, frames it to the accuracy of the fix and
follows it; dragging the map keeps the dot and frees the camera; a second
press turns the watch off and removes the dot.

The control is reused rather than rewritten. Its behaviour is what a
Trilium implementation would have had to copy: fitBounds on the accuracy
radius with a zoom cap, the active/background state machine driven by
movestart, the stale-dot treatment on error, and a permission probe that
notices an insecure origin and disables the button. Only its white button
clashes with the map's own controls, and that is a later step: the plan is
to hide the stock button and drive trigger() from an OverlayControlButton
on MapToolbar, mirroring the control's events. The dot and accuracy circle
are DOM markers, so unlike the layer-drawn pins they need no carrying
across a style switch.

The stock button stands one inset above MapToolbar's group, placed through
the existing --geo-map-foot variable, so the two do not overlap and the
button follows the group's safe-area insets in fullscreen.

Electron denied geolocation on purpose in the session permission
allowlist; it is now granted to the trilium-app://app shell only, gated by
the same origin check as clipboard-write and notifications, so a remote
embed in the default session does not learn where the device is. MapLibre
probes the permission through the synchronous check handler before it
enables its button, which is why the allowlist entry is needed for the
button to be usable at all on desktop.

Android declares coarse and fine location so Capacitor's WebChromeClient
can prompt for them, and marks the location hardware features as optional:
ACCESS_FINE_LOCATION otherwise implies GPS as a required feature, which
Google Play uses to hide the app from GPS-less devices. iOS declares the
when-in-use usage description, without which WebKit refuses the API.

Verified: the MapToolbar spec asserts the control is added in tracking
mode, removed on unmount and not removed from a map that already tore down;
the desktop spec asserts the app shell is granted geolocation and embeds
and guests are not. Both fail with the respective change reverted. Not
verified: the running app, the mobile builds, and the Linux desktop path,
where Chromium's network location provider may need a Google API key.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-05 19:32:26 +02:00
..
app feat(geomap): show the device's location with MapLibre's locate button 2026-09-05 19:32:26 +02:00
gradle/wrapper Update Gradle to v9 2026-05-16 06:44:34 +00:00
.gitattributes chore(mobile): pin Capacitor gradle scaffold to LF to stop CRLF churn 2026-07-04 19:27:59 +03:00
.gitignore chore(mobile): init Android project 2026-04-20 15:38:02 +03:00
build.gradle fix(mobile): pin Android Gradle Plugin to 9.1.1 and stop Renovate bumping it 2026-07-03 17:28:50 +03:00
capacitor.settings.gradle chore(mobile): sync native projects for Capacitor 8.4.1 2026-07-04 23:56:38 +03:00
gradle.properties chore(mobile): init Android project 2026-04-20 15:38:02 +03:00
gradlew fix(ci): gradle not executable 2026-04-20 17:29:33 +03:00
gradlew.bat chore(mobile): init Android project 2026-04-20 15:38:02 +03:00
settings.gradle chore(mobile): init Android project 2026-04-20 15:38:02 +03:00
variables.gradle chore(mobile): init Android project 2026-04-20 15:38:02 +03:00