1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

Added Android "desktop" integration

This commit is contained in:
Martin Tůma 2023-02-07 00:32:36 +01:00
parent 820350d60b
commit 7bb2c3a09d
3 changed files with 86 additions and 1 deletions

View File

@ -4,11 +4,50 @@
<!-- %%INSERT_FEATURES --> <!-- %%INSERT_FEATURES -->
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/> <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>
<application android:name="org.qtproject.qt.android.bindings.QtApplication" android:extractNativeLibs="true" android:hardwareAccelerated="true" android:label="-- %%INSERT_APP_NAME%% --" android:requestLegacyExternalStorage="true" android:allowNativeHeapPointerTagging="false" android:icon="@drawable/icon"> <application android:name="org.qtproject.qt.android.bindings.QtApplication" android:extractNativeLibs="true" android:hardwareAccelerated="true" android:label="-- %%INSERT_APP_NAME%% --" android:requestLegacyExternalStorage="true" android:allowNativeHeapPointerTagging="false" android:icon="@drawable/icon">
<activity android:name="org.qtproject.qt.android.bindings.QtActivity" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:label="-- %%INSERT_APP_NAME%% --" android:launchMode="singleTop" android:screenOrientation="unspecified" android:exported="true"> <activity android:name="org.gpxsee.gpxsee.Activity" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:label="-- %%INSERT_APP_NAME%% --" android:launchMode="singleTop" android:screenOrientation="unspecified" android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<!-- data files -->
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.gpx"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.kml"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.kmz"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.nmea"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.fit"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.tcx"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.gpi"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.igc"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.plt"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.rte"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.wpt"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.trk"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.ov2"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.itn"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.slf"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.sml"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.cup"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.loc"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.geojson"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.omd"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.ghp"/>
<!-- maps -->
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.map"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.img"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.jnx"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.kap"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.000"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.rmap"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.aqm"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.gemf"/>
<data android:scheme="content" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\.xml"/>
</intent-filter>
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/> <meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
<meta-data android:name="android.app.arguments" android:value="-- %%INSERT_APP_ARGUMENTS%% --"/> <meta-data android:name="android.app.arguments" android:value="-- %%INSERT_APP_ARGUMENTS%% --"/>
<meta-data android:name="android.app.extract_android_style" android:value="minimal"/> <meta-data android:name="android.app.extract_android_style" android:value="minimal"/>

View File

@ -0,0 +1,26 @@
package org.gpxsee.gpxsee;
import android.content.Intent;
public class Activity extends org.qtproject.qt.android.bindings.QtActivity
{
@Override
public void onNewIntent(Intent intent)
{
setIntent(intent);
}
public String intentPath()
{
String path = "";
Intent intent = getIntent();
if (intent != null) {
if (intent.getAction() == Intent.ACTION_VIEW)
path = intent.getDataString();
setIntent(null);
}
return path;
}
}

View File

@ -6,6 +6,11 @@
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QLibraryInfo> #include <QLibraryInfo>
#include <QSurfaceFormat> #include <QSurfaceFormat>
#ifdef Q_OS_ANDROID
#include <QCoreApplication>
#include <QJniObject>
#endif // Q_OS_ANDROID
#include "common/programpaths.h" #include "common/programpaths.h"
#include "common/config.h" #include "common/config.h"
#include "common/downloader.h" #include "common/downloader.h"
@ -102,6 +107,21 @@ void App::appStateChanged(Qt::ApplicationState state)
{ {
if (state == Qt::ApplicationSuspended) if (state == Qt::ApplicationSuspended)
_gui->writeSettings(); _gui->writeSettings();
else if (state == Qt::ApplicationActive) {
QJniObject activity = QNativeInterface::QAndroidApplication::context();
QString path(activity.callObjectMethod<jstring>("intentPath").toString());
if (!path.isEmpty()) {
if (!_gui->openFile(path, true)) {
MapAction *a;
if (!_gui->loadMap(path, a, true))
_gui->openFile(path, false);
else {
if (a)
a->trigger();
}
}
}
}
} }
#endif // Q_OS_ANDROID #endif // Q_OS_ANDROID