Fix issues for 1.6 - make map magnifier visible & touchable, road maps overlay, autozoom adjust
This commit is contained in:
parent
9ffedce020
commit
d2b26a1e0a
8 changed files with 72 additions and 47 deletions
BIN
OsmAnd/res/drawable-hdpi/map_magnifier.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/map_magnifier.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1 KiB |
BIN
OsmAnd/res/drawable-large/map_magnifier.png
Normal file
BIN
OsmAnd/res/drawable-large/map_magnifier.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1 KiB |
BIN
OsmAnd/res/drawable-mdpi/map_magnifier.png
Normal file
BIN
OsmAnd/res/drawable-mdpi/map_magnifier.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 634 B |
BIN
OsmAnd/res/drawable-xhdpi/map_magnifier.png
Normal file
BIN
OsmAnd/res/drawable-xhdpi/map_magnifier.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -9,6 +9,8 @@
|
||||||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
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
|
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.
|
<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>
|
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>
|
<string name="auto_zoom_none">No auto zoom</string>
|
||||||
|
|
|
@ -186,9 +186,9 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
||||||
lastTimeAutoZooming = now;
|
lastTimeAutoZooming = now;
|
||||||
float settingsZoomScale = mapView.getSettingsZoomScale();
|
float settingsZoomScale = mapView.getSettingsZoomScale();
|
||||||
float complexZoom = tb.getZoom() + tb.getZoomScale() + zdelta;
|
float complexZoom = tb.getZoom() + tb.getZoomScale() + zdelta;
|
||||||
// round to 0.5
|
// round to 0.33
|
||||||
float newZoom = Math.round((complexZoom - settingsZoomScale) * 2) * 0.5f;
|
float newZoom = Math.round((complexZoom - settingsZoomScale) * 3) / 3f;
|
||||||
int nz = (int)newZoom;
|
int nz = (int)Math.round(newZoom);
|
||||||
float nzscale = newZoom - nz + settingsZoomScale;
|
float nzscale = newZoom - nz + settingsZoomScale;
|
||||||
mapView.setComplexZoom(nz, nzscale);
|
mapView.setComplexZoom(nz, nzscale);
|
||||||
// mapView.getAnimatedDraggingThread().startZooming(mapView.getFloatZoom() + zdelta, false);
|
// mapView.getAnimatedDraggingThread().startZooming(mapView.getFloatZoom() + zdelta, false);
|
||||||
|
|
|
@ -133,9 +133,11 @@ public class DownloadedRegionsLayer extends OsmandMapLayer {
|
||||||
currentObjects != null) {
|
currentObjects != null) {
|
||||||
path.reset();
|
path.reset();
|
||||||
for (BinaryMapDataObject o : currentObjects) {
|
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;
|
+ 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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +222,7 @@ public class DownloadedRegionsLayer extends OsmandMapLayer {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (set.size() > 1) {
|
if (set.size() > 1) {
|
||||||
s.append(" & ");
|
s.append(" ").append(view.getResources().getString(R.string.default_or)).append(" ");
|
||||||
filter.append(", ");
|
filter.append(", ");
|
||||||
} else {
|
} else {
|
||||||
s.append(" ");
|
s.append(" ");
|
||||||
|
|
|
@ -17,8 +17,11 @@ import net.osmand.plus.activities.MapActivity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Paint;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
@ -39,9 +42,7 @@ import android.widget.SeekBar;
|
||||||
public class MapControlsLayer extends OsmandMapLayer {
|
public class MapControlsLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private static final int SHOW_ZOOM_LEVEL_MSG_ID = 3;
|
private static final int SHOW_ZOOM_LEVEL_MSG_ID = 3;
|
||||||
private static final int SHOW_ZOOM_LEVEL_DELAY = 2000;
|
private static final int SHOW_ZOOM_LEVEL_DELAY = 4000;
|
||||||
private static final float ZOOM_DELTA = 1;
|
|
||||||
// private static final float ZOOM_DELTA = OsmandMapTileView.ZOOM_DELTA_1;
|
|
||||||
|
|
||||||
|
|
||||||
private OsmandMapTileView view;
|
private OsmandMapTileView view;
|
||||||
|
@ -57,6 +58,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private TextPaint zoomTextPaint;
|
private TextPaint zoomTextPaint;
|
||||||
private Drawable zoomShadow;
|
private Drawable zoomShadow;
|
||||||
|
private Bitmap mapMagnifier;
|
||||||
|
private Paint bitmapPaint;
|
||||||
|
|
||||||
private Button backToMenuButton;
|
private Button backToMenuButton;
|
||||||
private Drawable modeShadow;
|
private Drawable modeShadow;
|
||||||
|
@ -134,8 +137,9 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
zoomTextPaint.setColor(sh == Color.WHITE ? Color.BLACK : 0xffC8C8C8);
|
zoomTextPaint.setColor(sh == Color.WHITE ? Color.BLACK : 0xffC8C8C8);
|
||||||
rulerTextPaint.setColor(sh == Color.WHITE ? Color.BLACK : 0xffC8C8C8);
|
rulerTextPaint.setColor(sh == Color.WHITE ? Color.BLACK : 0xffC8C8C8);
|
||||||
}
|
}
|
||||||
if (showZoomLevel || !view.getSettings().SHOW_RULER.get()) {
|
boolean drawZoomLevel = showZoomLevel || !view.getSettings().SHOW_RULER.get();
|
||||||
drawZoomLevel(canvas ,tileBox);
|
if (drawZoomLevel) {
|
||||||
|
drawZoomLevel(canvas, tileBox, view.isZooming());
|
||||||
} else {
|
} else {
|
||||||
drawRuler(canvas, tileBox);
|
drawRuler(canvas, tileBox);
|
||||||
}
|
}
|
||||||
|
@ -201,32 +205,35 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void drawZoomLevel(Canvas canvas, RotatedTileBox tb) {
|
private void drawZoomLevel(Canvas canvas, RotatedTileBox tb, boolean drawZoomLevel) {
|
||||||
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);
|
|
||||||
if (zoomShadow.getBounds().width() == 0) {
|
if (zoomShadow.getBounds().width() == 0) {
|
||||||
zoomShadow.setBounds(zoomInButton.getLeft() - 2, zoomInButton.getTop() - (int) (18 * scaleCoefficient), zoomInButton.getRight(),
|
zoomShadow.setBounds(zoomInButton.getLeft() - 2, zoomInButton.getTop() - (int) (18 * scaleCoefficient),
|
||||||
zoomInButton.getBottom());
|
zoomInButton.getRight(), zoomInButton.getBottom());
|
||||||
}
|
}
|
||||||
zoomShadow.draw(canvas);
|
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,
|
ShadowText.draw(zoomText, canvas, zoomInButton.getLeft() + (zoomInButton.getWidth() - length - 2) / 2,
|
||||||
zoomInButton.getTop() + 4 * scaleCoefficient, zoomTextPaint, shadowColor);
|
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(){
|
private void hideZoomLevelInTime(){
|
||||||
|
@ -251,6 +258,10 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
onApplicationModePress();
|
onApplicationModePress();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (showZoomLevel && zoomShadow.getBounds().contains((int) point.x, (int) point.y)) {
|
||||||
|
getOnClickMagnifierListener(view).onLongClick(null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +318,10 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
zoomTextPaint.setAntiAlias(true);
|
zoomTextPaint.setAntiAlias(true);
|
||||||
zoomTextPaint.setFakeBoldText(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 = new Button(ctx);
|
||||||
zoomInButton.setBackgroundResource(R.drawable.map_zoom_in);
|
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() {
|
final View.OnLongClickListener listener = new View.OnLongClickListener() {
|
||||||
|
|
||||||
@Override
|
@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());
|
final AlertDialog.Builder bld = new AlertDialog.Builder(view.getContext());
|
||||||
float scale = view.getZoomScale();
|
float scale = view.getZoomScale();
|
||||||
int p = (int) ((scale > 0 ? 1 : -1) * Math.round(scale * scale * 100)) + 100;
|
int p = (int) ((scale > 0 ? 1 : -1) * Math.round(scale * scale * 100)) + 100;
|
||||||
|
@ -393,14 +420,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
zoomInButton.setOnLongClickListener(listener);
|
return listener;
|
||||||
zoomOutButton.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
activity.changeZoom(- 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
zoomOutButton.setOnLongClickListener(listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -498,8 +518,9 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
cacheRulerTextLen = zoomTextPaint.measureText(cacheRulerText.getText());
|
cacheRulerTextLen = zoomTextPaint.measureText(cacheRulerText.getText());
|
||||||
|
|
||||||
Rect bounds = rulerDrawable.getBounds();
|
Rect bounds = rulerDrawable.getBounds();
|
||||||
|
Drawable buttonDrawable = view.getResources().getDrawable(R.drawable.map_zoom_in);
|
||||||
bounds.right = (int) (view.getWidth() - 7 * scaleCoefficient);
|
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.top = bounds.bottom - rulerDrawable.getMinimumHeight();
|
||||||
bounds.left = bounds.right - cacheRulerDistPix;
|
bounds.left = bounds.right - cacheRulerDistPix;
|
||||||
rulerDrawable.setBounds(bounds);
|
rulerDrawable.setBounds(bounds);
|
||||||
|
|
Loading…
Reference in a new issue