commit
9ad49fa23d
5 changed files with 80 additions and 32 deletions
|
@ -53,7 +53,7 @@ public class DoubleTapScaleDetector {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
if (event.getPointerCount() != 1) {
|
if (event.getPointerCount() != 1 || !view.mapGestureAllowed(OsmandMapLayer.MapGestureType.DOUBLE_TAP_ZOOM_CHANGE)) {
|
||||||
resetEvents();
|
resetEvents();
|
||||||
mIsDoubleTapping = false;
|
mIsDoubleTapping = false;
|
||||||
mScrolling = false;
|
mScrolling = false;
|
||||||
|
|
|
@ -1,24 +1,5 @@
|
||||||
package net.osmand.plus.views;
|
package net.osmand.plus.views;
|
||||||
|
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.osmand.data.LatLon;
|
|
||||||
import net.osmand.data.QuadRect;
|
|
||||||
import net.osmand.data.QuadTree;
|
|
||||||
import net.osmand.data.RotatedTileBox;
|
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.activities.MapActivity;
|
|
||||||
import net.osmand.plus.render.OsmandRenderer;
|
|
||||||
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
|
||||||
import net.osmand.render.RenderingRuleSearchRequest;
|
|
||||||
import net.osmand.render.RenderingRulesStorage;
|
|
||||||
import net.osmand.util.MapAlgorithms;
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
||||||
|
@ -34,11 +15,41 @@ import android.os.AsyncTask;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.data.QuadRect;
|
||||||
|
import net.osmand.data.QuadTree;
|
||||||
|
import net.osmand.data.RotatedTileBox;
|
||||||
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.render.OsmandRenderer;
|
||||||
|
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
||||||
|
import net.osmand.render.RenderingRuleSearchRequest;
|
||||||
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
|
import net.osmand.util.MapAlgorithms;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
|
||||||
public abstract class OsmandMapLayer {
|
public abstract class OsmandMapLayer {
|
||||||
|
|
||||||
protected List<LatLon> fullObjectsLatLon;
|
protected List<LatLon> fullObjectsLatLon;
|
||||||
protected List<LatLon> smallObjectsLatLon;
|
protected List<LatLon> smallObjectsLatLon;
|
||||||
|
|
||||||
|
public enum MapGestureType {
|
||||||
|
DOUBLE_TAP_ZOOM_IN,
|
||||||
|
DOUBLE_TAP_ZOOM_CHANGE,
|
||||||
|
TWO_POINTERS_ZOOM_OUT
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMapGestureAllowed(MapGestureType type) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void initLayer(OsmandMapTileView view);
|
public abstract void initLayer(OsmandMapTileView view);
|
||||||
|
|
||||||
public abstract void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings);
|
public abstract void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings);
|
||||||
|
|
|
@ -226,6 +226,9 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
||||||
@Override
|
@Override
|
||||||
public void onTwoFingerTap() {
|
public void onTwoFingerTap() {
|
||||||
//afterTwoFingersTap = true;
|
//afterTwoFingersTap = true;
|
||||||
|
if (!mapGestureAllowed(OsmandMapLayer.MapGestureType.TWO_POINTERS_ZOOM_OUT)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (isZoomingAllowed(getZoom(), -1.1f)) {
|
if (isZoomingAllowed(getZoom(), -1.1f)) {
|
||||||
getAnimatedDraggingThread().startZooming(getZoom() - 1, currentViewport.getZoomFloatPart(), false);
|
getAnimatedDraggingThread().startZooming(getZoom() - 1, currentViewport.getZoomFloatPart(), false);
|
||||||
if (wasMapLinkedBeforeGesture) {
|
if (wasMapLinkedBeforeGesture) {
|
||||||
|
@ -335,6 +338,15 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
||||||
this.wasZoomInMultiTouch = wasZoomInMultiTouch;
|
this.wasZoomInMultiTouch = wasZoomInMultiTouch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean mapGestureAllowed(OsmandMapLayer.MapGestureType type) {
|
||||||
|
for (OsmandMapLayer layer : layers) {
|
||||||
|
if (!layer.isMapGestureAllowed(type)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void setIntZoom(int zoom) {
|
public void setIntZoom(int zoom) {
|
||||||
zoom = zoom > getMaxZoom() ? getMaxZoom() : zoom;
|
zoom = zoom > getMaxZoom() ? getMaxZoom() : zoom;
|
||||||
zoom = zoom < getMinZoom() ? getMinZoom() : zoom;
|
zoom = zoom < getMinZoom() ? getMinZoom() : zoom;
|
||||||
|
|
|
@ -108,10 +108,18 @@ public class RulerControlLayer extends OsmandMapLayer {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isMapGestureAllowed(MapGestureType type) {
|
||||||
|
if (rulerModeOn() && type == MapGestureType.TWO_POINTERS_ZOOM_OUT) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings settings) {
|
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings settings) {
|
||||||
if (mapActivity.getMapLayers().getMapWidgetRegistry().isVisible("ruler") &&
|
if (rulerModeOn()) {
|
||||||
rightWidgetsPanel.getVisibility() == View.VISIBLE) {
|
|
||||||
lineAttrs.updatePaints(view, settings, tb);
|
lineAttrs.updatePaints(view, settings, tb);
|
||||||
circleAttrs.updatePaints(view, settings, tb);
|
circleAttrs.updatePaints(view, settings, tb);
|
||||||
circleAttrs.paint2.setStyle(Style.FILL);
|
circleAttrs.paint2.setStyle(Style.FILL);
|
||||||
|
@ -150,6 +158,11 @@ public class RulerControlLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean rulerModeOn() {
|
||||||
|
return mapActivity.getMapLayers().getMapWidgetRegistry().isVisible("ruler") &&
|
||||||
|
rightWidgetsPanel.getVisibility() == View.VISIBLE;
|
||||||
|
}
|
||||||
|
|
||||||
public void refreshMapDelayed() {
|
public void refreshMapDelayed() {
|
||||||
handler.sendEmptyMessageDelayed(0, DELAY + 50);
|
handler.sendEmptyMessageDelayed(0, DELAY + 50);
|
||||||
}
|
}
|
||||||
|
@ -208,7 +221,7 @@ public class RulerControlLayer extends OsmandMapLayer {
|
||||||
boolean move = tb.getZoom() != cacheIntZoom || Math.abs(tb.getCenterTileX() - cacheTileX) > 1 ||
|
boolean move = tb.getZoom() != cacheIntZoom || Math.abs(tb.getCenterTileX() - cacheTileX) > 1 ||
|
||||||
Math.abs(tb.getCenterTileY() - cacheTileY) > 1;
|
Math.abs(tb.getCenterTileY() - cacheTileY) > 1;
|
||||||
|
|
||||||
if (!mapActivity.getMapView().isZooming() && move) {
|
if (!tb.isZoomAnimated() && move) {
|
||||||
cacheIntZoom = tb.getZoom();
|
cacheIntZoom = tb.getZoom();
|
||||||
cacheTileX = tb.getCenterTileX();
|
cacheTileX = tb.getCenterTileX();
|
||||||
cacheTileY = tb.getCenterTileY();
|
cacheTileY = tb.getCenterTileY();
|
||||||
|
|
|
@ -207,8 +207,12 @@ public class MapInfoWidgetsFactory {
|
||||||
LatLon centerLoc = map.getMapLocation();
|
LatLon centerLoc = map.getMapLocation();
|
||||||
|
|
||||||
if (currentLoc != null && centerLoc != null) {
|
if (currentLoc != null && centerLoc != null) {
|
||||||
setDistanceText(currentLoc.getLatitude(), currentLoc.getLongitude(),
|
if (map.getMapViewTrackingUtilities().isMapLinkedToLocation()) {
|
||||||
centerLoc.getLatitude(), centerLoc.getLongitude());
|
setDistanceText(0);
|
||||||
|
} else {
|
||||||
|
setDistanceText(currentLoc.getLatitude(), currentLoc.getLongitude(),
|
||||||
|
centerLoc.getLatitude(), centerLoc.getLongitude());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setText(title, null);
|
setText(title, null);
|
||||||
|
@ -216,13 +220,21 @@ public class MapInfoWidgetsFactory {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDistanceText(double firstLat, double firstLon, double secondLat, double secondLon) {
|
private void setDistanceText(float dist) {
|
||||||
float dist = (float) MapUtils.getDistance(firstLat, firstLon, secondLat, secondLon);
|
calculateAndSetText(dist);
|
||||||
String distance = OsmAndFormatter.getFormattedDistance(dist, map.getMyApplication());
|
}
|
||||||
int ls = distance.lastIndexOf(' ');
|
|
||||||
setText(distance.substring(0, ls), distance.substring(ls + 1));
|
private void setDistanceText(double firstLat, double firstLon, double secondLat, double secondLon) {
|
||||||
}
|
float dist = (float) MapUtils.getDistance(firstLat, firstLon, secondLat, secondLon);
|
||||||
};
|
calculateAndSetText(dist);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calculateAndSetText(float dist) {
|
||||||
|
String distance = OsmAndFormatter.getFormattedDistance(dist, map.getMyApplication());
|
||||||
|
int ls = distance.lastIndexOf(' ');
|
||||||
|
setText(distance.substring(0, ls), distance.substring(ls + 1));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
rulerControl.setText(title, null);
|
rulerControl.setText(title, null);
|
||||||
setRulerControlIcon(rulerControl, map.getMyApplication().getSettings().RULER_MODE.get());
|
setRulerControlIcon(rulerControl, map.getMyApplication().getSettings().RULER_MODE.get());
|
||||||
|
|
Loading…
Reference in a new issue