Fix srtm/depth features

This commit is contained in:
max-klaus 2021-01-21 13:17:41 +03:00
parent 0ba936962e
commit 1fd47a6f14
17 changed files with 39 additions and 136 deletions

View file

@ -204,7 +204,7 @@ public class OsmandInAppPurchaseActivity extends AppCompatActivity implements In
}
onInAppPurchaseItemPurchased(sku);
fireInAppPurchaseItemPurchasedOnFragments(fragmentManager, sku, active);
if (purchaseHelper != null && purchaseHelper.getContourLines().getSku().equals(sku)) {
if (purchaseHelper != null && purchaseHelper.getFullVersion().getSku().equals(sku)) {
if (!(this instanceof MapActivity)) {
finish();
}

View file

@ -118,7 +118,7 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment
case SEA_DEPTH_MAPS:
return InAppPurchaseHelper.isDepthContoursPurchased(ctx);
case CONTOUR_LINES_HILLSHADE_MAPS:
return OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null;
return OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null || InAppPurchaseHelper.isContourLinesPurchased(ctx);
}
return false;
}

View file

@ -30,7 +30,8 @@ public class ChoosePlanFreeBannerDialogFragment extends ChoosePlanDialogFragment
private final OsmAndFeature[] planTypeFeatures = {
OsmAndFeature.WIKIPEDIA_OFFLINE,
OsmAndFeature.WIKIVOYAGE_OFFLINE,
OsmAndFeature.CONTOUR_LINES_HILLSHADE_MAPS,
OsmAndFeature.SEA_DEPTH_MAPS,
OsmAndFeature.UNLIMITED_DOWNLOADS,
OsmAndFeature.MONTHLY_MAP_UPDATES,
};

View file

@ -1,16 +1,6 @@
package net.osmand.plus.chooseplan;
import android.app.Activity;
import android.view.View;
import androidx.annotation.Nullable;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandInAppPurchaseActivity;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.inapp.InAppPurchases.InAppPurchase;
public class ChoosePlanHillshadeSrtmDialogFragment extends ChoosePlanDialogFragment {
public class ChoosePlanHillshadeSrtmDialogFragment extends ChoosePlanFreeBannerDialogFragment {
public static final String TAG = ChoosePlanHillshadeSrtmDialogFragment.class.getSimpleName();
private final OsmAndFeature[] osmLiveFeatures = {
@ -29,6 +19,10 @@ public class ChoosePlanHillshadeSrtmDialogFragment extends ChoosePlanDialogFragm
private final OsmAndFeature[] planTypeFeatures = {
OsmAndFeature.CONTOUR_LINES_HILLSHADE_MAPS,
OsmAndFeature.SEA_DEPTH_MAPS,
OsmAndFeature.WIKIPEDIA_OFFLINE,
OsmAndFeature.UNLIMITED_DOWNLOADS,
OsmAndFeature.MONTHLY_MAP_UPDATES,
};
private final OsmAndFeature[] selectedPlanTypeFeatures = {};
@ -51,48 +45,4 @@ public class ChoosePlanHillshadeSrtmDialogFragment extends ChoosePlanDialogFragm
public OsmAndFeature[] getSelectedPlanTypeFeatures() {
return selectedPlanTypeFeatures;
}
@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 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.purchaseContourLines(activity);
dismiss();
}
}
});
}
@Nullable
@Override
public InAppPurchase getPlanTypePurchase() {
InAppPurchaseHelper purchaseHelper = getOsmandApplication().getInAppPurchaseHelper();
if (purchaseHelper != null) {
return purchaseHelper.getContourLines();
}
return null;
}
}

View file

