Fix issues for 1.6 - make map magnifier visible & touchable, road maps overlay, autozoom adjust

This commit is contained in:
vshcherb 2013-10-29 01:26:42 +01:00
parent 9ffedce020
commit d2b26a1e0a
8 changed files with 72 additions and 47 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -9,6 +9,8 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="default_and">and</string>
<string name="default_or">or</string>
<string name="route_is_too_long">The route is possibly too long to be calculated by the OsmAnd offline router.
On average offline routing is possible between points up to 200km apart. Please add one or more intermediate waypoints to calculate the route.</string>
<string name="auto_zoom_none">No auto zoom</string>

View file

@ -186,9 +186,9 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
lastTimeAutoZooming = now;
float settingsZoomScale = mapView.getSettingsZoomScale();
float complexZoom = tb.getZoom() + tb.getZoomScale() + zdelta;
// round to 0.5
float newZoom = Math.round((complexZoom - settingsZoomScale) * 2) * 0.5f;
int nz = (int)newZoom;
// round to 0.33
float newZoom = Math.round((complexZoom - settingsZoomScale) * 3) / 3f;
int nz = (int)Math.round(newZoom);
float nzscale = newZoom - nz + settingsZoomScale;
mapView.setComplexZoom(nz, nzscale);
// mapView.getAnimatedDraggingThread().startZooming(mapView.getFloatZoom() + zdelta, false);

View file

@ -133,9 +133,11 @@ public class DownloadedRegionsLayer extends OsmandMapLayer {
currentObjects != null) {
path.reset();
for (BinaryMapDataObject o : currentObjects) {
final String key = Algorithms.capitalizeFirstLetterAndLowercase(osmandRegions.getDownloadName(o))
final String regionName = Algorithms.capitalizeFirstLetterAndLowercase(osmandRegions.getDownloadName(o))
+ IndexConstants.BINARY_MAP_INDEX_EXT;
if (!rm.getIndexFileNames().containsKey(key)) {
final String roadsRegionName = Algorithms.capitalizeFirstLetterAndLowercase(osmandRegions.getDownloadName(o)) + "-roads"
+ IndexConstants.BINARY_MAP_INDEX_EXT;
if (!rm.getIndexFileNames().containsKey(regionName) && !rm.getIndexFileNames().containsKey(roadsRegionName)) {
continue;
}
@ -220,7 +222,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer {
continue;
}
if (set.size() > 1) {
s.append(" & ");
s.append(" ").append(view.getResources().getString(R.string.default_or)).append(" ");
filter.append(", ");
} else {
s.append(" ");

View file

@ -17,8 +17,11 @@ import net.osmand.plus.activities.MapActivity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
@ -39,9 +42,7 @@ import android.widget.SeekBar;
public class MapControlsLayer extends OsmandMapLayer {
private static final int SHOW_ZOOM_LEVEL_MSG_ID = 3;
private static final int SHOW_ZOOM_LEVEL_DELAY = 2000;
private static final float ZOOM_DELTA = 1;
// private static final float ZOOM_DELTA = OsmandMapTileView.ZOOM_DELTA_1;
private static final int SHOW_ZOOM_LEVEL_DELAY = 4000;
private OsmandMapTileView view;
@ -57,6 +58,8 @@ public class MapControlsLayer extends OsmandMapLayer {
private TextPaint zoomTextPaint;
private Drawable zoomShadow;
private Bitmap mapMagnifier;
private Paint bitmapPaint;
private Button backToMenuButton;
private Drawable modeShadow;
@ -134,8 +137,9 @@ public class MapControlsLayer extends OsmandMapLayer {
zoomTextPaint.setColor(sh == Color.WHITE ? Color.BLACK : 0xffC8C8C8);
rulerTextPaint.setColor(sh == Color.WHITE ? Color.BLACK : 0xffC8C8C8);
}
if (showZoomLevel || !view.getSettings().SHOW_RULER.get()) {
drawZoomLevel(canvas ,tileBox);
boolean drawZoomLevel = showZoomLevel || !view.getSettings().SHOW_RULER.get();
if (drawZoomLevel) {
drawZoomLevel(canvas, tileBox, view.isZooming());
} else {
drawRuler(canvas, tileBox);
}
@ -201,32 +205,35 @@ public class MapControlsLayer extends OsmandMapLayer {
}
private void drawZoomLevel(Canvas canvas, RotatedTileBox tb) {
String zoomText = tb.getZoom() + "";
float frac = tb.getZoomScale();
if (frac != 0) {
if (frac > 0) {
zoomText += "+";
} else {
zoomText += "-";
}
int ifrac = ((int) Math.abs(frac));
if (frac >= 1) {
zoomText += ifrac;
}
if (frac != ifrac) {
zoomText += "." + ((int) ((Math.abs(frac) - ifrac) * 10f));
}
}
float length = zoomTextPaint.measureText(zoomText);
private void drawZoomLevel(Canvas canvas, RotatedTileBox tb, boolean drawZoomLevel) {
if (zoomShadow.getBounds().width() == 0) {
zoomShadow.setBounds(zoomInButton.getLeft() - 2, zoomInButton.getTop() - (int) (18 * scaleCoefficient), zoomInButton.getRight(),
zoomInButton.getBottom());
zoomShadow.setBounds(zoomInButton.getLeft() - 2, zoomInButton.getTop() - (int) (18 * scaleCoefficient),
zoomInButton.getRight(), zoomInButton.getBottom());
}
zoomShadow.draw(canvas);
if (drawZoomLevel) {
String zoomText = tb.getZoom() + "";
float frac = tb.getZoomScale();
if (frac != 0) {
int ifrac = (int) (frac * 10);
boolean pos = ifrac > 0;
zoomText += (pos ? "+" : "-");
zoomText += Math.abs(ifrac) / 10;
if (ifrac % 10 != 0) {
zoomText += "." + Math.abs(ifrac) % 10;
}
}
float length = zoomTextPaint.measureText(zoomText);
ShadowText.draw(zoomText, canvas, zoomInButton.getLeft() + (zoomInButton.getWidth() - length - 2) / 2,
zoomInButton.getTop() + 4 * scaleCoefficient, zoomTextPaint, shadowColor);
ShadowText.draw(zoomText, canvas, zoomInButton.getLeft() + (zoomInButton.getWidth() - length - 2) / 2,
zoomInButton.getTop() + 4 * scaleCoefficient, zoomTextPaint, shadowColor);
} else {
int size = (int) (16 * scaleCoefficient);
int top = (int) (zoomInButton.getTop() - size - 4 * scaleCoefficient);
int left = (int) (zoomInButton.getLeft() + (zoomInButton.getWidth() - mapMagnifier.getWidth() - 2 * scaleCoefficient) / 2);
// canvas density /2 ? size * 2
canvas.drawBitmap(mapMagnifier, null, new Rect(left, top, left + size * 2, top + size * 2), bitmapPaint);
}
}
private void hideZoomLevelInTime(){
@ -251,6 +258,10 @@ public class MapControlsLayer extends OsmandMapLayer {
onApplicationModePress();
return true;
}
if (showZoomLevel && zoomShadow.getBounds().contains((int) point.x, (int) point.y)) {
getOnClickMagnifierListener(view).onLongClick(null);
return true;
}
return false;
}
@ -307,7 +318,10 @@ public class MapControlsLayer extends OsmandMapLayer {
zoomTextPaint.setAntiAlias(true);
zoomTextPaint.setFakeBoldText(true);
zoomShadow = view.getResources().getDrawable(R.drawable.zoom_background);
zoomShadow = view.getResources().getDrawable(R.drawable.zoom_background).mutate();
mapMagnifier = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_magnifier);
bitmapPaint = new Paint();
zoomInButton = new Button(ctx);
zoomInButton.setBackgroundResource(R.drawable.map_zoom_in);
@ -341,11 +355,24 @@ public class MapControlsLayer extends OsmandMapLayer {
}
});
final OsmandSettings.OsmandPreference<Float> zoomScale = view.getSettings().MAP_ZOOM_SCALE_BY_DENSITY;
final View.OnLongClickListener listener = getOnClickMagnifierListener(view);
zoomInButton.setOnLongClickListener(listener);
zoomOutButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.changeZoom(- 1);
}
});
zoomOutButton.setOnLongClickListener(listener);
}
private static View.OnLongClickListener getOnClickMagnifierListener(final OsmandMapTileView view) {
final View.OnLongClickListener listener = new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
public boolean onLongClick(View notUseCouldBeNull) {
final OsmandSettings.OsmandPreference<Float> zoomScale = view.getSettings().MAP_ZOOM_SCALE_BY_DENSITY;
final AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
float scale = view.getZoomScale();
int p = (int) ((scale > 0 ? 1 : -1) * Math.round(scale * scale * 100)) + 100;
@ -393,14 +420,7 @@ public class MapControlsLayer extends OsmandMapLayer {
return true;
}
};
zoomInButton.setOnLongClickListener(listener);
zoomOutButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.changeZoom(- 1);
}
});
zoomOutButton.setOnLongClickListener(listener);
return listener;
}
@ -498,8 +518,9 @@ public class MapControlsLayer extends OsmandMapLayer {
cacheRulerTextLen = zoomTextPaint.measureText(cacheRulerText.getText());
Rect bounds = rulerDrawable.getBounds();
Drawable buttonDrawable = view.getResources().getDrawable(R.drawable.map_zoom_in);
bounds.right = (int) (view.getWidth() - 7 * scaleCoefficient);
bounds.bottom = (int) (view.getHeight() - view.getResources().getDrawable(R.drawable.map_zoom_in).getMinimumHeight());
bounds.bottom = (int) (view.getHeight() - buttonDrawable.getMinimumHeight());
bounds.top = bounds.bottom - rulerDrawable.getMinimumHeight();
bounds.left = bounds.right - cacheRulerDistPix;
rulerDrawable.setBounds(bounds);