From 75a839c1d3d30a34a7a7fb1aa9b84692f308afb5 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Thu, 21 Jan 2016 10:11:37 +0200 Subject: [PATCH 1/6] Update date if no updates available. --- .../net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java b/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java index 9e6e3eb5bb..b7c063e9b1 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java @@ -119,6 +119,8 @@ public class PerformLiveUpdateAsyncTask } } } + } else { + ((DownloadIndexesThread.DownloadEvents) context).downloadHasFinished(); } } } From f0991e246429b9248236f6c5d813023ba323cfba Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Thu, 21 Jan 2016 10:25:26 +0200 Subject: [PATCH 2/6] Fix world region reports URL. --- OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java index 56a50fb7b9..2ab27b22ae 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/ReportsFragment.java @@ -153,7 +153,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti for (WorldRegion group : groups) { String name = getHumanReadableName(group); regionNames.add(name); - queryRegionNames.put(name, group.getRegionDownloadName()); + queryRegionNames.put(name, group == root ? "" : group.getRegionDownloadName()); } } From 66175e3ce8cb0148b3c1b67e3aa5ae000d2d0fda Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Thu, 21 Jan 2016 10:27:42 +0200 Subject: [PATCH 3/6] Fix ClassCastException. --- .../osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java b/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java index b7c063e9b1..c2e6e78142 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/PerformLiveUpdateAsyncTask.java @@ -120,7 +120,9 @@ public class PerformLiveUpdateAsyncTask } } } else { - ((DownloadIndexesThread.DownloadEvents) context).downloadHasFinished(); + if (context instanceof DownloadIndexesThread.DownloadEvents) { + ((DownloadIndexesThread.DownloadEvents) context).downloadInProgress(); + } } } } From 266c085fbd2531e0ac4ab9d553399499bc636267 Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Thu, 21 Jan 2016 14:43:12 +0200 Subject: [PATCH 4/6] Better touch handling for doubletap scale. --- .../plus/views/DoubleTapScaleDetector.java | 71 +++++++++++++------ 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java b/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java index e04986ea8d..076cdf4bb4 100644 --- a/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java +++ b/OsmAnd/src/net/osmand/plus/views/DoubleTapScaleDetector.java @@ -13,21 +13,26 @@ import org.apache.commons.logging.Log; public class DoubleTapScaleDetector { 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 final DoubleTapZoomListener listener; protected final Context ctx; - private long startTime = 0; private boolean isDoubleTapping = false; - private float startX; - private float startY; private float scale; + private MotionEvent firstDown; + private MotionEvent firstUp; + private int mDoubleTapSlopSquare; public DoubleTapScaleDetector(Context ctx, DoubleTapZoomListener listener) { this.ctx = ctx; this.listener = listener; + + final ViewConfiguration configuration = ViewConfiguration.get(ctx); + int doubleTapSlop = configuration.getScaledTouchSlop(); + mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop; } public boolean onTouchEvent(MotionEvent event) { @@ -41,26 +46,28 @@ public class DoubleTapScaleDetector { listener.onZoomEnded(scale, 0); return true; } else { - startTime = currentTime; - return true; + firstUp = MotionEvent.obtain(event); } - } else if (event.getAction() == MotionEvent.ACTION_DOWN && !isDoubleTapping - && currentTime - startTime < DOUBLE_TAPPING_DELTA) { - isDoubleTapping = true; - startX = event.getX(); - startY = event.getY(); - listener.onGestureInit(startX, startY, startX, startY); - listener.onZoomStarted(new PointF(startX, startY)); - return true; - } else if (event.getAction() == MotionEvent.ACTION_MOVE) { - if (isDoubleTapping) { - float delta = convertPxToDp((int) (startY - event.getY())); - float scaleDelta = delta / DP_PER_1X; - scale = 1 - scaleDelta; - listener.onZoomingOrRotating(scale, 0); - return true; - } else { - return false; + } else { + if (event.getAction() == MotionEvent.ACTION_DOWN && !isDoubleTapping) { + if (isConsideredDoubleTap(firstDown, firstUp, event)) { + isDoubleTapping = true; + float x = event.getX(); + float y = event.getY(); + listener.onGestureInit(x, y, x, y); + listener.onZoomStarted(new PointF(x, y)); + return true; + } else { + firstDown = MotionEvent.obtain(event); + } + } else if (event.getAction() == MotionEvent.ACTION_MOVE) { + if (isDoubleTapping) { + float delta = convertPxToDp((int) (firstDown.getY() - event.getY())); + float scaleDelta = delta / DP_PER_1X; + scale = 1 - scaleDelta; + listener.onZoomingOrRotating(scale, 0); + return true; + } } } return false; @@ -74,6 +81,24 @@ public class DoubleTapScaleDetector { 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 void onZoomStarted(PointF centerPoint); From e550ba10d21fedcf98150b212854f2a184e0fe8c Mon Sep 17 00:00:00 2001 From: xmd5a Date: Thu, 21 Jan 2016 17:13:08 +0300 Subject: [PATCH 5/6] Fix osm version in BinaryInspector --- OsmAnd-java/src/net/osmand/binary/BinaryInspector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java b/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java index 7c57533581..21905665ca 100644 --- a/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java +++ b/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java @@ -780,7 +780,7 @@ public class BinaryInspector { final MapStats mapObjectStats = new MapStats(); if(vInfo.osm){ printToFile("\n" + - "\n"); + "\n"); } if(vInfo.isVStats()) { BinaryMapIndexReader.READ_STATS = true; From 92ece464da7e9d44b0f67d8a0de4a127033157f3 Mon Sep 17 00:00:00 2001 From: xmd5a Date: Thu, 21 Jan 2016 17:22:00 +0300 Subject: [PATCH 6/6] BinaryInspector: output to osm v0.6 --- OsmAnd-java/src/net/osmand/binary/BinaryInspector.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java b/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java index 21905665ca..06496e4a55 100644 --- a/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java +++ b/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java @@ -952,7 +952,7 @@ public class BinaryInspector { if(point) { float lon= (float) MapUtils.get31LongitudeX(obj.getPoint31XTile(0)); float lat = (float) MapUtils.get31LatitudeY(obj.getPoint31YTile(0)); - b.append("\n" ); + b.append("\n" ); b.append(tags); b.append("\n"); } else { @@ -962,7 +962,7 @@ public class BinaryInspector { float lon = (float) MapUtils.get31LongitudeX(obj.getPoint31XTile(i)); float lat = (float) MapUtils.get31LatitudeY(obj.getPoint31YTile(i)); int id = OSM_ID++; - b.append("\t\n" ); + b.append("\t\n" ); ids.add(id); } long outerId = printWay(ids, b, multipolygon ? null : tags); @@ -974,13 +974,13 @@ public class BinaryInspector { float lon = (float) MapUtils.get31LongitudeX(polygonInnerCoordinates[j][i]); float lat = (float) MapUtils.get31LatitudeY(polygonInnerCoordinates[j][i + 1]); int id = OSM_ID++; - b.append("\n"); + b.append("\n"); ids.add(id); } innerIds.add(printWay(ids, b, null)); } int id = OSM_ID++; - b.append("\n" ); + b.append("\n" ); b.append(tags); b.append("\t\n" ); TLongIterator it = innerIds.iterator(); @@ -995,7 +995,7 @@ public class BinaryInspector { private long printWay(TLongArrayList ids, StringBuilder b , StringBuilder tags){ int id = OSM_ID++; - b.append("\n" ); + b.append("\n" ); if(tags != null) { b.append(tags); }