Moving the map on geo: intents.
This commit is contained in:
parent
d71399e296
commit
f2f55a22bd
|
@ -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
|
||||
|
|
29
src/App.tsx
29
src/App.tsx
|
@ -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 (
|
||||
|
|
|
@ -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' &&
|
||||
|
|
Loading…
Reference in New Issue