When you'll change app to build that won't be visible in Git commit.
Also fixed application name not updated for translated strings.xml
This commit is contained in:
73
project/java/Accelerometer.java
Normal file
73
project/java/Accelerometer.java
Normal file
@@ -0,0 +1,73 @@
|
||||
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.os.Vibrator;
|
||||
import android.hardware.SensorManager;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
class AccelerometerReader implements SensorEventListener {
|
||||
|
||||
private SensorManager _manager = null;
|
||||
|
||||
public AccelerometerReader(Activity context) {
|
||||
System.out.println("libSDL: accelerometer start required: " + String.valueOf(Globals.UseAccelerometerAsArrowKeys));
|
||||
if( Globals.UseAccelerometerAsArrowKeys )
|
||||
{
|
||||
_manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||
if( _manager != null )
|
||||
{
|
||||
System.out.println("libSDL: starting accelerometer");
|
||||
// TODO: orientation allows for 3rd axis - azimuth, but it will be way too hard to the user
|
||||
// if( ! _manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ORIENTATION), SensorManager.SENSOR_DELAY_GAME) )
|
||||
_manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void stop() {
|
||||
if( _manager != null )
|
||||
{
|
||||
_manager.unregisterListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void onSensorChanged(SensorEvent event) {
|
||||
|
||||
if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER)
|
||||
{
|
||||
if( Globals.HorizontalOrientation )
|
||||
nativeAccelerometer(event.values[1], -event.values[0], event.values[2]);
|
||||
else
|
||||
nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested!
|
||||
}
|
||||
else
|
||||
{
|
||||
if( Globals.HorizontalOrientation )
|
||||
nativeOrientation(event.values[1], -event.values[2], event.values[0]);
|
||||
else
|
||||
nativeOrientation(event.values[2], event.values[1], event.values[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public synchronized void onAccuracyChanged(Sensor s, int a) {
|
||||
}
|
||||
|
||||
|
||||
private native void nativeAccelerometer(float accX, float accY, float accZ);
|
||||
private native void nativeOrientation(float accX, float accY, float accZ);
|
||||
}
|
||||
|
||||
|
||||
119
project/java/Audio.java
Normal file
119
project/java/Audio.java
Normal file
@@ -0,0 +1,119 @@
|
||||
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.media.AudioTrack;
|
||||
import android.media.AudioManager;
|
||||
import android.media.AudioFormat;
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import android.util.Log;
|
||||
import java.lang.Thread;
|
||||
|
||||
|
||||
class AudioThread {
|
||||
|
||||
private Activity mParent;
|
||||
private AudioTrack mAudio;
|
||||
private byte[] mAudioBuffer;
|
||||
private int mVirtualBufSize;
|
||||
|
||||
public AudioThread(Activity parent)
|
||||
{
|
||||
mParent = parent;
|
||||
mAudio = null;
|
||||
mAudioBuffer = null;
|
||||
nativeAudioInitJavaCallbacks();
|
||||
}
|
||||
|
||||
public int fillBuffer()
|
||||
{
|
||||
mAudio.write( mAudioBuffer, 0, mVirtualBufSize );
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int initAudio(int rate, int channels, int encoding, int bufSize)
|
||||
{
|
||||
if( mAudio == null )
|
||||
{
|
||||
channels = ( channels == 1 ) ? AudioFormat.CHANNEL_CONFIGURATION_MONO :
|
||||
AudioFormat.CHANNEL_CONFIGURATION_STEREO;
|
||||
encoding = ( encoding == 1 ) ? AudioFormat.ENCODING_PCM_16BIT :
|
||||
AudioFormat.ENCODING_PCM_8BIT;
|
||||
|
||||
mVirtualBufSize = bufSize;
|
||||
|
||||
if( AudioTrack.getMinBufferSize( rate, channels, encoding ) > bufSize )
|
||||
bufSize = AudioTrack.getMinBufferSize( rate, channels, encoding );
|
||||
|
||||
if(Globals.AudioBufferConfig != 0) { // application's choice - use minimal buffer
|
||||
bufSize = (int)((float)bufSize * (((float)(Globals.AudioBufferConfig - 1) * 2.5f) + 1.0f));
|
||||
mVirtualBufSize = bufSize;
|
||||
}
|
||||
mAudioBuffer = new byte[bufSize];
|
||||
|
||||
mAudio = new AudioTrack(AudioManager.STREAM_RING,
|
||||
rate,
|
||||
channels,
|
||||
encoding,
|
||||
bufSize,
|
||||
AudioTrack.MODE_STREAM );
|
||||
mAudio.play();
|
||||
}
|
||||
return mVirtualBufSize;
|
||||
}
|
||||
|
||||
public byte[] getBuffer()
|
||||
{
|
||||
return mAudioBuffer;
|
||||
}
|
||||
|
||||
public int deinitAudio()
|
||||
{
|
||||
if( mAudio != null )
|
||||
{
|
||||
mAudio.stop();
|
||||
mAudio.release();
|
||||
mAudio = null;
|
||||
}
|
||||
mAudioBuffer = null;
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int initAudioThread()
|
||||
{
|
||||
// Make audio thread priority higher so audio thread won't get underrun
|
||||
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int pauseAudioPlayback()
|
||||
{
|
||||
if( mAudio != null )
|
||||
{
|
||||
mAudio.pause();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int resumeAudioPlayback()
|
||||
{
|
||||
if( mAudio != null )
|
||||
{
|
||||
mAudio.play();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private native int nativeAudioInitJavaCallbacks();
|
||||
}
|
||||
|
||||
490
project/java/DataDownloader.java
Normal file
490
project/java/DataDownloader.java
Normal file
@@ -0,0 +1,490 @@
|
||||
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import android.widget.TextView;
|
||||
import org.apache.http.client.methods.*;
|
||||
import org.apache.http.*;
|
||||
import org.apache.http.impl.*;
|
||||
import org.apache.http.impl.client.*;
|
||||
import java.util.zip.*;
|
||||
import java.io.*;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import java.lang.String;
|
||||
|
||||
|
||||
class CountingInputStream extends BufferedInputStream {
|
||||
|
||||
private long bytesReadMark = 0;
|
||||
private long bytesRead = 0;
|
||||
|
||||
public CountingInputStream(InputStream in, int size) {
|
||||
|
||||
super(in, size);
|
||||
}
|
||||
|
||||
public CountingInputStream(InputStream in) {
|
||||
|
||||
super(in);
|
||||
}
|
||||
|
||||
public long getBytesRead() {
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
public synchronized int read() throws IOException {
|
||||
|
||||
int read = super.read();
|
||||
if (read >= 0) {
|
||||
bytesRead++;
|
||||
}
|
||||
return read;
|
||||
}
|
||||
|
||||
public synchronized int read(byte[] b, int off, int len) throws IOException {
|
||||
|
||||
int read = super.read(b, off, len);
|
||||
if (read >= 0) {
|
||||
bytesRead += read;
|
||||
}
|
||||
return read;
|
||||
}
|
||||
|
||||
public synchronized long skip(long n) throws IOException {
|
||||
|
||||
long skipped = super.skip(n);
|
||||
if (skipped >= 0) {
|
||||
bytesRead += skipped;
|
||||
}
|
||||
return skipped;
|
||||
}
|
||||
|
||||
public synchronized void mark(int readlimit) {
|
||||
|
||||
super.mark(readlimit);
|
||||
bytesReadMark = bytesRead;
|
||||
}
|
||||
|
||||
public synchronized void reset() throws IOException {
|
||||
|
||||
super.reset();
|
||||
bytesRead = bytesReadMark;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DataDownloader extends Thread
|
||||
{
|
||||
class StatusWriter
|
||||
{
|
||||
private TextView Status;
|
||||
private MainActivity Parent;
|
||||
private String oldText = "";
|
||||
|
||||
public StatusWriter( TextView _Status, MainActivity _Parent )
|
||||
{
|
||||
Status = _Status;
|
||||
Parent = _Parent;
|
||||
}
|
||||
public void setParent( TextView _Status, MainActivity _Parent )
|
||||
{
|
||||
synchronized(DataDownloader.this) {
|
||||
Status = _Status;
|
||||
Parent = _Parent;
|
||||
setText( oldText );
|
||||
}
|
||||
}
|
||||
|
||||
public void setText(final String str)
|
||||
{
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public TextView Status;
|
||||
public String text;
|
||||
public void run()
|
||||
{
|
||||
Status.setText(text);
|
||||
}
|
||||
}
|
||||
synchronized(DataDownloader.this) {
|
||||
Callback cb = new Callback();
|
||||
oldText = new String(str);
|
||||
cb.text = new String(str);
|
||||
cb.Status = Status;
|
||||
if( Parent != null && Status != null )
|
||||
Parent.runOnUiThread(cb);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public DataDownloader( MainActivity _Parent, TextView _Status )
|
||||
{
|
||||
Parent = _Parent;
|
||||
Status = new StatusWriter( _Status, _Parent );
|
||||
//Status.setText( "Connecting to " + Globals.DataDownloadUrl );
|
||||
outFilesDir = Parent.getFilesDir().getAbsolutePath();
|
||||
if( Globals.DownloadToSdcard )
|
||||
outFilesDir = "/sdcard/app-data/" + Globals.class.getPackage().getName();
|
||||
DownloadComplete = false;
|
||||
this.start();
|
||||
}
|
||||
|
||||
public void setParent(MainActivity _Parent, TextView _Status)
|
||||
{
|
||||
synchronized(this) {
|
||||
Parent = _Parent;
|
||||
Status.setParent( _Status, _Parent );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
String [] downloadFiles = Globals.DataDownloadUrl.split("\\^");
|
||||
for( int i = 0; i < downloadFiles.length; i++ )
|
||||
{
|
||||
if( downloadFiles[i].length() > 0 && Globals.OptionalDataDownload.length > i && Globals.OptionalDataDownload[i] )
|
||||
if( ! DownloadDataFile(downloadFiles[i], "libsdl-DownloadFinished-" + String.valueOf(i) + ".flag") )
|
||||
{
|
||||
DownloadFailed = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
DownloadComplete = true;
|
||||
initParent();
|
||||
}
|
||||
|
||||
public boolean DownloadDataFile(final String DataDownloadUrl, final String DownloadFlagFileName)
|
||||
{
|
||||
String [] downloadUrls = DataDownloadUrl.split("[|]");
|
||||
if( downloadUrls.length < 2 )
|
||||
return false;
|
||||
|
||||
Resources res = Parent.getResources();
|
||||
|
||||
String path = getOutFilePath(DownloadFlagFileName);
|
||||
InputStream checkFile = null;
|
||||
try {
|
||||
checkFile = new FileInputStream( path );
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch( SecurityException e ) { };
|
||||
if( checkFile != null )
|
||||
{
|
||||
try {
|
||||
byte b[] = new byte[ Globals.DataDownloadUrl.getBytes("UTF-8").length + 1 ];
|
||||
int readed = checkFile.read(b);
|
||||
String compare = new String( b, 0, readed, "UTF-8" );
|
||||
boolean matched = false;
|
||||
System.out.println("Read URL: '" + compare + "'");
|
||||
for( int i = 1; i < downloadUrls.length; i++ )
|
||||
{
|
||||
System.out.println("Comparing: '" + downloadUrls[i] + "'");
|
||||
if( compare.compareTo(downloadUrls[i]) == 0 )
|
||||
matched = true;
|
||||
}
|
||||
System.out.println("Matched: " + String.valueOf(matched));
|
||||
if( ! matched )
|
||||
throw new IOException();
|
||||
Status.setText( res.getString(R.string.download_unneeded) );
|
||||
return true;
|
||||
} catch ( IOException e ) {};
|
||||
}
|
||||
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 ) {};
|
||||
}
|
||||
|
||||
HttpResponse response = null;
|
||||
HttpGet request;
|
||||
long totalLen = 0;
|
||||
CountingInputStream stream;
|
||||
byte[] buf = new byte[16384];
|
||||
boolean DoNotUnzip = false;
|
||||
boolean FileInAssets = false;
|
||||
String url = "";
|
||||
|
||||
int downloadUrlIndex = 1;
|
||||
while( downloadUrlIndex < downloadUrls.length )
|
||||
{
|
||||
System.out.println("Processing download " + downloadUrls[downloadUrlIndex]);
|
||||
url = new String(downloadUrls[downloadUrlIndex]);
|
||||
DoNotUnzip = false;
|
||||
if(url.indexOf(":") == 0)
|
||||
{
|
||||
url = url.substring( url.indexOf(":", 1) + 1 );
|
||||
DoNotUnzip = true;
|
||||
}
|
||||
System.out.println("Connecting to " + url);
|
||||
Status.setText( res.getString(R.string.connecting_to, url) );
|
||||
if( url.indexOf("http://") == -1 && url.indexOf("https://") == -1 ) // File inside assets
|
||||
{
|
||||
FileInAssets = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
request = new HttpGet(url);
|
||||
request.addHeader("Accept", "*/*");
|
||||
try {
|
||||
DefaultHttpClient client = new DefaultHttpClient();
|
||||
client.getParams().setBooleanParameter("http.protocol.handle-redirects", true);
|
||||
response = client.execute(request);
|
||||
} catch (IOException e) {
|
||||
System.out.println("Failed to connect to " + downloadUrls[downloadUrlIndex]);
|
||||
downloadUrlIndex++;
|
||||
};
|
||||
if( response != null )
|
||||
{
|
||||
if( response.getStatusLine().getStatusCode() != 200 )
|
||||
{
|
||||
response = null;
|
||||
System.out.println("Failed to connect to " + url);
|
||||
downloadUrlIndex++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( FileInAssets )
|
||||
{
|
||||
try {
|
||||
stream = new CountingInputStream(Parent.getAssets().open(url));
|
||||
} catch( IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_dl_from, url) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( response == null )
|
||||
{
|
||||
System.out.println("Error connecting to " + url);
|
||||
Status.setText( res.getString(R.string.failed_connecting_to, url) );
|
||||
return false;
|
||||
}
|
||||
|
||||
Status.setText( res.getString(R.string.dl_from, url) );
|
||||
totalLen = response.getEntity().getContentLength();
|
||||
try {
|
||||
stream = new CountingInputStream(response.getEntity().getContent());
|
||||
} catch( java.io.IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_dl_from, url) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(DoNotUnzip)
|
||||
{
|
||||
path = getOutFilePath(downloadUrls[downloadUrlIndex].substring( 1,
|
||||
downloadUrls[downloadUrlIndex].indexOf(":", 1) ));
|
||||
OutputStream out = null;
|
||||
try {
|
||||
try {
|
||||
(new File( path.substring(0, path.lastIndexOf("/") ))).mkdirs();
|
||||
} catch( SecurityException e ) { };
|
||||
|
||||
out = new FileOutputStream( path );
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch( SecurityException e ) { };
|
||||
if( out == null )
|
||||
{
|
||||
Status.setText( res.getString(R.string.error_write, path) );
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
int len = stream.read(buf);
|
||||
while (len >= 0)
|
||||
{
|
||||
if(len > 0)
|
||||
out.write(buf, 0, len);
|
||||
len = stream.read(buf);
|
||||
|
||||
float percent = 0.0f;
|
||||
if( totalLen > 0 )
|
||||
percent = stream.getBytesRead() * 100.0f / totalLen;
|
||||
Status.setText( res.getString(R.string.dl_progress, percent, path) );
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
out = null;
|
||||
} catch( java.io.IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_write, path) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ZipInputStream zip = new ZipInputStream(stream);
|
||||
|
||||
while(true)
|
||||
{
|
||||
ZipEntry entry = null;
|
||||
try {
|
||||
entry = zip.getNextEntry();
|
||||
} catch( java.io.IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_dl_from, url) );
|
||||
return false;
|
||||
}
|
||||
if( entry == null )
|
||||
break;
|
||||
if( entry.isDirectory() )
|
||||
{
|
||||
try {
|
||||
(new File( getOutFilePath(entry.getName()) )).mkdirs();
|
||||
} catch( SecurityException e ) { };
|
||||
continue;
|
||||
}
|
||||
|
||||
OutputStream out = null;
|
||||
path = getOutFilePath(entry.getName());
|
||||
|
||||
try {
|
||||
CheckedInputStream check = new CheckedInputStream( new FileInputStream(path), new CRC32() );
|
||||
while( check.read(buf, 0, buf.length) > 0 ) {};
|
||||
check.close();
|
||||
if( check.getChecksum().getValue() != entry.getCrc() )
|
||||
{
|
||||
File ff = new File(path);
|
||||
ff.delete();
|
||||
throw new Exception();
|
||||
}
|
||||
continue;
|
||||
} catch( Exception e )
|
||||
{
|
||||
}
|
||||
|
||||
try {
|
||||
out = new FileOutputStream( path );
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch( SecurityException e ) { };
|
||||
if( out == null )
|
||||
{
|
||||
Status.setText( res.getString(R.string.error_write, path) );
|
||||
return false;
|
||||
}
|
||||
|
||||
float percent = 0.0f;
|
||||
if( totalLen > 0 )
|
||||
percent = stream.getBytesRead() * 100.0f / totalLen;
|
||||
Status.setText( res.getString(R.string.dl_progress, percent, path) );
|
||||
|
||||
try {
|
||||
int len = zip.read(buf);
|
||||
while (len >= 0)
|
||||
{
|
||||
if(len > 0)
|
||||
out.write(buf, 0, len);
|
||||
len = zip.read(buf);
|
||||
|
||||
percent = 0.0f;
|
||||
if( totalLen > 0 )
|
||||
percent = stream.getBytesRead() * 100.0f / totalLen;
|
||||
Status.setText( res.getString(R.string.dl_progress, percent, path) );
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
out = null;
|
||||
} catch( java.io.IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_write, path) );
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
CheckedInputStream check = new CheckedInputStream( new FileInputStream(path), new CRC32() );
|
||||
while( check.read(buf, 0, buf.length) > 0 ) {};
|
||||
check.close();
|
||||
if( check.getChecksum().getValue() != entry.getCrc() )
|
||||
{
|
||||
File ff = new File(path);
|
||||
ff.delete();
|
||||
throw new Exception();
|
||||
}
|
||||
} catch( Exception e )
|
||||
{
|
||||
Status.setText( res.getString(R.string.error_write, path) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
OutputStream out = null;
|
||||
path = getOutFilePath(DownloadFlagFileName);
|
||||
try {
|
||||
out = new FileOutputStream( path );
|
||||
out.write(downloadUrls[downloadUrlIndex].getBytes("UTF-8"));
|
||||
out.flush();
|
||||
out.close();
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch( SecurityException e ) {
|
||||
} catch( java.io.IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_write, path) );
|
||||
return false;
|
||||
};
|
||||
Status.setText( res.getString(R.string.dl_finished) );
|
||||
|
||||
try {
|
||||
stream.close();
|
||||
} catch( java.io.IOException e ) {
|
||||
};
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
private void initParent()
|
||||
{
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public MainActivity Parent;
|
||||
public void run()
|
||||
{
|
||||
Parent.initSDL();
|
||||
}
|
||||
}
|
||||
Callback cb = new Callback();
|
||||
synchronized(this) {
|
||||
cb.Parent = Parent;
|
||||
if(Parent != null)
|
||||
Parent.runOnUiThread(cb);
|
||||
}
|
||||
}
|
||||
|
||||
private String getOutFilePath(final String filename)
|
||||
{
|
||||
return outFilesDir + "/" + filename;
|
||||
};
|
||||
|
||||
public StatusWriter Status;
|
||||
public boolean DownloadComplete = false;
|
||||
public boolean DownloadFailed = false;
|
||||
private MainActivity Parent;
|
||||
private String outFilesDir = null;
|
||||
}
|
||||
|
||||
1172
project/java/GLSurfaceView_SDL.java
Normal file
1172
project/java/GLSurfaceView_SDL.java
Normal file
File diff suppressed because it is too large
Load Diff
60
project/java/Globals.java
Normal file
60
project/java/Globals.java
Normal file
@@ -0,0 +1,60 @@
|
||||
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount anywhere
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
class Globals {
|
||||
public static String ApplicationName = "CommanderGenius";
|
||||
|
||||
// Should be zip file
|
||||
public static String DataDownloadUrl = "Data files are 2 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-data.zip/download^High-quality GFX and music - 40 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-hqp.zip/download";
|
||||
|
||||
// Set this value to true if you're planning to render 3D using OpenGL - it eats some GFX resources, so disabled for 2D
|
||||
public static boolean NeedDepthBuffer = false;
|
||||
|
||||
// Set this value to true if you're planning to render 3D using OpenGL - it eats some GFX resources, so disabled for 2D
|
||||
public static boolean HorizontalOrientation = true;
|
||||
|
||||
// prevent device from going to suspend mode
|
||||
public static boolean InhibitSuspend = false;
|
||||
|
||||
// Readme text to be shown on download page
|
||||
public static String ReadmeText = "^You may press \"Home\" now - the data will be downloaded in background".replace("^","\n");
|
||||
|
||||
public static boolean AppUsesMouse = false;
|
||||
|
||||
public static boolean AppNeedsArrowKeys = true;
|
||||
|
||||
public static boolean AppUsesJoystick = false;
|
||||
|
||||
public static boolean AppHandlesJoystickSensitivity = false;
|
||||
|
||||
public static boolean AppUsesMultitouch = false;
|
||||
|
||||
public static boolean NonBlockingSwapBuffers = false;
|
||||
|
||||
public static int AppTouchscreenKeyboardKeysAmount = 4;
|
||||
|
||||
public static int AppTouchscreenKeyboardKeysAmountAutoFire = 1;
|
||||
|
||||
// Phone-specific config
|
||||
// It will download app data to /sdcard/alienblaster if set to true,
|
||||
// otherwise it will download it to /data/data/de.schwardtnet.alienblaster/files
|
||||
public static boolean DownloadToSdcard = false;
|
||||
public static boolean PhoneHasTrackball = false;
|
||||
public static boolean PhoneHasArrowKeys = false;
|
||||
public static boolean UseAccelerometerAsArrowKeys = false;
|
||||
public static boolean UseTouchscreenKeyboard = false;
|
||||
public static int TouchscreenKeyboardSize = 0;
|
||||
public static int TouchscreenKeyboardTheme = 0;
|
||||
public static int AccelerometerSensitivity = 0;
|
||||
public static int AccelerometerCenterPos = 0;
|
||||
public static int TrackballDampening = 0;
|
||||
public static int AudioBufferConfig = 0;
|
||||
public static boolean OptionalDataDownload[] = null;
|
||||
}
|
||||
|
||||
class LoadLibrary {
|
||||
public LoadLibrary() { System.loadLibrary("sdl-1.2"); };
|
||||
}
|
||||
256
project/java/MainActivity.java
Normal file
256
project/java/MainActivity.java
Normal file
@@ -0,0 +1,256 @@
|
||||
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// fullscreen mode
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
if(Globals.InhibitSuspend)
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
|
||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
System.out.println("libSDL: Creating startup screen");
|
||||
_layout = new LinearLayout(this);
|
||||
_layout.setOrientation(LinearLayout.VERTICAL);
|
||||
_layout.setLayoutParams(new LinearLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||
_layout2 = new LinearLayout(this);
|
||||
_layout2.setLayoutParams(new LinearLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
|
||||
_btn = new Button(this);
|
||||
_btn.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
_btn.setText(getResources().getString(R.string.device_change_cfg));
|
||||
class onClickListener implements View.OnClickListener
|
||||
{
|
||||
public MainActivity p;
|
||||
onClickListener( MainActivity _p ) { p = _p; }
|
||||
public void onClick(View v)
|
||||
{
|
||||
System.out.println("libSDL: User clicked change phone config button");
|
||||
Settings.showConfig(p);
|
||||
}
|
||||
};
|
||||
_btn.setOnClickListener(new onClickListener(this));
|
||||
|
||||
_layout2.addView(_btn);
|
||||
|
||||
_layout.addView(_layout2);
|
||||
|
||||
ImageView img = new ImageView(this);
|
||||
|
||||
img.setScaleType(ImageView.ScaleType.FIT_CENTER /* FIT_XY */ );
|
||||
img.setImageResource(R.drawable.publisherlogo);
|
||||
img.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||
_layout.addView(img);
|
||||
|
||||
setContentView(_layout);
|
||||
|
||||
if(mAudioThread == null) // Starting from background (should not happen)
|
||||
{
|
||||
System.out.println("libSDL: Loading libraries");
|
||||
mLoadLibraryStub = new LoadLibrary();
|
||||
mAudioThread = new AudioThread(this);
|
||||
System.out.println("libSDL: Loading settings");
|
||||
Settings.Load(this);
|
||||
}
|
||||
|
||||
if( !Settings.settingsChanged )
|
||||
{
|
||||
System.out.println("libSDL: 3-second timeout in startup screen");
|
||||
class Callback implements Runnable
|
||||
{
|
||||
MainActivity p;
|
||||
Callback( MainActivity _p ) { p = _p; }
|
||||
public void run()
|
||||
{
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch( InterruptedException e ) {};
|
||||
if( Settings.settingsChanged )
|
||||
return;
|
||||
System.out.println("libSDL: Timeout reached in startup screen, process with downloader");
|
||||
p.startDownloader();
|
||||
}
|
||||
};
|
||||
Thread changeConfigAlertThread = null;
|
||||
changeConfigAlertThread = new Thread(new Callback(this));
|
||||
changeConfigAlertThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
public void startDownloader()
|
||||
{
|
||||
System.out.println("libSDL: Starting data downloader");
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public MainActivity Parent;
|
||||
public void run()
|
||||
{
|
||||
System.out.println("libSDL: Removing button from startup screen and adding status text");
|
||||
if( Parent._btn != null )
|
||||
{
|
||||
Parent._layout2.removeView(Parent._btn);
|
||||
Parent._btn = null;
|
||||
}
|
||||
if( Parent._tv == null )
|
||||
{
|
||||
Parent._tv = new TextView(Parent);
|
||||
Parent._tv.setText(R.string.init);
|
||||
Parent._layout2.addView(Parent._tv);
|
||||
}
|
||||
|
||||
System.out.println("libSDL: Starting downloader");
|
||||
if( Parent.downloader == null )
|
||||
Parent.downloader = new DataDownloader(Parent, Parent._tv);
|
||||
}
|
||||
}
|
||||
Callback cb = new Callback();
|
||||
cb.Parent = this;
|
||||
this.runOnUiThread(cb);
|
||||
}
|
||||
|
||||
public void initSDL()
|
||||
{
|
||||
if(sdlInited)
|
||||
return;
|
||||
System.out.println("libSDL: Initializing video and SDL application");
|
||||
sdlInited = true;
|
||||
if(Globals.UseAccelerometerAsArrowKeys)
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
|
||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
mGLView = new DemoGLSurfaceView(this);
|
||||
setContentView(mGLView);
|
||||
// Receive keyboard events
|
||||
mGLView.setFocusableInTouchMode(true);
|
||||
mGLView.setFocusable(true);
|
||||
mGLView.requestFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
if( downloader != null ) {
|
||||
synchronized( downloader ) {
|
||||
downloader.setParent(null, null);
|
||||
}
|
||||
}
|
||||
if( mGLView != null )
|
||||
mGLView.onPause();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if( mGLView != null )
|
||||
mGLView.onResume();
|
||||
else
|
||||
if( downloader != null ) {
|
||||
synchronized( downloader ) {
|
||||
downloader.setParent(this, _tv);
|
||||
if( downloader.DownloadComplete )
|
||||
initSDL();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy()
|
||||
{
|
||||
if( downloader != null ) {
|
||||
synchronized( downloader ) {
|
||||
downloader.setParent(null, null);
|
||||
}
|
||||
}
|
||||
if( mGLView != null )
|
||||
mGLView.exitApp();
|
||||
super.onDestroy();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, final KeyEvent event) {
|
||||
// Overrides Back key to use in our app
|
||||
if( mGLView != null )
|
||||
mGLView.nativeKey( keyCode, 1 );
|
||||
else
|
||||
if( keyCode == KeyEvent.KEYCODE_BACK && downloader != null )
|
||||
{
|
||||
if( downloader.DownloadFailed )
|
||||
System.exit(1);
|
||||
if( !downloader.DownloadComplete )
|
||||
onStop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, final KeyEvent event) {
|
||||
if( mGLView != null )
|
||||
mGLView.nativeKey( keyCode, 0 );
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(final MotionEvent ev) {
|
||||
if(mGLView != null)
|
||||
mGLView.onTouchEvent(ev);
|
||||
else if( _btn != null )
|
||||
return _btn.dispatchTouchEvent(ev);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
// Do nothing here
|
||||
}
|
||||
|
||||
public void setText(final String t)
|
||||
{
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public TextView Status;
|
||||
public String text;
|
||||
public void run()
|
||||
{
|
||||
if(Status != null)
|
||||
Status.setText(text);
|
||||
}
|
||||
}
|
||||
Callback cb = new Callback();
|
||||
cb.text = new String(t);
|
||||
cb.Status = _tv;
|
||||
this.runOnUiThread(cb);
|
||||
}
|
||||
|
||||
private static DemoGLSurfaceView mGLView = null;
|
||||
private static LoadLibrary mLoadLibraryStub = null;
|
||||
private static AudioThread mAudioThread = null;
|
||||
private static DataDownloader downloader = null;
|
||||
private TextView _tv = null;
|
||||
private Button _btn = null;
|
||||
private LinearLayout _layout = null;
|
||||
private LinearLayout _layout2 = null;
|
||||
private boolean sdlInited = false;
|
||||
|
||||
}
|
||||
523
project/java/Settings.java
Normal file
523
project/java/Settings.java
Normal file
@@ -0,0 +1,523 @@
|
||||
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.util.Log;
|
||||
import java.io.*;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import java.util.Locale;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import java.lang.String;
|
||||
|
||||
class Settings
|
||||
{
|
||||
static String SettingsFileName = "libsdl-settings.cfg";
|
||||
|
||||
static boolean settingsLoaded = false;
|
||||
static boolean settingsChanged = false;
|
||||
|
||||
static void Save(final MainActivity p)
|
||||
{
|
||||
try {
|
||||
ObjectOutputStream out = new ObjectOutputStream(p.openFileOutput( SettingsFileName, p.MODE_WORLD_READABLE ));
|
||||
out.writeBoolean(Globals.DownloadToSdcard);
|
||||
out.writeBoolean(Globals.PhoneHasArrowKeys);
|
||||
out.writeBoolean(Globals.PhoneHasTrackball);
|
||||
out.writeBoolean(Globals.UseAccelerometerAsArrowKeys);
|
||||
out.writeBoolean(Globals.UseTouchscreenKeyboard);
|
||||
out.writeInt(Globals.TouchscreenKeyboardSize);
|
||||
out.writeInt(Globals.AccelerometerSensitivity);
|
||||
out.writeInt(Globals.AccelerometerCenterPos);
|
||||
out.writeInt(Globals.TrackballDampening);
|
||||
out.writeInt(Globals.AudioBufferConfig);
|
||||
out.writeInt(Globals.OptionalDataDownload.length);
|
||||
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
|
||||
out.writeBoolean(Globals.OptionalDataDownload[i]);
|
||||
out.writeInt(Globals.TouchscreenKeyboardTheme);
|
||||
out.close();
|
||||
settingsLoaded = true;
|
||||
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch( SecurityException e ) {
|
||||
} catch ( IOException e ) {};
|
||||
}
|
||||
|
||||
static void Load( final MainActivity p )
|
||||
{
|
||||
if(settingsLoaded) // Prevent starting twice
|
||||
{
|
||||
return;
|
||||
}
|
||||
System.out.println("libSDL: Settings.Load(): enter");
|
||||
try {
|
||||
ObjectInputStream settingsFile = new ObjectInputStream(new FileInputStream( p.getFilesDir().getAbsolutePath() + "/" + SettingsFileName ));
|
||||
Globals.DownloadToSdcard = settingsFile.readBoolean();
|
||||
Globals.PhoneHasArrowKeys = settingsFile.readBoolean();
|
||||
Globals.PhoneHasTrackball = settingsFile.readBoolean();
|
||||
Globals.UseAccelerometerAsArrowKeys = settingsFile.readBoolean();
|
||||
Globals.UseTouchscreenKeyboard = settingsFile.readBoolean();
|
||||
Globals.TouchscreenKeyboardSize = settingsFile.readInt();
|
||||
Globals.AccelerometerSensitivity = settingsFile.readInt();
|
||||
Globals.AccelerometerCenterPos = settingsFile.readInt();
|
||||
Globals.TrackballDampening = settingsFile.readInt();
|
||||
Globals.AudioBufferConfig = settingsFile.readInt();
|
||||
Globals.OptionalDataDownload = new boolean[settingsFile.readInt()];
|
||||
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
|
||||
Globals.OptionalDataDownload[i] = settingsFile.readBoolean();
|
||||
Globals.TouchscreenKeyboardTheme = settingsFile.readInt();
|
||||
|
||||
settingsLoaded = true;
|
||||
|
||||
System.out.println("libSDL: Settings.Load(): loaded settings successfully");
|
||||
|
||||
return;
|
||||
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch( SecurityException e ) {
|
||||
} catch ( IOException e ) {};
|
||||
|
||||
// This code fails for both of my phones!
|
||||
/*
|
||||
Configuration c = new Configuration();
|
||||
c.setToDefaults();
|
||||
|
||||
if( c.navigation == Configuration.NAVIGATION_TRACKBALL ||
|
||||
c.navigation == Configuration.NAVIGATION_DPAD ||
|
||||
c.navigation == Configuration.NAVIGATION_WHEEL )
|
||||
{
|
||||
Globals.AppNeedsArrowKeys = false;
|
||||
}
|
||||
|
||||
System.out.println( "libSDL: Phone keypad type: " +
|
||||
(
|
||||
c.navigation == Configuration.NAVIGATION_TRACKBALL ? "Trackball" :
|
||||
c.navigation == Configuration.NAVIGATION_DPAD ? "Dpad" :
|
||||
c.navigation == Configuration.NAVIGATION_WHEEL ? "Wheel" :
|
||||
c.navigation == Configuration.NAVIGATION_NONAV ? "None" :
|
||||
"Unknown" ) );
|
||||
*/
|
||||
|
||||
System.out.println("libSDL: Settings.Load(): loading settings failed, running config dialog");
|
||||
showConfig(p);
|
||||
}
|
||||
|
||||
public static void showConfig(final MainActivity p) {
|
||||
settingsChanged = true;
|
||||
showDownloadConfig(p);
|
||||
}
|
||||
|
||||
static void showDownloadConfig(final MainActivity p) {
|
||||
|
||||
long freeSdcard = 0;
|
||||
long freePhone = 0;
|
||||
try {
|
||||
StatFs sdcard = new StatFs(Environment.getExternalStorageDirectory().getPath());
|
||||
StatFs phone = new StatFs(Environment.getDataDirectory().getPath());
|
||||
freeSdcard = (long)sdcard.getAvailableBlocks() * sdcard.getBlockSize() / 1024 / 1024;
|
||||
freePhone = (long)phone.getAvailableBlocks() * phone.getBlockSize() / 1024 / 1024;
|
||||
}catch(Exception e) {}
|
||||
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.storage_phone, freePhone),
|
||||
p.getResources().getString(R.string.storage_sd, freeSdcard) };
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
String [] downloadFiles = Globals.DataDownloadUrl.split("\\^");
|
||||
builder.setTitle(downloadFiles[0].split("[|]")[0]);
|
||||
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.DownloadToSdcard = (item == 1);
|
||||
|
||||
dialog.dismiss();
|
||||
showOptionalDownloadConfig(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
};
|
||||
|
||||
static void showOptionalDownloadConfig(final MainActivity p) {
|
||||
|
||||
String [] downloadFiles = Globals.DataDownloadUrl.split("\\^");
|
||||
if(downloadFiles.length <= 1)
|
||||
{
|
||||
Globals.OptionalDataDownload = new boolean[1];
|
||||
Globals.OptionalDataDownload[0] = true;
|
||||
showKeyboardConfig(p);
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.optional_downloads));
|
||||
|
||||
CharSequence[] items = new CharSequence[ downloadFiles.length - 1 ];
|
||||
for(int i = 1; i < downloadFiles.length; i++ )
|
||||
items[i-1] = new String(downloadFiles[i].split("[|]")[0]);
|
||||
|
||||
if( Globals.OptionalDataDownload == null || Globals.OptionalDataDownload.length != items.length + 1 )
|
||||
Globals.OptionalDataDownload = new boolean[downloadFiles.length];
|
||||
Globals.OptionalDataDownload[0] = true;
|
||||
|
||||
builder.setMultiChoiceItems(items, null, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
Globals.OptionalDataDownload[item+1] = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
showKeyboardConfig(p);
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
};
|
||||
|
||||
static void showKeyboardConfig(final MainActivity p)
|
||||
{
|
||||
if( ! Globals.AppNeedsArrowKeys )
|
||||
{
|
||||
showTrackballConfig(p);
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.controls_arrows),
|
||||
p.getResources().getString(R.string.controls_trackball),
|
||||
p.getResources().getString(R.string.controls_touch) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.controls_question));
|
||||
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.PhoneHasArrowKeys = (item == 0);
|
||||
Globals.PhoneHasTrackball = (item == 1);
|
||||
|
||||
dialog.dismiss();
|
||||
showTrackballConfig(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showTrackballConfig(final MainActivity p)
|
||||
{
|
||||
Globals.TrackballDampening = 0;
|
||||
if( ! Globals.PhoneHasTrackball )
|
||||
{
|
||||
showAdditionalInputConfig(p);
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.trackball_no_dampening),
|
||||
p.getResources().getString(R.string.trackball_fast),
|
||||
p.getResources().getString(R.string.trackball_medium),
|
||||
p.getResources().getString(R.string.trackball_slow) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.trackball_question));
|
||||
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.TrackballDampening = item;
|
||||
|
||||
dialog.dismiss();
|
||||
showAdditionalInputConfig(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
|
||||
static void showAdditionalInputConfig(final MainActivity p)
|
||||
{
|
||||
if( ! Globals.AppNeedsArrowKeys && ! Globals.AppUsesJoystick )
|
||||
{
|
||||
showAccelerometerConfig(p);
|
||||
return;
|
||||
}
|
||||
final CharSequence[] items = {
|
||||
p.getResources().getString(R.string.controls_screenkb),
|
||||
p.getResources().getString(R.string.controls_accelnav),
|
||||
};
|
||||
|
||||
Globals.UseTouchscreenKeyboard = false;
|
||||
Globals.UseAccelerometerAsArrowKeys = false;
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.controls_additional));
|
||||
builder.setMultiChoiceItems(items, null, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
if( item == 0 )
|
||||
Globals.UseTouchscreenKeyboard = isChecked;
|
||||
if( item == 1 )
|
||||
Globals.UseAccelerometerAsArrowKeys = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
showAccelerometerConfig(p);
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showAccelerometerConfig(final MainActivity p)
|
||||
{
|
||||
Globals.AccelerometerSensitivity = 2; // Slow, full range
|
||||
if( ! Globals.UseAccelerometerAsArrowKeys || Globals.AppHandlesJoystickSensitivity )
|
||||
{
|
||||
showAccelerometerCenterConfig(p);
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.accel_fast),
|
||||
p.getResources().getString(R.string.accel_medium),
|
||||
p.getResources().getString(R.string.accel_slow) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.accel_question);
|
||||
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.AccelerometerSensitivity = item;
|
||||
|
||||
dialog.dismiss();
|
||||
showAccelerometerCenterConfig(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showAccelerometerCenterConfig(final MainActivity p)
|
||||
{
|
||||
Globals.AccelerometerCenterPos = 2; // Fixed horizontal center position
|
||||
if( ! Globals.UseAccelerometerAsArrowKeys || Globals.AppHandlesJoystickSensitivity )
|
||||
{
|
||||
showScreenKeyboardConfig(p);
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.accel_floating),
|
||||
p.getResources().getString(R.string.accel_fixed_start),
|
||||
p.getResources().getString(R.string.accel_fixed_horiz) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.accel_question_center);
|
||||
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.AccelerometerCenterPos = item;
|
||||
|
||||
dialog.dismiss();
|
||||
showScreenKeyboardConfig(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
|
||||
static void showScreenKeyboardConfig(final MainActivity p)
|
||||
{
|
||||
Globals.TouchscreenKeyboardSize = 0;
|
||||
if( ! Globals.UseTouchscreenKeyboard )
|
||||
{
|
||||
showScreenKeyboardThemeConfig(p);
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_large),
|
||||
p.getResources().getString(R.string.controls_screenkb_medium),
|
||||
p.getResources().getString(R.string.controls_screenkb_small),
|
||||
p.getResources().getString(R.string.controls_screenkb_tiny) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_size));
|
||||
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.TouchscreenKeyboardSize = item;
|
||||
|
||||
dialog.dismiss();
|
||||
showScreenKeyboardThemeConfig(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showScreenKeyboardThemeConfig(final MainActivity p)
|
||||
{
|
||||
Globals.TouchscreenKeyboardTheme = 0;
|
||||
if( ! Globals.UseTouchscreenKeyboard )
|
||||
{
|
||||
showAudioConfig(p);
|
||||
return;
|
||||
}
|
||||
|
||||
final CharSequence[] items = {
|
||||
p.getResources().getString(R.string.controls_screenkb_by, "Ultimate Droid", "Sean Stieber"),
|
||||
p.getResources().getString(R.string.controls_screenkb_by, "Ugly Arrows", "pelya")
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_theme));
|
||||
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
if( item == 0 )
|
||||
Globals.TouchscreenKeyboardTheme = 1;
|
||||
if( item == 1 )
|
||||
Globals.TouchscreenKeyboardTheme = 0;
|
||||
|
||||
dialog.dismiss();
|
||||
showAudioConfig(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showAudioConfig(final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.audiobuf_verysmall),
|
||||
p.getResources().getString(R.string.audiobuf_small),
|
||||
p.getResources().getString(R.string.audiobuf_medium),
|
||||
p.getResources().getString(R.string.audiobuf_large) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.audiobuf_question);
|
||||
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.AudioBufferConfig = item;
|
||||
dialog.dismiss();
|
||||
Save(p);
|
||||
p.startDownloader();
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void Apply(Activity p)
|
||||
{
|
||||
nativeIsSdcardUsed( Globals.DownloadToSdcard ? 1 : 0 );
|
||||
|
||||
if( Globals.PhoneHasTrackball )
|
||||
nativeSetTrackballUsed();
|
||||
if( Globals.AppUsesMouse )
|
||||
nativeSetMouseUsed();
|
||||
if( Globals.AppUsesJoystick )
|
||||
nativeSetJoystickUsed();
|
||||
if( Globals.AppUsesMultitouch )
|
||||
nativeSetMultitouchUsed();
|
||||
nativeSetAccelerometerSettings(Globals.AccelerometerSensitivity, Globals.AccelerometerCenterPos);
|
||||
nativeSetTrackballDampening(Globals.TrackballDampening);
|
||||
if( Globals.UseTouchscreenKeyboard )
|
||||
{
|
||||
nativeSetTouchscreenKeyboardUsed();
|
||||
nativeSetupScreenKeyboard( Globals.TouchscreenKeyboardSize,
|
||||
Globals.TouchscreenKeyboardTheme,
|
||||
Globals.AppTouchscreenKeyboardKeysAmount,
|
||||
Globals.AppTouchscreenKeyboardKeysAmountAutoFire);
|
||||
}
|
||||
SetupTouchscreenKeyboardGraphics(p);
|
||||
String lang = new String(Locale.getDefault().getLanguage());
|
||||
if( Locale.getDefault().getCountry().length() > 0 )
|
||||
lang = lang + "_" + Locale.getDefault().getCountry();
|
||||
System.out.println( "libSDL: setting envvar LANG to '" + lang + "'");
|
||||
nativeSetEnv( "LANG", lang );
|
||||
// TODO: get current user name and set envvar USER, the API is not availalbe on Android 1.6 so I don't bother with this
|
||||
}
|
||||
|
||||
static byte [] loadRaw(Activity p,int res)
|
||||
{
|
||||
byte [] buf = new byte[65536 * 2];
|
||||
byte [] a = new byte[0];
|
||||
try{
|
||||
InputStream is = new GZIPInputStream(p.getResources().openRawResource(res));
|
||||
int readed = 0;
|
||||
while( (readed = is.read(buf)) >= 0 )
|
||||
{
|
||||
byte [] b = new byte [a.length + readed];
|
||||
System.arraycopy(a, 0, b, 0, a.length);
|
||||
System.arraycopy(buf, 0, b, a.length, readed);
|
||||
a = b;
|
||||
}
|
||||
} catch(Exception e) {};
|
||||
return a;
|
||||
}
|
||||
|
||||
static void SetupTouchscreenKeyboardGraphics(Activity p)
|
||||
{
|
||||
if( Globals.UseTouchscreenKeyboard )
|
||||
{
|
||||
if( Globals.TouchscreenKeyboardTheme == 1 )
|
||||
{
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.ultimatedroid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
private static native void nativeSetMouseUsed();
|
||||
private static native void nativeSetJoystickUsed();
|
||||
private static native void nativeSetMultitouchUsed();
|
||||
private static native void nativeSetTouchscreenKeyboardUsed();
|
||||
private static native void nativeSetupScreenKeyboard(int size, int theme, int nbuttons, int nbuttonsAutoFire);
|
||||
private static native void nativeSetupScreenKeyboardButtons(byte[] img);
|
||||
public static native void nativeSetEnv(final String name, final String value);
|
||||
}
|
||||
|
||||
302
project/java/Video.java
Normal file
302
project/java/Video.java
Normal file
@@ -0,0 +1,302 @@
|
||||
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
import javax.microedition.khronos.egl.EGL10;
|
||||
import javax.microedition.khronos.egl.EGL11;
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.egl.EGLContext;
|
||||
import javax.microedition.khronos.egl.EGLDisplay;
|
||||
import javax.microedition.khronos.egl.EGLSurface;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import android.widget.TextView;
|
||||
import java.lang.Thread;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import android.os.Build;
|
||||
|
||||
abstract class DifferentTouchInput
|
||||
{
|
||||
public static DifferentTouchInput getInstance()
|
||||
{
|
||||
if (Integer.parseInt(Build.VERSION.SDK) <= 4)
|
||||
return SingleTouchInput.Holder.sInstance;
|
||||
else
|
||||
return MultiTouchInput.Holder.sInstance;
|
||||
}
|
||||
public abstract void process(final MotionEvent event);
|
||||
private static class SingleTouchInput extends DifferentTouchInput
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final SingleTouchInput sInstance = new SingleTouchInput();
|
||||
}
|
||||
public void process(final MotionEvent event)
|
||||
{
|
||||
int action = -1;
|
||||
if( event.getAction() == MotionEvent.ACTION_DOWN )
|
||||
action = 0;
|
||||
if( event.getAction() == MotionEvent.ACTION_UP )
|
||||
action = 1;
|
||||
if( event.getAction() == MotionEvent.ACTION_MOVE )
|
||||
action = 2;
|
||||
if ( action >= 0 )
|
||||
DemoGLSurfaceView.nativeMouse( (int)event.getX(), (int)event.getY(), action, 0,
|
||||
(int)(event.getPressure() * 1000.0),
|
||||
(int)(event.getSize() * 1000.0) );
|
||||
}
|
||||
}
|
||||
private static class MultiTouchInput extends DifferentTouchInput
|
||||
{
|
||||
|
||||
private static final int touchEventMax = 16; // Max multitouch pointers
|
||||
|
||||
private class touchEvent
|
||||
{
|
||||
public boolean down = false;
|
||||
public int x = 0;
|
||||
public int y = 0;
|
||||
public int pressure = 0;
|
||||
public int size = 0;
|
||||
}
|
||||
|
||||
private touchEvent touchEvents[];
|
||||
|
||||
MultiTouchInput()
|
||||
{
|
||||
touchEvents = new touchEvent[touchEventMax];
|
||||
for( int i = 0; i < touchEventMax; i++ )
|
||||
touchEvents[i] = new touchEvent();
|
||||
}
|
||||
|
||||
private static class Holder
|
||||
{
|
||||
private static final MultiTouchInput sInstance = new MultiTouchInput();
|
||||
}
|
||||
public void process(final MotionEvent event)
|
||||
{
|
||||
int action = -1;
|
||||
|
||||
if( event.getAction() == MotionEvent.ACTION_UP )
|
||||
{
|
||||
action = 1;
|
||||
for( int i = 0; i < touchEventMax; i++ )
|
||||
{
|
||||
if( touchEvents[i].down )
|
||||
{
|
||||
touchEvents[i].down = false;
|
||||
DemoGLSurfaceView.nativeMouse( touchEvents[i].x, touchEvents[i].y, action, i, touchEvents[i].pressure, touchEvents[i].size );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( event.getAction() == MotionEvent.ACTION_DOWN )
|
||||
{
|
||||
action = 0;
|
||||
for( int i = 0; i < event.getPointerCount(); i++ )
|
||||
{
|
||||
int id = event.getPointerId(i);
|
||||
if( id >= touchEventMax )
|
||||
id = touchEventMax-1;
|
||||
touchEvents[id].down = true;
|
||||
touchEvents[id].x = (int)event.getX(i);
|
||||
touchEvents[id].y = (int)event.getY(i);
|
||||
touchEvents[id].pressure = (int)(event.getPressure(i) * 1000.0);
|
||||
touchEvents[id].size = (int)(event.getSize(i) * 1000.0);
|
||||
DemoGLSurfaceView.nativeMouse( touchEvents[i].x, touchEvents[i].y, action, id, touchEvents[i].pressure, touchEvents[i].size );
|
||||
}
|
||||
}
|
||||
|
||||
if( event.getAction() == MotionEvent.ACTION_MOVE )
|
||||
{
|
||||
for( int i = 0; i < touchEventMax; i++ )
|
||||
{
|
||||
int ii;
|
||||
for( ii = 0; ii < event.getPointerCount(); ii++ )
|
||||
{
|
||||
if( i == event.getPointerId(ii) )
|
||||
break;
|
||||
}
|
||||
if( ii >= event.getPointerCount() )
|
||||
{
|
||||
// Up event
|
||||
if( touchEvents[i].down )
|
||||
{
|
||||
action = 1;
|
||||
touchEvents[i].down = false;
|
||||
DemoGLSurfaceView.nativeMouse( touchEvents[i].x, touchEvents[i].y, action, i, touchEvents[i].pressure, touchEvents[i].size );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int id = event.getPointerId(ii);
|
||||
if( id >= touchEventMax )
|
||||
id = touchEventMax-1;
|
||||
if( touchEvents[id].down )
|
||||
action = 2;
|
||||
else
|
||||
action = 0;
|
||||
touchEvents[id].down = true;
|
||||
touchEvents[id].x = (int)event.getX(i);
|
||||
touchEvents[id].y = (int)event.getY(i);
|
||||
touchEvents[id].pressure = (int)(event.getPressure(i) * 1000.0);
|
||||
touchEvents[id].size = (int)(event.getSize(i) * 1000.0);
|
||||
DemoGLSurfaceView.nativeMouse( touchEvents[i].x, touchEvents[i].y, action, id, touchEvents[i].pressure, touchEvents[i].size );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DemoRenderer extends GLSurfaceView_SDL.Renderer {
|
||||
|
||||
public DemoRenderer(Activity _context)
|
||||
{
|
||||
context = _context;
|
||||
}
|
||||
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
|
||||
mGlSurfaceCreated = true;
|
||||
if( mGlSurfaceCreated && ! mPaused && ! mFirstTimeStart )
|
||||
nativeGlContextRecreated();
|
||||
mFirstTimeStart = false;
|
||||
}
|
||||
|
||||
public void onSurfaceChanged(GL10 gl, int w, int h) {
|
||||
nativeResize(w, h);
|
||||
}
|
||||
|
||||
public void onSurfaceDestroyed() {
|
||||
mGlSurfaceCreated = false;
|
||||
mGlContextLost = true;
|
||||
nativeGlContextLost();
|
||||
};
|
||||
|
||||
public void onDrawFrame(GL10 gl) {
|
||||
|
||||
nativeInitJavaCallbacks();
|
||||
|
||||
// Make main thread priority lower so audio thread won't get underrun
|
||||
// Thread.currentThread().setPriority((Thread.currentThread().getPriority() + Thread.MIN_PRIORITY)/2);
|
||||
|
||||
mGlContextLost = false;
|
||||
System.loadLibrary("application");
|
||||
System.loadLibrary("sdl_main");
|
||||
Settings.Apply(context);
|
||||
accelerometer = new AccelerometerReader(context);
|
||||
// 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(); // 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
|
||||
}
|
||||
|
||||
public int swapBuffers() // Called from native code
|
||||
{
|
||||
synchronized (this) {
|
||||
this.notify();
|
||||
}
|
||||
if( ! super.SwapBuffers() && Globals.NonBlockingSwapBuffers )
|
||||
return 0;
|
||||
if(mGlContextLost) {
|
||||
mGlContextLost = false;
|
||||
Settings.SetupTouchscreenKeyboardGraphics(context); // Reload on-screen buttons graphics
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void exitApp() {
|
||||
nativeDone();
|
||||
};
|
||||
|
||||
private native void nativeInitJavaCallbacks();
|
||||
private native void nativeInit();
|
||||
private native void nativeResize(int w, int h);
|
||||
private native void nativeDone();
|
||||
private native void nativeGlContextLost();
|
||||
public native void nativeGlContextRecreated();
|
||||
|
||||
private Activity context = null;
|
||||
private AccelerometerReader accelerometer = null;
|
||||
|
||||
private EGL10 mEgl = null;
|
||||
private EGLDisplay mEglDisplay = null;
|
||||
private EGLSurface mEglSurface = null;
|
||||
private EGLContext mEglContext = null;
|
||||
private boolean mGlContextLost = false;
|
||||
public boolean mGlSurfaceCreated = false;
|
||||
public boolean mPaused = false;
|
||||
private boolean mFirstTimeStart = true;
|
||||
}
|
||||
|
||||
class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
public DemoGLSurfaceView(Activity context) {
|
||||
super(context);
|
||||
mParent = context;
|
||||
touchInput = DifferentTouchInput.getInstance();
|
||||
setEGLConfigChooser(Globals.NeedDepthBuffer);
|
||||
mRenderer = new DemoRenderer(context);
|
||||
setRenderer(mRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(final MotionEvent event)
|
||||
{
|
||||
touchInput.process(event);
|
||||
// Wait a bit, and try to synchronize to app framerate, or event thread will eat all CPU and we'll lose FPS
|
||||
synchronized (mRenderer) {
|
||||
try {
|
||||
mRenderer.wait(300L);
|
||||
} catch (InterruptedException e) { }
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
public void exitApp() {
|
||||
mRenderer.exitApp();
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mRenderer.mPaused = true;
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mRenderer.mPaused = false;
|
||||
if( mRenderer.mGlSurfaceCreated && ! mRenderer.mPaused )
|
||||
mRenderer.nativeGlContextRecreated();
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, final KeyEvent event) {
|
||||
nativeKey( keyCode, 1 );
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, final KeyEvent event) {
|
||||
nativeKey( keyCode, 0 );
|
||||
return true;
|
||||
}
|
||||
|
||||
DemoRenderer mRenderer;
|
||||
Activity mParent;
|
||||
DifferentTouchInput touchInput = null;
|
||||
|
||||
public static native void nativeMouse( int x, int y, int action, int pointerId, int pressure, int radius );
|
||||
public static native void nativeKey( int keyCode, int down );
|
||||
}
|
||||
|
||||
|
||||
46
project/java/translations/values-de/strings.xml
Executable file
46
project/java/translations/values-de/strings.xml
Executable file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Wormux</string>
|
||||
|
||||
<string name="init">Initialisiere</string>
|
||||
<string name="please_wait">Bitte warte, während die Dateien heruntergeladen werden.</string>
|
||||
|
||||
<string name="device_config">Gerätekonfiguration</string>
|
||||
<string name="device_change_cfg">Gerätekonfiguration bearbeiten</string>
|
||||
|
||||
<string name="download_unneeded">Download nicht nötig</string>
|
||||
<string name="connecting_to">Verbinde mit %s</string>
|
||||
<string name="failed_connecting_to">Verbindung mit %s fehlgeschlagen</string>
|
||||
<string name="error_connecting_to">Fehler beim Verbinden mit %s</string>
|
||||
<string name="dl_from">Lade Daten von %s</string>
|
||||
<string name="error_dl_from">Fehler beim Download von %s</string>
|
||||
<string name="error_write">Fehler beim schreiben auf %s</string>
|
||||
<string name="dl_crc_error">Datei %s fehlerhaft</string>
|
||||
<string name="dl_progress">Zu %d%% abgeschlossen: Datei %s</string>
|
||||
<string name="dl_finished">Abgeschlossen</string>
|
||||
|
||||
<string name="storage_phone">Interner Speicher: %d MiB frei</string>
|
||||
<string name="storage_sd">SD Karte: %d MiB frei</string>
|
||||
<string name="storage_question">Wohin sollen die Dateien gespeichert werden</string>
|
||||
|
||||
<string name="controls_arrows">Pfeiltasten / Joystick / dpad</string>
|
||||
<string name="controls_trackball">Trackball</string>
|
||||
<string name="controls_accel">Accelerometer</string>
|
||||
<string name="controls_question">Welche Arten von Navigationstasten hat das Gerät?</string>
|
||||
|
||||
<string name="trackball_no_dampening">Keine Dämpfung</string>
|
||||
<string name="trackball_fast">Schnell</string>
|
||||
<string name="trackball_medium">Mittel</string>
|
||||
<string name="trackball_slow">Langsam</string>
|
||||
<string name="trackball_question">Dämpfung des Trackball</string>
|
||||
|
||||
<string name="accel_fast">Schnell</string>
|
||||
<string name="accel_medium">Mittel</string>
|
||||
<string name="accel_slow">Langsam</string>
|
||||
<string name="accel_question">Empfindlichkeit des Accelerometers</string>
|
||||
|
||||
<string name="audiobuf_small">Klein (für schnelle Geräte)</string>
|
||||
<string name="audiobuf_medium">Mittel</string>
|
||||
<string name="audiobuf_large">Groß (Wenn Ton "hängt")</string>
|
||||
<string name="audiobuf_question">Größe des Audiopuffers</string>
|
||||
</resources>
|
||||
45
project/java/translations/values-fi/strings.xml
Executable file
45
project/java/translations/values-fi/strings.xml
Executable file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Wormux</string>
|
||||
|
||||
<string name="init">Käynnistetään</string>
|
||||
<string name="please_wait">Odota kun tietoja ladataan</string>
|
||||
|
||||
<string name="device_config">Laiteasetukset</string>
|
||||
<string name="device_change_cfg">Muuta laiteasetuksia</string>
|
||||
|
||||
<string name="download_unneeded">Ei tarvitse ladata</string>
|
||||
<string name="connecting_to">Yhdistetään %s</string>
|
||||
<string name="failed_connecting_to">Yhdistäminen epäonnistui %s</string>
|
||||
<string name="error_connecting_to">Virhe yhdistettäessä %s</string>
|
||||
<string name="dl_from">Ladataan kohteesta %s</string>
|
||||
<string name="error_dl_from">Virhe ladattaessa kohteesta %s</string>
|
||||
<string name="error_write">Virhe kirjoittaessa %s</string>
|
||||
<string name="dl_progress">%d%% valmis: tiedosto %s</string>
|
||||
<string name="dl_finished">Valmis</string>
|
||||
|
||||
<string name="storage_phone">Sisäinen muisti - %d Mt vapaana</string>
|
||||
<string name="storage_sd">SD kortti - %d Mt vapaana</string>
|
||||
<string name="storage_question">Minne sovelluksen data ladataan</string>
|
||||
|
||||
<string name="controls_arrows">Nuolinapit / joystick / dpad</string>
|
||||
<string name="controls_trackball">Pallohiiri</string>
|
||||
<string name="controls_accel">Kiihtyvyysanturi</string>
|
||||
<string name="controls_question">Millaiset navigointinapit laittessasi on?</string>
|
||||
|
||||
<string name="trackball_no_dampening">Ei vaimennusta</string>
|
||||
<string name="trackball_fast">Nopea</string>
|
||||
<string name="trackball_medium">Kohtalainen</string>
|
||||
<string name="trackball_slow">Hidas</string>
|
||||
<string name="trackball_question">Pallohiiren vaimennus</string>
|
||||
|
||||
<string name="accel_fast">Nopea</string>
|
||||
<string name="accel_medium">Kohtalainen</string>
|
||||
<string name="accel_slow">Hidas</string>
|
||||
<string name="accel_question">Kiihtyvyysanturin herkkyys</string>
|
||||
|
||||
<string name="audiobuf_small">Pieni (nopeat laitteet)</string>
|
||||
<string name="audiobuf_medium">Keskisuuri</string>
|
||||
<string name="audiobuf_large">Suuri (jos ääni pätkii)</string>
|
||||
<string name="audiobuf_question">Äänipuskurin koko</string>
|
||||
</resources>
|
||||
64
project/java/translations/values-fr/strings.xml
Normal file
64
project/java/translations/values-fr/strings.xml
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="init">Démarrage</string>
|
||||
<string name="please_wait">Veuillez patienter pendant ques les données sont téléchargées</string>
|
||||
|
||||
<string name="device_config">Configuration de l\'appareil</string>
|
||||
<string name="device_change_cfg">Changer la configuration</string>
|
||||
|
||||
<string name="download_unneeded">Inutile de télécharger</string>
|
||||
<string name="connecting_to">Connexion à %s</string>
|
||||
<string name="failed_connecting_to">Echec à la connexion à %s</string>
|
||||
<string name="error_connecting_to">Erreur durant la connection à %s</string>
|
||||
<string name="dl_from">Téléchargement à partir de %s</string>
|
||||
<string name="error_dl_from">Erreur lors du téléchargement à partir de %s</string>
|
||||
<string name="error_write">Erreur d\'écriture dans %s</string>
|
||||
<string name="dl_progress">%.0f%% fait: fichier %s</string>
|
||||
<string name="dl_finished">Fini</string>
|
||||
|
||||
<string name="storage_phone">Stockage interne - %d Mo de libre</string>
|
||||
<string name="storage_sd">Carte SD - %d Mo de libre</string>
|
||||
<string name="storage_question">Où télécharger les données</string>
|
||||
<string name="optional_downloads">Téléchargements en option</string>
|
||||
<string name="ok">Fait</string>
|
||||
|
||||
<string name="controls_arrows">Flèches / joystick / dpad</string>
|
||||
<string name="controls_trackball">Trackball</string>
|
||||
<string name="controls_accel">Accéléromètre</string>
|
||||
<string name="controls_touch">Écran tactile</string>
|
||||
<string name="controls_question">Quel type de touches votre appareil a-t-il?</string>
|
||||
|
||||
<string name="controls_additional">Contrôles supplémentaires</string>
|
||||
<string name="controls_screenkb">Clavier à l\'écran</string>
|
||||
<string name="controls_accelnav">Accéléromètre</string>
|
||||
|
||||
<string name="controls_screenkb_size">Taille du clavier à l\'écran</string>
|
||||
<string name="controls_screenkb_large">Grande</string>
|
||||
<string name="controls_screenkb_medium">Moyenne</string>
|
||||
<string name="controls_screenkb_small">Petite</string>
|
||||
<string name="controls_screenkb_tiny">Minuscule</string>
|
||||
<string name="controls_screenkb_theme">Thème du clavier à l\'écran</string>
|
||||
<string name="controls_screenkb_by">%s par %s</string>
|
||||
|
||||
<string name="trackball_no_dampening">Sans limite</string>
|
||||
<string name="trackball_fast">Rapide</string>
|
||||
<string name="trackball_medium">Moyenne</string>
|
||||
<string name="trackball_slow">Lente</string>
|
||||
<string name="trackball_question">Limitation du trackball</string>
|
||||
|
||||
<string name="accel_fast">Rapide</string>
|
||||
<string name="accel_medium">Moyenne</string>
|
||||
<string name="accel_slow">Slow</string>
|
||||
<string name="accel_question">Sensibilité de l\'accéléromètre</string>
|
||||
|
||||
<string name="accel_floating">Flottante</string>
|
||||
<string name="accel_fixed_start">Déterminée au démarrage de l\'application</string>
|
||||
<string name="accel_fixed_horiz">Orientaton de la table</string>
|
||||
<string name="accel_question_center">Position du centre de l\'accéléromètre</string>
|
||||
|
||||
<string name="audiobuf_verysmall">Très petite (appareils rapides, peu de délai)</string>
|
||||
<string name="audiobuf_small">Petite (appareils rapides)</string>
|
||||
<string name="audiobuf_medium">Moyenne</string>
|
||||
<string name="audiobuf_large">Grande (en cas de son par saccades)</string>
|
||||
<string name="audiobuf_question">Taille du tampon audio</string>
|
||||
</resources>
|
||||
68
project/java/translations/values/strings.xml
Normal file
68
project/java/translations/values/strings.xml
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Commander Genius</string>
|
||||
|
||||
|
||||
<string name="init">Initializing</string>
|
||||
<string name="please_wait">Please wait while data is being downloaded</string>
|
||||
|
||||
<string name="device_config">Device configuration</string>
|
||||
<string name="device_change_cfg">Change device configuration</string>
|
||||
|
||||
<string name="download_unneeded">No need to download</string>
|
||||
<string name="connecting_to">Connecting to %s</string>
|
||||
<string name="failed_connecting_to">Failed connecting to %s</string>
|
||||
<string name="error_connecting_to">Error connecting to %s</string>
|
||||
<string name="dl_from">Downloading data from %s</string>
|
||||
<string name="error_dl_from">Error downloading data from %s</string>
|
||||
<string name="error_write">Error writing to %s</string>
|
||||
<string name="dl_progress">%.0f%% done: file %s</string>
|
||||
<string name="dl_finished">Finished</string>
|
||||
|
||||
<string name="storage_phone">Internal storage - %d MB free</string>
|
||||
<string name="storage_sd">SD card storage - %d MB free</string>
|
||||
<string name="storage_question">Where to download application data</string>
|
||||
<string name="optional_downloads">Optional downloads</string>
|
||||
<string name="ok">OK</string>
|
||||
|
||||
<string name="controls_arrows">Arrows / joystick / dpad</string>
|
||||
<string name="controls_trackball">Trackball</string>
|
||||
<string name="controls_accel">Accelerometer</string>
|
||||
<string name="controls_touch">Touchscreen only</string>
|
||||
<string name="controls_question">What kind of navigation keys does your device have?</string>
|
||||
|
||||
<string name="controls_additional">Additional controls to use</string>
|
||||
<string name="controls_screenkb">On-screen keyboard</string>
|
||||
<string name="controls_accelnav">Accelerometer</string>
|
||||
|
||||
<string name="controls_screenkb_size">On-screen keyboard size</string>
|
||||
<string name="controls_screenkb_large">Large</string>
|
||||
<string name="controls_screenkb_medium">Medium</string>
|
||||
<string name="controls_screenkb_small">Small</string>
|
||||
<string name="controls_screenkb_tiny">Tiny</string>
|
||||
<string name="controls_screenkb_theme">On-screen keyboard theme</string>
|
||||
<string name="controls_screenkb_by">%s by %s</string>
|
||||
|
||||
<string name="trackball_no_dampening">No dampening</string>
|
||||
<string name="trackball_fast">Fast</string>
|
||||
<string name="trackball_medium">Medium</string>
|
||||
<string name="trackball_slow">Slow</string>
|
||||
<string name="trackball_question">Trackball dampening</string>
|
||||
|
||||
<string name="accel_fast">Fast</string>
|
||||
<string name="accel_medium">Medium</string>
|
||||
<string name="accel_slow">Slow</string>
|
||||
<string name="accel_question">Accelerometer sensitivity</string>
|
||||
|
||||
<string name="accel_floating">Floating</string>
|
||||
<string name="accel_fixed_start">Fixed when application starts</string>
|
||||
<string name="accel_fixed_horiz">Fixed to table desk orientation</string>
|
||||
<string name="accel_question_center">Accelerometer center position</string>
|
||||
|
||||
<string name="audiobuf_verysmall">Very small (fast devices, less lag)</string>
|
||||
<string name="audiobuf_small">Small</string>
|
||||
<string name="audiobuf_medium">Medium</string>
|
||||
<string name="audiobuf_large">Large (older devices, if sound is choppy)</string>
|
||||
<string name="audiobuf_question">Size of audio buffer</string>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user