From 1b53652adc3a0e1485de0f24bcf5e0a8e8c09580 Mon Sep 17 00:00:00 2001 From: max-klaus Date: Tue, 27 Oct 2020 18:41:24 +0300 Subject: [PATCH] Sync cancelling subscription with server --- .../src/net/osmand/plus/inapp/InAppPurchaseHelper.java | 10 ++++++---- OsmAnd/src/net/osmand/plus/inapp/InAppPurchases.java | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java index d855e36ab3..24a30762e6 100644 --- a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java +++ b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java @@ -557,10 +557,12 @@ public class InAppPurchaseHelper { // Do we have the live updates? boolean subscribedToLiveUpdates = false; List liveUpdatesPurchases = new ArrayList<>(); - for (InAppPurchase p : getLiveUpdates().getAllSubscriptions()) { - Purchase purchase = getPurchase(p.getSku()); - if (purchase != null) { - liveUpdatesPurchases.add(purchase); + for (InAppSubscription s : getLiveUpdates().getAllSubscriptions()) { + Purchase purchase = getPurchase(s.getSku()); + if (purchase != null || s.getState().isActive()) { + if (purchase != null) { + liveUpdatesPurchases.add(purchase); + } if (!subscribedToLiveUpdates) { subscribedToLiveUpdates = true; } diff --git a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchases.java b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchases.java index e9552bd9eb..b945108c9c 100644 --- a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchases.java +++ b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchases.java @@ -697,6 +697,10 @@ public class InAppPurchases { public boolean isGone() { return this == ON_HOLD || this == PAUSED || this == EXPIRED; } + + public boolean isActive() { + return this == ACTIVE || this == CANCELLED || this == IN_GRACE_PERIOD; + } } InAppSubscription(@NonNull String skuNoVersion, int version) {