Merge branch 'r3.5'

This commit is contained in:
max-klaus 2019-11-27 17:31:34 +03:00
commit 354cd0b1fa
2 changed files with 26 additions and 10 deletions

View file

@ -1707,6 +1707,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
data.getPath() != null && data.getPath().startsWith("/go")) {
String lat = data.getQueryParameter("lat");
String lon = data.getQueryParameter("lon");
String url = data.getQueryParameter("url");
if (lat != null && lon != null) {
try {
double lt = Double.parseDouble(lat);
@ -1720,6 +1721,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
} catch (NumberFormatException e) {
LOG.error("error", e);
}
} else if (url != null) {
url = DiscountHelper.parseUrl(app, url);
if (DiscountHelper.validateUrl(app, url)) {
DiscountHelper.openUrl(this, url);
}
}
setIntent(null);
return true;
@ -1736,7 +1742,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
data.getPath() != null && data.getPath().startsWith("/add-tile-source")) {
Map<String, String> attrs = new HashMap<>();
for (String name : data.getQueryParameterNames()) {
attrs.put(name, data.getQueryParameter(name));
String value = data.getQueryParameter(name);
if (value != null) {
attrs.put(name, value);
}
}
if (!attrs.isEmpty()) {
try {

View file

@ -141,13 +141,8 @@ public class DiscountHelper {
JSONObject application = obj.getJSONObject("application");
boolean showChristmasDialog = obj.optBoolean("show_christmas_dialog", false);
if (data.url.startsWith(INAPP_PREFIX) && data.url.length() > INAPP_PREFIX.length()) {
String inAppSku = data.url.substring(INAPP_PREFIX.length());
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
if (purchaseHelper != null
&& purchaseHelper.isPurchased(inAppSku) || InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
return;
}
if (!validateUrl(app, data.url)) {
return;
}
if (data.oneOfConditions != null) {
@ -215,7 +210,19 @@ public class DiscountHelper {
}
}
private static String parseUrl(OsmandApplication app, String url) {
public static boolean validateUrl(OsmandApplication app, String url) {
if (url.startsWith(INAPP_PREFIX) && url.length() > INAPP_PREFIX.length()) {
String inAppSku = url.substring(INAPP_PREFIX.length());
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();
if (purchaseHelper != null
&& purchaseHelper.isPurchased(inAppSku) || InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
return false;
}
}
return true;
}
public static String parseUrl(OsmandApplication app, String url) {
if (!Algorithms.isEmpty(url)) {
int i = url.indexOf("osmand-market-app:");
if (i != -1) {
@ -297,7 +304,7 @@ public class DiscountHelper {
mFilterVisible = true;
}
private static void openUrl(final MapActivity mapActivity, String url) {
public static void openUrl(final MapActivity mapActivity, String url) {
if (url.startsWith(INAPP_PREFIX)) {
OsmandApplication app = mapActivity.getMyApplication();
InAppPurchaseHelper purchaseHelper = app.getInAppPurchaseHelper();