Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-09-04 19:09:25 +02:00
commit a54a2bb186
41 changed files with 61 additions and 17 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 662 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,002 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 884 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 954 B

View file

@ -13,9 +13,11 @@ import android.webkit.WebView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.mapillary.MapillaryPlugin;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
public class ContextMenuCardDialogFragment extends Fragment { public class ContextMenuCardDialogFragment extends Fragment {
@ -115,6 +117,14 @@ public class ContextMenuCardDialogFragment extends Fragment {
public void dismiss() { public void dismiss() {
MapActivity activity = dialog.getMapActivity(); MapActivity activity = dialog.getMapActivity();
if (activity != null) { if (activity != null) {
if (dialog.getType() == ContextMenuCardDialog.CardDialogType.MAPILLARY) {
if (!activity.getMyApplication().getSettings().SHOW_MAPILLARY.get()) {
MapillaryPlugin mapillaryPlugin = OsmandPlugin.getPlugin(MapillaryPlugin.class);
if (mapillaryPlugin != null) {
mapillaryPlugin.updateLayers(activity.getMapView(), activity);
}
}
}
try { try {
activity.getSupportFragmentManager().popBackStack(TAG, activity.getSupportFragmentManager().popBackStack(TAG,
FragmentManager.POP_BACK_STACK_INCLUSIVE); FragmentManager.POP_BACK_STACK_INCLUSIVE);

View file

@ -3,6 +3,7 @@ package net.osmand.plus.mapillary;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard;
@ -21,9 +22,15 @@ public class MapillaryImageCard extends ImageCard {
OnClickListener onClickListener = new OnClickListener() { OnClickListener onClickListener = new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (!getMyApplication().getSettings().SHOW_MAPILLARY.get()) {
MapillaryPlugin mapillaryPlugin = OsmandPlugin.getPlugin(MapillaryPlugin.class);
if (mapillaryPlugin != null) {
mapillaryPlugin.updateLayers(getMapActivity().getMapView(), getMapActivity(), true);
}
}
getMapActivity().getContextMenu().hideMenues(); getMapActivity().getContextMenu().hideMenues();
MapillaryImageDialog.show(getMapActivity(), getKey(), getImageHiresUrl(), getUrl(), getLocation(), MapillaryImageDialog.show(getMapActivity(), getKey(), getImageHiresUrl(), getUrl(), getLocation(),
getCa(), getMyApplication().getString(R.string.mapillary), null); getCa(), getMyApplication().getString(R.string.mapillary), null, true);
} }
}; };
if (!Algorithms.isEmpty(buttonText)) { if (!Algorithms.isEmpty(buttonText)) {

View file

@ -80,6 +80,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
private String viewerUrl; private String viewerUrl;
private LatLon latLon; private LatLon latLon;
private double ca = Double.NaN; private double ca = Double.NaN;
private boolean sync;
private View staticImageView; private View staticImageView;
private View noInternetView; private View noInternetView;
@ -97,7 +98,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
} }
public MapillaryImageDialog(MapActivity mapActivity, String key, String sKey, String imageUrl, public MapillaryImageDialog(MapActivity mapActivity, String key, String sKey, String imageUrl,
String viewerUrl, LatLon latLon, double ca, String title, String description) { String viewerUrl, LatLon latLon, double ca, String title, String description, boolean sync) {
super(mapActivity, CardDialogType.MAPILLARY); super(mapActivity, CardDialogType.MAPILLARY);
this.title = title; this.title = title;
this.description = description; this.description = description;
@ -108,6 +109,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
this.latLon = latLon; this.latLon = latLon;
this.ca = ca; this.ca = ca;
this.ic = mapActivity.getMyApplication().getIconsCache(); this.ic = mapActivity.getMyApplication().getIconsCache();
this.sync = sync;
} }
public String getKey() { public String getKey() {
@ -475,7 +477,12 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
// asking tile image async // asking tile image async
boolean imgExist = mgr.tileExistOnFileSystem(tileId, map, tileX, tileY, TILE_ZOOM); boolean imgExist = mgr.tileExistOnFileSystem(tileId, map, tileX, tileY, TILE_ZOOM);
if (imgExist) { if (imgExist) {
tile = mgr.getGeometryTilesCache().getTileForMapAsync(tileId, map, tileX, tileY, TILE_ZOOM, false); if (sync) {
tile = mgr.getGeometryTilesCache().getTileForMapSync(tileId, map, tileX, tileY, TILE_ZOOM, false);
sync = false;
} else {
tile = mgr.getGeometryTilesCache().getTileForMapAsync(tileId, map, tileX, tileY, TILE_ZOOM, false);
}
} }
if (tile != null) { if (tile != null) {
tiles.put(tileId, new Pair<>(new QuadPointDouble(tileX, tileY), tile)); tiles.put(tileId, new Pair<>(new QuadPointDouble(tileX, tileY), tile));
@ -492,7 +499,16 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
String viewerUrl, LatLon latLon, double ca, String viewerUrl, LatLon latLon, double ca,
String title, String description) { String title, String description) {
MapillaryImageDialog dialog = new MapillaryImageDialog(mapActivity, key, null, imageUrl, MapillaryImageDialog dialog = new MapillaryImageDialog(mapActivity, key, null, imageUrl,
viewerUrl, latLon, ca, title, description); viewerUrl, latLon, ca, title, description, false);
ContextMenuCardDialogFragment.showInstance(dialog);
return dialog;
}
public static MapillaryImageDialog show(MapActivity mapActivity, String key, String imageUrl,
String viewerUrl, LatLon latLon, double ca,
String title, String description, boolean sync) {
MapillaryImageDialog dialog = new MapillaryImageDialog(mapActivity, key, null, imageUrl,
viewerUrl, latLon, ca, title, description, sync);
ContextMenuCardDialogFragment.showInstance(dialog); ContextMenuCardDialogFragment.showInstance(dialog);
return dialog; return dialog;
} }
@ -503,7 +519,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
String viewerUrl = MAPILLARY_VIEWER_URL_TEMPLATE + key; String viewerUrl = MAPILLARY_VIEWER_URL_TEMPLATE + key;
LatLon latLon = new LatLon(latitude, longitude); LatLon latLon = new LatLon(latitude, longitude);
MapillaryImageDialog dialog = new MapillaryImageDialog(mapActivity, key, sKey, imageUrl, viewerUrl, MapillaryImageDialog dialog = new MapillaryImageDialog(mapActivity, key, sKey, imageUrl, viewerUrl,
latLon, ca, title, description); latLon, ca, title, description, false);
ContextMenuCardDialogFragment.showInstance(dialog); ContextMenuCardDialogFragment.showInstance(dialog);
return dialog; return dialog;
} }

View file

@ -2,7 +2,6 @@ package net.osmand.plus.mapillary;
import android.app.Activity; import android.app.Activity;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
@ -36,7 +35,6 @@ 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.lang.reflect.Method;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.List; import java.util.List;
@ -96,17 +94,21 @@ public class MapillaryPlugin extends OsmandPlugin {
@Override @Override
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) { public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
updateMapLayers(mapView, activity.getMapLayers()); updateMapLayers(mapView, activity.getMapLayers(), false);
} }
private void updateMapLayers(OsmandMapTileView mapView, final MapActivityLayers layers) { public void updateLayers(OsmandMapTileView mapView, MapActivity activity, boolean force) {
updateMapLayers(mapView, activity.getMapLayers(), force);
}
private void updateMapLayers(OsmandMapTileView mapView, final MapActivityLayers layers, boolean force) {
if (rasterLayer == null || vectorLayer == null) { if (rasterLayer == null || vectorLayer == null) {
createLayers(); createLayers();
} }
if (isActive()) { if (isActive()) {
ITileSource rasterSource = null; ITileSource rasterSource = null;
ITileSource vectorSource = null; ITileSource vectorSource = null;
if (settings.SHOW_MAPILLARY.get()) { if (settings.SHOW_MAPILLARY.get() || force) {
rasterSource = settings.getTileSourceByName(TileSourceManager.getMapillaryRasterSource().getName(), false); rasterSource = settings.getTileSourceByName(TileSourceManager.getMapillaryRasterSource().getName(), false);
vectorSource = settings.getTileSourceByName(TileSourceManager.getMapillaryVectorSource().getName(), false); vectorSource = settings.getTileSourceByName(TileSourceManager.getMapillaryVectorSource().getName(), false);
} }
@ -156,7 +158,7 @@ public class MapillaryPlugin extends OsmandPlugin {
OsmandMapTileView mapView = mapActivity.getMapView(); OsmandMapTileView mapView = mapActivity.getMapView();
MapActivityLayers mapLayers = mapActivity.getMapLayers(); MapActivityLayers mapLayers = mapActivity.getMapLayers();
settings.SHOW_MAPILLARY.set(!settings.SHOW_MAPILLARY.get()); settings.SHOW_MAPILLARY.set(!settings.SHOW_MAPILLARY.get());
updateMapLayers(mapView, mapLayers); updateMapLayers(mapView, mapLayers, false);
ContextMenuItem item = adapter.getItem(pos); ContextMenuItem item = adapter.getItem(pos);
if (item != null) { if (item != null) {
item.setSelected(settings.SHOW_MAPILLARY.get()); item.setSelected(settings.SHOW_MAPILLARY.get());

View file

@ -30,6 +30,7 @@ public class RulerControlLayer extends OsmandMapLayer {
private static final long DRAW_TIME = 2000; private static final long DRAW_TIME = 2000;
private static final long DELAY_BEFORE_DRAW = 500; private static final long DELAY_BEFORE_DRAW = 500;
private static final int TEXT_SIZE = 14; private static final int TEXT_SIZE = 14;
private static final int MAX_ITERATIONS = 50;
private final MapActivity mapActivity; private final MapActivity mapActivity;
private OsmandApplication app; private OsmandApplication app;
@ -272,12 +273,18 @@ public class RulerControlLayer extends OsmandMapLayer {
int currY = (int) tb.getPixYFromLatLon(currentLoc.getLatitude(), currentLoc.getLongitude()); int currY = (int) tb.getPixYFromLatLon(currentLoc.getLatitude(), currentLoc.getLongitude());
int width = tb.getPixWidth(); int width = tb.getPixWidth();
int height = tb.getPixHeight(); int height = tb.getPixHeight();
boolean needDraw = true;
if (currX < 0 || currY < 0 || currX > width || currY > height) { if ((currX < 0 && x == 0) || (currY < 0 && y == 0)
|| (currX > width && x == width) || (currY > height && y == height)) {
needDraw = false;
} else if (currX < 0 || currY < 0 || currX > width || currY > height) {
float xNew = (currX + x) / 2; float xNew = (currX + x) / 2;
float yNew = (currY + y) / 2; float yNew = (currY + y) / 2;
int count = 0;
while (true) { while (count < MAX_ITERATIONS) {
count++;
if (xNew < 0 || yNew < 0 || xNew > width || yNew > height) { if (xNew < 0 || yNew < 0 || xNew > width || yNew > height) {
currX = (int) xNew; currX = (int) xNew;
currY = (int) yNew; currY = (int) yNew;
@ -289,10 +296,12 @@ public class RulerControlLayer extends OsmandMapLayer {
} }
} }
canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); if (needDraw) {
canvas.drawLine(currX, currY, x, y, lineAttrs.paint); canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
drawFingerTouchIcon(canvas, x, y, nightMode); canvas.drawLine(currX, currY, x, y, lineAttrs.paint);
canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY()); drawFingerTouchIcon(canvas, x, y, nightMode);
canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
}
} }
private void updateData(RotatedTileBox tb, QuadPoint center) { private void updateData(RotatedTileBox tb, QuadPoint center) {