Android 1.5 support
This commit is contained in:
parent
11a29ac213
commit
126433c42c
10 changed files with 141 additions and 83 deletions
|
@ -4,17 +4,21 @@
|
|||
#APP_STL := stlport_static
|
||||
|
||||
XASH_SDL ?= 0
|
||||
|
||||
XASH_LEGACY ?= 0
|
||||
ifeq ($(XASH_SDL),1)
|
||||
APP_PLATFORM := android-12
|
||||
else
|
||||
ifneq ($(XASH_LEGACY),1)
|
||||
APP_PLATFORM := android-8
|
||||
else
|
||||
APP_PLATFORM := android-3
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
CFLAGS_OPT := -O3 -fomit-frame-pointer -ggdb -funsafe-math-optimizations -ftree-vectorize -fgraphite-identity -floop-interchange -funsafe-loop-optimizations -finline-limit=1024
|
||||
CFLAGS_OPT_ARM := -mthumb -mfpu=neon -mcpu=cortex-a9 -pipe -mvectorize-with-neon-quad -DVECTORIZE_SINCOS -fPIC
|
||||
CFLAGS_OPT_ARMv5 :=-march=armv6 -mfpu=vfp -marm -pipe
|
||||
CFLAGS_OPT_ARMv5 :=-march=armv5te -marm -pipe -msoft-float
|
||||
CFLAGS_OPT_X86 := -mtune=atom -march=atom -mssse3 -mfpmath=sse -funroll-loops -pipe -DVECTORIZE_SINCOS
|
||||
CFLAGS_HARDFP := -D_NDK_MATH_NO_SOFTFP=1 -mhard-float -mfloat-abi=hard -DLOAD_HARDFP -DSOFTFP_LINK
|
||||
APPLICATIONMK_PATH = $(call my-dir)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/folder"
|
||||
android:id="@+id/button2"
|
||||
android:id="@+id/button_fpicker_select"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:onClick="onFileClick" />
|
||||
|
|
|
@ -224,7 +224,7 @@
|
|||
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:id="@+id/button_shortcut"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
|
@ -263,7 +263,7 @@
|
|||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:id="@+id/button_about"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left"
|
||||
|
|
|
@ -18,6 +18,7 @@ import android.widget.ImageView;
|
|||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.Button;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
|
@ -32,15 +33,22 @@ public class FPicker extends Activity {
|
|||
private File currentDir;
|
||||
private FileArrayAdapter adapter;
|
||||
static ListView delta;
|
||||
public static final int sdk = Integer.valueOf(Build.VERSION.SDK);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if ( Build.VERSION.SDK_INT >= 21 )
|
||||
if ( sdk >= 21 )
|
||||
super.setTheme( 0x01030224 );
|
||||
setContentView(R.layout.activity_fpicker);
|
||||
String path = Environment.getExternalStorageDirectory().toString();
|
||||
currentDir = new File(path);
|
||||
|
||||
((Button)findViewById( R.id.button_fpicker_select )).setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onFileClick(v);
|
||||
}
|
||||
});
|
||||
fill(currentDir);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,12 +3,45 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
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 );
|
||||
if( context.getPackageName() == arg1.getData().getEncodedSchemeSpecificPart() )
|
||||
extractPAK(context, true);
|
||||
}
|
||||
public static SharedPreferences mPref = null;
|
||||
private static final int PAK_VERSION = 5;
|
||||
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();
|
||||
} catch( Exception e )
|
||||
{
|
||||
Log.e( TAG, "Failed to extract PAK:" + e.toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import in.celest.xash3d.hl.R;
|
|||
|
||||
public class LauncherActivity extends Activity {
|
||||
// public final static String ARGV = "in.celest.xash3d.MESSAGE";
|
||||
public final static int sdk = Integer.valueOf(Build.VERSION.SDK);
|
||||
static EditText cmdArgs;
|
||||
static ToggleButton useVolume;
|
||||
static EditText resPath;
|
||||
|
@ -47,7 +48,7 @@ public class LauncherActivity extends Activity {
|
|||
super.onCreate(savedInstanceState);
|
||||
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
//super.setTheme( 0x01030005 );
|
||||
if ( Build.VERSION.SDK_INT >= 21 )
|
||||
if ( sdk >= 21 )
|
||||
super.setTheme( 0x01030224 );
|
||||
setContentView(R.layout.activity_launcher);
|
||||
|
||||
|
@ -66,7 +67,31 @@ public class LauncherActivity extends Activity {
|
|||
tabSpec.setContent(R.id.tab2);
|
||||
tabHost.addTab(tabSpec);
|
||||
|
||||
Button selectFolder = ( Button ) findViewById( R.id.button_select );
|
||||
Button selectFolderButton = ( Button ) findViewById( R.id.button_select );
|
||||
selectFolderButton.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
selectFolder(v);
|
||||
}
|
||||
});
|
||||
((Button)findViewById( R.id.button_launch )).setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startXash(v);
|
||||
}
|
||||
});
|
||||
((Button)findViewById( R.id.button_shortcut )).setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
createShortcut(v);
|
||||
}
|
||||
});
|
||||
((Button)findViewById( R.id.button_about )).setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
aboutXash(v);
|
||||
}
|
||||
});
|
||||
// if ( Build.VERSION.SDK_INT < 21 )
|
||||
// selectFolder.setVisibility( View.GONE );
|
||||
mPref = getSharedPreferences("engine", 0);
|
||||
|
@ -88,7 +113,6 @@ public class LauncherActivity extends Activity {
|
|||
editor.putBoolean("usevolume",useVolume.isChecked());
|
||||
editor.putString("basedir", resPath.getText().toString());
|
||||
editor.commit();
|
||||
editor.apply();
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.graphics.BitmapFactory;
|
|||
import android.widget.Toast;
|
||||
import in.celest.xash3d.hl.R;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Button;
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
|
||||
|
@ -17,12 +18,13 @@ public class ShortcutActivity extends Activity
|
|||
{
|
||||
static EditText name, gamedir, pkgname, argv;
|
||||
String [] env = null;
|
||||
public static final int sdk = Integer.valueOf(Build.VERSION.SDK);
|
||||
@Override
|
||||
protected void onCreate(Bundle bundle)
|
||||
{
|
||||
super.onCreate(bundle);
|
||||
//material dialog
|
||||
if ( Build.VERSION.SDK_INT >= 21 )
|
||||
if ( sdk >= 21 )
|
||||
super.setTheme( 0x01030225 );
|
||||
setContentView(R.layout.activity_shortcut);
|
||||
Intent intent=getIntent();
|
||||
|
@ -30,6 +32,12 @@ public class ShortcutActivity extends Activity
|
|||
pkgname = (EditText)findViewById(R.id.shortcut_pkgname);
|
||||
gamedir = (EditText)findViewById(R.id.shortcut_gamedir);
|
||||
argv = (EditText)findViewById(R.id.shortcut_cmdArgs);
|
||||
((Button)findViewById( R.id.shortcut_buttonOk )).setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
saveShortcut(v);
|
||||
}
|
||||
});
|
||||
String argvs = intent.getStringExtra("argv");
|
||||
if( argvs != null )
|
||||
argv.setText(argvs);
|
||||
|
|
|
@ -29,6 +29,7 @@ public class XashActivity extends Activity {
|
|||
protected static XashActivity mSingleton;
|
||||
private static EngineSurface mSurface;
|
||||
private static String mArgv[];
|
||||
public static final int sdk = Integer.valueOf(Build.VERSION.SDK);
|
||||
|
||||
// Preferences
|
||||
public static SharedPreferences mPref = null;
|
||||
|
@ -270,7 +271,8 @@ public class XashActivity extends Activity {
|
|||
class XashMain implements Runnable {
|
||||
public void run() {
|
||||
// Runs SDL_main()
|
||||
XashActivity.createGLContext();
|
||||
|
||||
XashActivity.createGLContext();
|
||||
|
||||
XashActivity.nativeInit(XashActivity.getArguments());
|
||||
|
||||
|
@ -286,7 +288,7 @@ class XashMain implements Runnable {
|
|||
Because of this, that's where we set up the SDL thread
|
||||
*/
|
||||
class EngineSurface extends SurfaceView implements SurfaceHolder.Callback,
|
||||
View.OnKeyListener, View.OnTouchListener {
|
||||
View.OnKeyListener {
|
||||
|
||||
// This is what SDL runs in. It invokes SDL_main(), eventually
|
||||
private Thread mEngThread;
|
||||
|
@ -307,7 +309,10 @@ View.OnKeyListener, View.OnTouchListener {
|
|||
setFocusableInTouchMode(true);
|
||||
requestFocus();
|
||||
setOnKeyListener(this);
|
||||
setOnTouchListener(this);
|
||||
if( XashActivity.sdk >= 5 )
|
||||
setOnTouchListener(new EngineTouchListener_v5());
|
||||
else
|
||||
setOnTouchListener(new EngineTouchListener_v1());
|
||||
}
|
||||
|
||||
// Called when we have a valid drawing surface
|
||||
|
@ -412,11 +417,10 @@ View.OnKeyListener, View.OnTouchListener {
|
|||
|
||||
int[] configSpec = {
|
||||
EGL10.EGL_DEPTH_SIZE, 8,
|
||||
EGL10.EGL_RED_SIZE, 8,
|
||||
EGL10.EGL_GREEN_SIZE, 8,
|
||||
EGL10.EGL_BLUE_SIZE, 8,
|
||||
EGL10.EGL_RED_SIZE, 5,
|
||||
EGL10.EGL_GREEN_SIZE, 6,
|
||||
EGL10.EGL_BLUE_SIZE, 5,
|
||||
EGL10.EGL_ALPHA_SIZE, 0,
|
||||
EGL10.EGL_RENDERABLE_TYPE, 1,
|
||||
EGL10.EGL_NONE
|
||||
};
|
||||
EGLConfig[] configs = new EGLConfig[1];
|
||||
|
@ -505,11 +509,18 @@ View.OnKeyListener, View.OnTouchListener {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Touch events
|
||||
}
|
||||
class EngineTouchListener_v1 implements View.OnTouchListener{
|
||||
// Touch events
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
/* Ref: http://developer.android.com/training/gestures/multi.html */
|
||||
XashActivity.nativeTouch(0, event.getAction(), event.getX(), event.getY());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class EngineTouchListener_v5 implements View.OnTouchListener{
|
||||
// Touch events
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
final int touchDevId = event.getDeviceId();
|
||||
final int pointerCount = event.getPointerCount();
|
||||
int action = event.getActionMasked();
|
||||
|
@ -559,9 +570,7 @@ View.OnKeyListener, View.OnTouchListener {
|
|||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,6 @@ import android.content.*;
|
|||
*/
|
||||
public class SDLActivity extends Activity {
|
||||
private static final String TAG = "SDL";
|
||||
private static final int PAK_VERSION = 5;
|
||||
|
||||
// Keep track of the paused state
|
||||
public static boolean mIsPaused, mIsSurfaceReady, mHasFocus, mUseVolume;
|
||||
|
@ -226,7 +225,7 @@ public class SDLActivity extends Activity {
|
|||
setenv("XASH3D_GAMELIBDIR", gamelibdir, true);
|
||||
setenv("XASH3D_GAMEDIR", gamedir, true);
|
||||
|
||||
extractPAK(this, false);
|
||||
in.celest.xash3d.InstallReceiver.extractPAK(this, false);
|
||||
setenv("XASH3D_EXTRAS_PAK1", getFilesDir().getPath() + "/extras.pak", true);
|
||||
String pakfile = intent.getStringExtra("pakfile");
|
||||
if( pakfile != null && pakfile != "" )
|
||||
|
@ -1033,34 +1032,7 @@ 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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -97,7 +97,7 @@
|
|||
</application>
|
||||
|
||||
<!-- Android 2.3 -->
|
||||
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="9" />
|
||||
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="9" />
|
||||
|
||||
<!-- OpenGL ES 1.1 -->
|
||||
<uses-feature android:glEsVersion="0x00010000" />
|
||||
|
|
Loading…
Add table
Reference in a new issue