Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-01-21 08:53:55 +01:00
commit 9c08ad80c8
3 changed files with 35 additions and 32 deletions

View file

@ -27,7 +27,7 @@ import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceUpdateFreq
public class PerformLiveUpdateAsyncTask public class PerformLiveUpdateAsyncTask
extends AsyncTask<String, Object, IncrementalChangesManager.IncrementalUpdateList> { extends AsyncTask<String, Object, IncrementalChangesManager.IncrementalUpdateList> {
private final static Log LOG = PlatformUtil.getLog(OsmLiveActivity.class); private final static Log LOG = PlatformUtil.getLog(PerformLiveUpdateAsyncTask.class);
private final Context context; private final Context context;
private final LocalIndexInfo localIndexInfo; private final LocalIndexInfo localIndexInfo;
@ -42,6 +42,7 @@ public class PerformLiveUpdateAsyncTask
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
LOG.debug("onPreExecute");
if (context instanceof AbstractDownloadActivity) { if (context instanceof AbstractDownloadActivity) {
AbstractDownloadActivity activity = (AbstractDownloadActivity) context; AbstractDownloadActivity activity = (AbstractDownloadActivity) context;
activity.setSupportProgressBarIndeterminateVisibility(true); activity.setSupportProgressBarIndeterminateVisibility(true);
@ -58,6 +59,7 @@ public class PerformLiveUpdateAsyncTask
@Override @Override
protected IncrementalChangesManager.IncrementalUpdateList doInBackground(String... params) { protected IncrementalChangesManager.IncrementalUpdateList doInBackground(String... params) {
LOG.debug("doInBackground");
final OsmandApplication myApplication = getMyApplication(); final OsmandApplication myApplication = getMyApplication();
IncrementalChangesManager cm = myApplication.getResourceManager().getChangesManager(); IncrementalChangesManager cm = myApplication.getResourceManager().getChangesManager();
return cm.getUpdatesByMonth(params[0]); return cm.getUpdatesByMonth(params[0]);
@ -65,6 +67,7 @@ public class PerformLiveUpdateAsyncTask
@Override @Override
protected void onPostExecute(IncrementalChangesManager.IncrementalUpdateList result) { protected void onPostExecute(IncrementalChangesManager.IncrementalUpdateList result) {
LOG.debug("onPostExecute");
if (context instanceof AbstractDownloadActivity) { if (context instanceof AbstractDownloadActivity) {
AbstractDownloadActivity activity = (AbstractDownloadActivity) context; AbstractDownloadActivity activity = (AbstractDownloadActivity) context;
activity.setSupportProgressBarIndeterminateVisibility(false); activity.setSupportProgressBarIndeterminateVisibility(false);

View file

@ -14,7 +14,7 @@ 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_TAPPING_DELTA = ViewConfiguration.getTapTimeout() + 100;
private static final int DP_PER_1X = 100; private static final int DP_PER_1X = 200;
private final DoubleTapZoomListener listener; private final DoubleTapZoomListener listener;
protected final Context ctx; protected final Context ctx;
@ -23,6 +23,7 @@ public class DoubleTapScaleDetector {
private boolean isDoubleTapping = false; private boolean isDoubleTapping = false;
private float startX; private float startX;
private float startY; private float startY;
private float scale;
public DoubleTapScaleDetector(Context ctx, DoubleTapZoomListener listener) { public DoubleTapScaleDetector(Context ctx, DoubleTapZoomListener listener) {
this.ctx = ctx; this.ctx = ctx;
@ -37,7 +38,7 @@ public class DoubleTapScaleDetector {
if (event.getAction() == MotionEvent.ACTION_UP) { if (event.getAction() == MotionEvent.ACTION_UP) {
if (isDoubleTapping) { if (isDoubleTapping) {
isDoubleTapping = false; isDoubleTapping = false;
listener.onZoomEnded(1, 0); listener.onZoomEnded(scale, 0);
return true; return true;
} else { } else {
startTime = currentTime; startTime = currentTime;
@ -55,7 +56,7 @@ public class DoubleTapScaleDetector {
if (isDoubleTapping) { if (isDoubleTapping) {
float delta = convertPxToDp((int) (startY - event.getY())); float delta = convertPxToDp((int) (startY - event.getY()));
float scaleDelta = delta / DP_PER_1X; float scaleDelta = delta / DP_PER_1X;
float scale = 1 - scaleDelta; scale = 1 - scaleDelta;
listener.onZoomingOrRotating(scale, 0); listener.onZoomingOrRotating(scale, 0);
return true; return true;
} else { } else {

View file

@ -114,9 +114,9 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
private float rotate; // accumulate private float rotate; // accumulate
private int mapPosition; private int mapPosition;
private int mapPositionX; private int mapPositionX;
private boolean showMapPosition = true; private boolean showMapPosition = true;
private IMapLocationListener locationListener; private IMapLocationListener locationListener;
@ -179,7 +179,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
public void init(Context ctx, int w, int h) { public void init(Context ctx, int w, int h) {
application = (OsmandApplication) ctx.getApplicationContext(); application = (OsmandApplication) ctx.getApplicationContext();
settings = application.getSettings(); settings = application.getSettings();
paintGrayFill = new Paint(); paintGrayFill = new Paint();
paintGrayFill.setColor(Color.GRAY); paintGrayFill.setColor(Color.GRAY);
paintGrayFill.setStyle(Style.FILL); paintGrayFill.setStyle(Style.FILL);
@ -225,7 +225,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
currentViewport.setDensity(dm.density); currentViewport.setDensity(dm.density);
currentViewport.setMapDensity(getSettingsMapDensity()); currentViewport.setMapDensity(getSettingsMapDensity());
} }
public void setView(View view) { public void setView(View view) {
this.view = view; this.view = view;
view.setClickable(true); view.setClickable(true);
@ -267,9 +267,9 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
zOrders.remove(layer); zOrders.remove(layer);
layer.destroyLayer(); layer.destroyLayer();
} }
public synchronized void removeAllLayers() { public synchronized void removeAllLayers() {
while(layers.size() > 0) { while (layers.size() > 0) {
removeLayer(layers.get(0)); removeLayer(layers.get(0));
} }
} }
@ -356,7 +356,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
public int getZoom() { public int getZoom() {
return currentViewport.getZoom(); return currentViewport.getZoom();
} }
public double getZoomFractionalPart() { public double getZoomFractionalPart() {
return currentViewport.getZoomFloatPart(); return currentViewport.getZoomFloatPart();
} }
@ -406,7 +406,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
public void setMapPosition(int type) { public void setMapPosition(int type) {
this.mapPosition = type; this.mapPosition = type;
} }
public void setMapPositionX(int type) { public void setMapPositionX(int type) {
this.mapPositionX = type; this.mapPositionX = type;
} }
@ -481,7 +481,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
} }
private void refreshMapInternal(DrawSettings drawSettings) { private void refreshMapInternal(DrawSettings drawSettings) {
if(view == null) { if (view == null) {
return; return;
} }
final float ratioy = mapPosition == OsmandSettings.BOTTOM_CONSTANT ? 0.85f : 0.5f; final float ratioy = mapPosition == OsmandSettings.BOTTOM_CONSTANT ? 0.85f : 0.5f;
@ -489,7 +489,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
final int cy = (int) (ratioy * view.getHeight()); final int cy = (int) (ratioy * view.getHeight());
final int cx = (int) (ratiox * view.getWidth()); final int cx = (int) (ratiox * view.getWidth());
if (currentViewport.getPixWidth() != view.getWidth() || currentViewport.getPixHeight() != view.getHeight() || if (currentViewport.getPixWidth() != view.getWidth() || currentViewport.getPixHeight() != view.getHeight() ||
currentViewport.getCenterPixelY() != cy || currentViewport.getCenterPixelY() != cy ||
currentViewport.getCenterPixelX() != cx) { currentViewport.getCenterPixelX() != cx) {
currentViewport.setPixelDimensions(view.getWidth(), view.getHeight(), ratiox, ratioy); currentViewport.setPixelDimensions(view.getWidth(), view.getHeight(), ratiox, ratioy);
refreshBufferImage(drawSettings); refreshBufferImage(drawSettings);
@ -544,7 +544,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
@SuppressLint("WrongCall") @SuppressLint("WrongCall")
public void drawOverMap(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) { public void drawOverMap(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
if(mapRenderer == null) { if (mapRenderer == null) {
fillCanvas(canvas, drawSettings); fillCanvas(canvas, drawSettings);
} }
final QuadPoint c = tileBox.getCenterPixelPoint(); final QuadPoint c = tileBox.getCenterPixelPoint();
@ -565,7 +565,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
if (!layer.drawInScreenPixels()) { if (!layer.drawInScreenPixels()) {
canvas.rotate(tileBox.getRotate(), c.x, c.y); canvas.rotate(tileBox.getRotate(), c.x, c.y);
} }
if(mapRenderer != null) { if (mapRenderer != null) {
layer.onPrepareBufferImage(canvas, tileBox, drawSettings); layer.onPrepareBufferImage(canvas, tileBox, drawSettings);
} }
layer.onDraw(canvas, tileBox, drawSettings); layer.onDraw(canvas, tileBox, drawSettings);
@ -576,7 +576,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
} }
if (showMapPosition || animatedDraggingThread.isAnimatingZoom()) { if (showMapPosition || animatedDraggingThread.isAnimatingZoom()) {
drawMapPosition(canvas, c.x, c.y); drawMapPosition(canvas, c.x, c.y);
} else if(multiTouchSupport.isInZoomMode() || doubleTapScaleDetector.isInZoomMode()) { } else if (multiTouchSupport.isInZoomMode() || doubleTapScaleDetector.isInZoomMode()) {
drawMapPosition(canvas, multiTouchSupport.getCenterPoint().x, multiTouchSupport.getCenterPoint().y); drawMapPosition(canvas, multiTouchSupport.getCenterPoint().x, multiTouchSupport.getCenterPoint().y);
} }
} }
@ -587,7 +587,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
} }
private void refreshBufferImage(final DrawSettings drawSettings) { private void refreshBufferImage(final DrawSettings drawSettings) {
if(mapRenderer != null) { if (mapRenderer != null) {
return; return;
} }
if (!baseHandler.hasMessages(BASE_REFRESH_MESSAGE) || drawSettings.isUpdateVectorRendering()) { if (!baseHandler.hasMessages(BASE_REFRESH_MESSAGE) || drawSettings.isUpdateVectorRendering()) {
@ -770,19 +770,18 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
return true; return true;
} }
} }
if (!doubleTapScaleDetector.onTouchEvent(event)) { if (!multiTouchSupport.onTouchEvent(event)) {
if (!multiTouchSupport.onTouchEvent(event)) {
/* return */ /* return */
gestureDetector.onTouchEvent(event); doubleTapScaleDetector.onTouchEvent(event);
} gestureDetector.onTouchEvent(event);
} }
return true; return true;
} }
public void setMapRender(MapRendererView mapRenderer) { public void setMapRender(MapRendererView mapRenderer) {
this.mapRenderer = mapRenderer; this.mapRenderer = mapRenderer;
} }
public MapRendererView getMapRenderer() { public MapRendererView getMapRenderer() {
return mapRenderer; return mapRenderer;
} }
@ -903,18 +902,18 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
float calcRotate = calc.getRotate() + angle; float calcRotate = calc.getRotate() + angle;
calc.setRotate(calcRotate); calc.setRotate(calcRotate);
calc.setZoomAndAnimation(initialViewport.getZoom(), calc.setZoomAndAnimation(initialViewport.getZoom(),
dz, initialViewport.getZoomFloatPart()); dz, initialViewport.getZoomFloatPart());
final LatLon r = calc.getLatLonFromPixel(cp.x + dx, cp.y + dy); final LatLon r = calc.getLatLonFromPixel(cp.x + dx, cp.y + dy);
setLatLon(r.getLatitude(), r.getLongitude()); setLatLon(r.getLatitude(), r.getLongitude());
int baseZoom = initialViewport.getZoom(); int baseZoom = initialViewport.getZoom();
while(initialViewport.getZoomFloatPart() + dz > 1) { while (initialViewport.getZoomFloatPart() + dz > 1) {
dz --; dz--;
baseZoom ++; baseZoom++;
} }
while(initialViewport.getZoomFloatPart() + dz < 0) { while (initialViewport.getZoomFloatPart() + dz < 0) {
dz ++; dz++;
baseZoom --; baseZoom--;
} }
zoomToAnimate(baseZoom, dz, true); zoomToAnimate(baseZoom, dz, true);
rotateToAnimate(calcRotate); rotateToAnimate(calcRotate);
@ -1019,7 +1018,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
public Resources getResources() { public Resources getResources() {
return application.getResources(); return application.getResources();
} }
public Context getContext() { public Context getContext() {
return activity; return activity;
} }