From 0158fa496eaa111bf0b8a9b57374460f2cc87524 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 25 Apr 2018 13:20:40 +0200 Subject: [PATCH 1/2] Make implicit call for startForeground service --- OsmAnd/src/net/osmand/plus/OsmandApplication.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 05b7243e3a..8bc16880ee 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -831,7 +831,11 @@ public class OsmandApplication extends MultiDexApplication { } serviceIntent.putExtra(NavigationService.USAGE_INTENT, intent); serviceIntent.putExtra(NavigationService.USAGE_OFF_INTERVAL, interval); - startService(serviceIntent); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + startForegroundService(serviceIntent); + } else { + startService(serviceIntent); + } //getNotificationHelper().showNotifications(); } From 063a2f715492c9e41eda93d6d7f92af1e97f81b1 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 25 Apr 2018 15:34:29 +0300 Subject: [PATCH 2/2] Added srtm/hillshade, wikivoyage, osmlive choose plan fragments --- OsmAnd/no_translate.xml | 2 + .../OsmandInAppPurchaseActivity.java | 14 +++ .../chooseplan/ChoosePlanDialogFragment.java | 52 +++++++-- .../ChoosePlanFreeBannerDialogFragment.java | 16 +++ ...ChoosePlanHillshadeSrtmDialogFragment.java | 100 ++++++++++++++++++ ...ChoosePlanOsmLiveBannerDialogFragment.java | 14 +++ .../ChoosePlanSeaDepthMapsDialogFragment.java | 16 +++ .../ChoosePlanWikivoyageDialogFragment.java | 6 ++ .../plus/download/ui/ItemViewHolder.java | 11 +- .../download/ui/UpdatesIndexFragment.java | 11 +- .../plus/inapp/InAppPurchaseHelper.java | 20 ++++ .../travelcards/OpenBetaTravelCard.java | 2 +- 12 files changed, 239 insertions(+), 25 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanHillshadeSrtmDialogFragment.java create mode 100644 OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanOsmLiveBannerDialogFragment.java create mode 100644 OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanWikivoyageDialogFragment.java diff --git a/OsmAnd/no_translate.xml b/OsmAnd/no_translate.xml index f2f038699f..4f310b48ec 100644 --- a/OsmAnd/no_translate.xml +++ b/OsmAnd/no_translate.xml @@ -6,6 +6,8 @@ €7,99 + €2,99 + €1,39 OsmAnd Live UA-28342846-2 10 diff --git a/OsmAnd/src/net/osmand/plus/activities/OsmandInAppPurchaseActivity.java b/OsmAnd/src/net/osmand/plus/activities/OsmandInAppPurchaseActivity.java index ec1b82b139..75d7e6621e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/OsmandInAppPurchaseActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/OsmandInAppPurchaseActivity.java @@ -9,13 +9,17 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; +import android.widget.Toast; 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.inapp.InAppPurchaseHelper; import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseListener; import net.osmand.plus.inapp.InAppPurchaseHelper.InAppPurchaseTaskType; +import net.osmand.plus.srtmplugin.SRTMPlugin; import org.apache.commons.logging.Log; @@ -107,6 +111,16 @@ public class OsmandInAppPurchaseActivity extends AppCompatActivity implements In } } + public static void purchaseSrtmPlugin(@NonNull final Activity activity) { + OsmandPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class); + if(plugin == null || plugin.getInstallURL() == null) { + Toast.makeText(activity.getApplicationContext(), + activity.getString(R.string.activate_srtm_plugin), Toast.LENGTH_LONG).show(); + } else { + activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL()))); + } + } + public OsmandApplication getMyApplication() { return (OsmandApplication) getApplication(); } diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java index d68ddbd9d8..baa2a32d15 100644 --- a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanDialogFragment.java @@ -173,8 +173,14 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment if (!TextUtils.isEmpty(getInfoDescription())) { infoDescription.setText(getInfoDescription()); } - cardsContainer.addView(buildOsmLiveCard(ctx, cardsContainer)); - cardsContainer.addView(buildPlanTypeCard(ctx, cardsContainer)); + ViewGroup osmLiveCard = buildOsmLiveCard(ctx, cardsContainer); + if (osmLiveCard != null) { + cardsContainer.addView(osmLiveCard); + } + ViewGroup planTypeCard = buildPlanTypeCard(ctx, cardsContainer); + if (planTypeCard != null) { + cardsContainer.addView(planTypeCard); + } return view; } @@ -204,6 +210,10 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment public abstract String getPlanTypeHeaderDescription(); + public abstract String getPlanTypeButtonTitle(); + + public abstract String getPlanTypeButtonDescription(); + public abstract void setPlanTypeButtonClickListener(View button); private View inflate(@LayoutRes int layoutId, @Nullable ViewGroup container) { @@ -289,6 +299,9 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment } private ViewGroup buildPlanTypeCard(@NonNull Context ctx, ViewGroup container) { + if (getPlanTypeFeatures().length == 0) { + return null; + } ViewGroup cardView = (ViewGroup) inflate(R.layout.purchase_dialog_card, container); AppCompatImageView headerImageView = (AppCompatImageView) cardView.findViewById(R.id.header_img); TextView headerTitleView = (TextView) cardView.findViewById(R.id.header_title); @@ -335,12 +348,8 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment ProgressBar progressBar = (ProgressBar) planTypeCardButton.findViewById(R.id.card_button_progress); TextViewEx buttonTitle = (TextViewEx) planTypeCardButton.findViewById(R.id.card_button_title); TextViewEx buttonSubtitle = (TextViewEx) planTypeCardButton.findViewById(R.id.card_button_subtitle); - if (!purchaseHelper.hasPrices()) { - buttonTitle.setText(getString(R.string.purchase_unlim_title, getString(R.string.full_version_price))); - } else { - buttonTitle.setText(getString(R.string.purchase_unlim_title, purchaseHelper.getFullVersionPrice())); - } - buttonSubtitle.setText(R.string.in_app_purchase_desc); + buttonTitle.setText(getPlanTypeButtonTitle()); + buttonSubtitle.setText(getPlanTypeButtonDescription()); if (progress) { buttonTitle.setVisibility(View.GONE); buttonSubtitle.setVisibility(View.GONE); @@ -434,6 +443,15 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment } } + public static void showWikivoyageInstance(@NonNull FragmentManager fm) { + try { + ChoosePlanWikivoyageDialogFragment fragment = new ChoosePlanWikivoyageDialogFragment(); + fragment.show(fm, ChoosePlanWikivoyageDialogFragment.TAG); + } catch (RuntimeException e) { + LOG.error("showWikivoyageInstance", e); + } + } + public static void showSeaDepthMapsInstance(@NonNull FragmentManager fm) { try { ChoosePlanSeaDepthMapsDialogFragment fragment = new ChoosePlanSeaDepthMapsDialogFragment(); @@ -442,4 +460,22 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment LOG.error("showSeaDepthMapsInstance", e); } } + + public static void showHillshadeSrtmPluginInstance(@NonNull FragmentManager fm) { + try { + ChoosePlanHillshadeSrtmDialogFragment fragment = new ChoosePlanHillshadeSrtmDialogFragment(); + fragment.show(fm, ChoosePlanHillshadeSrtmDialogFragment.TAG); + } catch (RuntimeException e) { + LOG.error("showHillshadeSrtmPluginInstance", e); + } + } + + public static void showOsmLiveInstance(@NonNull FragmentManager fm) { + try { + ChoosePlanOsmLiveBannerDialogFragment fragment = new ChoosePlanOsmLiveBannerDialogFragment(); + fragment.show(fm, ChoosePlanOsmLiveBannerDialogFragment.TAG); + } catch (RuntimeException e) { + LOG.error("showOsmLiveInstance", e); + } + } } diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanFreeBannerDialogFragment.java b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanFreeBannerDialogFragment.java index b20efb3c8c..88b7a38f2c 100644 --- a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanFreeBannerDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanFreeBannerDialogFragment.java @@ -7,6 +7,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.OsmandInAppPurchaseActivity; import net.osmand.plus.download.DownloadValidationManager; +import net.osmand.plus.inapp.InAppPurchaseHelper; public class ChoosePlanFreeBannerDialogFragment extends ChoosePlanDialogFragment { public static final String TAG = ChoosePlanFreeBannerDialogFragment.class.getSimpleName(); @@ -79,6 +80,21 @@ public class ChoosePlanFreeBannerDialogFragment extends ChoosePlanDialogFragment } } + @Override + public String getPlanTypeButtonTitle() { + InAppPurchaseHelper purchaseHelper = getOsmandApplication().getInAppPurchaseHelper(); + if (purchaseHelper == null || !purchaseHelper.hasPrices()) { + return getString(R.string.purchase_unlim_title, getString(R.string.full_version_price)); + } else { + return getString(R.string.purchase_unlim_title, purchaseHelper.getFullVersionPrice()); + } + } + + @Override + public String getPlanTypeButtonDescription() { + return getString(R.string.in_app_purchase_desc); + } + @Override public void setPlanTypeButtonClickListener(View button) { button.setOnClickListener(new View.OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanHillshadeSrtmDialogFragment.java b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanHillshadeSrtmDialogFragment.java new file mode 100644 index 0000000000..aa459b9d20 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanHillshadeSrtmDialogFragment.java @@ -0,0 +1,100 @@ +package net.osmand.plus.chooseplan; + +import android.app.Activity; +import android.view.View; + +import net.osmand.plus.R; +import net.osmand.plus.activities.OsmandInAppPurchaseActivity; +import net.osmand.plus.inapp.InAppPurchaseHelper; + +public class ChoosePlanHillshadeSrtmDialogFragment extends ChoosePlanDialogFragment { + public static final String TAG = ChoosePlanHillshadeSrtmDialogFragment.class.getSimpleName(); + + private final OsmAndFeature[] osmLiveFeatures = { + OsmAndFeature.CONTOUR_LINES_HILLSHADE_MAPS, + OsmAndFeature.SEA_DEPTH_MAPS, + OsmAndFeature.DAILY_MAP_UPDATES, + OsmAndFeature.UNLIMITED_DOWNLOADS, + OsmAndFeature.WIKIPEDIA_OFFLINE, + OsmAndFeature.WIKIVOYAGE_OFFLINE, + OsmAndFeature.UNLOCK_ALL_FEATURES, + OsmAndFeature.DONATION_TO_OSM, + }; + private final OsmAndFeature[] selectedOsmLiveFeatures = { + OsmAndFeature.CONTOUR_LINES_HILLSHADE_MAPS, + OsmAndFeature.SEA_DEPTH_MAPS, + }; + + private final OsmAndFeature[] planTypeFeatures = { + OsmAndFeature.CONTOUR_LINES_HILLSHADE_MAPS, + }; + private final OsmAndFeature[] selectedPlanTypeFeatures = {}; + + @Override + public OsmAndFeature[] getOsmLiveFeatures() { + return osmLiveFeatures; + } + + @Override + public OsmAndFeature[] getPlanTypeFeatures() { + return planTypeFeatures; + } + + @Override + public OsmAndFeature[] getSelectedOsmLiveFeatures() { + return selectedOsmLiveFeatures; + } + + @Override + public OsmAndFeature[] getSelectedPlanTypeFeatures() { + return selectedPlanTypeFeatures; + } + + @Override + public String getInfoDescription() { + return ""; + } + + @Override + public int getPlanTypeHeaderImageId() { + return R.drawable.img_logo_38dp_contour_lines; + } + + @Override + public String getPlanTypeHeaderTitle() { + return getString(R.string.srtm_plugin_name); + } + + @Override + public String getPlanTypeHeaderDescription() { + return getString(R.string.paid_plugin); + } + + @Override + public String getPlanTypeButtonTitle() { + InAppPurchaseHelper purchaseHelper = getOsmandApplication().getInAppPurchaseHelper(); + if (purchaseHelper == null || !purchaseHelper.hasPrices()) { + return getString(R.string.purchase_unlim_title, getString(R.string.srtm_plugin_price)); + } else { + return getString(R.string.purchase_unlim_title, purchaseHelper.getContourLinesPrice()); + } + } + + @Override + public String getPlanTypeButtonDescription() { + return getString(R.string.in_app_purchase_desc); + } + + @Override + public void setPlanTypeButtonClickListener(View button) { + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Activity activity = getActivity(); + if (activity != null) { + OsmandInAppPurchaseActivity.purchaseSrtmPlugin(activity); + } + } + }); + } +} diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanOsmLiveBannerDialogFragment.java b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanOsmLiveBannerDialogFragment.java new file mode 100644 index 0000000000..3555ad179e --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanOsmLiveBannerDialogFragment.java @@ -0,0 +1,14 @@ +package net.osmand.plus.chooseplan; + +public class ChoosePlanOsmLiveBannerDialogFragment extends ChoosePlanFreeBannerDialogFragment { + public static final String TAG = ChoosePlanOsmLiveBannerDialogFragment.class.getSimpleName(); + + @Override + public OsmAndFeature[] getPlanTypeFeatures() { + return new OsmAndFeature[] {}; + } + @Override + public OsmAndFeature[] getSelectedPlanTypeFeatures() { + return new OsmAndFeature[] {}; + } +} diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanSeaDepthMapsDialogFragment.java b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanSeaDepthMapsDialogFragment.java index 4889d67a53..6f312bbee1 100644 --- a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanSeaDepthMapsDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanSeaDepthMapsDialogFragment.java @@ -5,6 +5,7 @@ import android.view.View; import net.osmand.plus.R; import net.osmand.plus.activities.OsmandInAppPurchaseActivity; +import net.osmand.plus.inapp.InAppPurchaseHelper; public class ChoosePlanSeaDepthMapsDialogFragment extends ChoosePlanDialogFragment { public static final String TAG = ChoosePlanSeaDepthMapsDialogFragment.class.getSimpleName(); @@ -69,6 +70,21 @@ public class ChoosePlanSeaDepthMapsDialogFragment extends ChoosePlanDialogFragme return getString(R.string.in_app_purchase); } + @Override + public String getPlanTypeButtonTitle() { + InAppPurchaseHelper purchaseHelper = getOsmandApplication().getInAppPurchaseHelper(); + if (purchaseHelper == null || !purchaseHelper.hasPrices()) { + return getString(R.string.purchase_unlim_title, getString(R.string.sea_depth_maps_price)); + } else { + return getString(R.string.purchase_unlim_title, purchaseHelper.getDepthContoursPrice()); + } + } + + @Override + public String getPlanTypeButtonDescription() { + return getString(R.string.in_app_purchase_desc); + } + @Override public void setPlanTypeButtonClickListener(View button) { button.setOnClickListener(new View.OnClickListener() { diff --git a/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanWikivoyageDialogFragment.java b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanWikivoyageDialogFragment.java new file mode 100644 index 0000000000..9272e3d067 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/chooseplan/ChoosePlanWikivoyageDialogFragment.java @@ -0,0 +1,6 @@ +package net.osmand.plus.chooseplan; + +public class ChoosePlanWikivoyageDialogFragment extends ChoosePlanWikipediaDialogFragment { + public static final String TAG = ChoosePlanWikivoyageDialogFragment.class.getSimpleName(); + +} diff --git a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java index 1fc3305975..c1ed2b5816 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java @@ -5,7 +5,6 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.res.Resources; import android.graphics.drawable.Drawable; -import android.net.Uri; import android.os.AsyncTask; import android.support.v4.view.ViewCompat; import android.support.v7.app.AlertDialog; @@ -21,7 +20,6 @@ import android.widget.TextView; import android.widget.Toast; import net.osmand.map.WorldRegion; -import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType; import net.osmand.plus.activities.LocalIndexInfo; @@ -34,7 +32,6 @@ 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.srtmplugin.SRTMPlugin; import net.osmand.util.Algorithms; import java.io.File; @@ -346,13 +343,7 @@ public class ItemViewHolder { context.getString(R.string.activate_seamarks_plugin), Toast.LENGTH_SHORT).show(); break; case ASK_FOR_SRTM_PLUGIN_PURCHASE: - OsmandPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class); - if(plugin == null || plugin.getInstallURL() == null) { - Toast.makeText(context.getApplicationContext(), - context.getString(R.string.activate_srtm_plugin), Toast.LENGTH_LONG).show(); - } else { - context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL()))); - } + ChoosePlanDialogFragment.showHillshadeSrtmPluginInstance(context.getSupportFragmentManager()); break; case ASK_FOR_SRTM_PLUGIN_ENABLE: context.startActivity(new Intent(context, context.getMyApplication().getAppCustomization() diff --git a/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java index 46023ee5a1..cc77789481 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/UpdatesIndexFragment.java @@ -2,7 +2,6 @@ package net.osmand.plus.download.ui; import android.app.Activity; import android.content.Context; -import android.content.Intent; import android.os.Bundle; import android.support.v4.view.MenuItemCompat; import android.support.v7.app.ActionBar; @@ -22,11 +21,11 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.base.OsmAndListFragment; +import net.osmand.plus.chooseplan.ChoosePlanDialogFragment; 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.liveupdates.OsmLiveActivity; import net.osmand.util.Algorithms; import java.util.Comparator; @@ -166,10 +165,10 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download @Override public void onListItemClick(ListView l, View v, int position, long id) { if (listAdapter.isShowOsmLiveBanner() && position == 0) { - Intent intent = new Intent(getMyActivity(), OsmLiveActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - intent.putExtra(OsmLiveActivity.OPEN_SUBSCRIPTION_INTENT_PARAM, true); - getMyActivity().startActivity(intent); + DownloadActivity activity = getMyActivity(); + if (activity != null) { + ChoosePlanDialogFragment.showOsmLiveInstance(activity.getSupportFragmentManager()); + } } else { final IndexItem e = (IndexItem) getListAdapter().getItem(position); ItemViewHolder vh = (ItemViewHolder) v.getTag(); diff --git a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java index 65e8cb08be..d30665dfc7 100644 --- a/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java +++ b/OsmAnd/src/net/osmand/plus/inapp/InAppPurchaseHelper.java @@ -42,6 +42,7 @@ public class InAppPurchaseHelper { private String liveUpdatesPrice; private String fullVersionPrice; private String depthContoursPrice; + private String contourLinesPrice; public static final String SKU_FULL_VERSION_PRICE = "osmand_full_version_price"; @@ -49,9 +50,12 @@ public class InAppPurchaseHelper { private static final String SKU_LIVE_UPDATES_FREE = "osm_free_live_subscription_2"; private static final String SKU_DEPTH_CONTOURS_FULL = "net.osmand.seadepth_plus"; private static final String SKU_DEPTH_CONTOURS_FREE = "net.osmand.seadepth"; + private static final String SKU_CONTOUR_LINES_FULL = "net.osmand.contourlines_plus"; + private static final String SKU_CONTOUR_LINES_FREE = "net.osmand.contourlines"; public static String SKU_LIVE_UPDATES; public static String SKU_DEPTH_CONTOURS; + public static String SKU_CONTOUR_LINES; private static final long PURCHASE_VALIDATION_PERIOD_MSEC = 1000 * 60 * 60 * 24; // daily // (arbitrary) request code for the purchase flow @@ -133,6 +137,10 @@ public class InAppPurchaseHelper { return depthContoursPrice; } + public String getContourLinesPrice() { + return contourLinesPrice; + } + public String getSkuLiveUpdates() { return SKU_LIVE_UPDATES; } @@ -157,6 +165,13 @@ public class InAppPurchaseHelper { SKU_DEPTH_CONTOURS = SKU_DEPTH_CONTOURS_FULL; } } + if (SKU_CONTOUR_LINES == null) { + if (Version.isFreeVersion(ctx)) { + SKU_CONTOUR_LINES = SKU_CONTOUR_LINES_FREE; + } else { + SKU_CONTOUR_LINES = SKU_CONTOUR_LINES_FULL; + } + } } public InAppPurchaseHelper(OsmandApplication ctx) { @@ -250,6 +265,7 @@ public class InAppPurchaseHelper { List skus = new ArrayList<>(); skus.add(SKU_LIVE_UPDATES); skus.add(SKU_DEPTH_CONTOURS); + skus.add(SKU_CONTOUR_LINES); skus.add(SKU_FULL_VERSION_PRICE); try { mHelper.queryInventoryAsync(true, skus, mGotInventoryListener); @@ -370,6 +386,10 @@ public class InAppPurchaseHelper { SkuDetails depthContoursDetails = inventory.getSkuDetails(SKU_DEPTH_CONTOURS); depthContoursPrice = depthContoursDetails.getPrice(); } + if (inventory.hasDetails(SKU_CONTOUR_LINES)) { + SkuDetails contourLinesDetails = inventory.getSkuDetails(SKU_CONTOUR_LINES); + contourLinesPrice = contourLinesDetails.getPrice(); + } OsmandSettings settings = ctx.getSettings(); settings.INAPPS_READ.set(true); diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/OpenBetaTravelCard.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/OpenBetaTravelCard.java index 017e5c4b4a..a5836b8baf 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/OpenBetaTravelCard.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/travelcards/OpenBetaTravelCard.java @@ -33,7 +33,7 @@ public class OpenBetaTravelCard extends BaseTravelCard { holder.button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - ChoosePlanDialogFragment.showFreeVersionInstance(fragmentManager); + ChoosePlanDialogFragment.showWikivoyageInstance(fragmentManager); } }); }