Moving the map on geo: intents.

This commit is contained in:
Eric van der Vlist 2022-12-15 19:45:30 +01:00
parent d71399e296
commit f2f55a22bd
3 changed files with 44 additions and 30 deletions

View File

@ -32,7 +32,11 @@
<data android:scheme="geo" />
</intent-filter>
<intent-filter>
<action android:name="com.darryncampbell.cordova.plugin.intent.ACTION"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<provider

View File

@ -1,35 +1,6 @@
import type { Component } from 'solid-js';
import { Routes, Route, Navigate } from '@solidjs/router';
import Map from './components/map';
import { AndroidFullScreen } from '@awesome-cordova-plugins/android-full-screen';
// 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 });
});
} else {
console.log({
caller: 'Intent',
message: "window.plugins doesn't exist",
window,
});
}
const App: Component = () => {
return (

View File

@ -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' &&