diff options
author | Juan Linietsky <reduzio@gmail.com> | 2014-03-13 22:57:24 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2014-03-13 22:57:24 -0300 |
commit | 31ce3c5fd0300aac1e86bced1efc5f9ec94bdb6b (patch) | |
tree | b6d3a290333c72940b49ed4c930ff6858a59515e /platform/android/java/src/com | |
parent | a65edb4caabec21654c56552e11aacf0fd9291de (diff) |
-fix bug in cache for atlas import/export
-fix some menus
-fixed bug in out transition curves
-detect and remove file:/// in collada
-remove multiscript for now
-remove dependencies on mouse in OS, moved to Input
-avoid fscache from screwing up (fix might make it slower, but it works)
-funcref was missing, it's there now
Diffstat (limited to 'platform/android/java/src/com')
3 files changed, 80 insertions, 12 deletions
diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java index cf1545df82..9868e62957 100644 --- a/platform/android/java/src/com/android/godot/Godot.java +++ b/platform/android/java/src/com/android/godot/Godot.java @@ -49,15 +49,19 @@ import android.media.*; import android.hardware.*; import android.content.*; +import android.net.Uri; +import android.media.MediaPlayer; + import java.lang.reflect.Method; import java.util.List; import java.util.ArrayList; +import com.android.godot.payments.PaymentsManager; +import java.io.IOException; import android.provider.Settings.Secure; public class Godot extends Activity implements SensorEventListener -{ - +{ static public class SingletonBase { protected void registerClass(String p_name, String[] p_methods) { @@ -131,8 +135,12 @@ public class Godot extends Activity implements SensorEventListener }; public ResultCallback result_callback; + private PaymentsManager mPaymentsManager; + @Override protected void onActivityResult (int requestCode, int resultCode, Intent data) { - if (result_callback != null) { + if(requestCode == PaymentsManager.REQUEST_CODE_FOR_PURCHASE){ + mPaymentsManager.processPurchaseResponse(resultCode, data); + }else if (result_callback != null) { result_callback.callback(requestCode, resultCode, data); result_callback = null; }; @@ -152,13 +160,17 @@ public class Godot extends Activity implements SensorEventListener } + private static Godot _self; + + public static Godot getInstance(){ + return Godot._self; + } + @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); - - - + _self = this; Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); @@ -172,12 +184,20 @@ public class Godot extends Activity implements SensorEventListener mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL); result_callback = null; - + + mPaymentsManager = PaymentsManager.createManager(this).initService(); + // instanceSingleton( new GodotFacebook(this) ); } + @Override protected void onDestroy(){ + + if(mPaymentsManager != null ) mPaymentsManager.destroy(); + super.onDestroy(); + } + @Override protected void onPause() { super.onPause(); mView.onPause(); @@ -291,7 +311,15 @@ public class Godot extends Activity implements SensorEventListener @Override public boolean onKeyDown(int keyCode, KeyEvent event) { GodotLib.key(event.getUnicodeChar(0), true); return super.onKeyDown(keyCode, event); - }; + } + + public PaymentsManager getPaymentsManager() { + return mPaymentsManager; + } + +// public void setPaymentsManager(PaymentsManager mPaymentsManager) { +// this.mPaymentsManager = mPaymentsManager; +// }; // Audio diff --git a/platform/android/java/src/com/android/godot/GodotIO.java b/platform/android/java/src/com/android/godot/GodotIO.java index 1f3967cb8f..4b6a44335c 100644 --- a/platform/android/java/src/com/android/godot/GodotIO.java +++ b/platform/android/java/src/com/android/godot/GodotIO.java @@ -57,6 +57,9 @@ public class GodotIO { AssetManager am; Activity activity; + Context applicationContext; + MediaPlayer mediaPlayer; + final int SCREEN_LANDSCAPE=0; final int SCREEN_PORTRAIT=1; final int SCREEN_REVERSE_LANDSCAPE=2; @@ -326,7 +329,7 @@ public class GodotIO { activity=p_activity; streams=new HashMap<Integer,AssetData>(); dirs=new HashMap<Integer,AssetDir>(); - + applicationContext = activity.getApplicationContext(); } @@ -502,6 +505,43 @@ public class GodotIO { } }; + public void playVideo(String p_path) + { + Uri filePath = Uri.parse(p_path); + mediaPlayer = new MediaPlayer(); + + try { + mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); + mediaPlayer.setDataSource(applicationContext, filePath); + mediaPlayer.prepare(); + mediaPlayer.start(); + } + catch(IOException e) + { + System.out.println("IOError while playing video"); + } + } + + public boolean isVideoPlaying() { + if (mediaPlayer != null) { + return mediaPlayer.isPlaying(); + } + return false; + } + + public void pauseVideo() { + if (mediaPlayer != null) { + mediaPlayer.pause(); + } + } + + public void stopVideo() { + if (mediaPlayer != null) { + mediaPlayer.release(); + mediaPlayer = null; + } + } + protected static final String PREFS_FILE = "device_id.xml"; protected static final String PREFS_DEVICE_ID = "device_id"; diff --git a/platform/android/java/src/com/android/godot/GodotLib.java b/platform/android/java/src/com/android/godot/GodotLib.java index f0ec3e97c6..ffa3f306f1 100644 --- a/platform/android/java/src/com/android/godot/GodotLib.java +++ b/platform/android/java/src/com/android/godot/GodotLib.java @@ -51,14 +51,14 @@ public class GodotLib { public static native void step(); public static native void touch(int what,int pointer,int howmany, int[] arr); public static native void accelerometer(float x, float y, float z); - public static native void key(int p_unicode_char, boolean p_pressed); + public static native void key(int p_unicode_char, boolean p_pressed); public static native void focusin(); public static native void focusout(); public static native void audio(); public static native void singleton(String p_name,Object p_object); public static native void method(String p_sname,String p_name,String p_ret,String[] p_params); public static native String getGlobal(String p_key); - public static native void callobject(int p_ID, String p_method, Object[] p_params); - public static native void calldeferred(int p_ID, String p_method, Object[] p_params); + public static native void callobject(int p_ID, String p_method, Object[] p_params); + public static native void calldeferred(int p_ID, String p_method, Object[] p_params); } |