Added depth contours
This commit is contained in:
parent
2afd647daf
commit
35b1b4d1a3
12 changed files with 196 additions and 80 deletions
|
@ -85,6 +85,7 @@
|
||||||
android:paddingRight="18dp"
|
android:paddingRight="18dp"
|
||||||
android:background="@drawable/buy_btn_background_light"
|
android:background="@drawable/buy_btn_background_light"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginLeft="@dimen/dashFavIconMargin"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_marginRight="8dp"
|
||||||
android:textColor="@color/buy_button_color"
|
android:textColor="@color/buy_button_color"
|
||||||
android:text="@string/buy"
|
android:text="@string/buy"
|
||||||
|
|
|
@ -9,6 +9,12 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||||
-->
|
-->
|
||||||
|
<string name="sea_depth_thanks">Thank you for purchasing sea depth contours!</string>
|
||||||
|
<string name="index_item_depth_contours_osmand_ext">Depth contours</string>
|
||||||
|
<string name="index_item_depth_points_southern_hemisphere">Depth points southern hemisphere</string>
|
||||||
|
<string name="index_item_depth_points_northern_hemisphere">Depth points northern hemisphere</string>
|
||||||
|
<string name="download_depth_countours">Depth contours</string>
|
||||||
|
<string name="nautical_maps">Nautical maps</string>
|
||||||
<string name="analyze_on_map">Analyze on map</string>
|
<string name="analyze_on_map">Analyze on map</string>
|
||||||
<string name="shared_string_visible">Visible</string>
|
<string name="shared_string_visible">Visible</string>
|
||||||
<string name="restore_purchases">Restore purchases</string>
|
<string name="restore_purchases">Restore purchases</string>
|
||||||
|
|
|
@ -919,6 +919,7 @@ public class OsmandSettings {
|
||||||
public final OsmandPreference<Boolean> BILLING_PURCHASE_TOKEN_SENT = new BooleanPreference("billing_purchase_token_sent", 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<Boolean> LIVE_UPDATES_PURCHASED = new BooleanPreference("billing_live_updates_purchased", false).makeGlobal();
|
||||||
public final OsmandPreference<Boolean> FULL_VERSION_PURCHASED = new BooleanPreference("billing_full_version_purchased", 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<Integer> DISCOUNT_ID = new IntPreference("discount_id", 0).makeGlobal();
|
public final OsmandPreference<Integer> DISCOUNT_ID = new IntPreference("discount_id", 0).makeGlobal();
|
||||||
public final OsmandPreference<Integer> DISCOUNT_SHOW_NUMBER_OF_STARTS = new IntPreference("number_of_starts_on_discount_show", 0).makeGlobal();
|
public final OsmandPreference<Integer> DISCOUNT_SHOW_NUMBER_OF_STARTS = new IntPreference("number_of_starts_on_discount_show", 0).makeGlobal();
|
||||||
|
|
|
@ -229,6 +229,18 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void purchaseFullVersion() {
|
||||||
|
if (inAppHelper != null) {
|
||||||
|
inAppHelper.purchaseFullVersion(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void purchaseDepthContours() {
|
||||||
|
if (inAppHelper != null) {
|
||||||
|
inAppHelper.purchaseDepthContours(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public DownloadIndexesThread getDownloadThread() {
|
public DownloadIndexesThread getDownloadThread() {
|
||||||
return downloadThread;
|
return downloadThread;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ public class DownloadActivityType {
|
||||||
new DownloadActivityType(R.string.download_roads_only_maps, "road_map", 30);
|
new DownloadActivityType(R.string.download_roads_only_maps, "road_map", 30);
|
||||||
public static final DownloadActivityType SRTM_COUNTRY_FILE =
|
public static final DownloadActivityType SRTM_COUNTRY_FILE =
|
||||||
new DownloadActivityType(R.string.download_srtm_maps, R.drawable.ic_plugin_srtm, "srtm_map", 40);
|
new DownloadActivityType(R.string.download_srtm_maps, R.drawable.ic_plugin_srtm, "srtm_map", 40);
|
||||||
|
public static final DownloadActivityType DEPTH_CONTOUR_FILE =
|
||||||
|
new DownloadActivityType(R.string.download_regular_maps, "depth", 45);
|
||||||
public static final DownloadActivityType HILLSHADE_FILE =
|
public static final DownloadActivityType HILLSHADE_FILE =
|
||||||
new DownloadActivityType(R.string.download_hillshade_maps, R.drawable.ic_action_hillshade_dark, "hillshade", 50);
|
new DownloadActivityType(R.string.download_hillshade_maps, R.drawable.ic_action_hillshade_dark, "hillshade", 50);
|
||||||
public static final DownloadActivityType WIKIPEDIA_FILE =
|
public static final DownloadActivityType WIKIPEDIA_FILE =
|
||||||
|
@ -124,13 +126,15 @@ public class DownloadActivityType {
|
||||||
IndexConstants.BINARY_MAP_VERSION));
|
IndexConstants.BINARY_MAP_VERSION));
|
||||||
} else if (HILLSHADE_FILE == this) {
|
} else if (HILLSHADE_FILE == this) {
|
||||||
return fileName.endsWith(IndexConstants.SQLITE_EXT);
|
return fileName.endsWith(IndexConstants.SQLITE_EXT);
|
||||||
|
} else if (DEPTH_CONTOUR_FILE == this) {
|
||||||
|
return fileName.endsWith(addVersionToExt(IndexConstants.BINARY_MAP_INDEX_EXT_ZIP, IndexConstants.BINARY_MAP_VERSION));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getDownloadFolder(OsmandApplication ctx, IndexItem indexItem) {
|
public File getDownloadFolder(OsmandApplication ctx, IndexItem indexItem) {
|
||||||
if (NORMAL_FILE == this) {
|
if (NORMAL_FILE == this) {
|
||||||
if(indexItem.fileName.endsWith(IndexConstants.SQLITE_EXT)) {
|
if (indexItem.fileName.endsWith(IndexConstants.SQLITE_EXT)) {
|
||||||
return ctx.getAppPath(IndexConstants.TILES_INDEX_DIR);
|
return ctx.getAppPath(IndexConstants.TILES_INDEX_DIR);
|
||||||
}
|
}
|
||||||
return ctx.getAppPath(IndexConstants.MAPS_PATH);
|
return ctx.getAppPath(IndexConstants.MAPS_PATH);
|
||||||
|
@ -148,6 +152,8 @@ public class DownloadActivityType {
|
||||||
return ctx.getAppPath(IndexConstants.LIVE_INDEX_DIR);
|
return ctx.getAppPath(IndexConstants.LIVE_INDEX_DIR);
|
||||||
} else if (HILLSHADE_FILE == this) {
|
} else if (HILLSHADE_FILE == this) {
|
||||||
return ctx.getAppPath(IndexConstants.TILES_INDEX_DIR);
|
return ctx.getAppPath(IndexConstants.TILES_INDEX_DIR);
|
||||||
|
} else if (DEPTH_CONTOUR_FILE == this) {
|
||||||
|
return ctx.getAppPath(IndexConstants.MAPS_PATH);
|
||||||
}
|
}
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
@ -191,33 +197,34 @@ public class DownloadActivityType {
|
||||||
return BINARY_MAP_INDEX_EXT;
|
return BINARY_MAP_INDEX_EXT;
|
||||||
} else if (HILLSHADE_FILE == this) {
|
} else if (HILLSHADE_FILE == this) {
|
||||||
return IndexConstants.SQLITE_EXT;
|
return IndexConstants.SQLITE_EXT;
|
||||||
|
} else if (DEPTH_CONTOUR_FILE == this) {
|
||||||
|
return BINARY_MAP_INDEX_EXT;
|
||||||
}
|
}
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUrlSuffix(OsmandApplication ctx) {
|
public String getUrlSuffix(OsmandApplication ctx) {
|
||||||
if (this== DownloadActivityType.ROADS_FILE) {
|
if (this== ROADS_FILE) {
|
||||||
return "&road=yes";
|
return "&road=yes";
|
||||||
} else if (this == DownloadActivityType.LIVE_UPDATES_FILE) {
|
} else if (this == LIVE_UPDATES_FILE) {
|
||||||
return "&aosmc=yes";
|
return "&aosmc=yes";
|
||||||
} else if (this == DownloadActivityType.SRTM_COUNTRY_FILE) {
|
} else if (this == SRTM_COUNTRY_FILE) {
|
||||||
return "&srtmcountry=yes";
|
return "&srtmcountry=yes";
|
||||||
} else if (this == DownloadActivityType.WIKIPEDIA_FILE) {
|
} else if (this == WIKIPEDIA_FILE) {
|
||||||
return "&wiki=yes";
|
return "&wiki=yes";
|
||||||
}else if (this == DownloadActivityType.HILLSHADE_FILE) {
|
} else if (this == HILLSHADE_FILE) {
|
||||||
return "&hillshade=yes";
|
return "&hillshade=yes";
|
||||||
|
} else if (this == FONT_FILE) {
|
||||||
|
return "&fonts=yes";
|
||||||
|
} else if (this == DEPTH_CONTOUR_FILE) {
|
||||||
|
return "&inapp=depth";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBaseUrl(OsmandApplication ctx, String fileName) {
|
public String getBaseUrl(OsmandApplication ctx, String fileName) {
|
||||||
if (this == FONT_FILE) {
|
return "http://" + IndexConstants.INDEX_DOWNLOAD_DOMAIN + "/download?event=2&"
|
||||||
return "http://" + IndexConstants.INDEX_DOWNLOAD_DOMAIN + "/download?event=2&fonts=yes&"
|
+ Version.getVersionAsURLParam(ctx) + "&file=" + encode(fileName);
|
||||||
+ Version.getVersionAsURLParam(ctx) + "&file=" + encode(fileName);
|
|
||||||
} else {
|
|
||||||
return "http://" + IndexConstants.INDEX_DOWNLOAD_DOMAIN + "/download?event=2&"
|
|
||||||
+ Version.getVersionAsURLParam(ctx) + "&file=" + encode(fileName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -258,12 +265,16 @@ public class DownloadActivityType {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVisibleDescription(IndexItem indexItem, Context ctx) {
|
public String getVisibleDescription(IndexItem indexItem, Context ctx) {
|
||||||
if (this == DownloadActivityType.SRTM_COUNTRY_FILE) {
|
if (this == SRTM_COUNTRY_FILE) {
|
||||||
return ctx.getString(R.string.download_srtm_maps);
|
return ctx.getString(R.string.download_srtm_maps);
|
||||||
} else if (this == DownloadActivityType.WIKIPEDIA_FILE) {
|
} else if (this == WIKIPEDIA_FILE) {
|
||||||
return ctx.getString(R.string.shared_string_wikipedia);
|
return ctx.getString(R.string.shared_string_wikipedia);
|
||||||
} else if (this == DownloadActivityType.ROADS_FILE) {
|
} else if (this == ROADS_FILE) {
|
||||||
return ctx.getString(R.string.download_roads_only_item);
|
return ctx.getString(R.string.download_roads_only_item);
|
||||||
|
} else if (this == DEPTH_CONTOUR_FILE) {
|
||||||
|
return ctx.getString(R.string.download_depth_countours);
|
||||||
|
} else if (this == FONT_FILE) {
|
||||||
|
return ctx.getString(R.string.fonts_header);
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -334,13 +345,13 @@ public class DownloadActivityType {
|
||||||
l = fileName.length();
|
l = fileName.length();
|
||||||
}
|
}
|
||||||
String baseNameWithoutVersion = fileName.substring(0, l);
|
String baseNameWithoutVersion = fileName.substring(0, l);
|
||||||
if (this == DownloadActivityType.SRTM_COUNTRY_FILE) {
|
if (this == SRTM_COUNTRY_FILE) {
|
||||||
return baseNameWithoutVersion + IndexConstants.BINARY_SRTM_MAP_INDEX_EXT;
|
return baseNameWithoutVersion + IndexConstants.BINARY_SRTM_MAP_INDEX_EXT;
|
||||||
}
|
}
|
||||||
if (this == DownloadActivityType.WIKIPEDIA_FILE) {
|
if (this == WIKIPEDIA_FILE) {
|
||||||
return baseNameWithoutVersion + IndexConstants.BINARY_WIKI_MAP_INDEX_EXT;
|
return baseNameWithoutVersion + IndexConstants.BINARY_WIKI_MAP_INDEX_EXT;
|
||||||
}
|
}
|
||||||
if (this == DownloadActivityType.ROADS_FILE) {
|
if (this == ROADS_FILE) {
|
||||||
return baseNameWithoutVersion + IndexConstants.BINARY_ROAD_MAP_INDEX_EXT;
|
return baseNameWithoutVersion + IndexConstants.BINARY_ROAD_MAP_INDEX_EXT;
|
||||||
}
|
}
|
||||||
baseNameWithoutVersion += IndexConstants.BINARY_MAP_INDEX_EXT;
|
baseNameWithoutVersion += IndexConstants.BINARY_MAP_INDEX_EXT;
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class DownloadResourceGroup {
|
||||||
SRTM_HEADER(R.string.download_srtm_maps),
|
SRTM_HEADER(R.string.download_srtm_maps),
|
||||||
HILLSHADE_HEADER(R.string.download_hillshade_maps),
|
HILLSHADE_HEADER(R.string.download_hillshade_maps),
|
||||||
OTHER_MAPS_HEADER(R.string.download_select_map_types),
|
OTHER_MAPS_HEADER(R.string.download_select_map_types),
|
||||||
|
NAUTICAL_MAPS_HEADER(R.string.nautical_maps),
|
||||||
// headers with voice items
|
// headers with voice items
|
||||||
VOICE_HEADER_TTS(R.string.index_name_tts_voice),
|
VOICE_HEADER_TTS(R.string.index_name_tts_voice),
|
||||||
VOICE_HEADER_REC(R.string.index_name_voice),
|
VOICE_HEADER_REC(R.string.index_name_voice),
|
||||||
|
@ -79,7 +80,7 @@ public class DownloadResourceGroup {
|
||||||
|| this == WORLD_MAPS || this == REGION_MAPS || this == OTHER_GROUP
|
|| this == WORLD_MAPS || this == REGION_MAPS || this == OTHER_GROUP
|
||||||
|| this == HILLSHADE_HEADER || this == SRTM_HEADER
|
|| this == HILLSHADE_HEADER || this == SRTM_HEADER
|
||||||
|| this == OTHER_MAPS_HEADER || this == OTHER_MAPS_GROUP
|
|| this == OTHER_MAPS_HEADER || this == OTHER_MAPS_GROUP
|
||||||
|| this == FONTS_HEADER;
|
|| this == FONTS_HEADER || this == NAUTICAL_MAPS_HEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getVoiceTTSId() {
|
public static String getVoiceTTSId() {
|
||||||
|
|
|
@ -255,6 +255,8 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
DownloadResourceGroup fonts = new DownloadResourceGroup(otherGroup, DownloadResourceGroupType.FONTS_HEADER);
|
DownloadResourceGroup fonts = new DownloadResourceGroup(otherGroup, DownloadResourceGroupType.FONTS_HEADER);
|
||||||
|
|
||||||
DownloadResourceGroup worldMaps = new DownloadResourceGroup(this, DownloadResourceGroupType.WORLD_MAPS);
|
DownloadResourceGroup worldMaps = new DownloadResourceGroup(this, DownloadResourceGroupType.WORLD_MAPS);
|
||||||
|
DownloadResourceGroup nauticalMaps = new DownloadResourceGroup(this, DownloadResourceGroupType.NAUTICAL_MAPS_HEADER);
|
||||||
|
|
||||||
Map<WorldRegion, List<IndexItem> > groupByRegion = new LinkedHashMap<WorldRegion, List<IndexItem>>();
|
Map<WorldRegion, List<IndexItem> > groupByRegion = new LinkedHashMap<WorldRegion, List<IndexItem>>();
|
||||||
OsmandRegions regs = app.getRegions();
|
OsmandRegions regs = app.getRegions();
|
||||||
for (IndexItem ii : resources) {
|
for (IndexItem ii : resources) {
|
||||||
|
@ -270,6 +272,12 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
fonts.addItem(ii);
|
fonts.addItem(ii);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (ii.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE) {
|
||||||
|
if (app.getSettings().DEPTH_CONTOURS_PURCHASED.get() || nauticalMaps.size() == 0) {
|
||||||
|
nauticalMaps.addItem(ii);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
String basename = ii.getBasename().toLowerCase();
|
String basename = ii.getBasename().toLowerCase();
|
||||||
WorldRegion wg = regs.getRegionDataByDownloadName(basename);
|
WorldRegion wg = regs.getRegionDataByDownloadName(basename);
|
||||||
if (wg != null) {
|
if (wg != null) {
|
||||||
|
@ -279,7 +287,11 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
groupByRegion.get(wg).add(ii);
|
groupByRegion.get(wg).add(ii);
|
||||||
} else {
|
} else {
|
||||||
if (ii.getFileName().startsWith("World_")) {
|
if (ii.getFileName().startsWith("World_")) {
|
||||||
worldMaps.addItem(ii);
|
if (ii.getFileName().toLowerCase().startsWith(WORLD_SEAMARKS_KEY)) {
|
||||||
|
nauticalMaps.addItem(ii);
|
||||||
|
} else {
|
||||||
|
worldMaps.addItem(ii);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
otherMaps.addItem(ii);
|
otherMaps.addItem(ii);
|
||||||
}
|
}
|
||||||
|
@ -324,6 +336,7 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
// 2. if there is no subregions and there only 1 index item it could be merged to the level up - objection there is no such maps
|
// 2. if there is no subregions and there only 1 index item it could be merged to the level up - objection there is no such maps
|
||||||
// 3. if hillshade/srtm is disabled, all maps from inner level could be combined into 1
|
// 3. if hillshade/srtm is disabled, all maps from inner level could be combined into 1
|
||||||
addGroup(worldMaps);
|
addGroup(worldMaps);
|
||||||
|
addGroup(nauticalMaps);
|
||||||
if (otherMaps.size() > 0) {
|
if (otherMaps.size() > 0) {
|
||||||
addGroup(otherMapsGroup);
|
addGroup(otherMapsGroup);
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,6 +190,8 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemPurchased(String sku) {
|
public void onItemPurchased(String sku) {
|
||||||
|
getMyApplication().getDownloadThread().runReloadIndexFilesSilent();
|
||||||
|
//reloadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package net.osmand.plus.download.ui;
|
package net.osmand.plus.download.ui;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ActivityNotFoundException;
|
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
@ -23,7 +22,6 @@ import android.widget.Toast;
|
||||||
import net.osmand.map.WorldRegion;
|
import net.osmand.map.WorldRegion;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
|
||||||
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
|
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
|
||||||
import net.osmand.plus.activities.LocalIndexInfo;
|
import net.osmand.plus.activities.LocalIndexInfo;
|
||||||
import net.osmand.plus.download.CityItem;
|
import net.osmand.plus.download.CityItem;
|
||||||
|
@ -53,6 +51,7 @@ public class ItemViewHolder {
|
||||||
private boolean srtmNeedsInstallation;
|
private boolean srtmNeedsInstallation;
|
||||||
private boolean nauticalPluginDisabled;
|
private boolean nauticalPluginDisabled;
|
||||||
private boolean freeVersion;
|
private boolean freeVersion;
|
||||||
|
private boolean depthContoursPurchased;
|
||||||
|
|
||||||
protected final DownloadActivity context;
|
protected final DownloadActivity context;
|
||||||
|
|
||||||
|
@ -74,7 +73,8 @@ public class ItemViewHolder {
|
||||||
ASK_FOR_SEAMARKS_PLUGIN,
|
ASK_FOR_SEAMARKS_PLUGIN,
|
||||||
ASK_FOR_SRTM_PLUGIN_PURCHASE,
|
ASK_FOR_SRTM_PLUGIN_PURCHASE,
|
||||||
ASK_FOR_SRTM_PLUGIN_ENABLE,
|
ASK_FOR_SRTM_PLUGIN_ENABLE,
|
||||||
ASK_FOR_FULL_VERSION_PURCHASE
|
ASK_FOR_FULL_VERSION_PURCHASE,
|
||||||
|
ASK_FOR_DEPTH_CONTOURS_PURCHASE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,6 +130,7 @@ public class ItemViewHolder {
|
||||||
nauticalPluginDisabled = context.isNauticalPluginDisabled();
|
nauticalPluginDisabled = context.isNauticalPluginDisabled();
|
||||||
freeVersion = context.isFreeVersion();
|
freeVersion = context.isFreeVersion();
|
||||||
srtmNeedsInstallation = context.isSrtmNeedsInstallation();
|
srtmNeedsInstallation = context.isSrtmNeedsInstallation();
|
||||||
|
depthContoursPurchased = context.getMyApplication().getSettings().DEPTH_CONTOURS_PURCHASED.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindIndexItem(final IndexItem indexItem) {
|
public void bindIndexItem(final IndexItem indexItem) {
|
||||||
|
@ -177,7 +178,9 @@ public class ItemViewHolder {
|
||||||
if (!isDownloading) {
|
if (!isDownloading) {
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
descrTextView.setVisibility(View.VISIBLE);
|
descrTextView.setVisibility(View.VISIBLE);
|
||||||
if ((indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE ||
|
if (indexItem.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE && !depthContoursPurchased) {
|
||||||
|
descrTextView.setVisibility(View.GONE);
|
||||||
|
} else if ((indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE ||
|
||||||
indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) && srtmDisabled) {
|
indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) && srtmDisabled) {
|
||||||
if(showTypeInName) {
|
if(showTypeInName) {
|
||||||
descrTextView.setText("");
|
descrTextView.setText("");
|
||||||
|
@ -311,8 +314,12 @@ public class ItemViewHolder {
|
||||||
clickAction = RightButtonAction.ASK_FOR_SRTM_PLUGIN_ENABLE;
|
clickAction = RightButtonAction.ASK_FOR_SRTM_PLUGIN_ENABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (indexItem.getType() == DownloadActivityType.WIKIPEDIA_FILE && freeVersion) {
|
} else if (indexItem.getType() == DownloadActivityType.WIKIPEDIA_FILE && freeVersion
|
||||||
|
&& !context.getMyApplication().getSettings().FULL_VERSION_PURCHASED.get()) {
|
||||||
clickAction = RightButtonAction.ASK_FOR_FULL_VERSION_PURCHASE;
|
clickAction = RightButtonAction.ASK_FOR_FULL_VERSION_PURCHASE;
|
||||||
|
} else if (indexItem.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE
|
||||||
|
&& !context.getMyApplication().getSettings().DEPTH_CONTOURS_PURCHASED.get()) {
|
||||||
|
clickAction = RightButtonAction.ASK_FOR_DEPTH_CONTOURS_PURCHASE;
|
||||||
}
|
}
|
||||||
return clickAction;
|
return clickAction;
|
||||||
}
|
}
|
||||||
|
@ -323,39 +330,37 @@ public class ItemViewHolder {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
switch (clickAction) {
|
switch (clickAction) {
|
||||||
case ASK_FOR_FULL_VERSION_PURCHASE:
|
case ASK_FOR_FULL_VERSION_PURCHASE:
|
||||||
context.getMyApplication().logEvent(context, "click_buy_plus");
|
context.getMyApplication().logEvent(context, "click_buy_plus_inapp");
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.marketPrefix(context
|
context.purchaseFullVersion();
|
||||||
.getMyApplication()) + "net.osmand.plus"));
|
break;
|
||||||
try {
|
case ASK_FOR_DEPTH_CONTOURS_PURCHASE:
|
||||||
context.startActivity(intent);
|
context.getMyApplication().logEvent(context, "click_buy_depth_contours_inapp");
|
||||||
} catch (ActivityNotFoundException e) {
|
context.purchaseDepthContours();
|
||||||
//ignore
|
break;
|
||||||
}
|
case ASK_FOR_SEAMARKS_PLUGIN:
|
||||||
break;
|
context.startActivity(new Intent(context, context.getMyApplication().getAppCustomization()
|
||||||
case ASK_FOR_SEAMARKS_PLUGIN:
|
.getPluginsActivity()));
|
||||||
context.startActivity(new Intent(context, context.getMyApplication().getAppCustomization()
|
|
||||||
.getPluginsActivity()));
|
|
||||||
Toast.makeText(context.getApplicationContext(),
|
|
||||||
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(),
|
Toast.makeText(context.getApplicationContext(),
|
||||||
context.getString(R.string.activate_srtm_plugin), Toast.LENGTH_LONG).show();
|
context.getString(R.string.activate_seamarks_plugin), Toast.LENGTH_SHORT).show();
|
||||||
} else {
|
break;
|
||||||
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL())));
|
case ASK_FOR_SRTM_PLUGIN_PURCHASE:
|
||||||
}
|
OsmandPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
|
||||||
break;
|
if(plugin == null || plugin.getInstallURL() == null) {
|
||||||
case ASK_FOR_SRTM_PLUGIN_ENABLE:
|
Toast.makeText(context.getApplicationContext(),
|
||||||
context.startActivity(new Intent(context, context.getMyApplication().getAppCustomization()
|
context.getString(R.string.activate_srtm_plugin), Toast.LENGTH_LONG).show();
|
||||||
.getPluginsActivity()));
|
} else {
|
||||||
Toast.makeText(context, context.getString(R.string.activate_srtm_plugin),
|
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL())));
|
||||||
Toast.LENGTH_SHORT).show();
|
}
|
||||||
break;
|
break;
|
||||||
case DOWNLOAD:
|
case ASK_FOR_SRTM_PLUGIN_ENABLE:
|
||||||
break;
|
context.startActivity(new Intent(context, context.getMyApplication().getAppCustomization()
|
||||||
|
.getPluginsActivity()));
|
||||||
|
Toast.makeText(context, context.getString(R.string.activate_srtm_plugin),
|
||||||
|
Toast.LENGTH_SHORT).show();
|
||||||
|
break;
|
||||||
|
case DOWNLOAD:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -218,6 +218,12 @@ public class FileNameTranslationHelper {
|
||||||
return ctx.getString(R.string.index_item_world_bitcoin_payments);
|
return ctx.getString(R.string.index_item_world_bitcoin_payments);
|
||||||
} else if (basename.equals("world_seamarks_basemap")) {
|
} else if (basename.equals("world_seamarks_basemap")) {
|
||||||
return ctx.getString(R.string.index_item_world_seamarks);
|
return ctx.getString(R.string.index_item_world_seamarks);
|
||||||
|
} else if (basename.equals("depth_contours_osmand_ext")) {
|
||||||
|
return ctx.getString(R.string.index_item_depth_contours_osmand_ext);
|
||||||
|
} else if (basename.equals("depth_points_southern_hemisphere_osmand_ext")) {
|
||||||
|
return ctx.getString(R.string.index_item_depth_points_southern_hemisphere);
|
||||||
|
} else if (basename.equals("depth_points_northern_hemisphere_osmand_ext")) {
|
||||||
|
return ctx.getString(R.string.index_item_depth_points_northern_hemisphere);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,14 +38,19 @@ public class InAppHelper {
|
||||||
|
|
||||||
private static boolean mSubscribedToLiveUpdates = false;
|
private static boolean mSubscribedToLiveUpdates = false;
|
||||||
private static boolean mFullVersionPurchased = false;
|
private static boolean mFullVersionPurchased = false;
|
||||||
|
private static boolean mDepthContoursPurchased = false;
|
||||||
private static String mLiveUpdatesPrice;
|
private static String mLiveUpdatesPrice;
|
||||||
private static long lastValidationCheckTime;
|
private static long lastValidationCheckTime;
|
||||||
private static String mFullVersionPrice;
|
private static String mFullVersionPrice;
|
||||||
|
private static String mDepthContoursPrice;
|
||||||
|
|
||||||
public static final String SKU_FULL_VERSION_PRICE = "osmand_full_version_price";
|
public static final String SKU_FULL_VERSION_PRICE = "osmand_full_version_price";
|
||||||
private static final String SKU_LIVE_UPDATES_FULL = "osm_live_subscription_2";
|
private static final String SKU_LIVE_UPDATES_FULL = "osm_live_subscription_2";
|
||||||
private static final String SKU_LIVE_UPDATES_FREE = "osm_free_live_subscription_2";
|
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";
|
||||||
public static String SKU_LIVE_UPDATES;
|
public static String SKU_LIVE_UPDATES;
|
||||||
|
public static String SKU_DEPTH_CONTOURS;
|
||||||
|
|
||||||
private static final long PURCHASE_VALIDATION_PERIOD_MSEC = 1000 * 60 * 60 * 24; // daily
|
private static final long PURCHASE_VALIDATION_PERIOD_MSEC = 1000 * 60 * 60 * 24; // daily
|
||||||
// (arbitrary) request code for the purchase flow
|
// (arbitrary) request code for the purchase flow
|
||||||
|
@ -107,10 +112,18 @@ public class InAppHelper {
|
||||||
return mFullVersionPurchased;
|
return mFullVersionPurchased;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isDepthContoursPurchased() {
|
||||||
|
return mDepthContoursPurchased;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getLiveUpdatesPrice() {
|
public static String getLiveUpdatesPrice() {
|
||||||
return mLiveUpdatesPrice;
|
return mLiveUpdatesPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getDepthContoursPrice() {
|
||||||
|
return mDepthContoursPrice;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getFullVersionPrice() {
|
public static String getFullVersionPrice() {
|
||||||
return mFullVersionPrice;
|
return mFullVersionPrice;
|
||||||
}
|
}
|
||||||
|
@ -132,6 +145,13 @@ public class InAppHelper {
|
||||||
SKU_LIVE_UPDATES = SKU_LIVE_UPDATES_FULL;
|
SKU_LIVE_UPDATES = SKU_LIVE_UPDATES_FULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (SKU_DEPTH_CONTOURS == null) {
|
||||||
|
if (Version.isFreeVersion(ctx)) {
|
||||||
|
SKU_DEPTH_CONTOURS = SKU_DEPTH_CONTOURS_FREE;
|
||||||
|
} else {
|
||||||
|
SKU_DEPTH_CONTOURS = SKU_DEPTH_CONTOURS_FULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public InAppHelper(OsmandApplication ctx, boolean forceRequestInventory) {
|
public InAppHelper(OsmandApplication ctx, boolean forceRequestInventory) {
|
||||||
|
@ -142,8 +162,10 @@ public class InAppHelper {
|
||||||
if (isDeveloperVersion) {
|
if (isDeveloperVersion) {
|
||||||
mSubscribedToLiveUpdates = true;
|
mSubscribedToLiveUpdates = true;
|
||||||
mFullVersionPurchased = true;
|
mFullVersionPurchased = true;
|
||||||
|
mDepthContoursPurchased = true;
|
||||||
ctx.getSettings().LIVE_UPDATES_PURCHASED.set(true);
|
ctx.getSettings().LIVE_UPDATES_PURCHASED.set(true);
|
||||||
ctx.getSettings().FULL_VERSION_PURCHASED.set(true);
|
ctx.getSettings().FULL_VERSION_PURCHASED.set(true);
|
||||||
|
ctx.getSettings().DEPTH_CONTOURS_PURCHASED.set(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,9 +247,8 @@ public class InAppHelper {
|
||||||
logDebug("Setup successful. Querying inventory.");
|
logDebug("Setup successful. Querying inventory.");
|
||||||
List<String> skus = new ArrayList<>();
|
List<String> skus = new ArrayList<>();
|
||||||
skus.add(SKU_LIVE_UPDATES);
|
skus.add(SKU_LIVE_UPDATES);
|
||||||
if (forceRequestInventory) {
|
skus.add(SKU_DEPTH_CONTOURS);
|
||||||
skus.add(SKU_FULL_VERSION_PRICE);
|
skus.add(SKU_FULL_VERSION_PRICE);
|
||||||
}
|
|
||||||
mHelper.queryInventoryAsync(true, skus, mGotInventoryListener);
|
mHelper.queryInventoryAsync(true, skus, mGotInventoryListener);
|
||||||
} else {
|
} else {
|
||||||
notifyDismissProgress();
|
notifyDismissProgress();
|
||||||
|
@ -278,6 +299,12 @@ public class InAppHelper {
|
||||||
ctx.getSettings().FULL_VERSION_PURCHASED.set(true);
|
ctx.getSettings().FULL_VERSION_PURCHASED.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Purchase depthContoursPurchase = inventory.getPurchase(SKU_DEPTH_CONTOURS);
|
||||||
|
mDepthContoursPurchased = isDeveloperVersion || (depthContoursPurchase != null && depthContoursPurchase.getPurchaseState() == 0);
|
||||||
|
if (mDepthContoursPurchased) {
|
||||||
|
ctx.getSettings().DEPTH_CONTOURS_PURCHASED.set(true);
|
||||||
|
}
|
||||||
|
|
||||||
lastValidationCheckTime = System.currentTimeMillis();
|
lastValidationCheckTime = System.currentTimeMillis();
|
||||||
logDebug("User " + (mSubscribedToLiveUpdates ? "HAS" : "DOES NOT HAVE")
|
logDebug("User " + (mSubscribedToLiveUpdates ? "HAS" : "DOES NOT HAVE")
|
||||||
+ " live updates purchased.");
|
+ " live updates purchased.");
|
||||||
|
@ -287,6 +314,11 @@ public class InAppHelper {
|
||||||
mLiveUpdatesPrice = liveUpdatesDetails.getPrice();
|
mLiveUpdatesPrice = liveUpdatesDetails.getPrice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (inventory.hasDetails(SKU_DEPTH_CONTOURS)) {
|
||||||
|
SkuDetails depthContoursDetails = inventory.getSkuDetails(SKU_DEPTH_CONTOURS);
|
||||||
|
mDepthContoursPrice = depthContoursDetails.getPrice();
|
||||||
|
}
|
||||||
|
|
||||||
if (inventory.hasDetails(SKU_FULL_VERSION_PRICE)) {
|
if (inventory.hasDetails(SKU_FULL_VERSION_PRICE)) {
|
||||||
SkuDetails fullPriceDetails = inventory.getSkuDetails(SKU_FULL_VERSION_PRICE);
|
SkuDetails fullPriceDetails = inventory.getSkuDetails(SKU_FULL_VERSION_PRICE);
|
||||||
mFullVersionPrice = fullPriceDetails.getPrice();
|
mFullVersionPrice = fullPriceDetails.getPrice();
|
||||||
|
@ -335,9 +367,9 @@ public class InAppHelper {
|
||||||
};
|
};
|
||||||
|
|
||||||
public void purchaseFullVersion(final Activity activity) {
|
public void purchaseFullVersion(final Activity activity) {
|
||||||
if (mHelper == null || !mHelper.subscriptionsSupported()) {
|
if (mHelper == null) {
|
||||||
complain("Subscriptions not supported on your device yet. Sorry!");
|
complain("In-app hepler is not initialized!");
|
||||||
notifyError("Subscriptions not supported on your device yet. Sorry!");
|
notifyError("In-app hepler is not initialized!");
|
||||||
if (stopAfterResult) {
|
if (stopAfterResult) {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
@ -351,6 +383,23 @@ public class InAppHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void purchaseDepthContours(final Activity activity) {
|
||||||
|
if (mHelper == null) {
|
||||||
|
complain("In-app hepler is not initialized!");
|
||||||
|
notifyError("In-app hepler is not initialized!");
|
||||||
|
if (stopAfterResult) {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logDebug("Launching purchase flow for sea depth contours");
|
||||||
|
if (mHelper != null) {
|
||||||
|
mHelper.launchPurchaseFlow(activity,
|
||||||
|
SKU_DEPTH_CONTOURS, RC_REQUEST, mPurchaseFinishedListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void purchaseLiveUpdates(final Activity activity, final String email, final String userName,
|
public void purchaseLiveUpdates(final Activity activity, final String email, final String userName,
|
||||||
final String countryDownloadName, final boolean hideUserName) {
|
final String countryDownloadName, final boolean hideUserName) {
|
||||||
if (mHelper == null || !mHelper.subscriptionsSupported()) {
|
if (mHelper == null || !mHelper.subscriptionsSupported()) {
|
||||||
|
@ -504,20 +553,29 @@ public class InAppHelper {
|
||||||
if (purchase.getSku().equals(SKU_FULL_VERSION_PRICE)) {
|
if (purchase.getSku().equals(SKU_FULL_VERSION_PRICE)) {
|
||||||
// bought full version
|
// bought full version
|
||||||
logDebug("Full version purchased.");
|
logDebug("Full version purchased.");
|
||||||
sendToken(purchase.getToken(), new OnRequestResultListener() {
|
showToast(ctx.getString(R.string.full_version_thanks));
|
||||||
@Override
|
mFullVersionPurchased = true;
|
||||||
public void onResult(String result) {
|
ctx.getSettings().FULL_VERSION_PURCHASED.set(true);
|
||||||
showToast(ctx.getString(R.string.full_version_thanks));
|
|
||||||
mFullVersionPurchased = true;
|
|
||||||
ctx.getSettings().FULL_VERSION_PURCHASED.set(true);
|
|
||||||
|
|
||||||
notifyDismissProgress();
|
notifyDismissProgress();
|
||||||
notifyItemPurchased(SKU_FULL_VERSION_PRICE);
|
notifyItemPurchased(SKU_FULL_VERSION_PRICE);
|
||||||
if (stopAfterResult) {
|
if (stopAfterResult) {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
if (purchase.getSku().equals(SKU_DEPTH_CONTOURS)) {
|
||||||
|
// bought sea depth contours
|
||||||
|
logDebug("Sea depth contours purchased.");
|
||||||
|
showToast(ctx.getString(R.string.sea_depth_thanks));
|
||||||
|
mDepthContoursPurchased = true;
|
||||||
|
ctx.getSettings().DEPTH_CONTOURS_PURCHASED.set(true);
|
||||||
|
ctx.getSettings().getCustomRenderBooleanProperty("depthContours").set(true);
|
||||||
|
|
||||||
|
notifyDismissProgress();
|
||||||
|
notifyItemPurchased(SKU_DEPTH_CONTOURS);
|
||||||
|
if (stopAfterResult) {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -723,10 +723,10 @@ public class ResourceManager {
|
||||||
collectFiles(appPath, IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
collectFiles(appPath, IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
||||||
renameRoadsFiles(files, roadsPath);
|
renameRoadsFiles(files, roadsPath);
|
||||||
collectFiles(roadsPath, IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
collectFiles(roadsPath, IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
||||||
if(!Version.isFreeVersion(context)) {
|
if (!Version.isFreeVersion(context) || context.getSettings().FULL_VERSION_PURCHASED.get()) {
|
||||||
collectFiles(context.getAppPath(IndexConstants.WIKI_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
collectFiles(context.getAppPath(IndexConstants.WIKI_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
||||||
}
|
}
|
||||||
if(OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null) {
|
if (OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null) {
|
||||||
collectFiles(context.getAppPath(IndexConstants.SRTM_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
collectFiles(context.getAppPath(IndexConstants.SRTM_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue