Fix discount banner at first startup

This commit is contained in:
Alexey Kulish 2017-07-25 17:26:23 +03:00
parent 42c0766f6d
commit 12c49c7f15
3 changed files with 10 additions and 5 deletions

View file

@ -926,6 +926,8 @@ public class OsmandSettings {
public static final String BILLING_USER_DONATION_WORLD_PARAMETER = ""; public static final String BILLING_USER_DONATION_WORLD_PARAMETER = "";
public static final String BILLING_USER_DONATION_NONE_PARAMETER = "none"; public static final String BILLING_USER_DONATION_NONE_PARAMETER = "none";
public final OsmandPreference<Boolean> INAPPS_READ = new BooleanPreference("inapps_read", false).makeGlobal();
public final OsmandPreference<String> BILLING_USER_ID = new StringPreference("billing_user_id", "").makeGlobal(); public final OsmandPreference<String> BILLING_USER_ID = new StringPreference("billing_user_id", "").makeGlobal();
public final OsmandPreference<String> BILLING_USER_TOKEN = new StringPreference("billing_user_token", "").makeGlobal(); public final OsmandPreference<String> BILLING_USER_TOKEN = new StringPreference("billing_user_token", "").makeGlobal();
public final OsmandPreference<String> BILLING_USER_NAME = new StringPreference("billing_user_name", "").makeGlobal(); public final OsmandPreference<String> BILLING_USER_NAME = new StringPreference("billing_user_name", "").makeGlobal();

View file

@ -43,16 +43,17 @@ public class DiscountHelper {
public static void checkAndDisplay(final MapActivity mapActivity) { public static void checkAndDisplay(final MapActivity mapActivity) {
if (mapActivity.getMyApplication().getSettings().DO_NOT_SHOW_STARTUP_MESSAGES.get()) { OsmandApplication app = mapActivity.getMyApplication();
OsmandSettings settings = app.getSettings();
if (settings.DO_NOT_SHOW_STARTUP_MESSAGES.get() || !settings.INAPPS_READ.get()) {
return; return;
} }
if (mBannerVisible) { if (mBannerVisible) {
showDiscountBanner(mapActivity, mTitle, mDescription, mIcon, mUrl); showDiscountBanner(mapActivity, mTitle, mDescription, mIcon, mUrl);
} }
OsmandApplication app = mapActivity.getMyApplication();
if (System.currentTimeMillis() - mLastCheckTime < 1000 * 60 * 60 * 24 if (System.currentTimeMillis() - mLastCheckTime < 1000 * 60 * 60 * 24
|| !app.getSettings().isInternetConnectionAvailable() || !settings.isInternetConnectionAvailable()
|| app.getSettings().NO_DISCOUNT_INFO.get()) { || settings.NO_DISCOUNT_INFO.get()) {
return; return;
} }
mLastCheckTime = System.currentTimeMillis(); mLastCheckTime = System.currentTimeMillis();

View file

@ -363,9 +363,11 @@ public class InAppHelper {
mFullVersionPrice = fullPriceDetails.getPrice(); mFullVersionPrice = fullPriceDetails.getPrice();
} }
OsmandSettings settings = ctx.getSettings();
settings.INAPPS_READ.set(true);
boolean needSendToken = false; boolean needSendToken = false;
if (!isDeveloperVersion && liveUpdatesPurchase != null) { if (!isDeveloperVersion && liveUpdatesPurchase != null) {
OsmandSettings settings = ctx.getSettings();
if ((Algorithms.isEmpty(settings.BILLING_USER_ID.get()) || Algorithms.isEmpty(settings.BILLING_USER_TOKEN.get())) if ((Algorithms.isEmpty(settings.BILLING_USER_ID.get()) || Algorithms.isEmpty(settings.BILLING_USER_TOKEN.get()))
&& !Algorithms.isEmpty(liveUpdatesPurchase.getDeveloperPayload())) { && !Algorithms.isEmpty(liveUpdatesPurchase.getDeveloperPayload())) {
String payload = liveUpdatesPurchase.getDeveloperPayload(); String payload = liveUpdatesPurchase.getDeveloperPayload();