From f2f55a22bd1d1e7124fa1329cc005c882273bda6 Mon Sep 17 00:00:00 2001 From: evlist Date: Thu, 15 Dec 2022 19:45:30 +0100 Subject: [PATCH] Moving the map on geo: intents. --- AndroidManifest.xml | 6 +++++- src/App.tsx | 29 ---------------------------- src/components/map/Map.tsx | 39 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 30 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index ec0a0df..730d0f7 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -32,7 +32,11 @@ - + + + + + AndroidFullScreen.immersiveMode()) - .catch(console.warn); - -if (window.plugins) { - window.plugins.intentShim.registerBroadcastReceiver( - { - filterActions: ['android.intent.action.VIEW'], - }, - function (intent: any) { - console.log({ - caller: 'Intent broadcast receiver', - intent, - }); - } - ); - window.plugins.intentShim.onIntent(function (intent: any) { - console.log({ caller: 'Intent receiver', intent }); - }); -} else { - console.log({ - caller: 'Intent', - message: "window.plugins doesn't exist", - window, - }); -} const App: Component = () => { return ( diff --git a/src/components/map/Map.tsx b/src/components/map/Map.tsx index 34f0bdb..76e5f29 100644 --- a/src/components/map/Map.tsx +++ b/src/components/map/Map.tsx @@ -39,6 +39,8 @@ import GpxRecord from '../gpx-record'; import dispatch from '../../workers/dispatcher-main'; import { debounce } from 'lodash'; +import { AndroidFullScreen } from '@awesome-cordova-plugins/android-full-screen'; + const [getState, setState] = createSignal({ lon: 0, lat: 0, @@ -57,6 +59,43 @@ const Map: Component = () => { const navigate = useNavigate(); const params = useParams(); + // See https://stackoverflow.com/questions/71288670/how-to-make-fullscreen-ionic-capacitor-app + AndroidFullScreen.isImmersiveModeSupported() + .then(() => AndroidFullScreen.immersiveMode()) + .catch(console.warn); + + if (window.plugins) { + window.plugins.intentShim.registerBroadcastReceiver( + { + filterActions: ['android.intent.action.VIEW'], + }, + function (intent: any) { + console.log({ + caller: 'Intent broadcast receiver', + intent, + }); + } + ); + window.plugins.intentShim.onIntent(function (intent: any) { + console.log({ caller: 'Intent receiver', intent }); + const url = new URL(intent.data); + const q = url.search; + const [, lat, lon] = q.match(/q=([0-9.]+),([0-9.]+)/); + const zoom = Math.min(18, getState().zoom); + navigate( + `/map/${getState().provider}/${lon}/${lat}/${zoom}/${ + getState().rotation + }` + ); + }); + } else { + console.log({ + caller: 'Intent', + message: "window.plugins doesn't exist", + window, + }); + } + if ( params.lat === '0' && params.lon === '0' &&