Merge branch 'master' of ssh://github.com/osmandapp/Osmand into transport_improvements

This commit is contained in:
PavelRatushny 2017-12-29 14:12:43 +02:00
commit 3716dab532

View file

@ -72,7 +72,13 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
private Activity activity;
private OsmandApplication application;
protected OsmandSettings settings = null;
private Integer defaultColor = null;
private CanvasColors canvasColors = null;
private Boolean nightMode = null;
private class CanvasColors {
int colorDay = MAP_DEFAULT_COLOR;
int colorNight = MAP_DEFAULT_COLOR;
}
private class FPSMeasurement {
int fpsMeasureCount = 0;
@ -112,10 +118,6 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
public void onDrawOverMap();
}
public int getDefaultColor() {
return defaultColor;
}
protected static final Log LOG = PlatformUtil.getLog(OsmandMapTileView.class);
@ -649,29 +651,39 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
}
private void fillCanvas(Canvas canvas, DrawSettings drawSettings) {
Integer color = defaultColor;
if (color == null) {
color = updateDefaultColor(drawSettings.isNightMode());
int color = MAP_DEFAULT_COLOR;
CanvasColors canvasColors = this.canvasColors;
if (canvasColors == null) {
canvasColors = updateCanvasColors();
this.canvasColors = canvasColors;
}
if (canvasColors != null) {
color = drawSettings.isNightMode() ? canvasColors.colorNight : canvasColors.colorDay;
}
canvas.drawColor(color);
}
public void resetDefaultColor() {
defaultColor = null;
canvasColors = null;
}
private int updateDefaultColor(boolean nightMode) {
int color = MAP_DEFAULT_COLOR;
private CanvasColors updateCanvasColors() {
CanvasColors canvasColors = null;
RenderingRulesStorage rrs = application.getRendererRegistry().getCurrentSelectedRenderer();
if (rrs != null) {
canvasColors = new CanvasColors();
RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs);
req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode);
req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, false);
if (req.searchRenderingAttribute(RenderingRuleStorageProperties.A_DEFAULT_COLOR)) {
color = req.getIntPropertyValue(req.ALL.R_ATTR_COLOR_VALUE);
defaultColor = color;
canvasColors.colorDay = req.getIntPropertyValue(req.ALL.R_ATTR_COLOR_VALUE);
}
req = new RenderingRuleSearchRequest(rrs);
req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, true);
if (req.searchRenderingAttribute(RenderingRuleStorageProperties.A_DEFAULT_COLOR)) {
canvasColors.colorNight = req.getIntPropertyValue(req.ALL.R_ATTR_COLOR_VALUE);
}
}
return color;
return canvasColors;
}
public boolean isMeasureFPS() {
@ -752,6 +764,11 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
baseHandler.removeMessages(BASE_REFRESH_MESSAGE);
try {
DrawSettings param = drawSettings;
Boolean currentNightMode = nightMode;
if (currentNightMode != null && currentNightMode != param.isNightMode()) {
param = new DrawSettings(currentNightMode, true);
resetDefaultColor();
}
if (handler.hasMessages(MAP_FORCE_REFRESH_MESSAGE)) {
if (!param.isUpdateVectorRendering()) {
param = new DrawSettings(drawSettings.isNightMode(), true);
@ -780,7 +797,13 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
public void refreshMap(final boolean updateVectorRendering) {
if (view != null && view.isShown()) {
boolean nightMode = application.getDaynightHelper().isNightMode();
DrawSettings drawSettings = new DrawSettings(nightMode, updateVectorRendering);
Boolean currentNightMode = this.nightMode;
boolean forceUpdateVectorDrawing = currentNightMode != null && currentNightMode != nightMode;
if (forceUpdateVectorDrawing) {
resetDefaultColor();
}
this.nightMode = nightMode;
DrawSettings drawSettings = new DrawSettings(nightMode, updateVectorRendering || forceUpdateVectorDrawing);
sendRefreshMapMsg(drawSettings, 20);
refreshBufferImage(drawSettings);
}
@ -946,7 +969,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
}
public void fitLocationToMap(double clat, double clon, int zoom,
int tileBoxWidthPx, int tileBoxHeightPx, int marginTopPx, boolean animated) {
int tileBoxWidthPx, int tileBoxHeightPx, int marginTopPx, boolean animated) {
RotatedTileBox tb = currentViewport.copy();
int dy = 0;
@ -1127,7 +1150,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
firstTouchPointLatLon = currentViewport.getLatLonFromPixel(x1, y1);
secondTouchPointLatLon = currentViewport.getLatLonFromPixel(x2, y2);
multiTouch = true;
wasZoomInMultiTouch = false;
wasZoomInMultiTouch = false;
multiTouchStartTime = System.currentTimeMillis();
}
}