mirror of
https://github.com/FWGS/xash3d-fwgs
synced 2024-11-27 04:11:08 +01:00
Update java part. InstallReceiver, env, verbump
This commit is contained in:
parent
34c0b256f6
commit
91cc1af64c
@ -21,7 +21,7 @@
|
||||
<!-- TODO: Remove or change this placeholder text -->
|
||||
<string name="about_main" translatable="false">Xash3D Android</string>
|
||||
<string name="about_copyright">SDLash3D is not affiliated with Valve or any of their partners. All copyrights reserved to their respective owners.</string>
|
||||
<string name="version_string" translatable="false">v0.16</string>
|
||||
<string name="version_string" translatable="false">v0.17 test</string>
|
||||
<string name="about_authors">Port to Android by SDLash3D team: \n
|
||||
• a1batross\n
|
||||
• mittorn \n
|
||||
|
14
src/in/celest/xash3d/InstallReceiver.java
Normal file
14
src/in/celest/xash3d/InstallReceiver.java
Normal file
@ -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 );
|
||||
}
|
||||
}
|
@ -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());
|
||||
|
@ -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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="in.celest.xash3d.hl.test"
|
||||
android:versionCode="1"
|
||||
android:versionName="0.16pre"
|
||||
android:versionName="0.17test"
|
||||
android:installLocation="auto">
|
||||
|
||||
<!-- Create a Java class extending SDLActivity and place it in a
|
||||
@ -63,6 +63,17 @@
|
||||
android:screenOrientation="landscape"
|
||||
android:label="@string/app_name">
|
||||
</activity>
|
||||
<receiver android:name="in.celest.xash3d.InstallReceiver">
|
||||
<intent-filter android:priority="100">
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<action android:name="android.intent.action.PACKAGE_ADDED" />
|
||||
<action android:name="android.intent.action.PACKAGE_CHANGED" />
|
||||
<action android:name="android.intent.action.PACKAGE_INSTALL" />
|
||||
<action android:name="android.intent.action.PACKAGE_REMOVED" />
|
||||
<action android:name="android.intent.action.PACKAGE_REPLACED" />
|
||||
<data android:scheme="package" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
|
||||
<!-- Android 2.3 -->
|
||||
|
Loading…
Reference in New Issue
Block a user