@ -1,21 +1,11 @@
package net.osmand.plus.chooseplan;
import android.app.Activity;
import android.view.View;
import androidx.annotation.Nullable;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmandInAppPurchaseActivity;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.inapp.InAppPurchases.InAppPurchase;
public class ChoosePlanSeaDepthMapsDialogFragment extends ChoosePlanDialogFragment {
public class ChoosePlanSeaDepthMapsDialogFragment extends ChoosePlanFreeBannerDialogFragment {
public static final String TAG = ChoosePlanSeaDepthMapsDialogFragment.class.getSimpleName();
private final OsmAndFeature[] osmLiveFeatures = {
OsmAndFeature.CONTOUR_LINES_HILLSHADE_MAPS,
OsmAndFeature.SEA_DEPTH_MAPS,
OsmAndFeature.CONTOUR_LINES_HILLSHADE_MAPS,
OsmAndFeature.WIKIPEDIA_OFFLINE,
OsmAndFeature.WIKIVOYAGE_OFFLINE,
OsmAndFeature.DAILY_MAP_UPDATES,
@ -23,12 +13,16 @@ public class ChoosePlanSeaDepthMapsDialogFragment extends ChoosePlanDialogFragme
OsmAndFeature.UNLOCK_ALL_FEATURES,
};
private final OsmAndFeature[] selectedOsmLiveFeatures = {
OsmAndFeature.CONTOUR_LINES_HILLSHADE_MAPS,
OsmAndFeature.SEA_DEPTH_MAPS,
OsmAndFeature.CONTOUR_LINES_HILLSHADE_MAPS,
};
private final OsmAndFeature[] planTypeFeatures = {
OsmAndFeature.SEA_DEPTH_MAPS,
OsmAndFeature.CONTOUR_LINES_HILLSHADE_MAPS,
OsmAndFeature.WIKIPEDIA_OFFLINE,
OsmAndFeature.UNLIMITED_DOWNLOADS,
OsmAndFeature.MONTHLY_MAP_UPDATES,
};
private final OsmAndFeature[] selectedPlanTypeFeatures = {};
@ -51,47 +45,4 @@ public class ChoosePlanSeaDepthMapsDialogFragment extends ChoosePlanDialogFragme
public OsmAndFeature[] getSelectedPlanTypeFeatures() {
return selectedPlanTypeFeatures;
}
@Override
public int getPlanTypeHeaderImageId() {
return R.drawable.img_logo_38dp_sea_depth;
}
@Override
public String getPlanTypeHeaderTitle() {
return getString(R.string.index_item_depth_contours_osmand_ext);
}
@Override
public String getPlanTypeHeaderDescription() {
return getString(R.string.in_app_purchase);
}
@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.purchaseDepthContours(activity);
}
}
});
}
@Nullable
@Override
public InAppPurchase getPlanTypePurchase() {
InAppPurchaseHelper purchaseHelper = getOsmandApplication().getInAppPurchaseHelper();
if (purchaseHelper != null) {
return purchaseHelper.getDepthContours();
}
return null;
}
}

View file

@ -19,7 +19,6 @@ public class ChoosePlanWikipediaDialogFragment extends ChoosePlanFreeBannerDialo
private final OsmAndFeature[] planTypeFeatures = {
OsmAndFeature.WIKIPEDIA_OFFLINE,
OsmAndFeature.WIKIVOYAGE_OFFLINE,
OsmAndFeature.UNLIMITED_DOWNLOADS,
OsmAndFeature.MONTHLY_MAP_UPDATES,
};

View file

@ -251,7 +251,7 @@ public class ConfigureMapMenu {
OsmandPlugin.registerLayerContextMenu(activity.getMapView(), adapter, activity);
boolean srtmDisabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) == null
&& !InAppPurchaseHelper.isSubscribedToLiveUpdates(app);
&& !InAppPurchaseHelper.isContourLinesPurchased(app);
if (srtmDisabled) {
SRTMPlugin srtmPlugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
if (srtmPlugin != null) {

View file

@ -684,11 +684,12 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
}
public void initAppStatusVariables() {
OsmandApplication app = getMyApplication();
srtmDisabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) == null
&& !InAppPurchaseHelper.isSubscribedToLiveUpdates(getMyApplication());
&& !InAppPurchaseHelper.isContourLinesPurchased(app);
nauticalPluginDisabled = OsmandPlugin.getEnabledPlugin(NauticalMapsPlugin.class) == null;
freeVersion = Version.isFreeVersion(getMyApplication());
OsmandPlugin srtmPlugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
freeVersion = Version.isFreeVersion(app);
SRTMPlugin srtmPlugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
srtmNeedsInstallation = srtmPlugin == null || srtmPlugin.needsInstallation();
}

View file

