Merge remote-tracking branch 'origin/master'

This commit is contained in:
Alex Sytnyk 2018-04-30 13:05:20 +03:00
commit 4e3a17269d
17 changed files with 77 additions and 55 deletions

View file

@ -19,6 +19,7 @@ import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper;
public class SecondSplashScreenFragment extends Fragment {
public static final String TAG = "SecondSplashScreenFragment";
@ -99,15 +100,15 @@ public class SecondSplashScreenFragment extends Fragment {
logoLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
ImageView text = new ImageView(activity);
if (Version.isFreeVersion(app)) {
if (settings.LIVE_UPDATES_PURCHASED.get()) {
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_osmlive));
} else if (settings.FULL_VERSION_PURCHASED.get()) {
} else if (InAppPurchaseHelper.isFullVersionPurchased(app)) {
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_inapp));
} else {
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand));
}
} else if (Version.isPaidVersion(app) || Version.isDeveloperVersion(app)) {
if (settings.LIVE_UPDATES_PURCHASED.get()) {
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_plus_osmlive));
} else {
text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_plus));

View file

@ -878,8 +878,8 @@ public class OsmandApplication extends MultiDexApplication {
try {
if (Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)
&& !osmandSettings.DO_NOT_SEND_ANONYMOUS_APP_USAGE.get()
&& !osmandSettings.FULL_VERSION_PURCHASED.get()
&& !osmandSettings.LIVE_UPDATES_PURCHASED.get()) {
&& !InAppPurchaseHelper.isFullVersionPurchased(this)
&& !InAppPurchaseHelper.isSubscribedToLiveUpdates(this)) {
Class<?> cl = Class.forName("com.google.firebase.analytics.FirebaseAnalytics");
Method mm = cl.getMethod("getInstance", Context.class);
Object inst = mm.invoke(null, ctx == null ? this : ctx);

View file

@ -965,6 +965,9 @@ public class OsmandSettings {
public final OsmandPreference<Boolean> BILLING_HIDE_USER_NAME = new BooleanPreference("billing_hide_user_name", false).makeGlobal();
public final OsmandPreference<Boolean> BILLING_PURCHASE_TOKEN_SENT = new BooleanPreference("billing_purchase_token_sent", false).makeGlobal();
public final OsmandPreference<Boolean> LIVE_UPDATES_PURCHASED = new BooleanPreference("billing_live_updates_purchased", false).makeGlobal();
public final OsmandPreference<Long> LIVE_UPDATES_PURCHASE_CANCELLED_TIME = new LongPreference("live_updates_purchase_cancelled_time", 0).makeGlobal();
public final OsmandPreference<Boolean> LIVE_UPDATES_PURCHASE_CANCELLED_FIRST_DLG_SHOWN = new BooleanPreference("live_updates_purchase_cancelled_first_dlg_shown", false).makeGlobal();
public final OsmandPreference<Boolean> LIVE_UPDATES_PURCHASE_CANCELLED_SECOND_DLG_SHOWN = new BooleanPreference("live_updates_purchase_cancelled_second_dlg_shown", false).makeGlobal();
public final OsmandPreference<Boolean> FULL_VERSION_PURCHASED = new BooleanPreference("billing_full_version_purchased", false).makeGlobal();
public final OsmandPreference<Boolean> DEPTH_CONTOURS_PURCHASED = new BooleanPreference("billing_sea_depth_purchased", false).makeGlobal();
public final OsmandPreference<Boolean> EMAIL_SUBSCRIBED = new BooleanPreference("email_subscribed", false).makeGlobal();
@ -974,8 +977,6 @@ public class OsmandSettings {
public final OsmandPreference<Integer> DISCOUNT_TOTAL_SHOW = new IntPreference("discount_total_show", 0).makeGlobal();
public final OsmandPreference<Long> DISCOUNT_SHOW_DATETIME_MS = new LongPreference("show_discount_datetime_ms", 0).makeGlobal();
public final OsmandPreference<Boolean> TRAVEL_ARTICLES_PURCHASED = new BooleanPreference("travel_articles_purchased", false).makeGlobal();
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<String> USER_OSM_BUG_NAME =
new StringPreference("user_osm_bug_name", "NoName/OsmAnd").makeGlobal();

View file

@ -6,6 +6,8 @@ import java.net.URLEncoder;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import net.osmand.plus.inapp.InAppPurchaseHelper;
public class Version {
private final String appVersion;
@ -121,14 +123,18 @@ public class Version {
public static boolean isPaidVersion(OsmandApplication ctx) {
return !isFreeVersion(ctx)
|| ctx.getSettings().FULL_VERSION_PURCHASED.get()
|| ctx.getSettings().LIVE_UPDATES_PURCHASED.get();
|| InAppPurchaseHelper.isFullVersionPurchased(ctx)
|| InAppPurchaseHelper.isSubscribedToLiveUpdates(ctx);
}
public static boolean isDeveloperVersion(OsmandApplication ctx){
return getAppName(ctx).contains("~") || ctx.getPackageName().equals(FREE_DEV_VERSION_NAME);
}
public static boolean isDeveloperBuild(OsmandApplication ctx){
return getAppName(ctx).contains("~");
}
public static String getVersionForTracker(OsmandApplication ctx) {
String v = Version.getAppName(ctx);
if(Version.isProductionVersion(ctx)){

View file

@ -48,6 +48,7 @@ import net.osmand.plus.dashboard.DashChooseAppDirFragment.ChooseAppDirFragment;
import net.osmand.plus.dashboard.DashChooseAppDirFragment.MoveFilesToDifferentDirectory;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.render.RenderingRulesStorage;
@ -495,8 +496,10 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
misc.addPreference(createCheckBoxPreference(settings.DO_NOT_USE_ANIMATIONS, R.string.do_not_use_animations, R.string.do_not_use_animations_descr));
misc.addPreference(createCheckBoxPreference(settings.MAP_EMPTY_STATE_ALLOWED, R.string.tap_on_map_to_hide_interface, R.string.tap_on_map_to_hide_interface_descr));
misc.addPreference(createCheckBoxPreference(settings.DO_NOT_SHOW_STARTUP_MESSAGES, R.string.do_not_show_startup_messages, R.string.do_not_show_startup_messages_desc));
if (Version.isGooglePlayEnabled(getMyApplication()) && Version.isFreeVersion(getMyApplication())
&& !settings.FULL_VERSION_PURCHASED.get() && !settings.LIVE_UPDATES_PURCHASED.get()) {
OsmandApplication app = getMyApplication();
if (Version.isGooglePlayEnabled(getMyApplication()) && Version.isFreeVersion(app)
&& !InAppPurchaseHelper.isFullVersionPurchased(app)
&& !InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
misc.addPreference(createCheckBoxPreference(settings.DO_NOT_SEND_ANONYMOUS_APP_USAGE, R.string.do_not_send_anonymous_app_usage, R.string.do_not_send_anonymous_app_usage_desc));
}
}

View file

@ -32,6 +32,7 @@ import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndDialogFragment;
import net.osmand.plus.inapp.InAppPurchaseHelper;
@ -89,11 +90,10 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment
case WIKIPEDIA_OFFLINE:
case UNLOCK_ALL_FEATURES:
case DONATION_TO_OSM:
case WIKIVOYAGE_OFFLINE:
return false;
case SEA_DEPTH_MAPS:
return ctx.getSettings().DEPTH_CONTOURS_PURCHASED.get();
case WIKIVOYAGE_OFFLINE:
return ctx.getSettings().TRAVEL_ARTICLES_PURCHASED.get();
return InAppPurchaseHelper.isDepthContoursPurchased(ctx);
case CONTOUR_LINES_HILLSHADE_MAPS:
return OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null;
}

View file

@ -58,6 +58,7 @@ import net.osmand.plus.download.ui.DownloadResourceGroupFragment;
import net.osmand.plus.download.ui.LocalIndexesFragment;
import net.osmand.plus.download.ui.UpdatesIndexFragment;
import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseListener;
import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseTaskType;
import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
@ -403,8 +404,8 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
}
public static boolean shouldShowFreeVersionBanner(OsmandApplication application) {
return (Version.isFreeVersion(application) && !application.getSettings().LIVE_UPDATES_PURCHASED.get()
&& !application.getSettings().FULL_VERSION_PURCHASED.get())
return (Version.isFreeVersion(application) && !InAppPurchaseHelper.isSubscribedToLiveUpdates(application)
&& !InAppPurchaseHelper.isFullVersionPurchased(application))
|| application.getSettings().SHOULD_SHOW_FREE_VERSION_BANNER.get();
}

View file

@ -32,6 +32,7 @@ import net.osmand.plus.Version;
import net.osmand.plus.base.BasicProgressAsyncTask;
import net.osmand.plus.download.DownloadFileHelper.DownloadFileShowWarning;
import net.osmand.plus.helpers.DatabaseHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.resources.ResourceManager;
import net.osmand.util.Algorithms;
@ -563,8 +564,8 @@ public class DownloadIndexesThread {
private boolean validateNotExceedsFreeLimit(IndexItem item) {
boolean exceed = Version.isFreeVersion(app)
&& !app.getSettings().LIVE_UPDATES_PURCHASED.get()
&& !app.getSettings().FULL_VERSION_PURCHASED.get()
&& !InAppPurchaseHelper.isSubscribedToLiveUpdates(app)
&& !InAppPurchaseHelper.isFullVersionPurchased(app)
&& DownloadActivityType.isCountedInDownloads(item)
&& downloads.get() >= DownloadValidationManager.MAXIMUM_AVAILABLE_FREE_DOWNLOADS;
if(exceed) {

View file

@ -12,6 +12,7 @@ import net.osmand.map.OsmandRegions;
import net.osmand.map.WorldRegion;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.download.DownloadOsmandIndexesHelper.AssetIndexItem;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.util.MapUtils;
import org.apache.commons.logging.Log;
@ -321,7 +322,7 @@ public class DownloadResources extends DownloadResourceGroup {
continue;
}
if (ii.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE) {
if (app.getSettings().DEPTH_CONTOURS_PURCHASED.get() || nauticalMaps.size() == 0) {
if (InAppPurchaseHelper.isDepthContoursPurchased(app) || nauticalMaps.size() == 0) {
nauticalMaps.addItem(ii);
}
continue;

View file

@ -17,6 +17,7 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import java.io.File;
import java.text.MessageFormat;
@ -154,8 +155,8 @@ public class DownloadValidationManager {
}
protected void downloadFilesCheck_1_FreeVersion(FragmentActivity context, IndexItem[] items) {
if (Version.isFreeVersion(getMyApplication()) && !app.getSettings().LIVE_UPDATES_PURCHASED.get()
&& !app.getSettings().FULL_VERSION_PURCHASED.get()) {
if (Version.isFreeVersion(getMyApplication()) && !InAppPurchaseHelper.isSubscribedToLiveUpdates(app)
&& !InAppPurchaseHelper.isFullVersionPurchased(app)) {
int total = settings.NUMBER_OF_FREE_DOWNLOADS.get();
if (total > MAXIMUM_AVAILABLE_FREE_DOWNLOADS) {
if (context instanceof FragmentActivity) {

View file

@ -32,6 +32,7 @@ import net.osmand.plus.download.DownloadResources;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.download.ui.LocalIndexesFragment.LocalIndexOperationTask;
import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.util.Algorithms;
import java.io.File;
@ -129,7 +130,7 @@ public class ItemViewHolder {
nauticalPluginDisabled = context.isNauticalPluginDisabled();
freeVersion = context.isFreeVersion();
srtmNeedsInstallation = context.isSrtmNeedsInstallation();
depthContoursPurchased = context.getMyApplication().getSettings().DEPTH_CONTOURS_PURCHASED.get();
depthContoursPurchased = InAppPurchaseHelper.isDepthContoursPurchased(context.getMyApplication());
}
public void bindIndexItem(final IndexItem indexItem) {
@ -314,10 +315,10 @@ public class ItemViewHolder {
}
} else if (indexItem.getType() == DownloadActivityType.WIKIPEDIA_FILE && freeVersion
&& !context.getMyApplication().getSettings().FULL_VERSION_PURCHASED.get()) {
&& !InAppPurchaseHelper.isFullVersionPurchased(context.getMyApplication())) {
clickAction = RightButtonAction.ASK_FOR_FULL_VERSION_PURCHASE;
} else if (indexItem.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE
&& !context.getMyApplication().getSettings().DEPTH_CONTOURS_PURCHASED.get()) {
&& !InAppPurchaseHelper.isDepthContoursPurchased(context.getMyApplication())) {
clickAction = RightButtonAction.ASK_FOR_DEPTH_CONTOURS_PURCHASE;
}
return clickAction;

View file

@ -56,6 +56,7 @@ import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.resources.IncrementalChangesManager;
import net.osmand.util.Algorithms;
@ -469,7 +470,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
if (operation == DELETE_OPERATION) {
File f = new File(info.getPathToData());
successfull = Algorithms.removeAllFiles(f);
if (getMyApplication().getSettings().LIVE_UPDATES_PURCHASED.get()) {
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication())) {
String fileNameWithoutExtension =
Algorithms.getFileNameWithoutExtension(f);
IncrementalChangesManager changesManager =

View file

@ -26,6 +26,7 @@ import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.download.DownloadResources;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.util.Algorithms;
import java.util.Comparator;
@ -92,7 +93,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
getMyApplication().getResourceManager().getOsmandRegions();
OsmandSettings settings = getMyApplication().getSettings();
listAdapter = new UpdateIndexAdapter(a, R.layout.download_index_list_item, indexItems,
!settings.LIVE_UPDATES_PURCHASED.get() || settings.SHOULD_SHOW_FREE_VERSION_BANNER.get());
!InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication()) || settings.SHOULD_SHOW_FREE_VERSION_BANNER.get());
listAdapter.sort(new Comparator<IndexItem>() {
@Override
public int compare(IndexItem indexItem, IndexItem indexItem2) {

View file

@ -121,8 +121,16 @@ public class InAppPurchaseHelper {
return activeTask;
}
public boolean isSubscribedToLiveUpdates() {
return ctx.getSettings().LIVE_UPDATES_PURCHASED.get();
public static boolean isSubscribedToLiveUpdates(@NonNull OsmandApplication ctx) {
return Version.isDeveloperBuild(ctx) || ctx.getSettings().LIVE_UPDATES_PURCHASED.get();
}
public static boolean isFullVersionPurchased(@NonNull OsmandApplication ctx) {
return Version.isDeveloperBuild(ctx) || ctx.getSettings().FULL_VERSION_PURCHASED.get();
}
public static boolean isDepthContoursPurchased(@NonNull OsmandApplication ctx) {
return Version.isDeveloperBuild(ctx) || ctx.getSettings().DEPTH_CONTOURS_PURCHASED.get();
}
public String getLiveUpdatesPrice() {
@ -176,12 +184,7 @@ public class InAppPurchaseHelper {
public InAppPurchaseHelper(OsmandApplication ctx) {
this.ctx = ctx;
this.isDeveloperVersion = Version.isDeveloperVersion(ctx);
if (this.isDeveloperVersion) {
ctx.getSettings().LIVE_UPDATES_PURCHASED.set(true);
ctx.getSettings().FULL_VERSION_PURCHASED.set(true);
ctx.getSettings().DEPTH_CONTOURS_PURCHASED.set(true);
}
isDeveloperVersion = Version.isDeveloperVersion(ctx);
initialize();
}
@ -192,11 +195,11 @@ public class InAppPurchaseHelper {
public boolean isPurchased(String inAppSku) {
OsmandSettings settings = ctx.getSettings();
if (inAppSku.equals(SKU_FULL_VERSION_PRICE)) {
return settings.FULL_VERSION_PURCHASED.get();
return isFullVersionPurchased(ctx);
} else if (inAppSku.equals(SKU_LIVE_UPDATES_FULL) || inAppSku.equals(SKU_LIVE_UPDATES_FREE)) {
return settings.LIVE_UPDATES_PURCHASED.get();
return isSubscribedToLiveUpdates(ctx);
} else if (inAppSku.equals(SKU_DEPTH_CONTOURS_FULL) || inAppSku.equals(SKU_DEPTH_CONTOURS_FREE)) {
return settings.DEPTH_CONTOURS_PURCHASED.get();
return isDepthContoursPurchased(ctx);
}
return false;
}
@ -252,7 +255,7 @@ public class InAppPurchaseHelper {
}
public boolean needRequestInventory() {
return (ctx.getSettings().LIVE_UPDATES_PURCHASED.get() && !ctx.getSettings().BILLING_PURCHASE_TOKEN_SENT.get())
return (isSubscribedToLiveUpdates(ctx) && !ctx.getSettings().BILLING_PURCHASE_TOKEN_SENT.get())
|| System.currentTimeMillis() - lastValidationCheckTime > PURCHASE_VALIDATION_PERIOD_MSEC;
}
@ -355,7 +358,9 @@ public class InAppPurchaseHelper {
// Do we have the live updates?
Purchase liveUpdatesPurchase = inventory.getPurchase(SKU_LIVE_UPDATES);
boolean subscribedToLiveUpdates = (liveUpdatesPurchase != null && liveUpdatesPurchase.getPurchaseState() == 0);
//subscribedToLiveUpdates = false;
if (!subscribedToLiveUpdates && ctx.getSettings().LIVE_UPDATES_PURCHASED.get()) {
ctx.getSettings().LIVE_UPDATES_PURCHASE_CANCELLED_TIME.set(System.currentTimeMillis());
}
ctx.getSettings().LIVE_UPDATES_PURCHASED.set(subscribedToLiveUpdates);
Purchase fullVersionPurchase = inventory.getPurchase(SKU_FULL_VERSION_PRICE);

View file

@ -130,8 +130,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
listView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
InAppPurchaseHelper purchaseHelper = getInAppPurchaseHelper();
if (!processing && purchaseHelper != null && purchaseHelper.isSubscribedToLiveUpdates()) {
if (!processing && InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication())) {
final FragmentManager fragmentManager = getChildFragmentManager();
LiveUpdatesSettingsDialogFragment
.createInstance(adapter.getChild(groupPosition, childPosition).getFileName())
@ -153,8 +152,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
InAppPurchaseHelper purchaseHelper = getInAppPurchaseHelper();
if (position == 0 && !processing && purchaseHelper != null && purchaseHelper.isSubscribedToLiveUpdates()) {
if (position == 0 && !processing && InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication())) {
SubscriptionFragment subscriptionFragment = new SubscriptionFragment();
subscriptionFragment.setEditMode(true);
subscriptionFragment.show(getChildFragmentManager(), SubscriptionFragment.TAG);
@ -174,7 +172,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
if (getActivity() instanceof OsmLiveActivity) {
View subscriptionBanner = subscriptionHeader.findViewById(R.id.subscription_banner);
View subscriptionInfo = subscriptionHeader.findViewById(R.id.subscription_info);
if (getSettings().LIVE_UPDATES_PURCHASED.get()) {
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication())) {
ImageView statusIcon = (ImageView) subscriptionHeader.findViewById(R.id.statusIcon);
TextView statusTextView = (TextView) subscriptionHeader.findViewById(R.id.statusTextView);
TextView regionNameHeaderTextView = (TextView) subscriptionHeader.findViewById(R.id.regionHeaderTextView);
@ -267,7 +265,9 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
@SuppressWarnings("deprecation")
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
if (getSettings().LIVE_UPDATES_PURCHASED.get() && !Version.isDeveloperVersion(getMyApplication())) {
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication())
&& !Version.isDeveloperVersion(getMyApplication())) {
ActionBar actionBar = getMyActivity().getSupportActionBar();
if (actionBar != null) {
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
@ -404,8 +404,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
InAppPurchaseHelper purchaseHelper = getInAppPurchaseHelper();
if (purchaseHelper != null && purchaseHelper.isSubscribedToLiveUpdates()) {
if (InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication())) {
switchOnLiveUpdates(settings);
} else {
liveUpdatesSwitch.setChecked(false);
@ -606,8 +605,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
descriptionTextView.setText(context.getString(R.string.last_map_change, lastCheckString));
}
InAppPurchaseHelper purchaseHelper = fragment.getInAppPurchaseHelper();
if (!fragment.isProcessing() && purchaseHelper != null && purchaseHelper.isSubscribedToLiveUpdates()) {
if (!fragment.isProcessing() && InAppPurchaseHelper.isSubscribedToLiveUpdates(context)) {
final View.OnClickListener clickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -708,8 +706,7 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppPurc
@Override
public void onGetItems() {
InAppPurchaseHelper purchaseHelper = getInAppPurchaseHelper();
if (purchaseHelper != null && !purchaseHelper.isSubscribedToLiveUpdates()) {
if (!InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication())) {
getSettings().IS_LIVE_UPDATES_ON.set(false);
adapter.enableLiveUpdates(false);
}

View file

@ -21,6 +21,7 @@ import net.osmand.plus.chooseplan.ChoosePlanDialogFragment;
import net.osmand.plus.chooseplan.ChoosePlanDialogFragment.ChoosePlanDialogListener;
import net.osmand.plus.download.AbstractDownloadActivity;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import org.apache.commons.logging.Log;
@ -86,7 +87,7 @@ public class OsmLiveActivity extends AbstractDownloadActivity implements Downloa
@Override
protected void onResume() {
super.onResume();
if (!getMyApplication().getSettings().LIVE_UPDATES_PURCHASED.get() && showSettingOnly) {
if (!InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication()) && showSettingOnly) {
ChoosePlanDialogFragment.showOsmLiveInstance(getSupportFragmentManager());
}
}

View file

@ -36,6 +36,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.render.MapRenderRepositories;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.plus.resources.AsyncLoadingThread.MapLoadRequest;
@ -581,7 +582,7 @@ public class ResourceManager {
collectFiles(appPath, IndexConstants.BINARY_MAP_INDEX_EXT, files);
renameRoadsFiles(files, roadsPath);
collectFiles(roadsPath, IndexConstants.BINARY_MAP_INDEX_EXT, files);
if (!Version.isFreeVersion(context) || context.getSettings().FULL_VERSION_PURCHASED.get()) {
if (!Version.isFreeVersion(context) || InAppPurchaseHelper.isFullVersionPurchased(context)) {
collectFiles(context.getAppPath(IndexConstants.WIKI_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
}
if (OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null) {
@ -618,7 +619,7 @@ public class ResourceManager {
}
boolean wikiMap = (f.getName().contains("_wiki") || f.getName().contains(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT));
boolean srtmMap = f.getName().contains(IndexConstants.BINARY_SRTM_MAP_INDEX_EXT);
if (mapReader == null || (Version.isFreeVersion(context) && wikiMap && !context.getSettings().FULL_VERSION_PURCHASED.get())) {
if (mapReader == null || (Version.isFreeVersion(context) && wikiMap && !InAppPurchaseHelper.isFullVersionPurchased(context))) {
warnings.add(MessageFormat.format(context.getString(R.string.version_index_is_not_supported), f.getName())); //$NON-NLS-1$
} else {
if (mapReader.isBasemap()) {