From c4cf068f1b4ea83fe1802bdcd226850468e7893f Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Wed, 17 Mar 2021 18:52:17 +0200 Subject: [PATCH 1/3] Fix compilation --- .../plus/inapp/InAppPurchaseHelperImpl.java | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java b/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java index 7a16429bd5..3fc73e6f1d 100644 --- a/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java +++ b/OsmAnd/src-huawei/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java @@ -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 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); - } + 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); } From 2910df88e1a03bb4d96c3f364e38a9669eeebf7e Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 18 Mar 2021 10:43:56 +0200 Subject: [PATCH 2/3] Add src-amazon --- OsmAnd/AndroidManifest-amazon.xml | 27 ++++++++ OsmAnd/build.gradle | 6 +- .../plus/inapp/InAppPurchaseHelperImpl.java | 69 +++++++++++++++++++ .../osmand/plus/inapp/InAppPurchasesImpl.java | 41 +++++++++++ 4 files changed, 140 insertions(+), 3 deletions(-) create mode 100644 OsmAnd/AndroidManifest-amazon.xml create mode 100644 OsmAnd/src-amazon/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java create mode 100644 OsmAnd/src-amazon/net/osmand/plus/inapp/InAppPurchasesImpl.java diff --git a/OsmAnd/AndroidManifest-amazon.xml b/OsmAnd/AndroidManifest-amazon.xml new file mode 100644 index 0000000000..93e028dd17 --- /dev/null +++ b/OsmAnd/AndroidManifest-amazon.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index ad12988def..a565c924f7 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -84,11 +84,11 @@ android { manifest.srcFile "AndroidManifest-nightlyFree.xml" } amazonFree { - java.srcDirs = ["src-nogms", "src-google"] - manifest.srcFile "AndroidManifest-gplayFree.xml" + java.srcDirs = ["src-nogms", "src-amazon"] + manifest.srcFile "AndroidManifest-amazon.xml" } amazonFull { - java.srcDirs = ["src-nogms", "src-google"] + java.srcDirs = ["src-nogms", "src-amazon"] } huawei { java.srcDirs = ["src-nogms", "src-huawei"] diff --git a/OsmAnd/src-amazon/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java b/OsmAnd/src-amazon/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java new file mode 100644 index 0000000000..f59569ecc2 --- /dev/null +++ b/OsmAnd/src-amazon/net/osmand/plus/inapp/InAppPurchaseHelperImpl.java @@ -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, 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() { + + } +} \ No newline at end of file diff --git a/OsmAnd/src-amazon/net/osmand/plus/inapp/InAppPurchasesImpl.java b/OsmAnd/src-amazon/net/osmand/plus/inapp/InAppPurchasesImpl.java new file mode 100644 index 0000000000..c67c90308f --- /dev/null +++ b/OsmAnd/src-amazon/net/osmand/plus/inapp/InAppPurchasesImpl.java @@ -0,0 +1,41 @@ +package net.osmand.plus.inapp; + +import net.osmand.plus.OsmandApplication; + +public class InAppPurchasesImpl extends InAppPurchases { + + private static final InAppSubscription[] LIVE_UPDATES_FREE = new InAppSubscription[] {}; + + public InAppPurchasesImpl(OsmandApplication ctx) { + super(ctx); + inAppPurchases = new InAppPurchase[] {}; + liveUpdates = new LiveUpdatesInAppPurchasesFree(); + } + + @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 LiveUpdatesInAppPurchasesFree extends InAppSubscriptionList { + + public LiveUpdatesInAppPurchasesFree() { + super(LIVE_UPDATES_FREE); + } + } +} \ No newline at end of file From 67039222c5ad7cf465e785ace9b484f1acd44103 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 18 Mar 2021 11:14:57 +0200 Subject: [PATCH 3/3] Remove unnecessary changes --- OsmAnd/AndroidManifest-amazon.xml | 27 ------------------- OsmAnd/build.gradle | 2 +- .../osmand/plus/inapp/InAppPurchasesImpl.java | 10 +++---- 3 files changed, 5 insertions(+), 34 deletions(-) delete mode 100644 OsmAnd/AndroidManifest-amazon.xml diff --git a/OsmAnd/AndroidManifest-amazon.xml b/OsmAnd/AndroidManifest-amazon.xml deleted file mode 100644 index 93e028dd17..0000000000 --- a/OsmAnd/AndroidManifest-amazon.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - diff --git a/OsmAnd/build.gradle b/OsmAnd/build.gradle index a565c924f7..46192a3144 100644 --- a/OsmAnd/build.gradle +++ b/OsmAnd/build.gradle @@ -85,7 +85,7 @@ android { } amazonFree { java.srcDirs = ["src-nogms", "src-amazon"] - manifest.srcFile "AndroidManifest-amazon.xml" + manifest.srcFile "AndroidManifest-gplayFree.xml" } amazonFull { java.srcDirs = ["src-nogms", "src-amazon"] diff --git a/OsmAnd/src-amazon/net/osmand/plus/inapp/InAppPurchasesImpl.java b/OsmAnd/src-amazon/net/osmand/plus/inapp/InAppPurchasesImpl.java index c67c90308f..00bbea9693 100644 --- a/OsmAnd/src-amazon/net/osmand/plus/inapp/InAppPurchasesImpl.java +++ b/OsmAnd/src-amazon/net/osmand/plus/inapp/InAppPurchasesImpl.java @@ -4,12 +4,10 @@ import net.osmand.plus.OsmandApplication; public class InAppPurchasesImpl extends InAppPurchases { - private static final InAppSubscription[] LIVE_UPDATES_FREE = new InAppSubscription[] {}; - public InAppPurchasesImpl(OsmandApplication ctx) { super(ctx); inAppPurchases = new InAppPurchase[] {}; - liveUpdates = new LiveUpdatesInAppPurchasesFree(); + liveUpdates = new EmptyLiveUpdatesList(); } @Override @@ -32,10 +30,10 @@ public class InAppPurchasesImpl extends InAppPurchases { return false; } - private static class LiveUpdatesInAppPurchasesFree extends InAppSubscriptionList { + private static class EmptyLiveUpdatesList extends InAppSubscriptionList { - public LiveUpdatesInAppPurchasesFree() { - super(LIVE_UPDATES_FREE); + public EmptyLiveUpdatesList() { + super(new InAppSubscription[] {}); } } } \ No newline at end of file