Adding scale gestures in progress.

This commit is contained in:
GaidamakUA 2016-01-18 13:19:00 +02:00
parent e4d3286f03
commit 3d15fb9659

View file

@ -1,10 +1,33 @@
package net.osmand.plus.views;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.PointF;
import android.graphics.RectF;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.util.DisplayMetrics;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;
import net.osmand.PlatformUtil;
import net.osmand.access.AccessibilityActionsProvider;
@ -30,32 +53,10 @@ import net.osmand.util.MapUtils;
import org.apache.commons.logging.Log;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.PointF;
import android.graphics.RectF;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.util.DisplayMetrics;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class OsmandMapTileView implements IMapDownloaderCallback {
@ -160,6 +161,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
private Paint paintImg;
private boolean afterTwoFingerTap = false;
private ScaleGestureDetector scaleDetector;
TwoFingerTapDetector twoFingerTapDetector = new TwoFingerTapDetector() {
@Override
public void onTwoFingerTap() {
@ -209,6 +211,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
handler = new Handler();
baseHandler = new Handler(application.getResourceManager().getRenderingBufferImageThread().getLooper());
animatedDraggingThread = new AnimateDraggingMapThread(this);
scaleDetector = new ScaleGestureDetector(ctx, new MapOnScaleGestureListener());
gestureDetector = new GestureDetector(ctx, new MapExplorer(this, new MapTileViewOnGestureListener()));
multiTouchSupport = new MultiTouchSupport(ctx, new MapTileViewMultiTouchZoomListener());
@ -755,6 +758,8 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
mapRenderer.resumeSymbolsUpdate();
}
}
// scaleDetector.onTouchEvent(event);
// if (scaleDetector.isInProgress()) {
if (twoFingerTapDetector.onTouchEvent(event)) {
return true;
}
@ -992,6 +997,24 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
}
}
private class MapOnScaleGestureListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
private double scaleFactor;
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
scaleFactor = 1;
return true;
}
@Override
public boolean onScale(ScaleGestureDetector detector) {
log.debug("Scale factor=" + detector.getScaleFactor());
scaleFactor *= detector.getScaleFactor();
getAnimatedDraggingThread().startZooming(getZoom() - 1, currentViewport.getZoomFloatPart(), true);
return true;
}
}
public Resources getResources() {
return application.getResources();
}