qt6-qmake-android
Simon Stürz 2025-10-16 16:13:42 +02:00
parent 6cf4fccdb6
commit 40881e0cf1
6 changed files with 65 additions and 24 deletions

View File

@ -81,9 +81,6 @@ linux:!android: {
android: {
message("Android package source dir $${ANDROID_PACKAGE_SOURCE_DIR}")
# SUBDIRS += androidservice
# androidservice.depends = libnymea-app
NYMEA_APP_ROOT_PROPERTY="nymeaAppRoot=$${top_srcdir}"
no-firebase: FIREBASE_PROPERTY="useFirebase=false"
else: FIREBASE_PROPERTY="useFirebase=true"

View File

@ -237,3 +237,4 @@ INSTALLS += target
DISTFILES +=
android: include(/usr/local/android/android_openssl/openssl.pri)

View File

@ -20,6 +20,11 @@ import androidx.core.content.FileProvider;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowCompat;
import android.view.WindowInsets;
import android.graphics.Insets;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import org.qtproject.qt.android.bindings.QtActivity;
@ -44,6 +49,7 @@ public class NymeaAppActivity extends QtActivity
@Override
public void onCreate(Bundle savedInstanceState) {
logStaticInitClassesMetadata();
super.onCreate(savedInstanceState);
// Move th app to the background (Edge to edge is forced since SDK 35)
//WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
@ -145,12 +151,62 @@ public class NymeaAppActivity extends QtActivity
public int topPadding() {
WindowInsets windowInsets = getWindow().getDecorView().getRootWindowInsets();
return windowInsets.getInsets(WindowInsets.Type.statusBars() | WindowInsets.Type.displayCutout()).top;
if (windowInsets == null) {
return 0;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Insets insets = windowInsets.getInsets(WindowInsets.Type.statusBars() | WindowInsets.Type.displayCutout());
return insets != null ? insets.top : 0;
}
return windowInsets.getStableInsetTop();
}
public int bottomPadding() {
WindowInsets windowInsets = getWindow().getDecorView().getRootWindowInsets();
return windowInsets.getInsets(WindowInsets.Type.navigationBars() | WindowInsets.Type.displayCutout()).bottom;
if (windowInsets == null) {
return 0;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Insets insets = windowInsets.getInsets(WindowInsets.Type.navigationBars() | WindowInsets.Type.displayCutout());
return insets != null ? insets.bottom : 0;
}
return windowInsets.getStableInsetBottom();
}
private void logStaticInitClassesMetadata() {
try {
ApplicationInfo appInfo = getPackageManager().getApplicationInfo(getPackageName(), PackageManager.GET_META_DATA);
if (appInfo.metaData == null || !appInfo.metaData.containsKey("android.app.static_init_classes")) {
Log.w(TAG, "No android.app.static_init_classes meta-data present in the manifest");
return;
}
Object value = appInfo.metaData.get("android.app.static_init_classes");
if (!(value instanceof Integer)) {
Log.w(TAG, "android.app.static_init_classes meta-data is not a resource reference: " + value);
return;
}
int resId = (Integer) value;
if (resId == 0) {
Log.e(TAG, "android.app.static_init_classes meta-data resolves to resource id 0");
return;
}
try {
String resName = getResources().getResourceName(resId);
String resValue = getResources().getString(resId);
Log.i(TAG, "android.app.static_init_classes -> " + resName + " = " + resValue);
} catch (Resources.NotFoundException notFoundException) {
Log.e(TAG, "android.app.static_init_classes references missing resource 0x" + Integer.toHexString(resId), notFoundException);
}
} catch (PackageManager.NameNotFoundException exception) {
Log.e(TAG, "Failed to inspect android.app.static_init_classes meta-data", exception);
}
}
}

View File

@ -63,9 +63,11 @@
<meta-data android:name="android.app.splash_screen_sticky" android:value="true"/>
<!-- Splash screen -->
<meta-data android:name="android.app.load_local_libs_resource_id" android:resource="@array/load_local_libs"/>
<meta-data
android:name="android.app.lib_name"
android:value="nymea-app" />
android:name="android.app.lib_name"
android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
<meta-data
android:name="android.app.arguments"
@ -83,8 +85,6 @@
</provider>
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
<meta-data android:name="com.google.firebase.messaging.default_notification_icon" android:resource="@drawable/notificationicon"/>
<meta-data android:name="com.google.firebase.messaging.default_notification_color" android:resource="@color/notification_icon_color"/>
@ -97,12 +97,7 @@
</intent-filter>
</service>
<service android:name="io.guh.nymeaapp.NymeaAppControlService" android:permission="android.permission.BIND_CONTROLS" android:exported="true">
<intent-filter>
<action android:name="android.service.controls.ControlsProviderService"/>
</intent-filter>
</service>
<!--
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="io.guh.nymeaapp.fileprovider"
@ -111,7 +106,7 @@
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</provider>-->
</application>
</manifest>

View File

@ -10,7 +10,6 @@ println "Package source root ${nymeaAppRoot}"
buildscript {
repositories {
jcenter()
google()
mavenCentral()
}
@ -24,7 +23,6 @@ buildscript {
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}

View File

@ -1,9 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
<array name="qt_sources">
<item>https://download.qt.io/ministro/android/qt6/qt-6.8</item>
</array>
<!-- The following is handled automatically by the deployment tool. It should
not be edited manually. -->
@ -26,6 +22,4 @@
<!-- %%INSERT_LOCAL_LIBS%% -->
</array>
<string name="qt_static_init_classes"></string>
</resources>