|
|
|
|
@ -90,9 +90,7 @@ import android.os.Bundle;
|
|
|
|
|
import android.os.Messenger;
|
|
|
|
|
import android.os.SystemClock;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class Godot extends Activity implements SensorEventListener, IDownloaderClient
|
|
|
|
|
{
|
|
|
|
|
public class Godot extends Activity implements SensorEventListener, IDownloaderClient {
|
|
|
|
|
|
|
|
|
|
static final int MAX_SINGLETONS = 64;
|
|
|
|
|
private IStub mDownloaderClientStub;
|
|
|
|
|
@ -118,7 +116,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
|
|
|
|
|
static private Intent mCurrentIntent;
|
|
|
|
|
|
|
|
|
|
@Override public void onNewIntent(Intent intent) {
|
|
|
|
|
@Override
|
|
|
|
|
public void onNewIntent(Intent intent) {
|
|
|
|
|
mCurrentIntent = intent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -176,16 +175,12 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
ptr.toArray(pt);
|
|
|
|
|
|
|
|
|
|
GodotLib.method(p_name, method.getName(), method.getReturnType().getName(), pt);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Godot.singletons[Godot.singleton_count++] = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void onMainActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void onMainPause() {}
|
|
|
|
|
@ -207,7 +202,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
s.registerMethods();
|
|
|
|
|
singletons.add(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
private String[] command_line;
|
|
|
|
|
@ -216,7 +210,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
public GodotView mView;
|
|
|
|
|
private boolean godot_initialized = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private SensorManager mSensorManager;
|
|
|
|
|
private Sensor mAccelerometer;
|
|
|
|
|
private Sensor mGravity;
|
|
|
|
|
@ -226,26 +219,24 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
public FrameLayout layout;
|
|
|
|
|
public RelativeLayout adLayout;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static public GodotIO io;
|
|
|
|
|
|
|
|
|
|
public static void setWindowTitle(String title) {
|
|
|
|
|
//setTitle(title);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static SingletonBase singletons[] = new SingletonBase[MAX_SINGLETONS];
|
|
|
|
|
static int singleton_count = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public interface ResultCallback {
|
|
|
|
|
public void callback(int requestCode, int resultCode, Intent data);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
public ResultCallback result_callback;
|
|
|
|
|
|
|
|
|
|
private PaymentsManager mPaymentsManager = null;
|
|
|
|
|
|
|
|
|
|
@Override protected void onActivityResult (int requestCode, int resultCode, Intent data) {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
|
if (requestCode == PaymentsManager.REQUEST_CODE_FOR_PURCHASE) {
|
|
|
|
|
mPaymentsManager.processPurchaseResponse(resultCode, data);
|
|
|
|
|
} else if (result_callback != null) {
|
|
|
|
|
@ -313,7 +304,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setKeepScreenOn(final boolean p_enabled) {
|
|
|
|
|
@ -353,7 +343,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
return Godot._self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String[] getCommandLine() {
|
|
|
|
|
InputStream is;
|
|
|
|
|
try {
|
|
|
|
|
@ -392,14 +381,10 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
Log.d("GODOT", "**ERROR** Exception " + e.getClass().getName() + ":" + e.getMessage());
|
|
|
|
|
return new String[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String expansion_pack_path;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initializeGodot() {
|
|
|
|
|
|
|
|
|
|
if (expansion_pack_path != null) {
|
|
|
|
|
@ -450,7 +435,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
mPaymentsManager = PaymentsManager.createManager(this).initService();
|
|
|
|
|
|
|
|
|
|
godot_initialized = true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@ -459,8 +443,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
mRemoteService.onClientUpdated(mDownloaderClientStub.getMessenger());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle icicle) {
|
|
|
|
|
|
|
|
|
|
@ -481,7 +463,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
|
|
|
|
|
List<String> new_args = new LinkedList<String>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < command_line.length; i++) {
|
|
|
|
|
|
|
|
|
|
boolean has_extra = i < command_line.length - 1;
|
|
|
|
|
@ -491,12 +472,12 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
use_immersive = true;
|
|
|
|
|
if (Build.VERSION.SDK_INT >= 19.0) { // check if the application runs on an android 4.4+
|
|
|
|
|
window.getDecorView().setSystemUiVisibility(
|
|
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
|
|
|
|
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
|
|
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
|
|
|
|
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
|
|
|
|
|
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
|
|
|
|
|
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
|
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
|
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
|
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
|
|
|
|
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | // hide nav bar
|
|
|
|
|
View.SYSTEM_UI_FLAG_FULLSCREEN | // hide status bar
|
|
|
|
|
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
|
|
|
|
|
|
|
|
|
UiChangeListener();
|
|
|
|
|
}
|
|
|
|
|
@ -534,7 +515,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
// Build the full path to the app's expansion files
|
|
|
|
|
try {
|
|
|
|
|
expansion_pack_path = Helpers.getSaveFilePath(getApplicationContext());
|
|
|
|
|
expansion_pack_path+="/"+"main."+getPackageManager().getPackageInfo(getPackageName(), 0).versionCode+"."+this.getPackageName()+".obb";
|
|
|
|
|
expansion_pack_path += "/main." + getPackageManager().getPackageInfo(getPackageName(), 0).versionCode + "." + this.getPackageName() + ".obb";
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
@ -605,9 +586,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
Log.d("GODOT", "Error downloading expansion package:" + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -615,14 +594,11 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
|
|
|
|
|
initializeGodot();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//instanceSingleton( new GodotFacebook(this) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override protected void onDestroy(){
|
|
|
|
|
@Override
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
|
|
|
|
|
if (mPaymentsManager != null) mPaymentsManager.destroy();
|
|
|
|
|
for (int i = 0; i < singleton_count; i++) {
|
|
|
|
|
@ -631,7 +607,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override protected void onPause() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onPause() {
|
|
|
|
|
super.onPause();
|
|
|
|
|
if (!godot_initialized) {
|
|
|
|
|
if (null != mDownloaderClientStub) {
|
|
|
|
|
@ -653,7 +630,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override protected void onResume() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onResume() {
|
|
|
|
|
super.onResume();
|
|
|
|
|
if (!godot_initialized) {
|
|
|
|
|
if (null != mDownloaderClientStub) {
|
|
|
|
|
@ -677,21 +655,18 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
if (use_immersive && Build.VERSION.SDK_INT >= 19.0) { // check if the application runs on an android 4.4+
|
|
|
|
|
Window window = getWindow();
|
|
|
|
|
window.getDecorView().setSystemUiVisibility(
|
|
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
|
|
|
|
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
|
|
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
|
|
|
|
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
|
|
|
|
|
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
|
|
|
|
|
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
|
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
|
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
|
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
|
|
|
|
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | // hide nav bar
|
|
|
|
|
View.SYSTEM_UI_FLAG_FULLSCREEN | // hide status bar
|
|
|
|
|
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < singleton_count; i++) {
|
|
|
|
|
|
|
|
|
|
singletons[i].onMainResume();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UiChangeListener() {
|
|
|
|
|
@ -701,18 +676,19 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
public void onSystemUiVisibilityChange(int visibility) {
|
|
|
|
|
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
|
|
|
|
|
decorView.setSystemUiVisibility(
|
|
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
|
|
|
|
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
|
|
|
|
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
|
|
|
|
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
|
|
|
|
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
|
|
|
|
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
|
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
|
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
|
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
|
|
|
|
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
|
|
|
|
View.SYSTEM_UI_FLAG_FULLSCREEN |
|
|
|
|
|
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override public void onSensorChanged(SensorEvent event) {
|
|
|
|
|
@Override
|
|
|
|
|
public void onSensorChanged(SensorEvent event) {
|
|
|
|
|
Display display = ((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
|
|
|
|
|
int displayRotation = display.getRotation();
|
|
|
|
|
|
|
|
|
|
@ -721,7 +697,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
{ 1, -1, 0, 1 }, // ROTATION_0
|
|
|
|
|
{ -1, -1, 1, 0 }, // ROTATION_90
|
|
|
|
|
{ -1, 1, 0, 1 }, // ROTATION_180
|
|
|
|
|
{ 1, 1, 1, 0 } }; // ROTATION_270
|
|
|
|
|
{ 1, 1, 1, 0 }
|
|
|
|
|
}; // ROTATION_270
|
|
|
|
|
|
|
|
|
|
final int[] as = axisSwap[displayRotation];
|
|
|
|
|
adjustedValues[0] = (float)as[0] * event.values[as[2]];
|
|
|
|
|
@ -754,7 +731,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override public final void onAccuracyChanged(Sensor sensor, int accuracy) {
|
|
|
|
|
@Override
|
|
|
|
|
public final void onAccuracyChanged(Sensor sensor, int accuracy) {
|
|
|
|
|
// Do something here if sensor accuracy changes.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -774,7 +752,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@Override public void onBackPressed() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onBackPressed() {
|
|
|
|
|
boolean shouldQuit = true;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < singleton_count; i++) {
|
|
|
|
|
@ -799,8 +778,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean obbIsCorrupted(String f, String main_pack_md5) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
@ -819,7 +796,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
}
|
|
|
|
|
} while (numRead != -1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fis.close();
|
|
|
|
|
byte[] messageDigest = complete.digest();
|
|
|
|
|
|
|
|
|
|
@ -911,14 +887,16 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override public boolean onKeyMultiple(final int inKeyCode, int repeatCount, KeyEvent event) {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onKeyMultiple(final int inKeyCode, int repeatCount, KeyEvent event) {
|
|
|
|
|
String s = event.getCharacters();
|
|
|
|
|
if (s == null || s.length() == 0)
|
|
|
|
|
return super.onKeyMultiple(inKeyCode, repeatCount, event);
|
|
|
|
|
|
|
|
|
|
final char[] cc = s.toCharArray();
|
|
|
|
|
int cnt = 0;
|
|
|
|
|
for (int i = cc.length; --i >= 0; cnt += cc[i] != 0 ? 1 : 0);
|
|
|
|
|
for (int i = cc.length; --i >= 0; cnt += cc[i] != 0 ? 1 : 0)
|
|
|
|
|
;
|
|
|
|
|
if (cnt == 0) return super.onKeyMultiple(inKeyCode, repeatCount, event);
|
|
|
|
|
final Activity me = this;
|
|
|
|
|
queueEvent(new Runnable() {
|
|
|
|
|
@ -939,7 +917,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
|
|
|
|
|
private void queueEvent(Runnable runnable) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PaymentsManager getPaymentsManager() {
|
|
|
|
|
@ -952,7 +929,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Audio
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -1046,7 +1022,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
setButtonPausedState(paused);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDownloadProgress(DownloadProgressInfo progress) {
|
|
|
|
|
mAverageSpeed.setText(getString(com.godot.game.R.string.kilobytes_per_second,
|
|
|
|
|
@ -1057,13 +1032,10 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
|
|
|
|
|
progress.mOverallTotal = progress.mOverallTotal;
|
|
|
|
|
mPB.setMax((int)(progress.mOverallTotal >> 8));
|
|
|
|
|
mPB.setProgress((int)(progress.mOverallProgress >> 8));
|
|
|
|
|
mProgressPercent.setText(Long.toString(progress.mOverallProgress
|
|
|
|
|
* 100 /
|
|
|
|
|
progress.mOverallTotal) + "%");
|
|
|
|
|
mProgressFraction.setText(Helpers.getDownloadProgressString
|
|
|
|
|
(progress.mOverallProgress,
|
|
|
|
|
mProgressPercent.setText(Long.toString(progress.mOverallProgress * 100 /
|
|
|
|
|
progress.mOverallTotal) +
|
|
|
|
|
"%");
|
|
|
|
|
mProgressFraction.setText(Helpers.getDownloadProgressString(progress.mOverallProgress,
|
|
|
|
|
progress.mOverallTotal));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|