SDL: new option AppOpenFileExtension to open a file with specific extension using the app

This commit is contained in:
Sergii Pylypenko
2017-05-26 20:45:04 +03:00
parent d179d4d2c7
commit 5ab39a579a
5 changed files with 52 additions and 7 deletions

View File

@@ -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

View File

@@ -26,6 +26,16 @@
<action android:name="com.sec.android.airview.HOVER" /> <!-- Stupid Samsung requires their own intent for finger-hover events -->
<category android:name="android.intent.category.LEANBACK_LAUNCHER" /> <!-- Android TV requires this -->
<category android:name="tv.ouya.intent.category.GAME" /> <!-- For that one user who still got an OUYA in his living room and won't throw it away just because someone else decides that it's dead -->
<!-- ==OPENFILE== --> <action android:name="android.intent.action.VIEW" />
<!-- ==OPENFILE== --> <category android:name="android.intent.category.DEFAULT" />
<!-- ==OPENFILE== --> <category android:name="android.intent.category.BROWSABLE" />
<!-- ==OPENFILE== --> <data android:scheme="file" />
<!-- ==OPENFILE== --> <data android:mimeType="*/*" />
<!-- ==OPENFILE== --> <data android:host="*" />
<!-- ==OPENFILE== --> <data android:pathPattern=".*\\.==OPENFILE-EXT==" />
<!-- ==OPENFILE== --> <data android:pathPattern=".*\\..*\\.==OPENFILE-EXT==" />
<!-- ==OPENFILE== --> <data android:pathPattern=".*\\..*\\..*\\.==OPENFILE-EXT==" />
<!-- ==OPENFILE== --> <data android:pathPattern=".*\\..*\\..*\\..*\\.==OPENFILE-EXT==" />
</intent-filter>
</activity>
<!-- ==ADMOB== --> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"/>

View File

@@ -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

View File

@@ -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'

View File

@@ -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");