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