Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-07-01 11:00:29 +02:00
commit e511c2f126

View file

@ -34,8 +34,11 @@ import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
import net.osmand.plus.views.mapwidgets.TextInfoWidget; import net.osmand.plus.views.mapwidgets.TextInfoWidget;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import java.text.MessageFormat;
import java.util.List; import java.util.List;
import static android.content.Intent.ACTION_VIEW;
public class MapillaryPlugin extends OsmandPlugin { public class MapillaryPlugin extends OsmandPlugin {
public static final String ID = "osmand.mapillary"; public static final String ID = "osmand.mapillary";
private static final String MAPILLARY_PACKAGE_ID = "app.mapillary"; private static final String MAPILLARY_PACKAGE_ID = "app.mapillary";
@ -216,14 +219,16 @@ public class MapillaryPlugin extends OsmandPlugin {
boolean success = false; boolean success = false;
OsmandApplication app = (OsmandApplication) activity.getApplication(); OsmandApplication app = (OsmandApplication) activity.getApplication();
if (isPackageInstalled(MAPILLARY_PACKAGE_ID, app)) { if (isPackageInstalled(MAPILLARY_PACKAGE_ID, app)) {
Intent launchIntent = app.getPackageManager().getLaunchIntentForPackage(MAPILLARY_PACKAGE_ID); if (imageKey != null) {
if (launchIntent != null) { Intent intent = new Intent(ACTION_VIEW, Uri.parse(MessageFormat.format("mapillary://mapillary/photo/{0}?image_key={0}", imageKey)));
if (imageKey != null) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
launchIntent.putExtra("photo_id", imageKey); app.startActivity(intent);
} } else {
app.startActivity(launchIntent); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mapillary://mapillary/capture"));
success = true; intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
app.startActivity(intent);
} }
success = true;
} else { } else {
new MapillaryInstallDialogFragment().show(activity.getSupportFragmentManager(), MapillaryInstallDialogFragment.TAG); new MapillaryInstallDialogFragment().show(activity.getSupportFragmentManager(), MapillaryInstallDialogFragment.TAG);
} }
@ -239,7 +244,7 @@ public class MapillaryPlugin extends OsmandPlugin {
} }
private static boolean execInstall(OsmandApplication app, String url) { private static boolean execInstall(OsmandApplication app, String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); Intent intent = new Intent(ACTION_VIEW, Uri.parse(url));
try { try {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
app.startActivity(intent); app.startActivity(intent);