Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f25101b
Convert one method end-to-end to get all the scaffolding in place
stuartmorgan-g Feb 29, 2024
2cc9af3
Partially convert startConnection
stuartmorgan-g Mar 4, 2024
85f2071
Finish converting startConnection
stuartmorgan-g Mar 4, 2024
4024906
Convert endConnection
stuartmorgan-g Mar 4, 2024
9e9dcaf
Convert isAlternativeBillingOnlyAvailable
stuartmorgan-g Mar 4, 2024
511ce22
Minor warning fixes from IDE
stuartmorgan-g Mar 4, 2024
6bada49
Remove unreachable code
stuartmorgan-g Mar 4, 2024
22a9434
Convert showAlternativeBillingOnlyInformationDialog
stuartmorgan-g Mar 4, 2024
f3b6938
Convert consumeAsync, and fix issues caused by not having regenerated…
stuartmorgan-g Mar 5, 2024
2f161c2
Convert isFeatureSupported
stuartmorgan-g Mar 5, 2024
b9dda04
Convert acknowledgePurchase
stuartmorgan-g Mar 5, 2024
a7ddda7
Convert launchBillingFlow
stuartmorgan-g Mar 5, 2024
8ab863b
Naming consistency
stuartmorgan-g Mar 5, 2024
b40e792
Convert queryProductDetailsAsync
stuartmorgan-g Mar 6, 2024
8e51f8f
Convert createAlternativeBillingOnlyReportingDetailsAsync, and fix so…
stuartmorgan-g Mar 6, 2024
1c43bc9
Convert getBillingConfigAsync, extract some Java test boilerplate
stuartmorgan-g Mar 6, 2024
8a6803e
Ensure that success and error are mutually exlusive everywhere
stuartmorgan-g Mar 6, 2024
47f988c
Partially convert queryPurchases, move some hard-coded logic from Jav…
stuartmorgan-g Mar 7, 2024
447863a
Convert queryPurchaseHistoryAsync
stuartmorgan-g Mar 7, 2024
55a9541
Remove old testing stub
stuartmorgan-g Mar 7, 2024
b14eefb
Java cleanup
stuartmorgan-g Mar 7, 2024
fb68b77
Replace the Java->Dart calls as well
stuartmorgan-g Mar 11, 2024
27a8856
Merge branch 'main' into iap-android-pigeon
stuartmorgan-g Mar 12, 2024
770f92b
Version bump
stuartmorgan-g Mar 12, 2024
4ba0b40
Add exception handlers to async methods
stuartmorgan-g Mar 12, 2024
356aad1
Nullability fix
stuartmorgan-g Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.2+1

* Converts internal platform communication to Pigeon.

## 0.3.2

* Adds UserChoiceBilling APIs to platform addition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import androidx.annotation.Nullable;
import com.android.billingclient.api.BillingClient;
import com.android.billingclient.api.UserChoiceBillingListener;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugins.inapppurchase.Messages.PlatformBillingChoiceMode;