@ -352,9 +352,7 @@ public class DownloadResources extends DownloadResourceGroup {
continue;
}
if (ii.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE) {
if (InAppPurchaseHelper.isDepthContoursPurchased(app)
|| InAppPurchaseHelper.isSubscribedToLiveUpdates(app)
|| nauticalMaps.size() == 0) {
if (InAppPurchaseHelper.isDepthContoursPurchased(app) || nauticalMaps.size() == 0) {
nauticalMaps.addItem(ii);
}
continue;

View file

@ -134,8 +134,7 @@ public class ItemViewHolder {
srtmDisabled = context.isSrtmDisabled();
nauticalPluginDisabled = context.isNauticalPluginDisabled();
srtmNeedsInstallation = context.isSrtmNeedsInstallation();
depthContoursPurchased = InAppPurchaseHelper.isDepthContoursPurchased(context.getMyApplication())
|| InAppPurchaseHelper.isSubscribedToLiveUpdates(context.getMyApplication());
depthContoursPurchased = InAppPurchaseHelper.isDepthContoursPurchased(context.getMyApplication());
}
public void bindIndexItem(final IndexItem indexItem) {

View file

@ -153,11 +153,15 @@ public abstract class InAppPurchaseHelper {
}
public static boolean isDepthContoursPurchased(@NonNull OsmandApplication ctx) {
return Version.isDeveloperBuild(ctx) || ctx.getSettings().DEPTH_CONTOURS_PURCHASED.get();
return Version.isDeveloperBuild(ctx)
|| Version.isPaidVersion(ctx)
|| ctx.getSettings().DEPTH_CONTOURS_PURCHASED.get();
}
public static boolean isContourLinesPurchased(@NonNull OsmandApplication ctx) {
return Version.isDeveloperBuild(ctx) || ctx.getSettings().CONTOUR_LINES_PURCHASED.get();
return Version.isDeveloperBuild(ctx)
|| Version.isPaidVersion(ctx)
|| ctx.getSettings().CONTOUR_LINES_PURCHASED.get();
}
public InAppPurchases getInAppPurchases() {

View file

@ -85,7 +85,7 @@ public class MapDataMenuController extends MenuController {
}
srtmDisabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) == null
&& !InAppPurchaseHelper.isSubscribedToLiveUpdates(app);
&& !InAppPurchaseHelper.isContourLinesPurchased(app);
OsmandPlugin srtmPlugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
srtmNeedsInstallation = srtmPlugin == null || srtmPlugin.needsInstallation();

View file

@ -639,7 +639,7 @@ public class ResourceManager {
collectFiles(context.getAppPath(IndexConstants.WIKI_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
collectFiles(context.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR), IndexConstants.BINARY_TRAVEL_GUIDE_MAP_INDEX_EXT, files);
}
if (OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null || InAppPurchaseHelper.isSubscribedToLiveUpdates(context)) {
if (OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null || InAppPurchaseHelper.isContourLinesPurchased(context)) {
collectFiles(context.getAppPath(IndexConstants.SRTM_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
}

View file

@ -52,7 +52,7 @@ public class ContourLinesMenu {
final OsmandApplication app = mapActivity.getMyApplication();
final OsmandSettings settings = app.getSettings();
final SRTMPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
final boolean srtmEnabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null || InAppPurchaseHelper.isSubscribedToLiveUpdates(app);
final boolean srtmEnabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null || InAppPurchaseHelper.isContourLinesPurchased(app);
final RenderingRuleProperty contourLinesProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_LINES_ATTR);
final RenderingRuleProperty colorSchemeProp = app.getRendererRegistry().getCustomRenderingRuleProperty(CONTOUR_LINES_SCHEME_ATTR);

View file

@ -14,14 +14,11 @@ import androidx.core.content.ContextCompat;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.DialogListItemAdapter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.DashboardOnMap;
@ -31,6 +28,9 @@ import net.osmand.plus.download.DownloadResources;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.quickaction.QuickActionType;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.render.RenderingRuleProperty;
import net.osmand.util.Algorithms;
@ -88,13 +88,13 @@ public class SRTMPlugin extends OsmandPlugin {
@Override
public boolean needsInstallation() {
return super.needsInstallation() && !InAppPurchaseHelper.isSubscribedToLiveUpdates(app);
return super.needsInstallation()
&& !InAppPurchaseHelper.isContourLinesPurchased(app);
}
@Override
protected boolean pluginAvailable(OsmandApplication app) {
return super.pluginAvailable(app)
|| InAppPurchaseHelper.isSubscribedToLiveUpdates(app)
|| InAppPurchaseHelper.isContourLinesPurchased(app);
}

View file

@ -61,7 +61,7 @@ public class NativeCoreContext {
ObfsCollection obfsCollection = new ObfsCollection();
obfsCollection.addDirectory(directory.getAbsolutePath(), false);
if(OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null || InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
if (OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null || InAppPurchaseHelper.isContourLinesPurchased(app)) {
obfsCollection.addDirectory(app.getAppPath(IndexConstants.SRTM_INDEX_DIR).getAbsolutePath(), false);
}

View file

@ -10,7 +10,7 @@ buildscript {
}
dependencies {
//classpath 'com.android.tools.build:gradle:2.+'
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.google.gms:google-services:3.0.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"