diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index 324cc191ed..3345a8e46f 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -178,7 +178,7 @@ public abstract class OsmandPlugin { allPlugins.add(srtm); } else { if (marketEnabled) { - srtm.setInstallURL(Version.marketPrefix(app) + id); + srtm.setInstallURL(Version.getUrlWithUtmRef(app, id)); allPlugins.add(srtm); } } diff --git a/OsmAnd/src/net/osmand/plus/Version.java b/OsmAnd/src/net/osmand/plus/Version.java index adfc89ce78..5600d8c073 100644 --- a/OsmAnd/src/net/osmand/plus/Version.java +++ b/OsmAnd/src/net/osmand/plus/Version.java @@ -13,7 +13,7 @@ public class Version { private final static String FREE_VERSION_NAME = "net.osmand"; private final static String FREE_DEV_VERSION_NAME = "net.osmand.dev"; private final static String SHERPAFY_VERSION_NAME = "net.osmand.sherpafy"; - + private final static String UTM_REF = "&referrer=utm_source%3Dosmand"; public static boolean isGpsStatusEnabled(OsmandApplication ctx) { return isGooglePlayEnabled(ctx) && !isBlackberry(ctx); @@ -35,6 +35,10 @@ public class Version { } return "https://osmand.net/apps?id="; } + + public static String getUrlWithUtmRef(OsmandApplication ctx, String appName) { + return marketPrefix(ctx) + appName + UTM_REF; + } private static boolean isAmazonEnabled(OsmandApplication ctx) { return ctx.getString(R.string.versionFeatures).contains("+amazon"); diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java b/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java index f147eef5be..300f9641d5 100644 --- a/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java +++ b/OsmAnd/src/net/osmand/plus/activities/actions/ShareDialog.java @@ -198,8 +198,7 @@ public class ShareDialog { builder.setPositiveButton(activity.getString(R.string.shared_string_yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.marketPrefix((OsmandApplication) activity.getApplication()) - + ZXING_BARCODE_SCANNER_COMPONENT)); + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.getUrlWithUtmRef((OsmandApplication) activity.getApplication(), ZXING_BARCODE_SCANNER_COMPONENT))); try { activity.startActivity(intent); } catch (ActivityNotFoundException e) { diff --git a/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java b/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java index 9a3ac4cc7b..d49079edd0 100644 --- a/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java +++ b/OsmAnd/src/net/osmand/plus/activities/actions/StartGPSStatus.java @@ -26,7 +26,6 @@ import net.osmand.AndroidUtils; import net.osmand.plus.R; import net.osmand.plus.Version; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.views.OsmandMapTileView; public class StartGPSStatus extends OsmAndAction { @@ -178,7 +177,7 @@ public class StartGPSStatus extends OsmAndAction { builder.setPositiveButton(mapActivity.getString(R.string.shared_string_yes), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.marketPrefix(getMyApplication()) + g.appName)); + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.getUrlWithUtmRef(getMyApplication(), g.appName))); try { mapActivity.startActivity(intent); } catch (ActivityNotFoundException e) { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashRateUsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashRateUsFragment.java index bd7d2f5b1e..bb372f91f9 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashRateUsFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashRateUsFragment.java @@ -86,7 +86,7 @@ public class DashRateUsFragment extends DashBaseFragment { return; case USER_LIKES_APP: settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.LIKED); - Uri uri = Uri.parse(Version.marketPrefix(getMyApplication()) + getActivity().getPackageName()); + Uri uri = Uri.parse(Version.getUrlWithUtmRef(getMyApplication(), getActivity().getPackageName())); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); startActivity(goToMarket); break; diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RateUsBottomSheetDialog.java b/OsmAnd/src/net/osmand/plus/dialogs/RateUsBottomSheetDialog.java index 93a12ec345..b6c437d614 100644 --- a/OsmAnd/src/net/osmand/plus/dialogs/RateUsBottomSheetDialog.java +++ b/OsmAnd/src/net/osmand/plus/dialogs/RateUsBottomSheetDialog.java @@ -115,7 +115,7 @@ public class RateUsBottomSheetDialog extends BottomSheetDialogFragment { return; case USER_LIKES_APP: settings.RATE_US_STATE.set(RateUsBottomSheetDialog.RateUsState.LIKED); - Uri uri = Uri.parse(Version.marketPrefix(getMyApplication()) + getActivity().getPackageName()); + Uri uri = Uri.parse(Version.getUrlWithUtmRef(getMyApplication(), getActivity().getPackageName())); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); startActivity(goToMarket); break; diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index 919f666165..55ff51d757 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -248,7 +248,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo } else { app.logEvent(this, "paid_version_redirect"); Intent intent = new Intent(Intent.ACTION_VIEW, - Uri.parse(Version.marketPrefix(app) + "net.osmand.plus")); + Uri.parse(Version.getUrlWithUtmRef(app, "net.osmand.plus"))); try { startActivity(intent); } catch (ActivityNotFoundException e) { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java index 9c428db783..3b029993df 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java @@ -381,7 +381,7 @@ public class DownloadIndexesThread { builder.setPositiveButton(R.string.button_upgrade_osmandplus, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=net.osmand.plus")); + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.getUrlWithUtmRef(app, "net.osmand.plus"))); try { ctx.startActivity(intent); } catch (ActivityNotFoundException e) { diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadValidationManager.java b/OsmAnd/src/net/osmand/plus/download/DownloadValidationManager.java index 36cb5733b3..4a7ec8f60d 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadValidationManager.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadValidationManager.java @@ -224,8 +224,7 @@ public class DownloadValidationManager { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Intent.ACTION_VIEW, - Uri.parse(Version.marketPrefix(getMyApplication()) - + "net.osmand.plus")); + Uri.parse(Version.getUrlWithUtmRef(getMyApplication(), "net.osmand.plus"))); try { startActivity(intent); } catch (ActivityNotFoundException e) { diff --git a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java index 44987b5ba3..c8abbd7808 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/DiscountHelper.java @@ -147,7 +147,7 @@ public class DiscountHelper { int i = url.indexOf("osmand-market-app:"); if (i != -1) { String appName = url.substring(i + 18); - return Version.marketPrefix(app) + appName; + return Version.getUrlWithUtmRef(app, appName); } } return url; diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryInstallDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryInstallDialogFragment.java index ccf1043fdf..2d4d4b477e 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryInstallDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryInstallDialogFragment.java @@ -35,8 +35,7 @@ public class MapillaryInstallDialogFragment extends DialogFragment { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); - mapActivity.getMyApplication().logEvent(mapActivity, "click_install_mapillary"); - MapillaryPlugin.installMapillary(mapActivity.getMyApplication()); + MapillaryPlugin.installMapillary(mapActivity, mapActivity.getMyApplication()); } }); diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java index e65ccaf8d2..86146dd45a 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java @@ -2,6 +2,7 @@ package net.osmand.plus.mapillary; import android.app.Activity; import android.content.ActivityNotFoundException; +import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -23,6 +24,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; +import net.osmand.plus.Version; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivityLayers; import net.osmand.plus.base.BottomSheetDialogFragment; @@ -34,6 +36,7 @@ import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo; import net.osmand.plus.views.mapwidgets.TextInfoWidget; import net.osmand.util.Algorithms; +import java.lang.reflect.Method; import java.text.MessageFormat; import java.util.List; @@ -235,8 +238,9 @@ public class MapillaryPlugin extends OsmandPlugin { return success; } - public static boolean installMapillary(OsmandApplication app) { - boolean success = execInstall(app, "market://details?id=" + MAPILLARY_PACKAGE_ID); + public static boolean installMapillary(Activity activity, OsmandApplication app) { + app.logEvent(activity, "install_mapillary"); + boolean success = execInstall(app, Version.getUrlWithUtmRef(app, MAPILLARY_PACKAGE_ID)); if (!success) { success = execInstall(app, "https://play.google.com/store/apps/details?id=" + MAPILLARY_PACKAGE_ID); }