/** Responsible for creating a {@link BillingClient} object. */
interface BillingClientFactory {
Expand All @@ -18,14 +18,14 @@ interface BillingClientFactory {
* Creates and returns a {@link BillingClient}.
*
* @param context The context used to create the {@link BillingClient}.
* @param channel The method channel used to create the {@link BillingClient}.
* @param callbackApi The callback API to be used by the {@link BillingClient}.
* @param billingChoiceMode Enables the ability to offer alternative billing or Google Play
* billing.
* @return The {@link BillingClient} object that is created.
*/
BillingClient createBillingClient(
@NonNull Context context,
@NonNull MethodChannel channel,
int billingChoiceMode,
@NonNull Messages.InAppPurchaseCallbackApi callbackApi,
PlatformBillingChoiceMode billingChoiceMode,
@Nullable UserChoiceBillingListener userChoiceBillingListener);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,24 @@
import com.android.billingclient.api.BillingClient;
import com.android.billingclient.api.UserChoiceBillingListener;
import io.flutter.Log;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugins.inapppurchase.MethodCallHandlerImpl.BillingChoiceMode;
import io.flutter.plugins.inapppurchase.Messages.PlatformBillingChoiceMode;

/** The implementation for {@link BillingClientFactory} for the plugin. */
final class BillingClientFactoryImpl implements BillingClientFactory {

@Override
public BillingClient createBillingClient(
@NonNull Context context,
@NonNull MethodChannel channel,
int billingChoiceMode,
@NonNull Messages.InAppPurchaseCallbackApi callbackApi,
PlatformBillingChoiceMode billingChoiceMode,
@Nullable UserChoiceBillingListener userChoiceBillingListener) {
BillingClient.Builder builder = BillingClient.newBuilder(context).enablePendingPurchases();
switch (billingChoiceMode) {
case BillingChoiceMode.ALTERNATIVE_BILLING_ONLY:
case ALTERNATIVE_BILLING_ONLY:
// https://developer.android.com/google/play/billing/alternative/alternative-billing-without-user-choice-in-app
builder.enableAlternativeBillingOnly();
break;
case BillingChoiceMode.USER_CHOICE_BILLING:
case USER_CHOICE_BILLING:
if (userChoiceBillingListener != null) {
// https://developer.android.com/google/play/billing/alternative/alternative-billing-with-user-choice-in-app
builder.enableUserChoiceBilling(userChoiceBillingListener);
Expand All @@ -38,7 +37,7 @@ public BillingClient createBillingClient(
"userChoiceBillingListener null when USER_CHOICE_BILLING set. Defaulting to PLAY_BILLING_ONLY");
}
break;
case BillingChoiceMode.PLAY_BILLING_ONLY:
case PLAY_BILLING_ONLY:
// Do nothing.
break;
default:
Expand All @@ -47,6 +46,6 @@ public BillingClient createBillingClient(
"Unknown BillingChoiceMode " + billingChoiceMode + ", Defaulting to PLAY_BILLING_ONLY");
break;
}
return builder.setListener(new PluginPurchaseListener(channel)).build();
return builder.setListener(new PluginPurchaseListener(callbackApi)).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodChannel;

/** Wraps a {@link BillingClient} instance and responds to Dart calls for it. */
public class InAppPurchasePlugin implements FlutterPlugin, ActivityAware {
Expand All @@ -25,7 +24,6 @@ public class InAppPurchasePlugin implements FlutterPlugin, ActivityAware {
// code owner of this package.
static final String PROXY_VALUE = "io.flutter.plugins.inapppurchase";

private MethodChannel methodChannel;
private MethodCallHandlerImpl methodCallHandler;

/** Plugin registration. */
Expand All @@ -45,7 +43,7 @@ public void onAttachedToEngine(@NonNull FlutterPlugin.FlutterPluginBinding bindi

@Override
public void onDetachedFromEngine(@NonNull FlutterPlugin.FlutterPluginBinding binding) {
teardownMethodChannel();
teardownMethodChannel(binding.getBinaryMessenger());
}

@Override
Expand All @@ -71,16 +69,15 @@ public void onDetachedFromActivityForConfigChanges() {
}

private void setUpMethodChannel(BinaryMessenger messenger, Context context) {
methodChannel = new MethodChannel(messenger, "plugins.flutter.io/in_app_purchase");
Messages.InAppPurchaseCallbackApi handler = new Messages.InAppPurchaseCallbackApi(messenger);
methodCallHandler =
new MethodCallHandlerImpl(
/*activity=*/ null, context, methodChannel, new BillingClientFactoryImpl());
methodChannel.setMethodCallHandler(methodCallHandler);
/*activity=*/ null, context, handler, new BillingClientFactoryImpl());
Messages.InAppPurchaseApi.setUp(messenger, methodCallHandler);
}

private void teardownMethodChannel() {
methodChannel.setMethodCallHandler(null);
methodChannel = null;
private void teardownMethodChannel(BinaryMessenger messenger) {
Messages.InAppPurchaseApi.setUp(messenger, null);
methodCallHandler = null;
}

Expand Down
Loading