diff --git a/res/values/strings.xml b/res/values/strings.xml
index 31f52446..7b7640c1 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -21,7 +21,7 @@
Xash3D Android
SDLash3D is not affiliated with Valve or any of their partners. All copyrights reserved to their respective owners.
- v0.16
+ v0.17 test
Port to Android by SDLash3D team: \n
• a1batross\n
• mittorn \n
diff --git a/src/in/celest/xash3d/InstallReceiver.java b/src/in/celest/xash3d/InstallReceiver.java
new file mode 100644
index 00000000..ecbb6809
--- /dev/null
+++ b/src/in/celest/xash3d/InstallReceiver.java
@@ -0,0 +1,14 @@
+package in.celest.xash3d;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+public class InstallReceiver extends BroadcastReceiver {
+private static final String TAG = "XASH3D";
+@Override
+public void onReceive(Context context, Intent arg1) {
+ Log.d( TAG, "Install received, extracting PAK" );
+ org.libsdl.app.SDLActivity.extractPAK( context, true );
+ }
+}
diff --git a/src/in/celest/xash3d/ShortcutActivity.java b/src/in/celest/xash3d/ShortcutActivity.java
index d94438fb..6533c07a 100644
--- a/src/in/celest/xash3d/ShortcutActivity.java
+++ b/src/in/celest/xash3d/ShortcutActivity.java
@@ -16,6 +16,7 @@ import android.os.*;
public class ShortcutActivity extends Activity
{
static EditText name, gamedir, pkgname, argv;
+ String [] env = null;
@Override
protected void onCreate(Bundle bundle)
{
@@ -38,6 +39,7 @@ public class ShortcutActivity extends Activity
String names = intent.getStringExtra("name");
if( names != null )
name.setText(names);
+ env = intent.getStringArrayExtra("env");
//name.setText("Name");
}
@@ -52,6 +54,8 @@ public class ShortcutActivity extends Activity
intent.putExtra("pakfile", "/data/data/"+pkgname.getText().toString().replace("!","in.celest.xash3d.")+"/files/extras.pak");
}
if(gamedir.length() != 0) intent.putExtra("gamedir",gamedir.getText().toString());
+ if(env != null)
+ intent.putExtra("env", env);
Intent wrapIntent = new Intent();
wrapIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
wrapIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, name.getText().toString());
diff --git a/src/org/libsdl/app/SDLActivity.java b/src/org/libsdl/app/SDLActivity.java
index 33b5cd55..ae53a3d9 100644
--- a/src/org/libsdl/app/SDLActivity.java
+++ b/src/org/libsdl/app/SDLActivity.java
@@ -91,7 +91,7 @@ public class SDLActivity extends Activity {
protected static AudioTrack mAudioTrack;
// Preferences
- public static SharedPreferences mPref;
+ public static SharedPreferences mPref = null;
// Arguments
public static String[] mArgv;
@@ -222,11 +222,24 @@ public class SDLActivity extends Activity {
setenv("XASH3D_GAMELIBDIR", gamelibdir, true);
setenv("XASH3D_GAMEDIR", gamedir, true);
- extractPAK();
+ extractPAK(this, false);
setenv("XASH3D_EXTRAS_PAK1", getFilesDir().getPath() + "/extras.pak", true);
String pakfile = intent.getStringExtra("pakfile");
if( pakfile != null && pakfile != "" )
setenv("XASH3D_EXTRAS_PAK2", pakfile, true);
+ String[] env = intent.getStringArrayExtra("env");
+ try
+ {
+ if( env != null )
+ for(int i = 0; i+1 < env.length; i+=2)
+ {
+ setenv(env[i],env[i+1], true);
+ }
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ }
// Set up the surface
mSurface = new SDLSurface(getApplication());
@@ -973,7 +986,7 @@ public class SDLActivity extends Activity {
return dialog;
}
- private void extractPAK() {
+ /*private void extractPAK() {
InputStream is = null;
FileOutputStream os = null;
if( mPref.getInt( "pakversion", 0 ) == PAK_VERSION )
@@ -996,6 +1009,34 @@ public class SDLActivity extends Activity {
{
Log.e( TAG, "Failed to extract PAK:" + e.toString() );
}
+ }*/
+ public static void extractPAK(Context context, Boolean force) {
+ InputStream is = null;
+ FileOutputStream os = null;
+ try {
+ if( mPref == null )
+ mPref = context.getSharedPreferences("engine", 0);
+ if( mPref.getInt( "pakversion", 0 ) == PAK_VERSION && !force )
+ return;
+ String path = context.getFilesDir().getPath()+"/extras.pak";
+
+ is = context.getAssets().open("extras.pak");
+ os = new FileOutputStream(path);
+ byte[] buffer = new byte[1024];
+ int length;
+ while ((length = is.read(buffer)) > 0) {
+ os.write(buffer, 0, length);
+ }
+ os.close();
+ is.close();
+ SharedPreferences.Editor editor = mPref.edit();
+ editor.putInt( "pakversion", PAK_VERSION );
+ editor.commit();
+ editor.apply();
+ } catch( Exception e )
+ {
+ Log.e( TAG, "Failed to extract PAK:" + e.toString() );
+ }
}
}
diff --git a/test/AndroidManifest.xml b/test/AndroidManifest.xml
index 8e7dd25f..64f2f39d 100644
--- a/test/AndroidManifest.xml
+++ b/test/AndroidManifest.xml
@@ -5,7 +5,7 @@