Add ruler widget

This commit is contained in:
Alexander Sytnyk 2017-05-30 16:01:50 +03:00
parent c316d23c0c
commit f157388b60
2 changed files with 15 additions and 1 deletions

View file

@ -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() {

View file

@ -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();