Implement updated library methods

This commit is contained in:
cepprice 2021-03-03 19:49:51 +05:00
parent c762e072d2
commit cfd7dfef6b
5 changed files with 11 additions and 13 deletions

View file

@ -16,7 +16,6 @@
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

View file

@ -348,7 +348,7 @@ dependencies {
implementation 'org.immutables:gson:2.5.0' implementation 'org.immutables:gson:2.5.0'
implementation 'com.vividsolutions:jts-core:1.14.0' implementation 'com.vividsolutions:jts-core:1.14.0'
implementation 'com.google.openlocationcode:openlocationcode:1.0.4' implementation 'com.google.openlocationcode:openlocationcode:1.0.4'
implementation 'com.android.billingclient:billing:2.0.3' implementation 'com.android.billingclient:billing:3.0.2'
// turn off for now // turn off for now
//implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0' //implementation 'com.atilika.kuromoji:kuromoji-ipadic:0.9.0'
implementation 'com.squareup.picasso:picasso:2.71828' implementation 'com.squareup.picasso:picasso:2.71828'

View file

@ -511,7 +511,7 @@ public class InAppPurchaseHelperImpl extends InAppPurchaseHelper {
String introductoryPrice = skuDetails.getIntroductoryPrice(); String introductoryPrice = skuDetails.getIntroductoryPrice();
String introductoryPricePeriod = skuDetails.getIntroductoryPricePeriod(); String introductoryPricePeriod = skuDetails.getIntroductoryPricePeriod();
String introductoryPriceCycles = skuDetails.getIntroductoryPriceCycles(); int introductoryPriceCycles = skuDetails.getIntroductoryPriceCycles();
long introductoryPriceAmountMicros = skuDetails.getIntroductoryPriceAmountMicros(); long introductoryPriceAmountMicros = skuDetails.getIntroductoryPriceAmountMicros();
if (!Algorithms.isEmpty(introductoryPrice)) { if (!Algorithms.isEmpty(introductoryPrice)) {
try { try {

View file

@ -405,16 +405,12 @@ public abstract class InAppPurchases {
String introductoryPrice, String introductoryPrice,
long introductoryPriceAmountMicros, long introductoryPriceAmountMicros,
String introductoryPeriodString, String introductoryPeriodString,
String introductoryCycles) throws ParseException { int introductoryCycles) throws ParseException {
this.subscription = subscription; this.subscription = subscription;
this.introductoryPrice = introductoryPrice; this.introductoryPrice = introductoryPrice;
this.introductoryPriceAmountMicros = introductoryPriceAmountMicros; this.introductoryPriceAmountMicros = introductoryPriceAmountMicros;
this.introductoryPeriodString = introductoryPeriodString; this.introductoryPeriodString = introductoryPeriodString;
try { this.introductoryCycles = introductoryCycles;
this.introductoryCycles = Integer.parseInt(introductoryCycles);
} catch (NumberFormatException e) {
throw new ParseException("Cannot parse introductoryCycles = " + introductoryCycles, 0);
}
introductoryPriceValue = introductoryPriceAmountMicros / 1000000d; introductoryPriceValue = introductoryPriceAmountMicros / 1000000d;
introductoryPeriod = Period.parse(introductoryPeriodString); introductoryPeriod = Period.parse(introductoryPeriodString);
} }

View file

@ -135,18 +135,21 @@ public class BillingManager implements PurchasesUpdatedListener {
* Start a purchase flow * Start a purchase flow
*/ */
public void initiatePurchaseFlow(final Activity activity, final SkuDetails skuDetails) { public void initiatePurchaseFlow(final Activity activity, final SkuDetails skuDetails) {
initiatePurchaseFlow(activity, skuDetails, null); initiatePurchaseFlow(activity, skuDetails, null, null);
} }
/** /**
* Start a purchase or subscription replace flow * Start a purchase or subscription replace flow
*/ */
public void initiatePurchaseFlow(final Activity activity, final SkuDetails skuDetails, final String oldSku) { public void initiatePurchaseFlow(final Activity activity, final SkuDetails skuDetails, final String oldSku, final String purchaseToken) {
Runnable purchaseFlowRequest = new Runnable() { Runnable purchaseFlowRequest = new Runnable() {
@Override @Override
public void run() { public void run() {
LOG.debug("Launching in-app purchase flow. Replace old SKU? " + (oldSku != null)); BillingFlowParams.Builder paramsBuilder = BillingFlowParams.newBuilder().setSkuDetails(skuDetails);
BillingFlowParams purchaseParams = BillingFlowParams.newBuilder().setSkuDetails(skuDetails).setOldSku(oldSku).build(); if (oldSku != null) {
paramsBuilder.setOldSku(oldSku, purchaseToken);
}
BillingFlowParams purchaseParams = paramsBuilder.build();
mBillingClient.launchBillingFlow(activity, purchaseParams); mBillingClient.launchBillingFlow(activity, purchaseParams);
} }
}; };