From 5ab39a579abd47c25f4864da0d58cf9696bdb9ce Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Fri, 26 May 2017 20:45:04 +0300 Subject: [PATCH] SDL: new option AppOpenFileExtension to open a file with specific extension using the app --- changeAppSettings.sh | 12 ++++++++++ project/AndroidManifestTemplate.xml | 10 ++++++++ project/java/Video.java | 11 +++++++-- .../ballfield/AndroidAppSettings.cfg | 24 +++++++++++++++---- .../jni/application/ballfield/ballfield.cpp | 2 +- 5 files changed, 52 insertions(+), 7 deletions(-) diff --git a/changeAppSettings.sh b/changeAppSettings.sh index d1e6db2af..bd7f2b1c7 100755 --- a/changeAppSettings.sh +++ b/changeAppSettings.sh @@ -435,6 +435,9 @@ echo >> AndroidAppSettings.cfg echo "# Google Play Game Services application ID, required for cloud saves to work" >> AndroidAppSettings.cfg echo GooglePlayGameServicesId=$GooglePlayGameServicesId >> AndroidAppSettings.cfg echo >> AndroidAppSettings.cfg +echo "# The app will open files with following extension, file path will be added to commandline params" >> AndroidAppSettings.cfg +echo AppOpenFileExtension=\'$AppOpenFileExtension\' >> AndroidAppSettings.cfg +echo >> AndroidAppSettings.cfg fi AppShortName=`echo $AppName | sed 's/ //g'` @@ -837,6 +840,15 @@ if [ "$AccessInternet" = "n" ]; then $SEDI "/==INTERNET==/ d" project/AndroidManifest.xml fi +if [ -z "$AppOpenFileExtension" ]; then + $SEDI "/==OPENFILE==/ d" project/AndroidManifest.xml +else + EXTS="`for EXT in $AppOpenFileExtension; do echo -n '\\\\1'$EXT'\\\\2' ; done`" + echo "EXTS $EXTS" + #$SEDI "s/\(.*\)==OPENFILE-EXT==\(.*\)/$EXTS/g" project/AndroidManifest.xml + $SEDI "s/\(.*\)==OPENFILE-EXT==\(.*\)/$EXTS/g" project/AndroidManifest.xml +fi + if [ "$ImmersiveMode" = "n" ]; then ImmersiveMode=false else diff --git a/project/AndroidManifestTemplate.xml b/project/AndroidManifestTemplate.xml index 8c0c07132..4d3abacaf 100644 --- a/project/AndroidManifestTemplate.xml +++ b/project/AndroidManifestTemplate.xml @@ -26,6 +26,16 @@ + + + + + + + + + + diff --git a/project/java/Video.java b/project/java/Video.java index cb0eb8761..f0bd8dd64 100644 --- a/project/java/Video.java +++ b/project/java/Video.java @@ -710,9 +710,16 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer // Tweak video thread priority, if user selected big audio buffer if( Globals.AudioBufferConfig >= 2 ) Thread.currentThread().setPriority( (Thread.NORM_PRIORITY + Thread.MIN_PRIORITY) / 2 ); // Lower than normal - // Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code + // Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code + String commandline = Globals.CommandLine; + if( context.getIntent() != null && context.getIntent().getScheme() != null && + context.getIntent().getScheme().compareTo(android.content.ContentResolver.SCHEME_FILE) == 0 && + context.getIntent().getData() != null && context.getIntent().getData().getPath() != null ) + { + commandline += " " + context.getIntent().getData().getPath(); + } nativeInit( Globals.DataDir, - Globals.CommandLine, + commandline, ( (Globals.SwVideoMode && Globals.MultiThreadedVideo) || Globals.CompatibilityHacksVideo ) ? 1 : 0, 0 ); System.exit(0); // The main() returns here - I don't bother with deinit stuff, just terminate process diff --git a/project/jni/application/ballfield/AndroidAppSettings.cfg b/project/jni/application/ballfield/AndroidAppSettings.cfg index 7a410ef16..cf051843b 100644 --- a/project/jni/application/ballfield/AndroidAppSettings.cfg +++ b/project/jni/application/ballfield/AndroidAppSettings.cfg @@ -46,12 +46,16 @@ NeedDepthBuffer=n # Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n) NeedStencilBuffer=n -# Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by device +# Use GLES 2.x context # you need this option only if you're developing 3-d app (y) or (n) NeedGles2=n -# Use glshim library for provide OpenGL 1.x functionality to OpenGL ES accelerated cards (y) or (n) -UseGlshim= +# Use GLES 3.x context +# you need this option only if you're developing 3-d app (y) or (n) +NeedGles3=n + +# Use gl4es library for provide OpenGL 1.x functionality to OpenGL ES accelerated cards (y) or (n) +UseGl4es= # Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL, # this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n) @@ -182,6 +186,9 @@ AccessInternet= # Immersive mode - Android will hide on-screen Home/Back keys. Looks bad if you invoke Android keyboard. (y) / (n) ImmersiveMode=y +# Hide Android system mouse cursor image when USB mouse is attached (y) or (n) - the app must draw it's own mouse cursor +HideSystemMousePointer= + # Application implements Android-specific routines to put to background, and will not draw anything to screen # between SDL_ACTIVEEVENT lost / gained notifications - you should check for them # rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n) @@ -240,6 +247,12 @@ AppMinimumRAM=0 # GCC version, or 'clang' for CLANG NDK_TOOLCHAIN_VERSION=clang +# Android platform version. +# android-9 = Android 2.3, the earliest supported version. +# android-18 = Android 4.3, the first version supporting GLES3. +# android-21 = Android 5.1, the first version with SO_REUSEPORT defined. +APP_PLATFORM= + # Specify architectures to compile, 'all' or 'y' to compile for all architectures. # Available architectures: armeabi armeabi-v7a x86 mips arm64-v8a MultiABI='armeabi-v7a x86 arm64-v8a' @@ -271,7 +284,7 @@ AppSubdirsBuild='' AppBuildExclude='' # Application command line parameters, including app name as 0-th param -AppCmdline='' +AppCmdline='ballfield' # Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens # Minimum screen size that application supports: (s)mall / (m)edium / (l)arge @@ -289,3 +302,6 @@ AdmobBannerSize= # Google Play Game Services application ID, required for cloud saves to work GooglePlayGameServicesId= +# The app will open files with following extension, file path will be added to commandline params +AppOpenFileExtension='png PNG jpg JPG jpeg JPEG gif GIF' + diff --git a/project/jni/application/ballfield/ballfield.cpp b/project/jni/application/ballfield/ballfield.cpp index 7756c6c72..f334ab178 100644 --- a/project/jni/application/ballfield/ballfield.cpp +++ b/project/jni/application/ballfield/ballfield.cpp @@ -488,7 +488,7 @@ int main(int argc, char* argv[]) /* * Load background image */ - temp_image = IMG_Load("sun.gif"); + temp_image = IMG_Load(argc > 1 ? argv[1] : "sun.gif"); if(!temp_image) { fprintf(stderr, "Could not load background!\n");