This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[In_App_Purchase] Improve testability #2016
Merged
mklim
merged 14 commits into
flutter:master
from
juliocbcotta:plugin/in_app_purchase_improve_testability
Sep 3, 2019
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
52cd0a0
Do not register plugin if Activity is null.
juliocbcotta da055d5
Revert unrelated changes.
juliocbcotta bcf733a
Adds UnitTest for registration.
juliocbcotta ed97762
Improved testability.
juliocbcotta 469a7ac
Updated CHANGELOG.md and pubspec.yaml
juliocbcotta cdaea15
Allow background registration and adds check for Activity nullability…
juliocbcotta 65a6a1a
update tests and changelog.
juliocbcotta c673a21
Merge branch 'plugin/in_app_purchase_null_fix' into plugin/in_app_pur…
juliocbcotta ab48f81
Merge branch 'master' into plugin/in_app_purchase_improve_testability
juliocbcotta daa9a07
Merge branch 'master' into plugin/in_app_purchase_improve_testability
juliocbcotta e026980
removed empty line from CHANGELOG.md
juliocbcotta 739e199
Extract BillingClientFactory to an interface to make testing simpler.
juliocbcotta a07f6e2
fix file formatting
juliocbcotta 6eabb6c
formatted file using clang-format-7
juliocbcotta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...purchase/android/src/main/java/io/flutter/plugins/inapppurchase/BillingClientFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.flutter.plugins.inapppurchase; | ||
|
||
import android.content.Context; | ||
import com.android.billingclient.api.BillingClient; | ||
import io.flutter.plugin.common.MethodChannel; | ||
|
||
interface BillingClientFactory { | ||
BillingClient createBillingClient(Context context, MethodChannel channel); | ||
} | ||
|
||
final class BillingClientFactoryImpl implements BillingClientFactory { | ||
|
||
@Override | ||
public BillingClient createBillingClient(Context context, MethodChannel channel) { | ||
return BillingClient.newBuilder(context) | ||
.setListener(new PluginPurchaseListener(channel)) | ||
.build(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...rchase/android/src/main/java/io/flutter/plugins/inapppurchase/PluginPurchaseListener.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.flutter.plugins.inapppurchase; | ||
|
||
import static io.flutter.plugins.inapppurchase.Translator.fromPurchasesList; | ||
|
||
import androidx.annotation.Nullable; | ||
import com.android.billingclient.api.Purchase; | ||
import com.android.billingclient.api.PurchasesUpdatedListener; | ||
import io.flutter.plugin.common.MethodChannel; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
class PluginPurchaseListener implements PurchasesUpdatedListener { | ||
private final MethodChannel channel; | ||
|
||
PluginPurchaseListener(MethodChannel channel) { | ||
this.channel = channel; | ||
} | ||
|
||
@Override | ||
public void onPurchasesUpdated(int responseCode, @Nullable List<Purchase> purchases) { | ||
final Map<String, Object> callbackArgs = new HashMap<>(); | ||
callbackArgs.put("responseCode", responseCode); | ||
callbackArgs.put("purchasesList", fromPurchasesList(purchases)); | ||
channel.invokeMethod(InAppPurchasePlugin.MethodNames.ON_PURCHASES_UPDATED, callbackArgs); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: in_app_purchase | |
description: A Flutter plugin for in-app purchases. Exposes APIs for making in-app purchases through the App Store and Google Play. | ||
author: Flutter Team <[email protected]> | ||
homepage: https://github.com/flutter/plugins/tree/master/packages/in_app_purchase | ||
version: 0.2.1+2 | ||
version: 0.2.1+3 | ||
|
||
|
||
dependencies: | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.