@ -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 ( ) { }
@ -215,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 ;
@ -225,26 +219,25 @@ 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 ) {
@ -284,7 +277,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
adLayout = new RelativeLayout ( this ) ;
adLayout . setLayoutParams ( new LayoutParams ( LayoutParams . FILL_PARENT , LayoutParams . FILL_PARENT ) ) ;
layout . addView ( adLayout ) ;
}
public void setKeepScreenOn ( final boolean p_enabled ) {
@ -324,7 +316,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
return Godot . _self ;
}
private String [ ] getCommandLine ( ) {
InputStream is ;
try {
@ -363,14 +354,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 ) {
@ -419,7 +406,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
mPaymentsManager = PaymentsManager . createManager ( this ) . initService ( ) ;
godot_initialized = true ;
}
@Override
@ -428,8 +414,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
mRemoteService . onClientUpdated ( mDownloaderClientStub . getMessenger ( ) ) ;
}
@Override
protected void onCreate ( Bundle icicle ) {
@ -441,7 +425,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
//window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
window . addFlags ( WindowManager . LayoutParams . FLAG_TURN_SCREEN_ON ) ;
//check for apk expansion API
if ( true ) {
boolean md5mismatch = false ;
@ -452,7 +435,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 ;
@ -462,10 +444,7 @@ 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_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 ) ;
@ -505,7 +484,8 @@ 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 ( ) ;
}
@ -576,9 +556,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
// TODO Auto-generated catch block
Log . d ( "GODOT" , "Error downloading expansion package:" + e . getMessage ( ) ) ;
}
}
}
}
@ -586,14 +564,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 + + ) {
@ -602,7 +577,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 ) {
@ -619,7 +595,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 ) {
@ -637,10 +614,7 @@ 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_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 ) ;
}
@ -649,9 +623,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
singletons [ i ] . onMainResume ( ) ;
}
}
public void UiChangeListener ( ) {
@ -661,18 +632,14 @@ 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 ( ) ;
@ -681,7 +648,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 ] ] ;
@ -707,7 +675,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.
}
@ -727,7 +696,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 + + ) {
@ -748,8 +718,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
System . exit ( 0 ) ;
}
private boolean obbIsCorrupted ( String f , String main_pack_md5 ) {
try {
@ -768,7 +736,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
}
} while ( numRead ! = - 1 ) ;
fis . close ( ) ;
byte [ ] messageDigest = complete . digest ( ) ;
@ -845,19 +812,20 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
// System.out.printf("%d - up! %f,%f\n",i, event.getX(i),event.getY(i));
//}
} break ;
}
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 ( ) {
@ -878,7 +846,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
private void queueEvent ( Runnable runnable ) {
// TODO Auto-generated method stub
}
public PaymentsManager getPaymentsManager ( ) {
@ -889,7 +856,6 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC
// this.mPaymentsManager = mPaymentsManager;
// };
// Audio
/ * *
@ -983,7 +949,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 ,
@ -994,13 +959,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 ) ) ;
}
}