summaryrefslogtreecommitdiff
path: root/platform/android/java/src/com
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-05-24 01:35:47 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-05-24 01:35:47 -0300
commit1cad087969efefa401a11051343cd0689f660770 (patch)
tree1595dd049bdb7289752012dca4398b2251fb08fa /platform/android/java/src/com
parentf9ff086235cd4ff406b136f62fff77b85c0873f9 (diff)
Making Godot Easier to Use..
-=-=-=-=-=-=-=-=-=-=-=-=-=-= -Auto indenter in code editor, this makes it much easier to paste external code. -Zoom in 2D viewport now uses the mouse pointer as reference. -Obscure hack to see where code/line of GDScript in C++ backtrace. -Fixed a bug where keys would get stuck on X11 if pressed simultaneously -Added Api on IP singleton to request local IPs. -Premultiplied alpha support when importing texture, editing PNGs and as a blend mode.
Diffstat (limited to 'platform/android/java/src/com')
-rw-r--r--platform/android/java/src/com/android/godot/Godot.java33
-rw-r--r--platform/android/java/src/com/android/godot/GodotPaymentV3.java37
-rw-r--r--platform/android/java/src/com/android/godot/payments/ConsumeTask.java3
-rw-r--r--platform/android/java/src/com/android/godot/payments/HandlePurchaseTask.java10
-rw-r--r--platform/android/java/src/com/android/godot/payments/PaymentsCache.java3
-rw-r--r--platform/android/java/src/com/android/godot/payments/PaymentsManager.java12
-rw-r--r--platform/android/java/src/com/android/godot/payments/PurchaseTask.java6
7 files changed, 83 insertions, 21 deletions
diff --git a/platform/android/java/src/com/android/godot/Godot.java b/platform/android/java/src/com/android/godot/Godot.java
index 35ecdc818e..bd973ce49b 100644
--- a/platform/android/java/src/com/android/godot/Godot.java
+++ b/platform/android/java/src/com/android/godot/Godot.java
@@ -65,6 +65,9 @@ import java.io.InputStream;
public class Godot extends Activity implements SensorEventListener
{
+
+ static final int MAX_SINGLETONS = 64;
+
static public class SingletonBase {
protected void registerClass(String p_name, String[] p_methods) {
@@ -104,8 +107,21 @@ public class Godot extends Activity implements SensorEventListener
}
+
+ Godot.singletons[Godot.singleton_count++]=this;
+ }
+
+ protected void onMainActivityResult(int requestCode, int resultCode, Intent data) {
+
+
+ }
+
+ protected void onMainResume() {
+
+
}
+
public void registerMethods() {}
}
@@ -133,6 +149,12 @@ public class Godot extends Activity implements SensorEventListener
//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);
};
@@ -147,6 +169,11 @@ public class Godot extends Activity implements SensorEventListener
result_callback.callback(requestCode, resultCode, data);
result_callback = null;
};
+
+ for(int i=0;i<singleton_count;i++) {
+
+ singletons[i].onMainActivityResult(requestCode,resultCode,data);
+ }
};
public void onVideoInit(boolean use_gl2) {
@@ -271,6 +298,12 @@ public class Godot extends Activity implements SensorEventListener
mView.onResume();
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);
GodotLib.focusin();
+
+ for(int i=0;i<singleton_count;i++) {
+
+ singletons[i].onMainResume();
+ }
+
}
@Override public void onSensorChanged(SensorEvent event) {
diff --git a/platform/android/java/src/com/android/godot/GodotPaymentV3.java b/platform/android/java/src/com/android/godot/GodotPaymentV3.java
index 23f5bf34d3..dba4a9a774 100644
--- a/platform/android/java/src/com/android/godot/GodotPaymentV3.java
+++ b/platform/android/java/src/com/android/godot/GodotPaymentV3.java
@@ -1,7 +1,10 @@
package com.android.godot;
+import org.json.JSONObject;
+
import android.app.Activity;
+import android.util.Log;
public class GodotPaymentV3 extends Godot.SingletonBase {
@@ -13,14 +16,17 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
private String accessToken;
private String purchaseValidationUrlPrefix;
+
+ private String transactionId;
- public void purchase( String _sku) {
+ public void purchase( String _sku, String _transactionId) {
final String sku = _sku;
+ final String transactionId = _transactionId;
activity.getPaymentsManager().setBaseSingleton(this);
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
- activity.getPaymentsManager().requestPurchase(sku);
+ activity.getPaymentsManager().requestPurchase(sku, transactionId);
}
});
};
@@ -38,22 +44,31 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
public GodotPaymentV3(Activity p_activity) {
- registerClass("GodotPayments", new String[] {"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix"});
+ registerClass("GodotPayments", new String[] {"purchase", "setPurchaseCallbackId", "setPurchaseValidationUrlPrefix", "setTransactionId", "getSignature"});
activity=(Godot) p_activity;
}
+ private String signature;
+ public String getSignature(){
+ return this.signature;
+ }
+
- public void callbackSuccess(String ticket){
- GodotLib.callobject(purchaseCallbackId, "purchase_success", new Object[]{ticket});
+ public void callbackSuccess(String ticket, String signature){
+ Log.d(this.getClass().getName(), "PRE-Send callback to purchase success");
+ GodotLib.calldeferred(purchaseCallbackId, "purchase_success", new Object[]{ticket, signature});
+ Log.d(this.getClass().getName(), "POST-Send callback to purchase success");
}
public void callbackFail(){
- GodotLib.callobject(purchaseCallbackId, "purchase_fail", new Object[]{});
+ GodotLib.calldeferred(purchaseCallbackId, "purchase_fail", new Object[]{});
+// GodotLib.callobject(purchaseCallbackId, "purchase_fail", new Object[]{});
}
public void callbackCancel(){
- GodotLib.callobject(purchaseCallbackId, "purchase_cancel", new Object[]{});
+ GodotLib.calldeferred(purchaseCallbackId, "purchase_cancel", new Object[]{});
+// GodotLib.callobject(purchaseCallbackId, "purchase_cancel", new Object[]{});
}
public int getPurchaseCallbackId() {
@@ -84,4 +99,12 @@ public class GodotPaymentV3 extends Godot.SingletonBase {
this.accessToken = accessToken;
}
+ public void setTransactionId(String transactionId){
+ this.transactionId = transactionId;
+ }
+
+ public String getTransactionId(){
+ return this.transactionId;
+ }
+
}
diff --git a/platform/android/java/src/com/android/godot/payments/ConsumeTask.java b/platform/android/java/src/com/android/godot/payments/ConsumeTask.java
index 855bc0578d..c983960770 100644
--- a/platform/android/java/src/com/android/godot/payments/ConsumeTask.java
+++ b/platform/android/java/src/com/android/godot/payments/ConsumeTask.java
@@ -56,8 +56,7 @@ abstract public class ConsumeTask {
protected void onPostExecute(String param){
if(param == null){
-
- success(new PaymentsCache(context).getConsumableValue("ticket", sku));
+ success( new PaymentsCache(context).getConsumableValue("ticket", sku) );
}else{
error(param);
}
diff --git a/platform/android/java/src/com/android/godot/payments/HandlePurchaseTask.java b/platform/android/java/src/com/android/godot/payments/HandlePurchaseTask.java
index a32ecf2895..a810ac40ae 100644
--- a/platform/android/java/src/com/android/godot/payments/HandlePurchaseTask.java
+++ b/platform/android/java/src/com/android/godot/payments/HandlePurchaseTask.java
@@ -34,7 +34,8 @@ abstract public class HandlePurchaseTask {
String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
Log.d("XXX", "Purchase data:" + purchaseData);
-// String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
+ String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");
+ Log.d("XXX", "Purchase signature:" + dataSignature);
if (resultCode == Activity.RESULT_OK) {
@@ -57,12 +58,13 @@ abstract public class HandlePurchaseTask {
error("Untrusted callback");
return;
}
-
+ Log.d("XXX", "Este es el product ID:" + productId);
+ pc.setConsumableValue("ticket_signautre", productId, dataSignature);
pc.setConsumableValue("ticket", productId, purchaseData);
pc.setConsumableFlag("block", productId, true);
pc.setConsumableValue("token", productId, purchaseToken);
- success(productId);
+ success(productId, dataSignature);
return;
} catch (JSONException e) {
error(e.getMessage());
@@ -72,7 +74,7 @@ abstract public class HandlePurchaseTask {
}
}
- abstract protected void success(String ticket);
+ abstract protected void success(String ticket, String signature);
abstract protected void error(String message);
abstract protected void canceled();
diff --git a/platform/android/java/src/com/android/godot/payments/PaymentsCache.java b/platform/android/java/src/com/android/godot/payments/PaymentsCache.java
index ba84097732..7337acc0b8 100644
--- a/platform/android/java/src/com/android/godot/payments/PaymentsCache.java
+++ b/platform/android/java/src/com/android/godot/payments/PaymentsCache.java
@@ -2,6 +2,7 @@ package com.android.godot.payments;
import android.content.Context;
import android.content.SharedPreferences;
+import android.util.Log;
public class PaymentsCache {
@@ -30,12 +31,14 @@ public class PaymentsCache {
SharedPreferences sharedPref = context.getSharedPreferences("consumables_" + set, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString(sku, value);
+ Log.d("XXX", "Setting asset: consumables_" + set + ":" + sku);
editor.commit();
}
public String getConsumableValue(String set, String sku){
SharedPreferences sharedPref = context.getSharedPreferences(
"consumables_" + set, Context.MODE_PRIVATE);
+ Log.d("XXX", "Getting asset: consumables_" + set + ":" + sku);
return sharedPref.getString(sku, null);
}
diff --git a/platform/android/java/src/com/android/godot/payments/PaymentsManager.java b/platform/android/java/src/com/android/godot/payments/PaymentsManager.java
index e8c487dbd8..d85a8ea8ea 100644
--- a/platform/android/java/src/com/android/godot/payments/PaymentsManager.java
+++ b/platform/android/java/src/com/android/godot/payments/PaymentsManager.java
@@ -6,6 +6,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
+import android.util.Log;
import com.android.godot.Godot;
import com.android.godot.GodotPaymentV3;
@@ -63,7 +64,7 @@ public class PaymentsManager {
}
};
- public void requestPurchase(String sku){
+ public void requestPurchase(String sku, String transactionId){
new PurchaseTask(mService, Godot.getInstance()) {
@Override
@@ -76,7 +77,7 @@ public class PaymentsManager {
protected void canceled() {
godotPaymentV3.callbackCancel();
}
- }.purchase(sku);
+ }.purchase(sku, transactionId);
}
@@ -84,13 +85,14 @@ public class PaymentsManager {
new HandlePurchaseTask(activity){
@Override
- protected void success(final String sku) {
+ protected void success(final String sku, final String signature) {
new ConsumeTask(mService, activity) {
@Override
protected void success(String ticket) {
// godotPaymentV3.callbackSuccess("");
- godotPaymentV3.callbackSuccess(ticket);
+ Log.d("XXX", "calling success:" + signature);
+ godotPaymentV3.callbackSuccess(ticket, signature);
}
@Override
@@ -131,7 +133,7 @@ public class PaymentsManager {
@Override
protected void success(String ticket) {
- godotPaymentV3.callbackSuccess(ticket);
+ godotPaymentV3.callbackSuccess(ticket, null);
}
diff --git a/platform/android/java/src/com/android/godot/payments/PurchaseTask.java b/platform/android/java/src/com/android/godot/payments/PurchaseTask.java
index f5d8a0298a..0856b4e900 100644
--- a/platform/android/java/src/com/android/godot/payments/PurchaseTask.java
+++ b/platform/android/java/src/com/android/godot/payments/PurchaseTask.java
@@ -31,7 +31,7 @@ abstract public class PurchaseTask {
private boolean isLooping = false;
- public void purchase(final String sku){
+ public void purchase(final String sku, final String transactionId){
Log.d("XXX", "Starting purchase for: " + sku);
PaymentsCache pc = new PaymentsCache(context);
Boolean isBlocked = pc.getConsumableFlag("block", sku);
@@ -40,7 +40,7 @@ abstract public class PurchaseTask {
// error("Awaiting payment confirmation");
// return;
// }
- final String hash = Crypt.createRandomHash() + Crypt.createRandomHash();
+ final String hash = transactionId;
Bundle buyIntentBundle;
try {
@@ -76,7 +76,7 @@ abstract public class PurchaseTask {
return;
}
isLooping=true;
- PurchaseTask.this.purchase(sku);
+ PurchaseTask.this.purchase(sku, transactionId);
}