Commit 6daf9b78 by Fredia Huya-Kouadio

Clean up the `GodotPlugin` public API.

parent 09566a96
...@@ -262,7 +262,7 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe ...@@ -262,7 +262,7 @@ public abstract class Godot extends FragmentActivity implements SensorEventListe
// Include the returned non-null views in the Godot view hierarchy. // Include the returned non-null views in the Godot view hierarchy.
for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) { for (GodotPlugin plugin : pluginRegistry.getAllPlugins()) {
View pluginView = plugin.onMainCreateView(this); View pluginView = plugin.onMainCreate(this);
if (pluginView != null) { if (pluginView != null) {
layout.addView(pluginView); layout.addView(pluginView);
} }
......
...@@ -35,6 +35,7 @@ import org.godotengine.godot.Godot; ...@@ -35,6 +35,7 @@ import org.godotengine.godot.Godot;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.Surface; import android.view.Surface;
import android.view.View; import android.view.View;
...@@ -93,6 +94,14 @@ public abstract class GodotPlugin { ...@@ -93,6 +94,14 @@ public abstract class GodotPlugin {
} }
/** /**
* Provides access to the underlying {@link Activity}.
*/
@Nullable
protected Activity getActivity() {
return godot;
}
/**
* Register the plugin with Godot native code. * Register the plugin with Godot native code.
* *
* This method is invoked on the render thread. * This method is invoked on the render thread.
...@@ -145,13 +154,14 @@ public abstract class GodotPlugin { ...@@ -145,13 +154,14 @@ public abstract class GodotPlugin {
* Invoked once during the Godot Android initialization process after creation of the * Invoked once during the Godot Android initialization process after creation of the
* {@link org.godotengine.godot.GodotView} view. * {@link org.godotengine.godot.GodotView} view.
* <p> * <p>
* This method should be overridden by descendants of this class that would like to add * The plugin can return a non-null {@link View} layout in order to add it to the Godot view
* their view/layout to the Godot view hierarchy. * hierarchy.
* *
* @return the view to be included; null if no views should be included. * @see Activity#onCreate(Bundle)
* @return the plugin's view to be included; null if no views should be included.
*/ */
@Nullable @Nullable
public View onMainCreateView(Activity activity) { public View onMainCreate(Activity activity) {
return null; return null;
} }
......
...@@ -67,7 +67,7 @@ public class GodotPayment extends GodotPlugin implements PurchasesUpdatedListene ...@@ -67,7 +67,7 @@ public class GodotPayment extends GodotPlugin implements PurchasesUpdatedListene
super(godot); super(godot);
billingClient = BillingClient billingClient = BillingClient
.newBuilder(getGodot()) .newBuilder(getActivity())
.enablePendingPurchases() .enablePendingPurchases()
.setListener(this) .setListener(this)
.build(); .build();
...@@ -182,7 +182,7 @@ public class GodotPayment extends GodotPlugin implements PurchasesUpdatedListene ...@@ -182,7 +182,7 @@ public class GodotPayment extends GodotPlugin implements PurchasesUpdatedListene
.setSkuDetails(skuDetails) .setSkuDetails(skuDetails)
.build(); .build();
BillingResult result = billingClient.launchBillingFlow(getGodot(), purchaseParams); BillingResult result = billingClient.launchBillingFlow(getActivity(), purchaseParams);
Dictionary returnValue = new Dictionary(); Dictionary returnValue = new Dictionary();
if (result.getResponseCode() == BillingClient.BillingResponseCode.OK) { if (result.getResponseCode() == BillingClient.BillingResponseCode.OK) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment