Fix old live updates in-apps
This commit is contained in:
parent
78d29e470d
commit
b406f76920
3 changed files with 39 additions and 10 deletions
|
@ -154,6 +154,11 @@ public class InAppPurchaseHelper {
|
||||||
return purchases.getMonthlyLiveUpdates();
|
return purchases.getMonthlyLiveUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public InAppSubscription getPurchasedMonthlyLiveUpdates() {
|
||||||
|
return purchases.getPurchasedMonthlyLiveUpdates();
|
||||||
|
}
|
||||||
|
|
||||||
public InAppPurchaseHelper(OsmandApplication ctx) {
|
public InAppPurchaseHelper(OsmandApplication ctx) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
isDeveloperVersion = Version.isDeveloperVersion(ctx);
|
isDeveloperVersion = Version.isDeveloperVersion(ctx);
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class InAppPurchases {
|
||||||
private InAppPurchase depthContours;
|
private InAppPurchase depthContours;
|
||||||
private InAppPurchase contourLines;
|
private InAppPurchase contourLines;
|
||||||
private InAppSubscription monthlyLiveUpdates;
|
private InAppSubscription monthlyLiveUpdates;
|
||||||
|
private InAppSubscription discountedMonthlyLiveUpdates;
|
||||||
private InAppSubscriptionList liveUpdates;
|
private InAppSubscriptionList liveUpdates;
|
||||||
|
|
||||||
InAppPurchases(OsmandApplication ctx) {
|
InAppPurchases(OsmandApplication ctx) {
|
||||||
|
@ -59,8 +60,11 @@ public class InAppPurchases {
|
||||||
}
|
}
|
||||||
for (InAppSubscription s : liveUpdates.getAllSubscriptions()) {
|
for (InAppSubscription s : liveUpdates.getAllSubscriptions()) {
|
||||||
if (s instanceof InAppPurchaseLiveUpdatesMonthly) {
|
if (s instanceof InAppPurchaseLiveUpdatesMonthly) {
|
||||||
monthlyLiveUpdates = s;
|
if (s.isDiscounted()) {
|
||||||
break;
|
discountedMonthlyLiveUpdates = s;
|
||||||
|
} else {
|
||||||
|
monthlyLiveUpdates = s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Version.isFreeVersion(ctx)) {
|
if (Version.isFreeVersion(ctx)) {
|
||||||
|
@ -91,6 +95,16 @@ public class InAppPurchases {
|
||||||
return monthlyLiveUpdates;
|
return monthlyLiveUpdates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public InAppSubscription getPurchasedMonthlyLiveUpdates() {
|
||||||
|
if (monthlyLiveUpdates.isAnyPurchased()) {
|
||||||
|
return monthlyLiveUpdates;
|
||||||
|
} else if (discountedMonthlyLiveUpdates.isAnyPurchased()) {
|
||||||
|
return discountedMonthlyLiveUpdates;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public InAppSubscriptionList getLiveUpdates() {
|
public InAppSubscriptionList getLiveUpdates() {
|
||||||
return liveUpdates;
|
return liveUpdates;
|
||||||
}
|
}
|
||||||
|
@ -559,17 +573,22 @@ public class InAppPurchases {
|
||||||
|
|
||||||
InAppPurchaseLiveUpdatesMonthly(String skuNoVersion, int version) {
|
InAppPurchaseLiveUpdatesMonthly(String skuNoVersion, int version) {
|
||||||
super(skuNoVersion, version);
|
super(skuNoVersion, version);
|
||||||
|
donationSupported = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
InAppPurchaseLiveUpdatesMonthly(@NonNull String sku, boolean discounted) {
|
||||||
|
super(sku, discounted);
|
||||||
|
donationSupported = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
InAppPurchaseLiveUpdatesMonthly(@NonNull String sku) {
|
InAppPurchaseLiveUpdatesMonthly(@NonNull String sku) {
|
||||||
super(sku, false);
|
this(sku, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPriceValue(double priceValue) {
|
public void setPriceValue(double priceValue) {
|
||||||
super.setPriceValue(priceValue);
|
super.setPriceValue(priceValue);
|
||||||
monthlyPriceValue = priceValue;
|
monthlyPriceValue = priceValue;
|
||||||
donationSupported = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -789,9 +808,9 @@ public class InAppPurchases {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class InAppPurchaseLiveUpdatesOldMonthly extends InAppSubscription {
|
public static class InAppPurchaseLiveUpdatesOldMonthly extends InAppPurchaseLiveUpdatesMonthly {
|
||||||
|
|
||||||
private InAppPurchaseLiveUpdatesOldMonthly(String sku) {
|
InAppPurchaseLiveUpdatesOldMonthly(String sku) {
|
||||||
super(sku, true);
|
super(sku, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -800,6 +819,11 @@ public class InAppPurchases {
|
||||||
return ctx.getString(R.string.osm_live_default_price);
|
return ctx.getString(R.string.osm_live_default_price);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDefaultMonthlyPrice(Context ctx) {
|
||||||
|
return ctx.getString(R.string.osm_live_default_price);
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
protected InAppSubscription newInstance(@NonNull String sku) {
|
protected InAppSubscription newInstance(@NonNull String sku) {
|
||||||
|
|
|
@ -192,8 +192,8 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
String countryName = getSettings().BILLING_USER_COUNTRY.get();
|
String countryName = getSettings().BILLING_USER_COUNTRY.get();
|
||||||
InAppPurchaseHelper purchaseHelper = getInAppPurchaseHelper();
|
InAppPurchaseHelper purchaseHelper = getInAppPurchaseHelper();
|
||||||
if (purchaseHelper != null) {
|
if (purchaseHelper != null) {
|
||||||
InAppSubscription s = purchaseHelper.getMonthlyLiveUpdates();
|
InAppSubscription monthlyPurchased = purchaseHelper.getPurchasedMonthlyLiveUpdates();
|
||||||
if (s.isDonationSupported() && s.isAnyPurchased()) {
|
if (monthlyPurchased != null && monthlyPurchased.isDonationSupported()) {
|
||||||
if (Algorithms.isEmpty(countryName)) {
|
if (Algorithms.isEmpty(countryName)) {
|
||||||
if (getSettings().BILLING_USER_COUNTRY_DOWNLOAD_NAME.get().equals(OsmandSettings.BILLING_USER_DONATION_NONE_PARAMETER)) {
|
if (getSettings().BILLING_USER_COUNTRY_DOWNLOAD_NAME.get().equals(OsmandSettings.BILLING_USER_DONATION_NONE_PARAMETER)) {
|
||||||
regionNameHeaderTextView.setText(R.string.default_buttons_support);
|
regionNameHeaderTextView.setText(R.string.default_buttons_support);
|
||||||
|
@ -324,8 +324,8 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
|
||||||
private boolean isDonationSupported() {
|
private boolean isDonationSupported() {
|
||||||
InAppPurchaseHelper purchaseHelper = getInAppPurchaseHelper();
|
InAppPurchaseHelper purchaseHelper = getInAppPurchaseHelper();
|
||||||
if (purchaseHelper != null) {
|
if (purchaseHelper != null) {
|
||||||
InAppSubscription s = purchaseHelper.getMonthlyLiveUpdates();
|
InAppSubscription monthlyPurchased = purchaseHelper.getPurchasedMonthlyLiveUpdates();
|
||||||
return s.isDonationSupported() && s.isAnyPurchased();
|
return monthlyPurchased != null && monthlyPurchased.isDonationSupported();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue