Add cancel button and half menu button
This commit is contained in:
parent
1568ab8288
commit
b83df978b1
17 changed files with 183 additions and 156 deletions
BIN
OsmAnd/res/drawable-hdpi/map_btn_cancel_o.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/map_btn_cancel_o.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
OsmAnd/res/drawable-hdpi/map_btn_cancel_p.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/map_btn_cancel_p.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
OsmAnd/res/drawable-hdpi/map_btn_hmenu_o.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/map_btn_hmenu_o.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 931 B |
BIN
OsmAnd/res/drawable-hdpi/map_btn_hmenu_p.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/map_btn_hmenu_p.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 980 B |
BIN
OsmAnd/res/drawable-large/map_btn_hmenu_o.png
Normal file
BIN
OsmAnd/res/drawable-large/map_btn_hmenu_o.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 931 B |
BIN
OsmAnd/res/drawable-large/map_btn_hmenu_p.png
Normal file
BIN
OsmAnd/res/drawable-large/map_btn_hmenu_p.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 980 B |
6
OsmAnd/res/drawable/map_btn_cancel.xml
Normal file
6
OsmAnd/res/drawable/map_btn_cancel.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@drawable/map_btn_menu_p" />
|
||||
<item android:state_enabled="false" android:drawable="@drawable/map_btn_menu_p" />
|
||||
<item android:drawable="@drawable/map_btn_menu_o" />
|
||||
</selector>
|
6
OsmAnd/res/drawable/map_btn_hmenu.xml
Normal file
6
OsmAnd/res/drawable/map_btn_hmenu.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@drawable/map_btn_hmenu_p" />
|
||||
<item android:state_enabled="false" android:drawable="@drawable/map_btn_hmenu_p" />
|
||||
<item android:drawable="@drawable/map_btn_hmenu_o" />
|
||||
</selector>
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true" android:drawable="@drawable/map_btn_menu_p" />
|
||||
<item android:state_enabled="false" android:drawable="@drawable/map_btn_menu_p" />
|
||||
<item android:drawable="@drawable/map_btn_menu_o" />
|
||||
<item android:state_pressed="true" android:drawable="@drawable/map_btn_cancel_p" />
|
||||
<item android:state_enabled="false" android:drawable="@drawable/map_btn_cancel_p" />
|
||||
<item android:drawable="@drawable/map_btn_cancel_o" />
|
||||
</selector>
|
||||
|
|
|
@ -782,6 +782,15 @@ public class MapActivityActions implements DialogProvider {
|
|||
return mapActivity.getMyApplication().getTargetPointsHelper();
|
||||
}
|
||||
|
||||
public void stopNavigationWithoutConfirm() {
|
||||
if(getMyApplication().getLocationProvider().getLocationSimulation().isRouteAnimating()) {
|
||||
getMyApplication().getLocationProvider().getLocationSimulation().startStopRouteAnimation(mapActivity);
|
||||
}
|
||||
routingHelper.setFinalAndCurrentLocation(null, new ArrayList<LatLon>(), getLastKnownLocation(),
|
||||
routingHelper.getCurrentGPXRoute());
|
||||
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
|
||||
}
|
||||
|
||||
public void stopNavigationActionConfirm(final OsmandMapTileView mapView){
|
||||
Builder builder = new AlertDialog.Builder(mapActivity);
|
||||
|
||||
|
@ -792,13 +801,10 @@ public class MapActivityActions implements DialogProvider {
|
|||
builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if(getMyApplication().getLocationProvider().getLocationSimulation().isRouteAnimating()) {
|
||||
getMyApplication().getLocationProvider().getLocationSimulation().startStopRouteAnimation(mapActivity);
|
||||
}
|
||||
routingHelper.setFinalAndCurrentLocation(null, new ArrayList<LatLon>(), getLastKnownLocation(),
|
||||
routingHelper.getCurrentGPXRoute());
|
||||
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
|
||||
stopNavigationWithoutConfirm();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
} else {
|
||||
// Clear the destination point
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.views.controls.MapCancelControl;
|
||||
import net.osmand.plus.views.controls.MapControls;
|
||||
import net.osmand.plus.views.controls.MapMenuControls;
|
||||
import net.osmand.plus.views.controls.MapZoomControls;
|
||||
import net.osmand.plus.views.controls.RulerControl;
|
||||
import net.osmand.plus.views.controls.SmallMapMenuControls;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.text.TextPaint;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -26,13 +25,15 @@ import android.widget.SeekBar;
|
|||
|
||||
public class MapControlsLayer extends OsmandMapLayer {
|
||||
|
||||
private static final int HOVER_COLOR = 0xffC8C8C8;
|
||||
private static final int NIGHT_COLOR = 0xffC8C8C8;
|
||||
private static final int TIMEOUT_TO_SHOW_BUTTONS = 5000;
|
||||
private final MapActivity mapActivity;
|
||||
private int shadowColor;
|
||||
|
||||
private MapZoomControls zoomControls;
|
||||
private MapMenuControls mapMenuControls;
|
||||
private SmallMapMenuControls mapSmallMenuControls;
|
||||
private MapCancelControl mapCancelNavigationControl;
|
||||
private RulerControl rulerControl;
|
||||
|
||||
private float scaleCoefficient;
|
||||
|
@ -58,31 +59,31 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
scaleCoefficient = view.getScaleCoefficient();
|
||||
FrameLayout parent = (FrameLayout) view.getParent();
|
||||
Handler showUIHandler = new Handler();
|
||||
zoomControls = new MapZoomControls(mapActivity, showUIHandler, scaleCoefficient);
|
||||
zoomControls.init(parent);
|
||||
mapMenuControls = new MapMenuControls(mapActivity, showUIHandler, scaleCoefficient);
|
||||
mapMenuControls.init(parent);
|
||||
rulerControl = new RulerControl(zoomControls, mapActivity, showUIHandler, scaleCoefficient);
|
||||
rulerControl.init(parent);
|
||||
zoomControls = init(new MapZoomControls(mapActivity, showUIHandler, scaleCoefficient), parent);
|
||||
mapMenuControls = init(new MapMenuControls(mapActivity, showUIHandler, scaleCoefficient), parent);
|
||||
mapSmallMenuControls = init(new SmallMapMenuControls(mapActivity, showUIHandler, scaleCoefficient), parent);
|
||||
mapCancelNavigationControl = init(new MapCancelControl(mapActivity, showUIHandler, scaleCoefficient), parent);
|
||||
rulerControl = init(new RulerControl(zoomControls, mapActivity, showUIHandler, scaleCoefficient), parent);
|
||||
initTransparencyBar(view, parent);
|
||||
}
|
||||
|
||||
private <T extends MapControls> T init(T c, FrameLayout parent) {
|
||||
c.init(parent);
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyLayer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
|
||||
int sh = Color.WHITE;
|
||||
if (nightMode != null && nightMode.isNightMode()) {
|
||||
sh = Color.TRANSPARENT;
|
||||
}
|
||||
if(shadowColor != sh) {
|
||||
shadowColor = sh;
|
||||
int textColor = sh == Color.WHITE ? Color.BLACK : HOVER_COLOR;
|
||||
rulerControl.setShadowColor(textColor, sh);
|
||||
zoomControls.setShadowColor(textColor, sh);
|
||||
mapMenuControls.setShadowColor(textColor, sh);
|
||||
boolean isNight = nightMode != null && nightMode.isNightMode();
|
||||
int shadw = isNight ? Color.TRANSPARENT : Color.WHITE;
|
||||
int textColor = isNight ? NIGHT_COLOR : Color.BLACK ;
|
||||
if(shadowColor != shadw) {
|
||||
shadowColor = shadw;
|
||||
updatextColor(textColor, shadw, rulerControl, zoomControls, mapMenuControls);
|
||||
}
|
||||
|
||||
boolean showZooms = false; //!mapActivity.getRoutingHelper().isRouteCalculated() && !mapActivity.getRoutingHelper().isFollowingMode();
|
||||
|
@ -90,10 +91,20 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
boolean showMenu = false;// !mapActivity.getRoutingHelper().isFollowingMode();
|
||||
checkVisibilityAndDraw(showMenu, mapMenuControls, canvas, tileBox, nightMode);
|
||||
boolean showSmallMenu = !mapMenuControls.isVisible();
|
||||
checkVisibilityAndDraw(showSmallMenu, mapSmallMenuControls, canvas, tileBox, nightMode);
|
||||
checkVisibilityAndDraw(showSmallMenu, mapCancelNavigationControl, canvas, tileBox, nightMode);
|
||||
|
||||
// the last one to check zoom controls visibility
|
||||
checkVisibilityAndDraw(true, rulerControl, canvas, tileBox, nightMode);
|
||||
}
|
||||
|
||||
private void updatextColor(int textColor, int shadowColor, MapControls... mc) {
|
||||
for(MapControls m : mc) {
|
||||
m.updateTextColor(textColor, shadowColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkVisibilityAndDraw(boolean visibility, MapControls controls, Canvas canvas,
|
||||
RotatedTileBox tileBox, DrawSettings nightMode) {
|
||||
if(visibility != controls.isVisible()){
|
||||
|
@ -189,93 +200,4 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////// Ruler ///////////////////
|
||||
// cache values for ruler
|
||||
|
||||
public static class RulerControl extends MapControls {
|
||||
|
||||
ShadowText cacheRulerText = null;
|
||||
float cacheRulerZoom = 0;
|
||||
double cacheRulerTileX = 0;
|
||||
double cacheRulerTileY = 0;
|
||||
float cacheRulerTextLen = 0;
|
||||
MapZoomControls zoomControls;
|
||||
Drawable rulerDrawable;
|
||||
TextPaint rulerTextPaint;
|
||||
final static double screenRulerPercent = 0.25;
|
||||
|
||||
public RulerControl(MapZoomControls zoomControls, MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
||||
super(mapActivity, showUIHandler, scaleCoefficient);
|
||||
this.zoomControls = zoomControls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void hideControls(FrameLayout layout) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShadowColor(int textColor, int shadowColor) {
|
||||
super.setShadowColor(textColor, shadowColor);
|
||||
rulerTextPaint.setColor(textColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showControls(FrameLayout layout) {
|
||||
rulerTextPaint = new TextPaint();
|
||||
rulerTextPaint.setTextSize(20 * scaleCoefficient);
|
||||
rulerTextPaint.setAntiAlias(true);
|
||||
rulerDrawable = mapActivity.getResources().getDrawable(R.drawable.ruler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings nightMode) {
|
||||
if( (zoomControls.isVisible() && zoomControls.isShowZoomLevel()) || !mapActivity.getMyApplication().getSettings().SHOW_RULER.get()){
|
||||
return;
|
||||
}
|
||||
OsmandMapTileView view = mapActivity.getMapView();
|
||||
// update cache
|
||||
if (view.isZooming()) {
|
||||
cacheRulerText = null;
|
||||
} else if((tb.getZoom() + tb.getZoomScale()) != cacheRulerZoom ||
|
||||
Math.abs(tb.getCenterTileX() - cacheRulerTileX) + Math.abs(tb.getCenterTileY() - cacheRulerTileY) > 1){
|
||||
cacheRulerZoom = (tb.getZoom() + tb.getZoomScale());
|
||||
cacheRulerTileX = tb.getCenterTileX();
|
||||
cacheRulerTileY = tb.getCenterTileY();
|
||||
final double dist = tb.getDistance(0, tb.getPixHeight() / 2, tb.getPixWidth(), tb.getPixHeight() / 2);
|
||||
double pixDensity = tb.getPixWidth() / dist;
|
||||
|
||||
double roundedDist = OsmAndFormatter.calculateRoundedDist(dist * screenRulerPercent, view.getApplication());
|
||||
|
||||
int cacheRulerDistPix = (int) (pixDensity * roundedDist);
|
||||
cacheRulerText = ShadowText.create(OsmAndFormatter.getFormattedDistance((float) roundedDist, view.getApplication()));
|
||||
cacheRulerTextLen = rulerTextPaint.measureText(cacheRulerText.getText());
|
||||
Rect bounds = rulerDrawable.getBounds();
|
||||
bounds.right = (int) (view.getWidth() - 7 * scaleCoefficient);
|
||||
bounds.bottom = (int) (view.getHeight() - (!zoomControls.isVisible() ? 0 : zoomControls.getHeight()));
|
||||
bounds.top = bounds.bottom - rulerDrawable.getMinimumHeight();
|
||||
bounds.left = bounds.right - cacheRulerDistPix;
|
||||
rulerDrawable.setBounds(bounds);
|
||||
}
|
||||
|
||||
|
||||
if (cacheRulerText != null) {
|
||||
Rect bounds = rulerDrawable.getBounds();
|
||||
int bottom = (int) (view.getHeight() - (!zoomControls.isVisible() ? 0 : zoomControls.getHeight()));
|
||||
if(bounds.bottom != bottom) {
|
||||
bounds.bottom = bottom;
|
||||
rulerDrawable.setBounds(bounds);
|
||||
}
|
||||
rulerDrawable.draw(canvas);
|
||||
cacheRulerText.draw(canvas, bounds.left + (bounds.width() - cacheRulerTextLen) / 2, bounds.bottom - 8 * scaleCoefficient,
|
||||
rulerTextPaint, shadowColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package net.osmand.plus.views.controls;
|
||||
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.os.Handler;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
public class MapCancelControl extends MapControls {
|
||||
private Button cancelButton;
|
||||
|
||||
|
||||
public MapCancelControl(MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
||||
super(mapActivity, showUIHandler, scaleCoefficient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showControls(FrameLayout parent) {
|
||||
Context ctx = mapActivity;
|
||||
cancelButton = new Button(ctx);
|
||||
cancelButton.setContentDescription(ctx.getString(R.string.cancel_navigation));
|
||||
cancelButton.setBackgroundResource(R.drawable.map_btn_cancel);
|
||||
android.widget.FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||
Gravity.BOTTOM | Gravity.LEFT);
|
||||
params.leftMargin = ctx.getResources().getDrawable(R.drawable.map_btn_cancel).getMinimumWidth();
|
||||
parent.addView(cancelButton, params);
|
||||
cancelButton.setEnabled(true);
|
||||
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
||||
}
|
||||
});
|
||||
mapActivity.accessibleContent.add(cancelButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideControls(FrameLayout layout) {
|
||||
layout.removeView(cancelButton);
|
||||
mapActivity.accessibleContent.remove(cancelButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ public abstract class MapControls {
|
|||
this.scaleCoefficient = scaleCoefficient;
|
||||
}
|
||||
|
||||
public void setShadowColor(int textColor, int shadowColor) {
|
||||
public void updateTextColor(int textColor, int shadowColor) {
|
||||
this.shadowColor = shadowColor;
|
||||
}
|
||||
|
||||
|
@ -79,8 +79,6 @@ public abstract class MapControls {
|
|||
protected void initControls(FrameLayout layout) {
|
||||
}
|
||||
|
||||
public abstract int getWidth();
|
||||
|
||||
protected abstract void hideControls(FrameLayout layout);
|
||||
|
||||
protected abstract void showControls(FrameLayout layout);
|
||||
|
|
|
@ -65,12 +65,6 @@ public class MapMenuControls extends MapControls {
|
|||
initBackToMenuButton(mapActivity.getMapView(), layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideControls(FrameLayout layout) {
|
||||
layout.removeView(backToMenuButton);
|
||||
|
|
|
@ -45,6 +45,10 @@ public class MapZoomControls extends MapControls {
|
|||
public MapZoomControls(MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
||||
super(mapActivity, showUIHandler, scaleCoefficient);
|
||||
view = mapActivity.getMapView();
|
||||
zoomTextPaint = new TextPaint();
|
||||
zoomTextPaint.setTextSize(18 * scaleCoefficient);
|
||||
zoomTextPaint.setAntiAlias(true);
|
||||
zoomTextPaint.setFakeBoldText(true);
|
||||
}
|
||||
|
||||
public boolean onSingleTap(PointF point, RotatedTileBox tileBox) {
|
||||
|
@ -105,15 +109,9 @@ public class MapZoomControls extends MapControls {
|
|||
|
||||
@Override
|
||||
public void initControls(FrameLayout parent) {
|
||||
zoomTextPaint = new TextPaint();
|
||||
zoomTextPaint.setTextSize(18 * scaleCoefficient);
|
||||
zoomTextPaint.setAntiAlias(true);
|
||||
zoomTextPaint.setFakeBoldText(true);
|
||||
|
||||
zoomShadow = view.getResources().getDrawable(R.drawable.zoom_background).mutate();
|
||||
mapMagnifier = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_magnifier);
|
||||
bitmapPaint = new Paint();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -218,8 +216,8 @@ public class MapZoomControls extends MapControls {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setShadowColor(int textColor, int shadowColor) {
|
||||
super.setShadowColor(textColor, shadowColor);
|
||||
public void updateTextColor(int textColor, int shadowColor) {
|
||||
super.updateTextColor(textColor, shadowColor);
|
||||
zoomTextPaint.setColor(textColor);
|
||||
}
|
||||
|
||||
|
@ -232,10 +230,5 @@ public class MapZoomControls extends MapControls {
|
|||
return buttonDrawable.getMinimumHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
Drawable buttonDrawable = view.getResources().getDrawable(R.drawable.map_zoom_in);
|
||||
return buttonDrawable.getMinimumWidth() + buttonDrawable.getMinimumWidth();
|
||||
}
|
||||
|
||||
}
|
|
@ -29,11 +29,10 @@ public class RulerControl extends MapControls {
|
|||
public RulerControl(MapZoomControls zoomControls, MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
||||
super(mapActivity, showUIHandler, scaleCoefficient);
|
||||
this.zoomControls = zoomControls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 0;
|
||||
rulerTextPaint = new TextPaint();
|
||||
rulerTextPaint.setTextSize(20 * scaleCoefficient);
|
||||
rulerTextPaint.setAntiAlias(true);
|
||||
rulerDrawable = mapActivity.getResources().getDrawable(R.drawable.ruler);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,17 +40,13 @@ public class RulerControl extends MapControls {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setShadowColor(int textColor, int shadowColor) {
|
||||
super.setShadowColor(textColor, shadowColor);
|
||||
public void updateTextColor(int textColor, int shadowColor) {
|
||||
super.updateTextColor(textColor, shadowColor);
|
||||
rulerTextPaint.setColor(textColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showControls(FrameLayout layout) {
|
||||
rulerTextPaint = new TextPaint();
|
||||
rulerTextPaint.setTextSize(20 * scaleCoefficient);
|
||||
rulerTextPaint.setAntiAlias(true);
|
||||
rulerDrawable = mapActivity.getResources().getDrawable(R.drawable.ruler);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,19 +73,19 @@ public class RulerControl extends MapControls {
|
|||
cacheRulerTextLen = rulerTextPaint.measureText(cacheRulerText.getText());
|
||||
Rect bounds = rulerDrawable.getBounds();
|
||||
bounds.right = (int) (view.getWidth() - 7 * scaleCoefficient);
|
||||
bounds.bottom = (int) (view.getHeight() - (!zoomControls.isVisible() ? 0 : zoomControls.getHeight()));
|
||||
bounds.top = bounds.bottom - rulerDrawable.getMinimumHeight();
|
||||
bounds.left = bounds.right - cacheRulerDistPix;
|
||||
rulerDrawable.setBounds(bounds);
|
||||
rulerDrawable.invalidateSelf();
|
||||
}
|
||||
|
||||
|
||||
if (cacheRulerText != null) {
|
||||
Rect bounds = rulerDrawable.getBounds();
|
||||
int bottom = (int) (view.getHeight() - (!zoomControls.isVisible() ? 0 : zoomControls.getHeight()));
|
||||
if(bounds.bottom != bottom) {
|
||||
bounds.bottom = bottom;
|
||||
bounds.top = bounds.bottom - rulerDrawable.getMinimumHeight();
|
||||
rulerDrawable.setBounds(bounds);
|
||||
rulerDrawable.invalidateSelf();
|
||||
}
|
||||
rulerDrawable.draw(canvas);
|
||||
cacheRulerText.draw(canvas, bounds.left + (bounds.width() - cacheRulerTextLen) / 2, bounds.bottom - 8 * scaleCoefficient,
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package net.osmand.plus.views.controls;
|
||||
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.os.Handler;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
public class SmallMapMenuControls extends MapControls {
|
||||
private Button backToMenuButton;
|
||||
|
||||
|
||||
public SmallMapMenuControls(MapActivity mapActivity, Handler showUIHandler, float scaleCoefficient) {
|
||||
super(mapActivity, showUIHandler, scaleCoefficient);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showControls(FrameLayout parent) {
|
||||
Context ctx = mapActivity;
|
||||
backToMenuButton = new Button(ctx);
|
||||
backToMenuButton.setContentDescription(ctx.getString(R.string.backToMenu));
|
||||
backToMenuButton.setBackgroundResource(R.drawable.map_btn_hmenu);
|
||||
android.widget.FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||
Gravity.BOTTOM | Gravity.LEFT);
|
||||
parent.addView(backToMenuButton, params);
|
||||
backToMenuButton.setEnabled(true);
|
||||
|
||||
backToMenuButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mapActivity.getMapActions().openOptionsMenuAsList();
|
||||
}
|
||||
});
|
||||
mapActivity.accessibleContent.add(backToMenuButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideControls(FrameLayout layout) {
|
||||
layout.removeView(backToMenuButton);
|
||||
mapActivity.accessibleContent.remove(backToMenuButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue