From f157388b609c8ceb1e0699b75647c9d88c160aeb Mon Sep 17 00:00:00 2001 From: Alexander Sytnyk Date: Tue, 30 May 2017 16:01:50 +0300 Subject: [PATCH] Add ruler widget --- OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java | 2 ++ .../views/mapwidgets/RouteInfoWidgetsFactory.java | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java index 8fdd297411..f3b3563305 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java @@ -193,6 +193,8 @@ public class MapInfoLayer extends OsmandMapLayer { registerSideWidget(plainTime, R.drawable.ic_action_time, R.string.map_widget_plain_time, "plain_time", false, 41); TextInfoWidget battery = ric.createBatteryControl(map); registerSideWidget(battery, R.drawable.ic_action_battery, R.string.map_widget_battery, "battery", false, 42); + TextInfoWidget ruler = ric.createRulerControl(map); + registerSideWidget(ruler, R.drawable.ic_action_ruler, R.string.map_widget_show_ruler, "ruler", false, 43); } public void recreateControls() { diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java index 1e420f964f..6bfc1d76a4 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java @@ -25,6 +25,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; +import android.widget.Toast; import net.osmand.Location; import net.osmand.binary.RouteDataObject; @@ -57,7 +58,6 @@ import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WidgetState; import net.osmand.router.RouteResultPreparation; import net.osmand.router.TurnType; import net.osmand.util.Algorithms; -import net.osmand.util.MapUtils; import java.util.ArrayList; import java.util.Arrays; @@ -375,6 +375,18 @@ public class RouteInfoWidgetsFactory { return batteryControl; } + public TextInfoWidget createRulerControl(final MapActivity map) { + final TextInfoWidget rulerControl = new TextInfoWidget(map); + rulerControl.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Toast.makeText(map, "Ruler Test", Toast.LENGTH_SHORT).show(); + } + }); + rulerControl.setIcons(R.drawable.widget_distance_day, R.drawable.widget_distance_night); + return rulerControl; + } + public TextInfoWidget createMaxSpeedControl(final MapActivity map) { final RoutingHelper rh = map.getMyApplication().getRoutingHelper();