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
+16 -3
View File
@@ -1,26 +1,39 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { hasNativeFeature } from './capabilities';
import { isNativeIos } from './platform';
import { isNativeApp, isNativeIos } from './platform';
import { mapboxTileCacheRequest, nativeRasterTemplate, tileCacheActive, toTileCacheUrl } from './tileCache';
vi.mock('./platform', () => ({ isNativeIos: vi.fn() }));
vi.mock('./platform', () => ({ isNativeIos: vi.fn(), isNativeApp: vi.fn() }));
vi.mock('./capabilities', () => ({ hasNativeFeature: vi.fn() }));
beforeEach(() => {
vi.mocked(isNativeIos).mockReturnValue(true);
vi.mocked(isNativeApp).mockReturnValue(true);
vi.mocked(hasNativeFeature).mockReturnValue(true);
});
describe('tileCache', () => {
it('is on only in an iOS binary that has the store', () => {
it('is on only in an app binary that has the store', () => {
expect(tileCacheActive()).toBe(true);
vi.mocked(hasNativeFeature).mockReturnValue(false);
expect(tileCacheActive()).toBe(false);
vi.mocked(hasNativeFeature).mockReturnValue(true);
vi.mocked(isNativeIos).mockReturnValue(false);
vi.mocked(isNativeApp).mockReturnValue(false);
expect(tileCacheActive()).toBe(false);
});
it('on Android keeps the store but leaves every URL as it is: the WebView client takes the requests', () => {
vi.mocked(isNativeIos).mockReturnValue(false);
expect(tileCacheActive()).toBe(true);
expect(nativeRasterTemplate('https://{s}.tiles.example.com/{z}/{x}/{y}.png')).toBe(
'https://{s}.tiles.example.com/{z}/{x}/{y}.png'
);
expect(mapboxTileCacheRequest('https://a.tiles.mapbox.com/v4/x/1/2/3.vector.pbf', 'Tile').url).toBe(
'https://a.tiles.mapbox.com/v4/x/1/2/3.vector.pbf'
);
});
it('swaps only the scheme, so the store knows where the tile lives', () => {
expect(toTileCacheUrl('https://a.tile.example.com/1/2/3.png?k=v')).toBe(
'trek-tile://a.tile.example.com/1/2/3.png?k=v'