commit
f02f469bf3
4 changed files with 114 additions and 15 deletions
|
@ -84,11 +84,11 @@ android {
|
|||
manifest.srcFile "AndroidManifest-nightlyFree.xml"
|
||||
}
|
||||
amazonFree {
|
||||
java.srcDirs = ["src-nogms", "src-google"]
|
||||
java.srcDirs = ["src-nogms", "src-amazon"]
|
||||
manifest.srcFile "AndroidManifest-gplayFree.xml"
|
||||
}
|
||||
amazonFull {
|
||||
java.srcDirs = ["src-nogms", "src-google"]
|
||||
java.srcDirs = ["src-nogms", "src-amazon"]
|
||||
}
|
||||
huawei {
|
||||
java.srcDirs = ["src-nogms", "src-huawei"]
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package net.osmand.plus.inapp;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class InAppPurchaseHelperImpl extends InAppPurchaseHelper {
|
||||
|
||||
public InAppPurchaseHelperImpl(OsmandApplication ctx) {
|
||||
super(ctx);
|
||||
purchases = new InAppPurchasesImpl(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isInAppPurchaseSupported(@NonNull Activity activity, @Nullable InAppPurchaseInitCallback callback) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execImpl(@NonNull InAppPurchaseTaskType taskType, @NonNull InAppCommand command) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purchaseFullVersion(@NonNull Activity activity) throws UnsupportedOperationException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purchaseDepthContours(@NonNull Activity activity) throws UnsupportedOperationException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void purchaseContourLines(@NonNull Activity activity) throws UnsupportedOperationException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void manageSubscription(@NonNull Context ctx, @Nullable String sku) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InAppCommand getPurchaseLiveUpdatesCommand(WeakReference<Activity> activity, String sku, String userInfo) throws UnsupportedOperationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InAppCommand getRequestInventoryCommand() throws UnsupportedOperationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isBillingManagerExists() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void destroyBillingManager() {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package net.osmand.plus.inapp;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
||||
public class InAppPurchasesImpl extends InAppPurchases {
|
||||
|
||||
public InAppPurchasesImpl(OsmandApplication ctx) {
|
||||
super(ctx);
|
||||
inAppPurchases = new InAppPurchase[] {};
|
||||
liveUpdates = new EmptyLiveUpdatesList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullVersion(String sku) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDepthContours(String sku) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isContourLines(String sku) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLiveUpdates(String sku) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class EmptyLiveUpdatesList extends InAppSubscriptionList {
|
||||
|
||||
public EmptyLiveUpdatesList() {
|
||||
super(new InAppSubscription[] {});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -31,7 +31,6 @@ import net.osmand.plus.inapp.InAppPurchases.InAppSubscription;
|
|||
import net.osmand.plus.inapp.InAppPurchases.InAppSubscriptionIntroductoryInfo;
|
||||
import net.osmand.plus.inapp.InAppPurchasesImpl.InAppPurchaseLiveUpdatesOldSubscription;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.settings.backend.OsmandPreference;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
@ -268,7 +267,7 @@ public class InAppPurchaseHelperImpl extends InAppPurchaseHelper {
|
|||
InAppSubscription s = (InAppSubscription) inAppPurchase;
|
||||
try {
|
||||
s.setIntroductoryInfo(new InAppSubscriptionIntroductoryInfo(s, introductoryPrice,
|
||||
introductoryPriceAmountMicros, introductoryPricePeriod, String.valueOf(introductoryPriceCycles)));
|
||||
introductoryPriceAmountMicros, introductoryPricePeriod, introductoryPriceCycles));
|
||||
} catch (ParseException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
@ -542,20 +541,12 @@ public class InAppPurchaseHelperImpl extends InAppPurchaseHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
OsmandPreference<Long> subscriptionCancelledTime = ctx.getSettings().LIVE_UPDATES_PURCHASE_CANCELLED_TIME;
|
||||
if (!subscribedToLiveUpdates && ctx.getSettings().LIVE_UPDATES_PURCHASED.get()) {
|
||||
if (subscriptionCancelledTime.get() == 0) {
|
||||
subscriptionCancelledTime.set(System.currentTimeMillis());
|
||||
ctx.getSettings().LIVE_UPDATES_PURCHASE_CANCELLED_FIRST_DLG_SHOWN.set(false);
|
||||
ctx.getSettings().LIVE_UPDATES_PURCHASE_CANCELLED_SECOND_DLG_SHOWN.set(false);
|
||||
} else if (System.currentTimeMillis() - subscriptionCancelledTime.get() > SUBSCRIPTION_HOLDING_TIME_MSEC) {
|
||||
ctx.getSettings().LIVE_UPDATES_PURCHASED.set(false);
|
||||
if (!isDepthContoursPurchased(ctx)) {
|
||||
ctx.getSettings().getCustomRenderBooleanProperty("depthContours").set(false);
|
||||
}
|
||||
}
|
||||
} else if (subscribedToLiveUpdates) {
|
||||
subscriptionCancelledTime.set(0L);
|
||||
ctx.getSettings().LIVE_UPDATES_PURCHASED.set(true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue