Editable data download path/application curdir, editable app commandline, updated teadme
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
KEYSTORE=~/.ssh/android.keystore
|
||||
ALIAS=pelya
|
||||
APPS_SKIP="src jooleem_0.1.4 lbreakout2 glxgears atari800 scummvm"
|
||||
APPS_SKIP="src scummvm"
|
||||
|
||||
mkdir -p apk
|
||||
|
||||
|
||||
@@ -148,9 +148,7 @@ class DataDownloader extends Thread
|
||||
Parent = _Parent;
|
||||
Status = new StatusWriter( _Status, _Parent );
|
||||
//Status.setText( "Connecting to " + Globals.DataDownloadUrl );
|
||||
outFilesDir = Parent.getFilesDir().getAbsolutePath();
|
||||
if( Globals.DownloadToSdcard )
|
||||
outFilesDir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/app-data/" + Globals.class.getPackage().getName();
|
||||
outFilesDir = Globals.DataDir;
|
||||
DownloadComplete = false;
|
||||
this.start();
|
||||
}
|
||||
@@ -217,18 +215,15 @@ class DataDownloader extends Thread
|
||||
checkFile = null;
|
||||
|
||||
// Create output directory (not necessary for phone storage)
|
||||
if( Globals.DownloadToSdcard )
|
||||
{
|
||||
try {
|
||||
(new File( outFilesDir )).mkdirs();
|
||||
OutputStream out = new FileOutputStream( getOutFilePath(".nomedia") );
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
catch( SecurityException e ) {}
|
||||
catch( FileNotFoundException e ) {}
|
||||
catch( IOException e ) {};
|
||||
try {
|
||||
(new File( outFilesDir )).mkdirs();
|
||||
OutputStream out = new FileOutputStream( getOutFilePath(".nomedia") );
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
catch( SecurityException e ) {}
|
||||
catch( FileNotFoundException e ) {}
|
||||
catch( IOException e ) {};
|
||||
|
||||
HttpResponse response = null;
|
||||
HttpGet request;
|
||||
|
||||
@@ -83,10 +83,12 @@ class Globals {
|
||||
public static int RemapHwKeycode[] = new int[SDL_Keys.JAVA_KEYCODE_LAST];
|
||||
public static int RemapScreenKbKeycode[] = new int[6];
|
||||
public static boolean ScreenKbControlsShown[] = new boolean[8]; /* Also joystick and text input button added */
|
||||
public static int ScreenKbControlsLayout[][] = new int[8][4];
|
||||
public static int RemapMultitouchGestureKeycode[] = new int[4];
|
||||
public static boolean MultitouchGesturesUsed[] = new boolean[4];
|
||||
public static int MultitouchGestureSensitivity = 1;
|
||||
public static int TouchscreenCalibration[] = new int[4];
|
||||
public static String DataDir = new String("");
|
||||
}
|
||||
|
||||
class LoadLibrary {
|
||||
|
||||
@@ -31,6 +31,9 @@ import android.widget.FrameLayout;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap;
|
||||
import android.widget.TextView;
|
||||
import android.widget.EditText;
|
||||
import android.text.Editable;
|
||||
|
||||
|
||||
|
||||
@@ -95,6 +98,12 @@ class Settings
|
||||
out.writeInt(Globals.MultitouchGestureSensitivity);
|
||||
for( int i = 0; i < Globals.TouchscreenCalibration.length; i++ )
|
||||
out.writeInt(Globals.TouchscreenCalibration[i]);
|
||||
out.writeInt(Globals.DataDir.length());
|
||||
for( int i = 0; i < Globals.DataDir.length(); i++ )
|
||||
out.writeChar(Globals.DataDir.charAt(i));
|
||||
out.writeInt(Globals.CommandLine.length());
|
||||
for( int i = 0; i < Globals.CommandLine.length(); i++ )
|
||||
out.writeChar(Globals.CommandLine.charAt(i));
|
||||
|
||||
out.close();
|
||||
settingsLoaded = true;
|
||||
@@ -200,6 +209,17 @@ class Settings
|
||||
Globals.MultitouchGestureSensitivity = settingsFile.readInt();
|
||||
for( int i = 0; i < Globals.TouchscreenCalibration.length; i++ )
|
||||
Globals.TouchscreenCalibration[i] = settingsFile.readInt();
|
||||
StringBuilder b = new StringBuilder();
|
||||
int len = settingsFile.readInt();
|
||||
for( int i = 0; i < len; i++ )
|
||||
b.append( settingsFile.readChar() );
|
||||
Globals.DataDir = b.toString();
|
||||
|
||||
b = new StringBuilder();
|
||||
len = settingsFile.readInt();
|
||||
for( int i = 0; i < len; i++ )
|
||||
b.append( settingsFile.readChar() );
|
||||
Globals.CommandLine = b.toString();
|
||||
|
||||
settingsLoaded = true;
|
||||
|
||||
@@ -211,6 +231,11 @@ class Settings
|
||||
} catch( SecurityException e ) {
|
||||
} catch ( IOException e ) {};
|
||||
|
||||
if( Globals.DataDir.length() == 0 )
|
||||
Globals.DataDir = Globals.DownloadToSdcard ?
|
||||
Environment.getExternalStorageDirectory().getAbsolutePath() + "/app-data/" + Globals.class.getPackage().getName() :
|
||||
p.getFilesDir().getAbsolutePath();
|
||||
|
||||
// This code fails for both of my phones!
|
||||
/*
|
||||
Configuration c = new Configuration();
|
||||
@@ -494,7 +519,8 @@ class Settings
|
||||
}catch(Exception e) {}
|
||||
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.storage_phone, freePhone),
|
||||
p.getResources().getString(R.string.storage_sd, freeSdcard) };
|
||||
p.getResources().getString(R.string.storage_sd, freeSdcard),
|
||||
p.getResources().getString(R.string.storage_custom) };
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
String [] downloadFiles = Globals.DataDownloadUrl.split("\\^");
|
||||
builder.setTitle(downloadFiles[0].split("[|]")[0]);
|
||||
@@ -502,9 +528,66 @@ class Settings
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.DownloadToSdcard = (item == 1);
|
||||
Globals.DownloadToSdcard = (item != 0);
|
||||
Globals.DataDir = Globals.DownloadToSdcard ?
|
||||
Environment.getExternalStorageDirectory().getAbsolutePath() + "/app-data/" + Globals.class.getPackage().getName() :
|
||||
p.getFilesDir().getAbsolutePath();
|
||||
|
||||
dialog.dismiss();
|
||||
|
||||
if( item == 2 )
|
||||
showCustomDownloadDirConfig(p);
|
||||
else
|
||||
showConfigMainMenu(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
};
|
||||
|
||||
static void showCustomDownloadDirConfig(final MainActivity p) {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.storage_custom));
|
||||
|
||||
final EditText edit = new EditText(p);
|
||||
edit.setFocusableInTouchMode(true);
|
||||
edit.setFocusable(true);
|
||||
edit.setText(Globals.DataDir);
|
||||
builder.setView(edit);
|
||||
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.DataDir = edit.getText().toString();
|
||||
dialog.dismiss();
|
||||
showCommandLineConfig(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
};
|
||||
|
||||
static void showCommandLineConfig(final MainActivity p) {
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.storage_commandline));
|
||||
|
||||
final EditText edit = new EditText(p);
|
||||
edit.setFocusableInTouchMode(true);
|
||||
edit.setFocusable(true);
|
||||
edit.setText(Globals.CommandLine);
|
||||
builder.setView(edit);
|
||||
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.CommandLine = edit.getText().toString();
|
||||
dialog.dismiss();
|
||||
showConfigMainMenu(p);
|
||||
}
|
||||
});
|
||||
@@ -1369,8 +1452,6 @@ class Settings
|
||||
|
||||
static void Apply(Activity p)
|
||||
{
|
||||
nativeIsSdcardUsed( Globals.DownloadToSdcard ? 1 : 0 );
|
||||
|
||||
if( Globals.PhoneHasTrackball )
|
||||
nativeSetTrackballUsed();
|
||||
if( Globals.AppUsesMouse )
|
||||
@@ -1452,7 +1533,6 @@ class Settings
|
||||
}
|
||||
}
|
||||
|
||||
private static native void nativeIsSdcardUsed(int flag);
|
||||
private static native void nativeSetTrackballUsed();
|
||||
private static native void nativeSetTrackballDampening(int value);
|
||||
private static native void nativeSetAccelerometerSettings(int sensitivity, int centerPos);
|
||||
|
||||
@@ -212,9 +212,7 @@ 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
|
||||
nativeInit( Globals.DownloadToSdcard ?
|
||||
Environment.getExternalStorageDirectory().getAbsolutePath() + "/app-data/" + Globals.class.getPackage().getName() :
|
||||
context.getFilesDir().getAbsolutePath(),
|
||||
nativeInit( Globals.DataDir,
|
||||
Globals.CommandLine); // Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code
|
||||
System.exit(0); // The main() returns here - I don't bother with deinit stuff, just terminate process
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
<string name="storage_phone">Internal storage - %d MB free</string>
|
||||
<string name="storage_sd">SD card storage - %d MB free</string>
|
||||
<string name="storage_custom">Specify directory</string>
|
||||
<string name="storage_commandline">Specify command line parameters</string>
|
||||
<string name="storage_question">Where to download application data</string>
|
||||
<string name="optional_downloads">Optional downloads</string>
|
||||
<string name="ok">OK</string>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# The application settings for Android libSDL port
|
||||
AppSettingVersion=15
|
||||
AppSettingVersion=16
|
||||
LibSdlVersion=1.2
|
||||
AppName="REminiscence"
|
||||
AppFullName=fr.freecyxdown.sdl
|
||||
@@ -20,6 +20,7 @@ NonBlockingSwapBuffers=n
|
||||
RedefinedKeys="RSHIFT RETURN BACKSPACE RETURN SPACE"
|
||||
AppTouchscreenKeyboardKeysAmount=3
|
||||
AppTouchscreenKeyboardKeysAmountAutoFire=0
|
||||
RedefinedKeysScreenKb="RSHIFT RETURN BACKSPACE RETURN SPACE"
|
||||
MultiABI=n
|
||||
AppVersionCode=01901
|
||||
AppVersionName="0.1.9"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# The application settings for Android libSDL port
|
||||
AppSettingVersion=15
|
||||
AppSettingVersion=16
|
||||
LibSdlVersion=1.3
|
||||
AppName="Alien Blaster"
|
||||
AppFullName=de.schwardtnet.alienblaster
|
||||
@@ -20,6 +20,7 @@ NonBlockingSwapBuffers=n
|
||||
RedefinedKeys="RETURN LCTRL PAGEUP PAGEDOWN LCTRL"
|
||||
AppTouchscreenKeyboardKeysAmount=4
|
||||
AppTouchscreenKeyboardKeysAmountAutoFire=1
|
||||
RedefinedKeysScreenKb="RETURN LCTRL PAGEUP PAGEDOWN LCTRL"
|
||||
MultiABI=n
|
||||
AppVersionCode=110013
|
||||
AppVersionName="1.1.0.13 - fixed crashes for some devices"
|
||||
|
||||
@@ -22,8 +22,8 @@ AppTouchscreenKeyboardKeysAmount=0
|
||||
AppTouchscreenKeyboardKeysAmountAutoFire=0
|
||||
RedefinedKeysScreenKb="LALT RETURN KP_PLUS KP_MINUS SPACE DELETE KP_PLUS KP_MINUS 1 2"
|
||||
MultiABI=n
|
||||
AppVersionCode=10508
|
||||
AppVersionName="1.0.5.08"
|
||||
AppVersionCode=10509
|
||||
AppVersionName="1.0.5.09"
|
||||
CompiledLibraries="jpeg png freetype timidity lzma lzo2"
|
||||
CustomBuildScript=y
|
||||
AppCflags=''
|
||||
|
||||
@@ -1 +1 @@
|
||||
fheroes2
|
||||
ballfield
|
||||
@@ -25,40 +25,27 @@
|
||||
#define JAVA_EXPORT_NAME(name) JAVA_EXPORT_NAME1(name,SDL_JAVA_PACKAGE_PATH)
|
||||
|
||||
|
||||
static int isSdcardUsed = 0;
|
||||
|
||||
extern C_LINKAGE void
|
||||
JAVA_EXPORT_NAME(DemoRenderer_nativeInit) ( JNIEnv* env, jobject thiz, jstring jcurdir, jstring cmdline )
|
||||
{
|
||||
int i = 0;
|
||||
char curdir[PATH_MAX] = "";
|
||||
char realcurdir[PATH_MAX] = "";
|
||||
const jbyte *jstr;
|
||||
const char * str = "sdl";
|
||||
int argc = 0;
|
||||
char ** argv = NULL;
|
||||
|
||||
if( isSdcardUsed )
|
||||
{
|
||||
strcpy(curdir, "/sdcard/app-data/");
|
||||
strcat(curdir, SDL_CURDIR_PATH);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(curdir, "/data/data/");
|
||||
strcat(curdir, SDL_CURDIR_PATH);
|
||||
strcat(curdir, "/files");
|
||||
}
|
||||
strcpy(curdir, "/sdcard/app-data/");
|
||||
strcat(curdir, SDL_CURDIR_PATH);
|
||||
|
||||
jstr = (*env)->GetStringUTFChars(env, jcurdir, NULL);
|
||||
if (jstr != NULL && strlen(jstr) > 0)
|
||||
strcpy(curdir, jstr);
|
||||
(*env)->ReleaseStringUTFChars(env, jcurdir, jstr);
|
||||
|
||||
if( realpath(curdir, realcurdir) == NULL )
|
||||
strcpy(realcurdir, curdir);
|
||||
chdir(realcurdir);
|
||||
setenv("HOME", realcurdir, 1);
|
||||
chdir(curdir);
|
||||
setenv("HOME", curdir, 1);
|
||||
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Changing curdir to \"%s\"", curdir);
|
||||
|
||||
jstr = (*env)->GetStringUTFChars(env, cmdline, NULL);
|
||||
|
||||
@@ -104,12 +91,6 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInit) ( JNIEnv* env, jobject thiz, jstring
|
||||
|
||||
};
|
||||
|
||||
extern C_LINKAGE void
|
||||
JAVA_EXPORT_NAME(Settings_nativeIsSdcardUsed) ( JNIEnv* env, jobject thiz, jint flag )
|
||||
{
|
||||
isSdcardUsed = flag;
|
||||
}
|
||||
|
||||
extern C_LINKAGE void
|
||||
JAVA_EXPORT_NAME(Settings_nativeSetEnv) ( JNIEnv* env, jobject thiz, jstring j_name, jstring j_value )
|
||||
{
|
||||
|
||||
17
readme.txt
17
readme.txt
@@ -16,28 +16,33 @@ http://www.pocketmagic.net/?p=1332 - guide how to set up environment in Cygwin.
|
||||
Please don't use NDK r5, it is buggy, wait for NDK r5b:
|
||||
http://groups.google.com/group/android-ndk/browse_thread/thread/6b35728eec7ef52f/b57f52776842041d
|
||||
|
||||
How to compile Alien Blaster demo application
|
||||
=============================================
|
||||
How to compile demo application
|
||||
===============================
|
||||
|
||||
Go to "project" directory and launch command
|
||||
android update project -p .
|
||||
rm project/jni/application/src
|
||||
ln -s ballfield project/jni/application/src
|
||||
Then go back, edit file build.sh if needed to add NDK dir to your PATH, then launch it.
|
||||
It will compile a bunch of libs under project/libs/armeabi,
|
||||
create file project/bin/DemoActivity-debug.apk and install it on your device or emulator.
|
||||
Then you can test it by launching Alien Blaster icon from Android applications menu.
|
||||
It's designed for 640x480, so if you have smaller screen it will be resized.
|
||||
Then you can test it by launching Ballfield icon from Android applications menu.
|
||||
It's designed for 320x240, so if you have smaller screen it will be resized.
|
||||
Note: The game enforces horizontal screen orientation, you may open your keyboard and use it for
|
||||
additional keys - the phone will just keep current screen orientation.
|
||||
Recent Android phone models like HTC Evo have no keyboard at all, on-screen keyboard built into libSDL
|
||||
is available for such devices - it has joystick (which can be configured as arrow buttons or analog joystick),
|
||||
and 6 configurable keys, full text input is toggled with 7-th key. Application may redefine button layout
|
||||
and returned keycodes, and also toggle full text input - see SDL_screenkeyboard.h.
|
||||
and 6 configurable keys, full text input is toggled with 7-th key. Both user and application may redefine
|
||||
button layout and returned keycodes, and also toggle full text input - see SDL_screenkeyboard.h.
|
||||
|
||||
This port also supports GL ES + SDL combo - there is GLXGears demo app in project/jni/application/glxgears,
|
||||
remove project/jni/application/src symlink and make new one pointing to glxgears, then run build.sh
|
||||
Note that GL ES is NOT pure OpenGL - there are no glBegin() and glEnd() call and other widely used functions,
|
||||
and generally it will take a lot of effort to port pure OpenGL application to GL ES.
|
||||
|
||||
Previously The Alien Blaster was the default demo application, however it uses SDL 1.3 and I'm breaking
|
||||
the compilation too often, so if something does not compile please try to use some older revision.
|
||||
|
||||
How to compile your own application
|
||||
===================================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user