From 482bd03fd1b84eadce63c4024575e3ebc8b81af8 Mon Sep 17 00:00:00 2001 From: DrBeef Date: Wed, 15 Oct 2025 22:28:55 +0100 Subject: [PATCH] few minor fixes - permissions bug - updated gradle configuration - fix missing mouse cursor --- .gitignore | 2 +- Projects/Android/AndroidManifest.xml | 52 +++--- Projects/Android/build.gradle | 161 +++++++++++++----- .../gradle/wrapper/gradle-wrapper.properties | 2 +- .../src/Xash3D/xash3d/engine/client/touch.c | 10 +- .../src/Xash3D/xash3d/engine/common/build.c | 2 +- .../xash3d/engine/common/imagelib/img_main.c | 3 + Projects/Android/local.properties | 1 - Projects/Android/settings.gradle | 5 +- .../drbeef/lambda1vr/GLES3JNIActivity.java | 41 +---- 10 files changed, 170 insertions(+), 109 deletions(-) diff --git a/.gitignore b/.gitignore index 53f5542..5e35b53 100644 --- a/.gitignore +++ b/.gitignore @@ -35,7 +35,7 @@ Projects/Android/.cxx/* Projects/Android/.externalNativeBuild/* Projects/Android/.gradle/* Projects/Android/.idea/codeStyles/Project.xml -.idea/* +Projects/.idea/* .gradle/* assets/* *.json diff --git a/Projects/Android/AndroidManifest.xml b/Projects/Android/AndroidManifest.xml index e4a1718..536956a 100644 --- a/Projects/Android/AndroidManifest.xml +++ b/Projects/Android/AndroidManifest.xml @@ -1,44 +1,50 @@ + package="com.drbeef.lambda1vr" + android:versionCode="35" + android:versionName="1.7.0" android:installLocation="auto" > - + + + android:required="true" /> + - - + + + - - - + android:extractNativeLibs="true" + android:requestLegacyExternalStorage="true" > + + + + + + + + + + - - - + android:name="com.drbeef.lambda1vr.GLES3JNIActivity" + android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" + android:launchMode="singleTask" + android:screenOrientation="landscape" + android:excludeFromRecents="false" + android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode"> diff --git a/Projects/Android/build.gradle b/Projects/Android/build.gradle index 0765e58..3717e8e 100644 --- a/Projects/Android/build.gradle +++ b/Projects/Android/build.gradle @@ -1,66 +1,147 @@ +buildscript { + repositories { + google() // For Gradle 4.0+ + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.3' + } +} + apply plugin: 'com.android.application' -apply from: "${rootProject.projectDir}/XrApp.gradle" android { - // This is the name of the generated apk file, which will have - // -debug.apk or -release.apk appended to it. - // The filename doesn't effect the Android installation process. - // Use only letters to remain compatible with the package name. - project.archivesBaseName = "lambda1vr" + // This is the name of the generated apk file, which will have + // -debug.apk or -release.apk appended to it. + // The filename doesn't effect the Android installation process. + // Use only letters to remain compatible with the package name. + project.archivesBaseName = "lambda1vr" - defaultConfig { - // Gradle replaces the manifest package with this value, which must - // be unique on a system. If you don't change it, a new app - // will replace an older one. - applicationId "com.drbeef." + project.archivesBaseName + defaultConfig { + // Gradle replaces the manifest package with this value, which must + // be unique on a system. If you don't change it, a new app + // will replace an older one. + applicationId "com.drbeef." + project.archivesBaseName + + externalNativeBuild { + ndk { + abiFilters 'arm64-v8a' + } + ndkBuild { + def numProcs = Runtime.runtime.availableProcessors() + arguments "V=0", "-j$numProcs", "-C$project.buildDir.parent", "APP_PLATFORM=android-29", "NDK_TOOLCHAIN_VERSION=clang", "APP_STL=c++_static" + abiFilters 'arm64-v8a' + } + } + + minSdkVersion 29 + targetSdkVersion 29 + } - // override app plugin abiFilters for both 32 and 64-bit support externalNativeBuild { - ndk { - abiFilters 'arm64-v8a' - } ndkBuild { - abiFilters 'arm64-v8a' + path file('jni/Android.mk') } } - - minSdkVersion 26 - targetSdkVersion 26 - } - sourceSets { - main { - manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = ['../../java'] - jniLibs.srcDir 'libs' - res.srcDirs = ['../../res'] - assets.srcDirs = ['../../assets'] + signingConfigs { + def keystorePath = (project.hasProperty('key.store')) ? + new File(project.getProperty('key.store')) : + project.file('android.debug.keystore') + + def keystorePassword = (project.hasProperty('key.store.password')) ? + project.getProperty('key.store.password') : 'android' + + def keystoreKeyAlias = (project.hasProperty('key.alias')) ? + project.getProperty('key.alias') : 'androiddebugkey' + + def keystoreKeyPassword = (project.hasProperty('key.alias.password')) ? + project.getProperty('key.alias.password') : 'android' + + debug { + storeFile keystorePath + storePassword keystorePassword + keyAlias keystoreKeyAlias + keyPassword keystoreKeyPassword + v2SigningEnabled true + } + + release { + storeFile keystorePath + storePassword keystorePassword + keyAlias keystoreKeyAlias + keyPassword keystoreKeyPassword + v2SigningEnabled true + } } - } + + buildTypes { + debug { + signingConfig signingConfigs.debug + debuggable true + jniDebuggable true + + externalNativeBuild { + ndkBuild { + arguments "NDK_DEBUG=1","USE_ASAN=1" + } + } + } + + release { + signingConfig signingConfigs.release + debuggable false + jniDebuggable false + + externalNativeBuild { + ndkBuild { + arguments "NDK_DEBUG=0","USE_ASAN=0" + } + } + } + } + + sourceSets.main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['../../java'] + jniLibs.srcDir 'libs' + res.srcDirs = ['../../res'] + assets.srcDirs = ['../../assets'] + jni.srcDirs = ['jni'] + } + + lintOptions { + checkReleaseBuilds false + disable 'ExpiredTargetSdkVersion' + } + + //packagingOptions { + // exclude 'lib/arm64-v8a/libopenxr_loader.so' + //} + compileOptions { sourceCompatibility = '1.8' targetCompatibility = '1.8' } - - packagingOptions { - exclude 'lib/arm64-v8a/libopenxr_loader.so' - } - - compileSdkVersion = 24 - buildToolsVersion = '29.0.2' + compileSdkVersion = 29 + buildToolsVersion = '29.0.3' + ndkVersion '21.1.6352462' } dependencies { implementation "com.android.support:support-compat:26.1.0" implementation "com.android.support:support-core-utils:26.1.0" - implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) + //implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) } repositories { google() } -buildscript { - repositories { - google() - } + +// Workaround to fix issue in Android Studio Chipmunk 2021.2.1 and later +// where opening a project would result in a 'prepareKotlinBuildScriptModel' +// not found error +if (!tasks.findByName("prepareKotlinBuildScriptModel")) { + tasks.register("prepareKotlinBuildScriptModel") {} } \ No newline at end of file diff --git a/Projects/Android/gradle/wrapper/gradle-wrapper.properties b/Projects/Android/gradle/wrapper/gradle-wrapper.properties index 8edb89e..46c41eb 100644 --- a/Projects/Android/gradle/wrapper/gradle-wrapper.properties +++ b/Projects/Android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Sat Sep 03 13:58:17 BST 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/touch.c b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/touch.c index d7451a7..af8e951 100644 --- a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/touch.c +++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/touch.c @@ -1027,7 +1027,7 @@ qboolean Touch_IsVisible( touch_button_t *button ) void Touch_DrawTouchPoint() { - if( !touch.initialized || (!touch_enable->integer && !touch.clientonly) ) + if( !touch.initialized)// || (!touch_enable->integer && !touch.clientonly) ) return; if( cls.key_dest == key_game ) @@ -1243,7 +1243,7 @@ void Touch_Draw( void ) { touch_button_t *button; - if( !touch.initialized || (!touch_enable->integer && !touch.clientonly) ) + if( !touch.initialized)// || (!touch_enable->integer && !touch.clientonly) ) return; if( cls.key_dest != key_game && touch_in_menu->integer == 0 ) @@ -1820,7 +1820,7 @@ int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx return 0; } - if( !touch.initialized || (!touch_enable->integer && !touch.clientonly) ) + if( !touch.initialized)// || (!touch_enable->integer && !touch.clientonly) ) { #if 0 if( type == event_down ) @@ -1852,8 +1852,8 @@ void Touch_KeyEvent( int key, int down ) int xi, yi; float x, y; - if( touch_enable->integer ) - return; +// if( touch_enable->integer ) +// return; if( !touch.clientonly ) return; diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/common/build.c b/Projects/Android/jni/src/Xash3D/xash3d/engine/common/build.c index 75b6553..d5da748 100644 --- a/Projects/Android/jni/src/Xash3D/xash3d/engine/common/build.c +++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/common/build.c @@ -139,7 +139,7 @@ Q_buildcommit will identify this build as release or "notset" */ const char *Q_buildcommit( void ) { - return "Lambda1VR-v1.6.3"; + return "Lambda1VR-v1.7.0"; } /* diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/common/imagelib/img_main.c b/Projects/Android/jni/src/Xash3D/xash3d/engine/common/imagelib/img_main.c index 9ce8d64..8d7b460 100644 --- a/Projects/Android/jni/src/Xash3D/xash3d/engine/common/imagelib/img_main.c +++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/common/imagelib/img_main.c @@ -223,6 +223,9 @@ rgbdata_t *FS_LoadImage( const char *filename, const byte *buffer, size_t size ) { const char *ext = FS_FileExtension( filename ); string path, loadname, sidename; + memset(path, 0, 256); + memset(loadname, 0, 256); + memset(sidename, 0, 256); qboolean anyformat = true; qboolean gamedironly = true; int i; diff --git a/Projects/Android/local.properties b/Projects/Android/local.properties index 4494cdd..14c1faf 100644 --- a/Projects/Android/local.properties +++ b/Projects/Android/local.properties @@ -5,5 +5,4 @@ # For customization when using a Version Control System, please read the # header note. #Thu Dec 12 20:21:11 GMT 2019 -ndk.dir=C\:\\Users\\Simon\\AppData\\Local\\Android\\Sdk\\ndk\\21.1.6352462 sdk.dir=C\:\\Users\\Simon\\AppData\\Local\\Android\\Sdk diff --git a/Projects/Android/settings.gradle b/Projects/Android/settings.gradle index bdaeba5..d57ad41 100644 --- a/Projects/Android/settings.gradle +++ b/Projects/Android/settings.gradle @@ -1,4 +1 @@ -rootProject.projectDir = new File(settingsDir, '../..') -rootProject.name = "Lambda1VR" - -include ':', 'Projects:Android' +rootProject.name = "Lambda1VR" \ No newline at end of file diff --git a/java/com/drbeef/lambda1vr/GLES3JNIActivity.java b/java/com/drbeef/lambda1vr/GLES3JNIActivity.java index 57304a9..e39f763 100644 --- a/java/com/drbeef/lambda1vr/GLES3JNIActivity.java +++ b/java/com/drbeef/lambda1vr/GLES3JNIActivity.java @@ -58,7 +58,8 @@ import static android.system.Os.setenv; private static final String TAG = "Lambda1VR"; - private int permissionCount = 0; + private boolean permissionsGranted = false; + private static final int READ_EXTERNAL_STORAGE_PERMISSION_ID = 1; private static final int WRITE_EXTERNAL_STORAGE_PERMISSION_ID = 2; @@ -82,17 +83,6 @@ import static android.system.Os.setenv; setContentView( mView ); mView.getHolder().addCallback( this ); - // Force the screen to stay on, rather than letting it dim and shut off - // while the user is watching a movie. - getWindow().addFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON ); - - // Force screen brightness to stay at maximum - WindowManager.LayoutParams params = getWindow().getAttributes(); - params.screenBrightness = 1.0f; - getWindow().setAttributes( params ); - - - checkPermissionsAndInitialize(); } @@ -105,15 +95,8 @@ import static android.system.Os.setenv; GLES3JNIActivity.this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_EXTERNAL_STORAGE_PERMISSION_ID); - } - else - { - permissionCount++; - } - - if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) - != PackageManager.PERMISSION_GRANTED) - { + } else if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) + != PackageManager.PERMISSION_GRANTED){ ActivityCompat.requestPermissions( GLES3JNIActivity.this, new String[] {Manifest.permission.READ_EXTERNAL_STORAGE}, @@ -121,10 +104,10 @@ import static android.system.Os.setenv; } else { - permissionCount++; + permissionsGranted = true; } - if (permissionCount == 2) { + if (permissionsGranted) { // Permissions have already been granted. create(); } @@ -134,21 +117,13 @@ import static android.system.Os.setenv; @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] results) { if (requestCode == READ_EXTERNAL_STORAGE_PERMISSION_ID) { - if (results.length > 0 && results[0] == PackageManager.PERMISSION_GRANTED) { - permissionCount++; - } - else - { + if (results.length > 0 && results[0] != PackageManager.PERMISSION_GRANTED) { System.exit(0); } } if (requestCode == WRITE_EXTERNAL_STORAGE_PERMISSION_ID) { - if (results.length > 0 && results[0] == PackageManager.PERMISSION_GRANTED) { - permissionCount++; - } - else - { + if (results.length > 0 && results[0] != PackageManager.PERMISSION_GRANTED) { System.exit(0); } }