feat(native): the Android app's widgets, location, tile store, Play Billing and Google Wallet

The UI now turns these on by feature on Android as well as iOS:

- widgets, widgetTrips and the travel day (liveActivity) write the same
  snapshot to the Android app's Glance widgets; the travel day also sends
  the next stop's minutes and the stops' colours for the Live Update.
- geolocation answers navigator.geolocation from the app's location stream.
- tileCache: Android keeps Mapbox's resources in its WebView client, so the
  map is offline-capable there too, without the iOS trek-tile:// rewrite.
- playBilling: the purchase client buys through Google Play on Android,
  with the purchase token as the receipt the control plane verifies.
- googleWallet: a booking's button adds it to Google Wallet on Android,
  through the save link the server asks the TREK services for.
This commit is contained in:
Maurice
2026-11-07 14:11:59 +01:00
parent d41a4f0827
commit 3beb5c4223
41 changed files with 404 additions and 60 deletions
+8 -4
View File
@@ -1,10 +1,10 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { hasNativeFeature } from './capabilities';
import { _resetNativeGeolocation, installNativeGeolocation } from './geolocation';
import { isNativeIos } from './platform';
import { isNativeApp } from './platform';
import { TrekShell, type NativeLocationPayload } from './trekShell';
vi.mock('./platform', () => ({ isNativeIos: vi.fn() }));
vi.mock('./platform', () => ({ isNativeApp: vi.fn() }));
vi.mock('./capabilities', () => ({ hasNativeFeature: vi.fn() }));
vi.mock('./trekShell', () => ({
TrekShell: { startLocation: vi.fn(), stopLocation: vi.fn(), addListener: vi.fn() },
@@ -16,7 +16,7 @@ const original = navigator.geolocation;
beforeEach(() => {
_resetNativeGeolocation();
Object.defineProperty(navigator, 'geolocation', { configurable: true, value: original });
vi.mocked(isNativeIos).mockReturnValue(true);
vi.mocked(isNativeApp).mockReturnValue(true);
vi.mocked(hasNativeFeature).mockReturnValue(true);
vi.mocked(TrekShell.startLocation).mockReset().mockResolvedValue();
vi.mocked(TrekShell.stopLocation).mockReset().mockResolvedValue();
@@ -71,9 +71,13 @@ describe('native geolocation', () => {
expect(failed.mock.calls[0][0]).toMatchObject({ code: 1, PERMISSION_DENIED: 1 });
});
it('leaves the browser API alone outside an iOS binary with the feature', () => {
it('leaves the browser API alone outside an app binary with the feature', () => {
vi.mocked(hasNativeFeature).mockReturnValue(false);
expect(installNativeGeolocation()).toBe(false);
expect(navigator.geolocation).toBe(original);
vi.mocked(hasNativeFeature).mockReturnValue(true);
vi.mocked(isNativeApp).mockReturnValue(false);
expect(installNativeGeolocation()).toBe(false);
expect(navigator.geolocation).toBe(original);
});
});