Add 2 fingers rotation
This commit is contained in:
parent
3a74fb7796
commit
3752cd25ab
17 changed files with 142 additions and 151 deletions
|
@ -49,14 +49,8 @@ public class RenderingContext {
|
|||
|
||||
private float density = 1;
|
||||
|
||||
public void setDensityValue(boolean highResMode, float mapTextSize, float density) {
|
||||
// boolean highResMode = false;
|
||||
// float mapTextSize = 1;
|
||||
if (highResMode && density > 1) {
|
||||
this.density = density * mapTextSize;
|
||||
} else {
|
||||
this.density = mapTextSize;
|
||||
}
|
||||
public void setDensityValue(float density) {
|
||||
this.density = density ;
|
||||
}
|
||||
|
||||
public float getDensityValue(float val) {
|
||||
|
|
|
@ -56,6 +56,7 @@ public class RotatedTileBox {
|
|||
rotateSin = r.rotateSin;
|
||||
oxTile = r.oxTile;
|
||||
oyTile =r.oyTile;
|
||||
if (r.tileBounds != null) {
|
||||
tileBounds = new QuadRect(r.tileBounds);
|
||||
latLonBounds = new QuadRect(r.latLonBounds);
|
||||
tileLT = new QuadPoint(r.tileLT);
|
||||
|
@ -63,6 +64,7 @@ public class RotatedTileBox {
|
|||
tileRB = new QuadPoint(r.tileRB);
|
||||
tileLB = new QuadPoint(r.tileLB);
|
||||
}
|
||||
}
|
||||
|
||||
private void init(int pixWidth, int pixHeight, float centerX, float centerY, double lat, double lon,
|
||||
int zoom, float zoomScale, float rotate, float density) {
|
||||
|
@ -94,7 +96,9 @@ public class RotatedTileBox {
|
|||
while(rotate > 360){
|
||||
rotate -= 360;
|
||||
}
|
||||
calculateTileRectangle();
|
||||
tileBounds = null;
|
||||
// lazy
|
||||
// calculateTileRectangle();
|
||||
}
|
||||
|
||||
public double getLatFromPixel(float x, float y) {
|
||||
|
@ -163,6 +167,7 @@ public class RotatedTileBox {
|
|||
|
||||
|
||||
public QuadRect getTileBounds() {
|
||||
checkTileRectangleCalculated();
|
||||
return tileBounds;
|
||||
}
|
||||
|
||||
|
@ -266,6 +271,7 @@ public class RotatedTileBox {
|
|||
}
|
||||
|
||||
public QuadRect getLatLonBounds() {
|
||||
checkTileRectangleCalculated();
|
||||
return latLonBounds;
|
||||
}
|
||||
|
||||
|
@ -326,6 +332,12 @@ public class RotatedTileBox {
|
|||
calculateDerivedFields();
|
||||
}
|
||||
|
||||
public void setZoomAndAnimation(int zoom, float zoomAnimation) {
|
||||
this.zoomAnimation = zoomAnimation;
|
||||
this.zoom = zoom;
|
||||
calculateDerivedFields();
|
||||
}
|
||||
|
||||
public void setCenterLocation(float ratiocx, float ratiocy) {
|
||||
this.cx = (int) (pixWidth * ratiocx);
|
||||
this.cy = (int) (pixHeight * ratiocy);
|
||||
|
@ -333,16 +345,25 @@ public class RotatedTileBox {
|
|||
}
|
||||
|
||||
public QuadPoint getLeftTopTilePoint() {
|
||||
checkTileRectangleCalculated();
|
||||
return tileLT;
|
||||
}
|
||||
|
||||
public LatLon getLeftTopLatLon() {
|
||||
checkTileRectangleCalculated();
|
||||
return new LatLon(MapUtils.getLatitudeFromTile(zoom, tileLT.y),
|
||||
MapUtils.getLongitudeFromTile(zoom, tileLT.x));
|
||||
|
||||
}
|
||||
|
||||
private void checkTileRectangleCalculated() {
|
||||
if(tileBounds == null){
|
||||
calculateTileRectangle();;
|
||||
}
|
||||
}
|
||||
|
||||
public LatLon getRightBottomLatLon() {
|
||||
checkTileRectangleCalculated();
|
||||
return new LatLon(MapUtils.getLatitudeFromTile(zoom, tileRB.y),
|
||||
MapUtils.getLongitudeFromTile(zoom, tileRB.x));
|
||||
}
|
||||
|
@ -353,6 +374,11 @@ public class RotatedTileBox {
|
|||
calculateDerivedFields();
|
||||
}
|
||||
|
||||
public void setZoom(int zoom) {
|
||||
this.zoom = zoom;
|
||||
calculateDerivedFields();
|
||||
}
|
||||
|
||||
public void setZoom(int zoom, float zoomScale, float zoomToAnimate) {
|
||||
this.zoom = zoom;
|
||||
this.zoomScale = zoomScale;
|
||||
|
@ -379,6 +405,8 @@ public class RotatedTileBox {
|
|||
|
||||
|
||||
public boolean containsTileBox(RotatedTileBox box) {
|
||||
checkTileRectangleCalculated();
|
||||
box.checkTileRectangleCalculated();
|
||||
QuadPoint temp = new QuadPoint();
|
||||
if(box.zoom != zoom){
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
@ -612,14 +612,11 @@ public class OsmandSettings {
|
|||
new BooleanAccessibilityPreference("accessibility_extensions", false).makeGlobal();
|
||||
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Boolean> USE_HIGH_RES_MAPS = new BooleanPreference("use_high_res_maps", true).makeGlobal().cache();
|
||||
|
||||
public final OsmandPreference<Boolean> USE_MAGNETIC_FIELD_SENSOR_COMPASS = new BooleanPreference("use_magnetic_field_sensor_compass", true).makeGlobal().cache();
|
||||
public final OsmandPreference<Boolean> USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference("use_kalman_filter_compass", true).makeGlobal().cache();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Float> MAP_TEXT_SIZE = new FloatPreference("map_text_size", 1.0f).makeProfile().cache();
|
||||
// public final OsmandPreference<Float> MAP_TEXT_SIZE = new FloatPreference("map_text_size", 1.0f).makeProfile().cache();
|
||||
public final OsmandPreference<Float> MAP_ZOOM_SCALE_BY_DENSITY = new FloatPreference("map_zoom_scale_by_density", 1.0f).makeProfile().cache();
|
||||
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
|
|
|
@ -550,6 +550,7 @@ public class MapActivity extends AccessibleActivity {
|
|||
mapLayers.getMapInfoLayer().recreateControls();
|
||||
}
|
||||
mapLayers.updateLayers(mapView);
|
||||
mapView.setComplexZoom(mapView.getZoom(), mapView.getSettingsZoomScale());
|
||||
app.getDaynightHelper().startSensorIfNeeded(new StateChangedListener<Boolean>() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -100,8 +100,6 @@ public class SettingsRasterMapsActivity extends SettingsBaseActivity {
|
|||
R.string.modify_transparency, 0, 255);
|
||||
cat.addPreference(sp);
|
||||
|
||||
cat.addPreference(createCheckBoxPreference(settings.USE_HIGH_RES_MAPS,
|
||||
R.string.use_high_res_maps, R.string.use_high_res_maps_descr));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -565,8 +565,7 @@ public class MapRenderRepositories {
|
|||
currentRenderingContext.height = (int) (requestedBox.getPixHeight() / mapDensity);
|
||||
currentRenderingContext.nightMode = nightMode;
|
||||
currentRenderingContext.useEnglishNames = prefs.USE_ENGLISH_NAMES.get();
|
||||
currentRenderingContext.setDensityValue(prefs.USE_HIGH_RES_MAPS.get(),
|
||||
prefs.MAP_TEXT_SIZE.get(), renderer.getDensity());
|
||||
currentRenderingContext.setDensityValue(renderer.getDensity() * prefs.MAP_ZOOM_SCALE_BY_DENSITY.get());
|
||||
// init rendering context
|
||||
currentRenderingContext.tileDivisor = (float) MapUtils.getPowZoom(31 - requestedBox.getZoom());
|
||||
if (checkWhetherInterrupted()) {
|
||||
|
|
|
@ -128,7 +128,7 @@ public class AnimateDraggingMapThread {
|
|||
float mStX = rb.getPixXFromLatLon(startLat, startLon) - rb.getPixXFromLatLon(finalLat, finalLon);
|
||||
float mStY = rb.getPixYFromLatLon(startLat, startLon) - rb.getPixYFromLatLon(finalLat, finalLon);
|
||||
while (Math.abs(mStX) + Math.abs(mStY) > 1200) {
|
||||
rb.setZoom(rb.getZoom() - 1, zoomScale);
|
||||
rb.setZoom(rb.getZoom() - 1);
|
||||
if(rb.getZoom() <= 4){
|
||||
skipAnimation = true;
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public class FavoritesLayer extends OsmandMapLayer implements ContextMenuLayer.I
|
|||
int ey = (int) point.y;
|
||||
for (FavouritePoint n : favorites.getFavouritePoints()) {
|
||||
int x = tb.getPixXFromLatLon(n.getLatitude(), n.getLongitude());
|
||||
int y = tb.getPixXFromLatLon(n.getLatitude(), n.getLongitude());
|
||||
int y = tb.getPixYFromLatLon(n.getLatitude(), n.getLongitude());
|
||||
if (calculateBelongs(ex, ey, x, y, r)) {
|
||||
res.add(n);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.londatiga.android.QuickAction;
|
|||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -46,7 +47,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
|
||||
private OsmandMapTileView view;
|
||||
private DisplayMetrics dm;
|
||||
private final MapActivity activity;
|
||||
private Handler showUIHandler;
|
||||
|
||||
|
@ -87,14 +87,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public void initLayer(final OsmandMapTileView view) {
|
||||
this.view = view;
|
||||
dm = new DisplayMetrics();
|
||||
WindowManager wmgr = (WindowManager) view.getContext().getSystemService(Context.WINDOW_SERVICE);
|
||||
wmgr.getDefaultDisplay().getMetrics(dm);
|
||||
scaleCoefficient = dm.density;
|
||||
if (Math.min(dm.widthPixels / (dm.density * 160), dm.heightPixels / (dm.density * 160)) > 2.5f) {
|
||||
// large screen
|
||||
scaleCoefficient *= 1.5f;
|
||||
}
|
||||
scaleCoefficient = view.getScaleCoefficient();
|
||||
FrameLayout parent = (FrameLayout) view.getParent();
|
||||
showUIHandler = new Handler();
|
||||
|
||||
|
@ -340,7 +333,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
}
|
||||
});
|
||||
zoomInButton.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
final OsmandSettings.OsmandPreference<Float> zoomScale = view.getSettings().MAP_ZOOM_SCALE_BY_DENSITY;
|
||||
final View.OnLongClickListener listener = new View.OnLongClickListener() {
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
|
@ -375,7 +369,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
float newScale = (float) Math.sqrt((tlist.get(which) - 100f) / 100f);
|
||||
view.getAnimatedDraggingThread().startZooming(view.getZoom(), newScale, false);
|
||||
zoomScale.set(newScale - (float) Math.sqrt(Math.max(view.getDensity() - 1, 0)));
|
||||
view.getAnimatedDraggingThread().startZooming(view.getZoom(), view.getSettingsZoomScale(), false);
|
||||
dialog.dismiss();
|
||||
|
||||
}
|
||||
|
@ -383,14 +378,15 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
bld.show();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
zoomInButton.setOnLongClickListener(listener);
|
||||
zoomOutButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
activity.changeZoom(- 1);
|
||||
}
|
||||
});
|
||||
zoomOutButton.setOnLongClickListener(listener);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -64,23 +64,41 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
|
||||
private MonitoringInfoControl monitoringServices;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public MapInfoLayer(MapActivity map, RouteLayer layer){
|
||||
this.map = map;
|
||||
this.routeLayer = layer;
|
||||
|
||||
WindowManager mgr = (WindowManager) map.getSystemService(Context.WINDOW_SERVICE);
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
mgr.getDefaultDisplay().getMetrics(dm);
|
||||
scaleCoefficient = dm.density;
|
||||
if (Math.min(dm.widthPixels / (dm.density * 160), dm.heightPixels / (dm.density * 160)) > 2.5f) {
|
||||
// large screen
|
||||
scaleCoefficient *= 1.5f;
|
||||
}
|
||||
|
||||
|
||||
public Paint getPaintSmallSubText() {
|
||||
return paintSmallSubText;
|
||||
}
|
||||
|
||||
public Paint getPaintText() {
|
||||
return paintText;
|
||||
}
|
||||
|
||||
public Paint getPaintSmallText() {
|
||||
return paintSmallText;
|
||||
}
|
||||
|
||||
public Paint getPaintSubText() {
|
||||
return paintSubText;
|
||||
}
|
||||
|
||||
public MonitoringInfoControl getMonitoringInfoControl() {
|
||||
return monitoringServices;
|
||||
}
|
||||
|
||||
public MapWidgetRegistry getMapInfoControls() {
|
||||
return mapInfoControls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initLayer(final OsmandMapTileView view) {
|
||||
this.view = view;
|
||||
scaleCoefficient = view.getScaleCoefficient();
|
||||
|
||||
paintText = new Paint();
|
||||
paintText.setStyle(Style.FILL_AND_STROKE);
|
||||
paintText.setColor(Color.BLACK);
|
||||
|
@ -114,37 +132,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
|
||||
|
||||
mapInfoControls = new MapWidgetRegistry(map.getMyApplication().getSettings());
|
||||
monitoringServices = new MonitoringInfoControl();
|
||||
}
|
||||
|
||||
|
||||
public Paint getPaintSmallSubText() {
|
||||
return paintSmallSubText;
|
||||
}
|
||||
|
||||
public Paint getPaintText() {
|
||||
return paintText;
|
||||
}
|
||||
|
||||
public Paint getPaintSmallText() {
|
||||
return paintSmallText;
|
||||
}
|
||||
|
||||
public Paint getPaintSubText() {
|
||||
return paintSubText;
|
||||
}
|
||||
|
||||
public MonitoringInfoControl getMonitoringInfoControl() {
|
||||
return monitoringServices;
|
||||
}
|
||||
|
||||
public MapWidgetRegistry getMapInfoControls() {
|
||||
return mapInfoControls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initLayer(final OsmandMapTileView view) {
|
||||
this.view = view;
|
||||
registerAllControls();
|
||||
createControls();
|
||||
}
|
||||
|
|
|
@ -129,20 +129,16 @@ public class MapTileLayer extends BaseMapLayer {
|
|||
final QuadRect tilesRect = tileBox.getTileBounds();
|
||||
|
||||
// recalculate for ellipsoid coordinates
|
||||
// TODO elliptic
|
||||
// if (map.isEllipticYTile()) {
|
||||
// return (float) MapUtils.getTileEllipsoidNumberY(getZoom(), currentViewport.get);
|
||||
// float ellipticYTile = view.getEllipticYTile();
|
||||
// tilesRect.bottom += (ellipticYTile - tileY);
|
||||
// tilesRect.top += (ellipticYTile - tileY);
|
||||
// tileY = ellipticYTile;
|
||||
// }
|
||||
float ellipticTileCorrection = 0;
|
||||
if (map.isEllipticYTile()) {
|
||||
ellipticTileCorrection = (float) (MapUtils.getTileEllipsoidNumberY(nzoom, tileBox.getLatitude()) - tileBox.getCenterTileY());
|
||||
}
|
||||
|
||||
|
||||
int left = (int) FloatMath.floor(tilesRect.left);
|
||||
int top = (int) FloatMath.floor(tilesRect.top);
|
||||
int top = (int) FloatMath.floor(tilesRect.top + ellipticTileCorrection);
|
||||
int width = (int) FloatMath.ceil(tilesRect.right - left);
|
||||
int height = (int) FloatMath.ceil(tilesRect.bottom - top);
|
||||
int height = (int) FloatMath.ceil(tilesRect.bottom + ellipticTileCorrection - top);
|
||||
|
||||
boolean useInternet = settings.USE_INTERNET_TO_DOWNLOAD_TILES.get()
|
||||
&& settings.isInternetConnectionAvailable() && map.couldBeDownloadedFromInternet();
|
||||
|
@ -154,25 +150,27 @@ public class MapTileLayer extends BaseMapLayer {
|
|||
for (int j = 0; j < height; j++) {
|
||||
int leftPlusI = left + i;
|
||||
int topPlusJ = top + j;
|
||||
|
||||
int x1 = tileBox.getPixXFromTileXNoRot(leftPlusI);
|
||||
int x2 = tileBox.getPixXFromTileXNoRot(leftPlusI + 1);
|
||||
int y1 = tileBox.getPixYFromTileYNoRot(topPlusJ);
|
||||
int y2 = tileBox.getPixYFromTileYNoRot(topPlusJ + 1);
|
||||
// TODO elliptic
|
||||
// float y1 = (top + j - tileY) * ftileSize + h;
|
||||
String ordImgTile = mgr.calculateTileId(map, leftPlusI, topPlusJ, nzoom);
|
||||
|
||||
int y1 = tileBox.getPixYFromTileYNoRot(topPlusJ - ellipticTileCorrection);
|
||||
int y2 = tileBox.getPixYFromTileYNoRot(topPlusJ + 1 - ellipticTileCorrection);
|
||||
final int tileX = leftPlusI;
|
||||
final int tileY = topPlusJ;
|
||||
String ordImgTile = mgr.calculateTileId(map, tileX, tileY, nzoom);
|
||||
// asking tile image async
|
||||
boolean imgExist = mgr.tileExistOnFileSystem(ordImgTile, map, leftPlusI, topPlusJ, nzoom, false);
|
||||
boolean imgExist = mgr.tileExistOnFileSystem(ordImgTile, map, tileX, tileY, nzoom, false);
|
||||
Bitmap bmp = null;
|
||||
boolean originalBeLoaded = useInternet && nzoom <= maxLevel;
|
||||
if (imgExist || originalBeLoaded) {
|
||||
bmp = mgr.getTileImageForMapAsync(ordImgTile, map, leftPlusI, topPlusJ, nzoom, useInternet);
|
||||
bmp = mgr.getTileImageForMapAsync(ordImgTile, map, tileX, tileY, nzoom, useInternet);
|
||||
}
|
||||
if (bmp == null) {
|
||||
int div = 2;
|
||||
// asking if there is small version of the map (in cache)
|
||||
String imgTile2 = mgr.calculateTileId(map, leftPlusI / 2, topPlusJ / 2, nzoom - 1);
|
||||
String imgTile4 = mgr.calculateTileId(map, leftPlusI / 4, topPlusJ / 4, nzoom - 2);
|
||||
String imgTile2 = mgr.calculateTileId(map, tileX / 2, tileY / 2, nzoom - 1);
|
||||
String imgTile4 = mgr.calculateTileId(map, tileX / 4, tileY / 4, nzoom - 2);
|
||||
if (originalBeLoaded || imgExist) {
|
||||
bmp = mgr.getTileImageFromCache(imgTile2);
|
||||
div = 2;
|
||||
|
@ -182,13 +180,13 @@ public class MapTileLayer extends BaseMapLayer {
|
|||
}
|
||||
}
|
||||
if (!originalBeLoaded && !imgExist) {
|
||||
if (mgr.tileExistOnFileSystem(imgTile2, map, leftPlusI / 2, topPlusJ / 2, nzoom - 1, false)
|
||||
if (mgr.tileExistOnFileSystem(imgTile2, map, tileX / 2, tileY / 2, nzoom - 1, false)
|
||||
|| (useInternet && nzoom - 1 <= maxLevel)) {
|
||||
bmp = mgr.getTileImageForMapAsync(imgTile2, map, leftPlusI / 2, topPlusJ / 2, nzoom - 1, useInternet);
|
||||
bmp = mgr.getTileImageForMapAsync(imgTile2, map, tileX / 2, tileY / 2, nzoom - 1, useInternet);
|
||||
div = 2;
|
||||
} else if (mgr.tileExistOnFileSystem(imgTile4, map, leftPlusI / 4, topPlusJ / 4, nzoom - 2, false)
|
||||
} else if (mgr.tileExistOnFileSystem(imgTile4, map, tileX / 4, tileY / 4, nzoom - 2, false)
|
||||
|| (useInternet && nzoom - 2 <= maxLevel)) {
|
||||
bmp = mgr.getTileImageForMapAsync(imgTile4, map, leftPlusI / 4, topPlusJ / 4, nzoom - 2, useInternet);
|
||||
bmp = mgr.getTileImageForMapAsync(imgTile4, map, tileX / 4, tileY / 4, nzoom - 2, useInternet);
|
||||
div = 4;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.lang.reflect.Method;
|
|||
|
||||
import net.osmand.PlatformUtil;
|
||||
|
||||
import net.osmand.util.MapUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import android.content.Context;
|
||||
|
@ -118,7 +119,7 @@ public class MultiTouchSupport {
|
|||
return true;
|
||||
} else if(inZoomMode && actionCode == MotionEvent.ACTION_MOVE){
|
||||
if(angleDefined) {
|
||||
angleRelative = angle - angleStarted;
|
||||
angleRelative = MapUtils.unifyRotationTo360(angle - angleStarted);
|
||||
}
|
||||
zoomRelative = distance / zoomStartedDistance;
|
||||
listener.onZoomingOrRotating(zoomRelative, angleRelative);
|
||||
|
|
|
@ -234,7 +234,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
public void setIntZoom(int zoom) {
|
||||
if (mainLayer != null && zoom <= mainLayer.getMaximumShownMapZoom() && zoom >= mainLayer.getMinimumShownMapZoom()) {
|
||||
animatedDraggingThread.stopAnimating();
|
||||
currentViewport.setZoom(zoom, currentViewport.getZoomScale(), 0);
|
||||
currentViewport.setZoomAndAnimation(zoom, 0);
|
||||
currentViewport.setRotate(zoom > LOWEST_ZOOM_TO_ROTATE ? rotate : 0 );
|
||||
refreshMap();
|
||||
}
|
||||
|
@ -294,6 +294,10 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
return currentViewport.getZoom();
|
||||
}
|
||||
|
||||
public float getSettingsZoomScale(){
|
||||
return settings.MAP_ZOOM_SCALE_BY_DENSITY.get() + (float)Math.sqrt(Math.max(0, getDensity() - 1));
|
||||
}
|
||||
|
||||
public float getZoomScale() {
|
||||
return currentViewport.getZoomScale();
|
||||
}
|
||||
|
@ -327,7 +331,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
if (mainLayer.getMinimumShownMapZoom() > zoom) {
|
||||
zoom = mainLayer.getMinimumShownMapZoom();
|
||||
}
|
||||
currentViewport.setZoom(zoom, currentViewport.getZoomScale());
|
||||
currentViewport.setZoomAndAnimation(zoom, 0);
|
||||
refreshMap();
|
||||
}
|
||||
|
||||
|
@ -527,8 +531,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
// for internal usage
|
||||
protected void zoomToAnimate(float tzoom, boolean notify) {
|
||||
int zoom = getZoom();
|
||||
float zoomToScale = getZoomScale();
|
||||
float zoomToAnimate = tzoom - zoom - zoomToScale;
|
||||
float zoomToAnimate = tzoom - zoom - getZoomScale();
|
||||
if(zoomToAnimate >= 1) {
|
||||
zoom += (int) zoomToAnimate;
|
||||
zoomToAnimate -= (int) zoomToAnimate;
|
||||
|
@ -538,7 +541,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
zoomToAnimate += 1;
|
||||
}
|
||||
if (mainLayer != null && mainLayer.getMaximumShownMapZoom() >= zoom && mainLayer.getMinimumShownMapZoom() <= zoom) {
|
||||
currentViewport.setZoom(zoom, zoomToScale, zoomToAnimate);
|
||||
currentViewport.setZoomAndAnimation(zoom, zoomToAnimate);
|
||||
currentViewport.setRotate(zoom > LOWEST_ZOOM_TO_ROTATE ? rotate : 0 );
|
||||
refreshMap();
|
||||
if (notify && locationListener != null) {
|
||||
|
@ -625,9 +628,10 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
|
||||
@Override
|
||||
public void onZoomEnded(double relativeToStart, float angleRelative) {
|
||||
// 1.5 works better even on dm.density=1 devices
|
||||
float dz = (float) (Math.log(relativeToStart) / Math.log(2)) * 1.5f;
|
||||
setComplexZoom(Math.round(dz) + initialViewport.getZoom(), initialViewport.getZoomScale());
|
||||
if(Math.abs(angleRelative) < 15){
|
||||
setIntZoom(Math.round(dz) + initialViewport.getZoom());
|
||||
if(Math.abs(angleRelative) < 17){
|
||||
angleRelative = 0;
|
||||
}
|
||||
rotateToAnimate(initialViewport.getRotate() + angleRelative);
|
||||
|
@ -667,7 +671,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
// keep only rotating
|
||||
dz = 0;
|
||||
}
|
||||
if(Math.abs(relAngle) < 20 && !startRotating) {
|
||||
if(Math.abs(relAngle) < 17 && !startRotating) {
|
||||
relAngle = 0;
|
||||
} else {
|
||||
startRotating = true;
|
||||
|
@ -688,7 +692,7 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
|
|||
float calcZoom = initialViewport.getZoom() + dz + initialViewport.getZoomScale();
|
||||
float calcRotate = calc.getRotate() + angle;
|
||||
calc.setRotate(angle);
|
||||
calc.setZoom(initialViewport.getZoom(), dz + initialViewport.getZoomScale());
|
||||
calc.setZoomAnimation(dz);
|
||||
final LatLon r = calc.getLatLonFromPixel(cp.x + dx, cp.y + dy);
|
||||
setLatLon(r.getLatitude(), r.getLongitude());
|
||||
if (Math.abs(currentViewport.getZoomAnimation() + currentViewport.getZoom() + currentViewport.getZoomScale() -
|
||||
|
|
|
@ -26,7 +26,6 @@ public class PointLocationLayer extends OsmandMapLayer {
|
|||
private Paint aroundArea;
|
||||
private Paint headingPaint;
|
||||
|
||||
private DisplayMetrics dm;
|
||||
private OsmandMapTileView view;
|
||||
|
||||
private ApplicationMode appMode;
|
||||
|
@ -65,9 +64,6 @@ public class PointLocationLayer extends OsmandMapLayer {
|
|||
public void initLayer(OsmandMapTileView view) {
|
||||
this.view = view;
|
||||
initUI();
|
||||
dm = new DisplayMetrics();
|
||||
WindowManager wmgr = (WindowManager) view.getContext().getSystemService(Context.WINDOW_SERVICE);
|
||||
wmgr.getDefaultDisplay().getMetrics(dm);
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,7 +92,7 @@ public class PointLocationLayer extends OsmandMapLayer {
|
|||
final double dist = box.getDistance(0, box.getPixHeight() / 2, box.getPixWidth(), box.getPixHeight() / 2);
|
||||
int radius = (int) (((double) box.getPixWidth()) / dist * lastKnownLocation.getAccuracy());
|
||||
|
||||
if (radius > RADIUS * dm.density) {
|
||||
if (radius > RADIUS * box.getDensity()) {
|
||||
int allowedRad = Math.min(box.getPixWidth() / 2, box.getPixHeight() / 2);
|
||||
canvas.drawCircle(locationX, locationY, Math.min(radius, allowedRad), area);
|
||||
canvas.drawCircle(locationX, locationY, Math.min(radius, allowedRad), aroundArea);
|
||||
|
|
|
@ -32,13 +32,12 @@ public class RouteInfoLayer extends OsmandMapLayer implements IRouteInformationL
|
|||
private View info;
|
||||
public static int directionInfo = -1;
|
||||
|
||||
private DisplayMetrics dm;
|
||||
private final ContextMenuLayer contextMenu;
|
||||
|
||||
|
||||
|
||||
public RouteInfoLayer(RoutingHelper routingHelper, MapActivity activity, ContextMenuLayer contextMenu){
|
||||
createLayout(activity);
|
||||
createLayout(activity, activity.getMapView().getDensity());
|
||||
this.routingHelper = routingHelper;
|
||||
this.contextMenu = contextMenu;
|
||||
routingHelper.addListener(this);
|
||||
|
@ -50,12 +49,11 @@ public class RouteInfoLayer extends OsmandMapLayer implements IRouteInformationL
|
|||
activity.accessibleContent.add(info);
|
||||
}
|
||||
|
||||
private void createLayout(MapActivity activity) {
|
||||
private void createLayout(MapActivity activity, float density) {
|
||||
FrameLayout fl = (FrameLayout) activity.getMapView().getParent();
|
||||
LinearLayout ll = new LinearLayout(activity);
|
||||
ll.setOrientation(LinearLayout.HORIZONTAL);
|
||||
DisplayMetrics dm = activity.getResources().getDisplayMetrics();
|
||||
ll.setPadding(0, 0, (int) (dm.density * 15), (int) (dm.density * 50));
|
||||
ll.setPadding(0, 0, (int) (density * 15), (int) (density * 50));
|
||||
fl.addView(ll, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.CENTER));
|
||||
prev = new ImageButton(activity);
|
||||
prev.setContentDescription(activity.getString(R.string.previous_button));
|
||||
|
@ -63,12 +61,12 @@ public class RouteInfoLayer extends OsmandMapLayer implements IRouteInformationL
|
|||
ll.addView(prev);
|
||||
info = new ImageButton(activity);
|
||||
info.setContentDescription(activity.getString(R.string.info_button));
|
||||
info.setPadding((int) (dm.density * 8), 0, 0, 0);
|
||||
info.setPadding((int) (density * 8), 0, 0, 0);
|
||||
info.setBackgroundDrawable(activity.getResources().getDrawable(R.drawable.ax_2_action_about_light));
|
||||
ll.addView(info);
|
||||
next = new ImageButton(activity);
|
||||
next.setContentDescription(activity.getString(R.string.next_button));
|
||||
next.setPadding((int) (dm.density * 8), 0, 0, 0);
|
||||
next.setPadding((int) (density * 8), 0, 0, 0);
|
||||
next.setBackgroundDrawable(activity.getResources().getDrawable(R.drawable.ax_1_navigation_next_item_light));
|
||||
ll.addView(next);
|
||||
}
|
||||
|
@ -76,9 +74,6 @@ public class RouteInfoLayer extends OsmandMapLayer implements IRouteInformationL
|
|||
@Override
|
||||
public void initLayer(OsmandMapTileView view) {
|
||||
this.view = view;
|
||||
dm = new DisplayMetrics();
|
||||
WindowManager wmgr = (WindowManager) view.getContext().getSystemService(Context.WINDOW_SERVICE);
|
||||
wmgr.getDefaultDisplay().getMetrics(dm);
|
||||
}
|
||||
|
||||
private void attachListeners() {
|
||||
|
|
|
@ -25,7 +25,6 @@ public class TransportInfoLayer extends OsmandMapLayer {
|
|||
private Paint paintInt;
|
||||
private Paint paintEnd;
|
||||
private boolean visible = true;
|
||||
private DisplayMetrics dm;
|
||||
|
||||
public TransportInfoLayer(TransportRouteHelper routeHelper){
|
||||
this.routeHelper = routeHelper;
|
||||
|
@ -34,9 +33,6 @@ public class TransportInfoLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public void initLayer(OsmandMapTileView view) {
|
||||
this.view = view;
|
||||
dm = new DisplayMetrics();
|
||||
WindowManager wmgr = (WindowManager) view.getContext().getSystemService(Context.WINDOW_SERVICE);
|
||||
wmgr.getDefaultDisplay().getMetrics(dm);
|
||||
|
||||
paintInt = new Paint();
|
||||
paintInt.setColor(view.getResources().getColor(R.color.transport_int));
|
||||
|
@ -56,9 +52,9 @@ public class TransportInfoLayer extends OsmandMapLayer {
|
|||
public int getRadius(RotatedTileBox tb){
|
||||
final float zoom = tb.getZoom() + tb.getZoomScale();
|
||||
if(zoom <= 16) {
|
||||
return (int) (dm.density * 8);
|
||||
return (int) (tb.getDensity() * 8);
|
||||
}
|
||||
return (int) (dm.density * 10);
|
||||
return (int) (tb.getDensity() * 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -107,7 +107,7 @@ public class AppearanceWidgetsFactory {
|
|||
|
||||
if (EXTRA_SETTINGS) {
|
||||
// previous extra settings
|
||||
final OsmandSettings.OsmandPreference<Float> textSizePref = view.getSettings().MAP_TEXT_SIZE;
|
||||
/*final OsmandSettings.OsmandPreference<Float> textSizePref = view.getSettings().MAP_TEXT_SIZE;
|
||||
final MapWidgetRegistry.MapWidgetRegInfo textSize = mapInfoControls.registerAppearanceWidget(R.drawable.widget_text_size, R.string.map_text_size,
|
||||
"text_size", textSizePref);
|
||||
textSize.setStateChangeListener(new Runnable() {
|
||||
|
@ -132,7 +132,7 @@ public class AppearanceWidgetsFactory {
|
|||
});
|
||||
b.show();
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
final MapWidgetRegistry.MapWidgetRegInfo showRuler = mapInfoControls.registerAppearanceWidget(R.drawable.widget_ruler, R.string.map_widget_show_ruler,
|
||||
"showRuler", view.getSettings().SHOW_RULER);
|
||||
|
|
Loading…
Reference in a new issue