Merge branch 'master' of https://github.com/osmandapp/Osmand
This commit is contained in:
commit
33e5f4748d
4 changed files with 59 additions and 30 deletions
|
@ -780,7 +780,7 @@ public class BinaryInspector {
|
||||||
final MapStats mapObjectStats = new MapStats();
|
final MapStats mapObjectStats = new MapStats();
|
||||||
if(vInfo.osm){
|
if(vInfo.osm){
|
||||||
printToFile("<?xml version='1.0' encoding='UTF-8'?>\n" +
|
printToFile("<?xml version='1.0' encoding='UTF-8'?>\n" +
|
||||||
"<osm version='0.5'>\n");
|
"<osm version='0.6'>\n");
|
||||||
}
|
}
|
||||||
if(vInfo.isVStats()) {
|
if(vInfo.isVStats()) {
|
||||||
BinaryMapIndexReader.READ_STATS = true;
|
BinaryMapIndexReader.READ_STATS = true;
|
||||||
|
@ -952,7 +952,7 @@ public class BinaryInspector {
|
||||||
if(point) {
|
if(point) {
|
||||||
float lon= (float) MapUtils.get31LongitudeX(obj.getPoint31XTile(0));
|
float lon= (float) MapUtils.get31LongitudeX(obj.getPoint31XTile(0));
|
||||||
float lat = (float) MapUtils.get31LatitudeY(obj.getPoint31YTile(0));
|
float lat = (float) MapUtils.get31LatitudeY(obj.getPoint31YTile(0));
|
||||||
b.append("<node id = '" + OSM_ID++ + "' lat='" +lat+"' lon='"+lon+"' >\n" );
|
b.append("<node id = '" + OSM_ID++ + "' version='1' lat='" +lat+"' lon='"+lon+"' >\n" );
|
||||||
b.append(tags);
|
b.append(tags);
|
||||||
b.append("</node>\n");
|
b.append("</node>\n");
|
||||||
} else {
|
} else {
|
||||||
|
@ -962,7 +962,7 @@ public class BinaryInspector {
|
||||||
float lon = (float) MapUtils.get31LongitudeX(obj.getPoint31XTile(i));
|
float lon = (float) MapUtils.get31LongitudeX(obj.getPoint31XTile(i));
|
||||||
float lat = (float) MapUtils.get31LatitudeY(obj.getPoint31YTile(i));
|
float lat = (float) MapUtils.get31LatitudeY(obj.getPoint31YTile(i));
|
||||||
int id = OSM_ID++;
|
int id = OSM_ID++;
|
||||||
b.append("\t<node id = '" + id + "' lat='" +lat+"' lon='"+lon+"' />\n" );
|
b.append("\t<node id = '" + id + "' version='1' lat='" +lat+"' lon='"+lon+"' />\n" );
|
||||||
ids.add(id);
|
ids.add(id);
|
||||||
}
|
}
|
||||||
long outerId = printWay(ids, b, multipolygon ? null : tags);
|
long outerId = printWay(ids, b, multipolygon ? null : tags);
|
||||||
|
@ -974,13 +974,13 @@ public class BinaryInspector {
|
||||||
float lon = (float) MapUtils.get31LongitudeX(polygonInnerCoordinates[j][i]);
|
float lon = (float) MapUtils.get31LongitudeX(polygonInnerCoordinates[j][i]);
|
||||||
float lat = (float) MapUtils.get31LatitudeY(polygonInnerCoordinates[j][i + 1]);
|
float lat = (float) MapUtils.get31LatitudeY(polygonInnerCoordinates[j][i + 1]);
|
||||||
int id = OSM_ID++;
|
int id = OSM_ID++;
|
||||||
b.append("<node id = '" + id + "' lat='" + lat + "' lon='" + lon + "' />\n");
|
b.append("<node id = '" + id + "' version='1' lat='" + lat + "' lon='" + lon + "' />\n");
|
||||||
ids.add(id);
|
ids.add(id);
|
||||||
}
|
}
|
||||||
innerIds.add(printWay(ids, b, null));
|
innerIds.add(printWay(ids, b, null));
|
||||||
}
|
}
|
||||||
int id = OSM_ID++;
|
int id = OSM_ID++;
|
||||||
b.append("<relation id = '" + id + "'>\n" );
|
b.append("<relation id = '" + id + "' version='1'>\n" );
|
||||||
b.append(tags);
|
b.append(tags);
|
||||||
b.append("\t<member type='way' role='outer' ref= '" + outerId + "'/>\n" );
|
b.append("\t<member type='way' role='outer' ref= '" + outerId + "'/>\n" );
|
||||||
TLongIterator it = innerIds.iterator();
|
TLongIterator it = innerIds.iterator();
|
||||||
|
@ -995,7 +995,7 @@ public class BinaryInspector {
|
||||||
|
|
||||||
private long printWay(TLongArrayList ids, StringBuilder b , StringBuilder tags){
|
private long printWay(TLongArrayList ids, StringBuilder b , StringBuilder tags){
|
||||||
int id = OSM_ID++;
|
int id = OSM_ID++;
|
||||||
b.append("<way id = '" + id + "'>\n" );
|
b.append("<way id = '" + id + "' version='1'>\n" );
|
||||||
if(tags != null) {
|
if(tags != null) {
|
||||||
b.append(tags);
|
b.append(tags);
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,6 +119,10 @@ public class PerformLiveUpdateAsyncTask
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (context instanceof DownloadIndexesThread.DownloadEvents) {
|
||||||
|
((DownloadIndexesThread.DownloadEvents) context).downloadInProgress();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
|
||||||
for (WorldRegion group : groups) {
|
for (WorldRegion group : groups) {
|
||||||
String name = getHumanReadableName(group);
|
String name = getHumanReadableName(group);
|
||||||
regionNames.add(name);
|
regionNames.add(name);
|
||||||
queryRegionNames.put(name, group.getRegionDownloadName());
|
queryRegionNames.put(name, group == root ? "" : group.getRegionDownloadName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,21 +13,26 @@ import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
public class DoubleTapScaleDetector {
|
public class DoubleTapScaleDetector {
|
||||||
private static final Log LOG = PlatformUtil.getLog(DoubleTapScaleDetector.class);
|
private static final Log LOG = PlatformUtil.getLog(DoubleTapScaleDetector.class);
|
||||||
private static final int DOUBLE_TAPPING_DELTA = ViewConfiguration.getTapTimeout() + 100;
|
private static final int DOUBLE_TAP_TIMEOUT = ViewConfiguration.getDoubleTapTimeout();
|
||||||
|
private static final int DOUBLE_TAP_MIN_TIME = 40;
|
||||||
private static final int DP_PER_1X = 200;
|
private static final int DP_PER_1X = 200;
|
||||||
|
|
||||||
private final DoubleTapZoomListener listener;
|
private final DoubleTapZoomListener listener;
|
||||||
protected final Context ctx;
|
protected final Context ctx;
|
||||||
|
|
||||||
private long startTime = 0;
|
|
||||||
private boolean isDoubleTapping = false;
|
private boolean isDoubleTapping = false;
|
||||||
private float startX;
|
|
||||||
private float startY;
|
|
||||||
private float scale;
|
private float scale;
|
||||||
|
private MotionEvent firstDown;
|
||||||
|
private MotionEvent firstUp;
|
||||||
|
private int mDoubleTapSlopSquare;
|
||||||
|
|
||||||
public DoubleTapScaleDetector(Context ctx, DoubleTapZoomListener listener) {
|
public DoubleTapScaleDetector(Context ctx, DoubleTapZoomListener listener) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
|
||||||
|
final ViewConfiguration configuration = ViewConfiguration.get(ctx);
|
||||||
|
int doubleTapSlop = configuration.getScaledTouchSlop();
|
||||||
|
mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
|
@ -41,26 +46,28 @@ public class DoubleTapScaleDetector {
|
||||||
listener.onZoomEnded(scale, 0);
|
listener.onZoomEnded(scale, 0);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
startTime = currentTime;
|
firstUp = MotionEvent.obtain(event);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
} else if (event.getAction() == MotionEvent.ACTION_DOWN && !isDoubleTapping
|
} else {
|
||||||
&& currentTime - startTime < DOUBLE_TAPPING_DELTA) {
|
if (event.getAction() == MotionEvent.ACTION_DOWN && !isDoubleTapping) {
|
||||||
isDoubleTapping = true;
|
if (isConsideredDoubleTap(firstDown, firstUp, event)) {
|
||||||
startX = event.getX();
|
isDoubleTapping = true;
|
||||||
startY = event.getY();
|
float x = event.getX();
|
||||||
listener.onGestureInit(startX, startY, startX, startY);
|
float y = event.getY();
|
||||||
listener.onZoomStarted(new PointF(startX, startY));
|
listener.onGestureInit(x, y, x, y);
|
||||||
return true;
|
listener.onZoomStarted(new PointF(x, y));
|
||||||
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
return true;
|
||||||
if (isDoubleTapping) {
|
} else {
|
||||||
float delta = convertPxToDp((int) (startY - event.getY()));
|
firstDown = MotionEvent.obtain(event);
|
||||||
float scaleDelta = delta / DP_PER_1X;
|
}
|
||||||
scale = 1 - scaleDelta;
|
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||||
listener.onZoomingOrRotating(scale, 0);
|
if (isDoubleTapping) {
|
||||||
return true;
|
float delta = convertPxToDp((int) (firstDown.getY() - event.getY()));
|
||||||
} else {
|
float scaleDelta = delta / DP_PER_1X;
|
||||||
return false;
|
scale = 1 - scaleDelta;
|
||||||
|
listener.onZoomingOrRotating(scale, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -74,6 +81,24 @@ public class DoubleTapScaleDetector {
|
||||||
return Math.round(px / (Resources.getSystem().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT));
|
return Math.round(px / (Resources.getSystem().getDisplayMetrics().xdpi / DisplayMetrics.DENSITY_DEFAULT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final boolean isConsideredDoubleTap(MotionEvent firstDown,
|
||||||
|
MotionEvent firstUp,
|
||||||
|
MotionEvent secondDown) {
|
||||||
|
if (firstDown == null || firstUp == null || secondDown == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final long deltaTime = secondDown.getEventTime() - firstUp.getEventTime();
|
||||||
|
if (deltaTime > DOUBLE_TAP_TIMEOUT || deltaTime < DOUBLE_TAP_MIN_TIME) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int deltaX = (int) firstDown.getX() - (int) secondDown.getX();
|
||||||
|
int deltaY = (int) firstDown.getY() - (int) secondDown.getY();
|
||||||
|
int squared = deltaX * deltaX + deltaY * deltaY;
|
||||||
|
boolean toReturn = squared < mDoubleTapSlopSquare;
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
public interface DoubleTapZoomListener {
|
public interface DoubleTapZoomListener {
|
||||||
public void onZoomStarted(PointF centerPoint);
|
public void onZoomStarted(PointF centerPoint);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue