Add packages for map widgets
This commit is contained in:
parent
790f4dbab3
commit
2966d87dd5
25 changed files with 481 additions and 453 deletions
|
@ -21,7 +21,7 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.views.AidlMapLayer;
|
||||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
|
@ -80,7 +80,7 @@ import net.osmand.plus.views.AidlMapLayer;
|
|||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||
import net.osmand.router.TurnType;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@ import net.osmand.plus.settings.fragments.BaseSettingsFragment;
|
|||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
|
||||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgetstates.WidgetState;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.GeoPointParserUtil.GeoParsedPoint;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
@ -2128,7 +2128,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
return DashAudioVideoNotesFragment.FRAGMENT_DATA;
|
||||
}
|
||||
|
||||
public class AudioVideoNotesWidgetState extends MapWidgetRegistry.WidgetState {
|
||||
public class AudioVideoNotesWidgetState extends WidgetState {
|
||||
|
||||
private static final int AV_WIDGET_STATE_ASK = R.id.av_notes_widget_state_ask;
|
||||
private static final int AV_WIDGET_STATE_AUDIO = R.id.av_notes_widget_state_audio;
|
||||
|
|
|
@ -18,7 +18,7 @@ import net.osmand.plus.settings.fragments.BaseSettingsFragment;
|
|||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||
|
||||
import static net.osmand.aidlapi.OsmAndCustomizationConstants.DRAWER_BUILDS_ID;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ import net.osmand.plus.views.MapInfoLayer;
|
|||
import net.osmand.plus.views.MapTileLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
|
||||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
|
|
@ -46,7 +46,7 @@ import net.osmand.plus.settings.fragments.BaseSettingsFragment;
|
|||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
|
|
@ -28,7 +28,7 @@ import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
|
|||
import net.osmand.plus.routing.RouteDirectionInfo;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.TurnPathHelper;
|
||||
import net.osmand.plus.views.mapwidgets.NextTurnInfoWidget.TurnDrawable;
|
||||
import net.osmand.plus.views.mapwidgets.TurnDrawable;
|
||||
import net.osmand.router.TurnType;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ import net.osmand.plus.views.AnimateDraggingMapThread;
|
|||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.CompassRulerControlWidgetState;
|
||||
import net.osmand.plus.views.mapwidgets.widgetstates.CompassRulerWidgetState;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopCoordinatesView;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||
|
@ -28,15 +28,15 @@ import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarView;
|
|||
import net.osmand.plus.views.mapwidgets.MapMarkersWidgetsFactory;
|
||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry;
|
||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
|
||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WidgetState;
|
||||
import net.osmand.plus.views.mapwidgets.NextTurnInfoWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgetstates.WidgetState;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.NextTurnWidget;
|
||||
import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory;
|
||||
import net.osmand.plus.views.mapwidgets.AlarmWidget;
|
||||
import net.osmand.plus.views.mapwidgets.BearingWidgetState;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.AlarmWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgetstates.BearingWidgetState;
|
||||
import net.osmand.plus.views.mapwidgets.LanesControl;
|
||||
import net.osmand.plus.views.mapwidgets.RulerWidget;
|
||||
import net.osmand.plus.views.mapwidgets.TimeControlWidgetState;
|
||||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.RulerWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgetstates.TimeWidgetState;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_ALTITUDE;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_BATTERY;
|
||||
|
@ -184,11 +184,11 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
// register left stack
|
||||
registerSideWidget(null, R.drawable.ic_action_compass, R.string.map_widget_compass, WIDGET_COMPASS, true, 4);
|
||||
|
||||
NextTurnInfoWidget bigInfoControl = ric.createNextInfoControl(map, app, false);
|
||||
NextTurnWidget bigInfoControl = ric.createNextInfoControl(map, app, false);
|
||||
registerSideWidget(bigInfoControl, R.drawable.ic_action_next_turn, R.string.map_widget_next_turn, WIDGET_NEXT_TURN, true, 5);
|
||||
NextTurnInfoWidget smallInfoControl = ric.createNextInfoControl(map, app, true);
|
||||
NextTurnWidget smallInfoControl = ric.createNextInfoControl(map, app, true);
|
||||
registerSideWidget(smallInfoControl, R.drawable.ic_action_next_turn, R.string.map_widget_next_turn_small, WIDGET_NEXT_TURN_SMALL, true, 6);
|
||||
NextTurnInfoWidget nextNextInfoControl = ric.createNextNextInfoControl(map, app, true);
|
||||
NextTurnWidget nextNextInfoControl = ric.createNextNextInfoControl(map, app, true);
|
||||
registerSideWidget(nextNextInfoControl, R.drawable.ic_action_next_turn, R.string.map_widget_next_next_turn, WIDGET_NEXT_NEXT_TURN,true, 7);
|
||||
|
||||
// register right stack
|
||||
|
@ -196,11 +196,11 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
TextInfoWidget intermediateDist = ric.createIntermediateDistanceControl(map);
|
||||
registerSideWidget(intermediateDist, R.drawable.ic_action_intermediate, R.string.map_widget_intermediate_distance, WIDGET_INTERMEDIATE_DISTANCE, false, 13);
|
||||
TextInfoWidget intermediateTime = ric.createTimeControl(map, true);
|
||||
registerSideWidget(intermediateTime, new TimeControlWidgetState(app, true), WIDGET_INTERMEDIATE_TIME, false, 14);
|
||||
registerSideWidget(intermediateTime, new TimeWidgetState(app, true), WIDGET_INTERMEDIATE_TIME, false, 14);
|
||||
TextInfoWidget dist = ric.createDistanceControl(map);
|
||||
registerSideWidget(dist, R.drawable.ic_action_target, R.string.map_widget_distance, WIDGET_DISTANCE, false, 15);
|
||||
TextInfoWidget time = ric.createTimeControl(map, false);
|
||||
registerSideWidget(time, new TimeControlWidgetState(app, false), WIDGET_TIME, false, 16);
|
||||
registerSideWidget(time, new TimeWidgetState(app, false), WIDGET_TIME, false, 16);
|
||||
|
||||
|
||||
TextInfoWidget marker = mwf.createMapMarkerControl(map, true);
|
||||
|
@ -224,7 +224,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
TextInfoWidget battery = ric.createBatteryControl(map);
|
||||
registerSideWidget(battery, R.drawable.ic_action_battery, R.string.map_widget_battery, WIDGET_BATTERY, false, 42);
|
||||
TextInfoWidget ruler = mic.createRulerControl(map);
|
||||
registerSideWidget(ruler, new CompassRulerControlWidgetState(app), WIDGET_RULER, false, 43);
|
||||
registerSideWidget(ruler, new CompassRulerWidgetState(app), WIDGET_RULER, false, 43);
|
||||
}
|
||||
|
||||
public void recreateControls() {
|
||||
|
|
|
@ -20,11 +20,13 @@ import net.osmand.plus.routing.RoutingHelper;
|
|||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||
import net.osmand.router.RouteResultPreparation;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class LanesControl {
|
||||
|
||||
private MapViewTrackingUtilities trackingUtilities;
|
||||
private OsmAndLocationProvider locationProvider;
|
||||
private MapRouteInfoMenu mapRouteInfoMenu;
|
||||
|
@ -39,19 +41,19 @@ public class LanesControl {
|
|||
private View centerInfo;
|
||||
private int shadowRadius;
|
||||
|
||||
public LanesControl(final MapActivity map, final OsmandMapTileView view) {
|
||||
lanesView = (ImageView) map.findViewById(R.id.map_lanes);
|
||||
lanesText = (TextView) map.findViewById(R.id.map_lanes_dist_text);
|
||||
lanesShadowText = (TextView) map.findViewById(R.id.map_lanes_dist_text_shadow);
|
||||
centerInfo = (View) map.findViewById(R.id.map_center_info);
|
||||
lanesDrawable = new LanesDrawable(map, map.getMapView().getScaleCoefficient());
|
||||
public LanesControl(MapActivity mapActivity, OsmandMapTileView view) {
|
||||
lanesView = mapActivity.findViewById(R.id.map_lanes);
|
||||
lanesText = mapActivity.findViewById(R.id.map_lanes_dist_text);
|
||||
lanesShadowText = mapActivity.findViewById(R.id.map_lanes_dist_text_shadow);
|
||||
centerInfo = mapActivity.findViewById(R.id.map_center_info);
|
||||
lanesDrawable = new LanesDrawable(mapActivity, mapActivity.getMapView().getScaleCoefficient());
|
||||
lanesView.setImageDrawable(lanesDrawable);
|
||||
trackingUtilities = map.getMapViewTrackingUtilities();
|
||||
locationProvider = map.getMyApplication().getLocationProvider();
|
||||
settings = map.getMyApplication().getSettings();
|
||||
mapRouteInfoMenu = map.getMapRouteInfoMenu();
|
||||
rh = map.getMyApplication().getRoutingHelper();
|
||||
app = map.getMyApplication();
|
||||
trackingUtilities = mapActivity.getMapViewTrackingUtilities();
|
||||
locationProvider = mapActivity.getMyApplication().getLocationProvider();
|
||||
settings = mapActivity.getMyApplication().getSettings();
|
||||
mapRouteInfoMenu = mapActivity.getMapRouteInfoMenu();
|
||||
rh = mapActivity.getMyApplication().getRoutingHelper();
|
||||
app = mapActivity.getMyApplication();
|
||||
}
|
||||
|
||||
public void updateTextSize(boolean isNight, int textColor, int textShadowColor, boolean textBold, int shadowRadius) {
|
||||
|
@ -134,4 +136,4 @@ public class LanesControl {
|
|||
AndroidUiHelper.updateVisibility(centerInfo, visible);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -68,8 +68,7 @@ import net.osmand.plus.settings.backend.OsmandSettings.RulerMode;
|
|||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.RulerControlLayer;
|
||||
import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WidgetState;
|
||||
import net.osmand.plus.views.mapwidgets.NextTurnInfoWidget.TurnDrawable;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||
import net.osmand.render.RenderingRuleSearchRequest;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -160,54 +159,6 @@ public class MapInfoWidgetsFactory {
|
|||
return gpsInfoControl;
|
||||
}
|
||||
|
||||
public static class CompassRulerControlWidgetState extends WidgetState {
|
||||
|
||||
public static final int COMPASS_CONTROL_WIDGET_STATE_SHOW = R.id.compass_ruler_control_widget_state_show;
|
||||
public static final int COMPASS_CONTROL_WIDGET_STATE_HIDE = R.id.compass_ruler_control_widget_state_hide;
|
||||
|
||||
private final OsmandSettings.OsmandPreference<Boolean> showCompass;
|
||||
|
||||
public CompassRulerControlWidgetState(OsmandApplication ctx) {
|
||||
super(ctx);
|
||||
showCompass = ctx.getSettings().SHOW_COMPASS_CONTROL_RULER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMenuTitleId() {
|
||||
return R.string.map_widget_ruler_control;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMenuIconId() {
|
||||
return R.drawable.ic_action_ruler_circle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMenuItemId() {
|
||||
return showCompass.get() ? COMPASS_CONTROL_WIDGET_STATE_SHOW : COMPASS_CONTROL_WIDGET_STATE_HIDE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getMenuTitleIds() {
|
||||
return new int[]{R.string.show_compass_ruler, R.string.hide_compass_ruler};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getMenuIconIds() {
|
||||
return new int[]{R.drawable.ic_action_compass_widget, R.drawable.ic_action_compass_widget_hide};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getMenuItemIds() {
|
||||
return new int[]{COMPASS_CONTROL_WIDGET_STATE_SHOW, COMPASS_CONTROL_WIDGET_STATE_HIDE};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeState(int stateId) {
|
||||
showCompass.set(stateId == COMPASS_CONTROL_WIDGET_STATE_SHOW);
|
||||
}
|
||||
}
|
||||
|
||||
public TextInfoWidget createRulerControl(final MapActivity map) {
|
||||
final String title = "—";
|
||||
final TextInfoWidget rulerControl = new TextInfoWidget(map) {
|
||||
|
@ -936,7 +887,7 @@ public class MapInfoWidgetsFactory {
|
|||
private boolean showMarker;
|
||||
|
||||
public TopTextView(OsmandApplication app, MapActivity map) {
|
||||
turnDrawable = new NextTurnInfoWidget.TurnDrawable(map, true);
|
||||
turnDrawable = new TurnDrawable(map, true);
|
||||
topBar = map.findViewById(R.id.map_top_bar);
|
||||
addressText = (TextView) map.findViewById(R.id.map_address_text);
|
||||
addressTextShadow = (TextView) map.findViewById(R.id.map_address_text_shadow);
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.osmand.plus.views.AnimateDraggingMapThread;
|
|||
import net.osmand.plus.views.DirectionDrawable;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ import net.osmand.plus.quickaction.QuickActionListFragment;
|
|||
import net.osmand.plus.views.MapInfoLayer;
|
||||
import net.osmand.plus.views.MapQuickActionLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgetstates.WidgetState;
|
||||
import net.osmand.plus.widgets.IconPopupMenu;
|
||||
|
||||
import java.util.Collections;
|
||||
|
@ -362,7 +364,7 @@ public class MapWidgetRegistry {
|
|||
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.coordinates_widget, map)
|
||||
.setIcon(R.drawable.ic_action_coordinates_widget)
|
||||
.setSelected(settings.SHOW_COORDINATES_WIDGET.get())
|
||||
.setListener(new ApearanceItemClickListener(settings.SHOW_COORDINATES_WIDGET, map))
|
||||
.setListener(new AppearanceItemClickListener(settings.SHOW_COORDINATES_WIDGET, map))
|
||||
.setLayout(R.layout.list_item_icon_and_switch).createItem());
|
||||
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_markers, map)
|
||||
.setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map))
|
||||
|
@ -408,14 +410,13 @@ public class MapWidgetRegistry {
|
|||
@StringRes int stringId, OsmandPreference<Boolean> pref) {
|
||||
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(stringId, map)
|
||||
.setSelected(pref.get())
|
||||
.setListener(new ApearanceItemClickListener(pref, map)).createItem());
|
||||
.setListener(new AppearanceItemClickListener(pref, map)).createItem());
|
||||
}
|
||||
|
||||
public static boolean distChanged(int oldDist, int dist) {
|
||||
return !(oldDist != 0 && oldDist - dist < 100 && Math.abs(((float) dist - oldDist) / oldDist) < 0.01);
|
||||
}
|
||||
|
||||
|
||||
public void addControls(MapActivity map, ContextMenuAdapter cm, ApplicationMode mode) {
|
||||
addQuickActionControl(map, cm, mode);
|
||||
// Right panel
|
||||
|
@ -819,49 +820,23 @@ public class MapWidgetRegistry {
|
|||
return cm;
|
||||
}
|
||||
|
||||
class ApearanceItemClickListener implements ContextMenuAdapter.ItemClickListener {
|
||||
private MapActivity map;
|
||||
static class AppearanceItemClickListener implements ContextMenuAdapter.ItemClickListener {
|
||||
|
||||
private MapActivity mapActivity;
|
||||
private OsmandPreference<Boolean> pref;
|
||||
|
||||
public ApearanceItemClickListener(OsmandPreference<Boolean> pref, MapActivity map) {
|
||||
public AppearanceItemClickListener(OsmandPreference<Boolean> pref, MapActivity mapActivity) {
|
||||
this.pref = pref;
|
||||
this.map = map;
|
||||
this.mapActivity = mapActivity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> a,
|
||||
int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
|
||||
pref.set(!pref.get());
|
||||
map.updateApplicationModeSettings();
|
||||
mapActivity.updateApplicationModeSettings();
|
||||
a.notifyDataSetChanged();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class WidgetState {
|
||||
|
||||
private OsmandApplication ctx;
|
||||
|
||||
public OsmandApplication getCtx() {
|
||||
return ctx;
|
||||
}
|
||||
|
||||
public WidgetState(OsmandApplication ctx) {
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public abstract int getMenuTitleId();
|
||||
|
||||
public abstract int getMenuIconId();
|
||||
|
||||
public abstract int getMenuItemId();
|
||||
|
||||
public abstract int[] getMenuTitleIds();
|
||||
|
||||
public abstract int[] getMenuIconIds();
|
||||
|
||||
public abstract int[] getMenuItemIds();
|
||||
|
||||
public abstract void changeState(int stateId);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,236 +0,0 @@
|
|||
package net.osmand.plus.views.mapwidgets;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Align;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextPaint;
|
||||
|
||||
import androidx.annotation.ColorRes;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.TurnPathHelper;
|
||||
import net.osmand.router.TurnType;
|
||||
|
||||
|
||||
|
||||
public class NextTurnInfoWidget extends TextInfoWidget {
|
||||
|
||||
protected boolean horisontalMini;
|
||||
|
||||
protected int deviatedPath = 0;
|
||||
protected int nextTurnDistance = 0;
|
||||
|
||||
private TurnDrawable turnDrawable;
|
||||
private OsmandApplication app;
|
||||
|
||||
|
||||
public NextTurnInfoWidget(Activity activity, OsmandApplication app, boolean horisontalMini) {
|
||||
super(activity);
|
||||
this.app = app;
|
||||
this.horisontalMini = horisontalMini;
|
||||
turnDrawable = new TurnDrawable(activity, horisontalMini);
|
||||
if(horisontalMini) {
|
||||
setImageDrawable(turnDrawable, false);
|
||||
setTopImageDrawable(null, null);
|
||||
} else {
|
||||
setImageDrawable(null, true);
|
||||
setTopImageDrawable(turnDrawable, "");
|
||||
}
|
||||
}
|
||||
|
||||
public TurnType getTurnType() {
|
||||
return turnDrawable.turnType;
|
||||
}
|
||||
|
||||
public void setTurnType(TurnType turnType) {
|
||||
boolean vis = updateVisibility(turnType != null);
|
||||
if (turnDrawable.setTurnType(turnType) || vis) {
|
||||
turnDrawable.setTextPaint(topTextView.getPaint());
|
||||
if(horisontalMini) {
|
||||
setImageDrawable(turnDrawable, false);
|
||||
} else {
|
||||
setTopImageDrawable(turnDrawable, "");
|
||||
// setTopImageDrawable(turnDrawable, turnType == null || turnType.getExitOut() == 0 ? "" :
|
||||
// turnType.getExitOut() + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTurnImminent(int turnImminent, boolean deviatedFromRoute) {
|
||||
if(turnDrawable.turnImminent != turnImminent || turnDrawable.deviatedFromRoute != deviatedFromRoute) {
|
||||
turnDrawable.setTurnImminent(turnImminent, deviatedFromRoute);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDeviatePath(int deviatePath) {
|
||||
if (RouteInfoWidgetsFactory.distChanged(deviatePath, this.deviatedPath)) {
|
||||
this.deviatedPath = deviatePath;
|
||||
updateDistance();
|
||||
}
|
||||
}
|
||||
|
||||
public void setTurnDistance(int nextTurnDistance) {
|
||||
if (RouteInfoWidgetsFactory.distChanged(nextTurnDistance, this.nextTurnDistance)) {
|
||||
this.nextTurnDistance = nextTurnDistance;
|
||||
updateDistance();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDistance() {
|
||||
int deviatePath = turnDrawable.deviatedFromRoute ? deviatedPath : nextTurnDistance;
|
||||
String ds = OsmAndFormatter.getFormattedDistance(deviatePath, app);
|
||||
|
||||
if (ds != null) {
|
||||
TurnType turnType = getTurnType();
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if ((turnType != null) && (routingHelper != null)) {
|
||||
setContentDescription(ds + " " + routingHelper.getRoute().toString(turnType, app, false));
|
||||
} else {
|
||||
setContentDescription(ds);
|
||||
}
|
||||
}
|
||||
|
||||
int ls = ds.lastIndexOf(' ');
|
||||
if (ls == -1) {
|
||||
setTextNoUpdateVisibility(ds, null);
|
||||
} else {
|
||||
setTextNoUpdateVisibility(ds.substring(0, ls), ds.substring(ls + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings drawSettings) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class TurnDrawable extends Drawable {
|
||||
protected Paint paintBlack;
|
||||
protected Paint paintRouteDirection;
|
||||
protected Path pathForTurn = new Path();
|
||||
protected Path pathForTurnOutlay = new Path();
|
||||
protected TurnType turnType = null;
|
||||
protected int turnImminent;
|
||||
protected boolean deviatedFromRoute;
|
||||
private Context ctx;
|
||||
private boolean mini;
|
||||
private PointF centerText;
|
||||
private TextPaint textPaint;
|
||||
private int clr;
|
||||
|
||||
public TurnDrawable(Context ctx, boolean mini) {
|
||||
this.ctx = ctx;
|
||||
this.mini = mini;
|
||||
centerText = new PointF();
|
||||
paintBlack = new Paint();
|
||||
paintBlack.setStyle(Style.STROKE);
|
||||
paintBlack.setColor(Color.BLACK);
|
||||
paintBlack.setAntiAlias(true);
|
||||
paintBlack.setStrokeWidth(2.5f);
|
||||
|
||||
|
||||
paintRouteDirection = new Paint();
|
||||
paintRouteDirection.setStyle(Style.FILL);
|
||||
paintRouteDirection.setAntiAlias(true);
|
||||
setColor(R.color.nav_arrow);
|
||||
}
|
||||
|
||||
@ColorRes
|
||||
public void setColor(int clr) {
|
||||
if(clr != this.clr) {
|
||||
this.clr = clr;
|
||||
paintRouteDirection.setColor(ctx.getResources().getColor(clr));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBoundsChange(Rect bounds) {
|
||||
Matrix m = new Matrix();
|
||||
float scaleX = bounds.width() / 72f;
|
||||
float scaleY = bounds.height() / 72f;
|
||||
m.setScale(scaleX, scaleY);
|
||||
pathForTurn.transform(m, pathForTurn);
|
||||
centerText.x = scaleX * centerText.x;
|
||||
centerText.y = scaleY * centerText.y;
|
||||
pathForTurnOutlay.transform(m, pathForTurnOutlay);
|
||||
}
|
||||
|
||||
public void setTurnImminent(int turnImminent, boolean deviatedFromRoute) {
|
||||
//if user deviates from route that we should draw grey arrow
|
||||
this.turnImminent = turnImminent;
|
||||
this.deviatedFromRoute = deviatedFromRoute;
|
||||
if (deviatedFromRoute){
|
||||
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow_distant));
|
||||
} else if (turnImminent > 0) {
|
||||
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow));
|
||||
} else if (turnImminent == 0) {
|
||||
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow_imminent));
|
||||
} else {
|
||||
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow_distant));
|
||||
}
|
||||
invalidateSelf();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
/// small indent
|
||||
// canvas.translate(0, 3 * scaleCoefficient);
|
||||
canvas.drawPath(pathForTurnOutlay, paintBlack);
|
||||
canvas.drawPath(pathForTurn, paintRouteDirection);
|
||||
canvas.drawPath(pathForTurn, paintBlack);
|
||||
if(textPaint != null ) {
|
||||
if (turnType != null && !mini && turnType.getExitOut() > 0) {
|
||||
canvas.drawText(turnType.getExitOut() + "", centerText.x,
|
||||
centerText.y - (textPaint.descent() + textPaint.ascent()) / 2, textPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTextPaint(TextPaint textPaint) {
|
||||
this.textPaint = textPaint;
|
||||
this.textPaint.setTextAlign(Align.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
paintRouteDirection.setAlpha(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
paintRouteDirection.setColorFilter(cf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean setTurnType(TurnType turnType) {
|
||||
if(turnType != this.turnType) {
|
||||
this.turnType = turnType;
|
||||
TurnPathHelper.calcTurnPath(pathForTurn, pathForTurnOutlay, turnType, null,
|
||||
centerText, mini, false, true, false);
|
||||
onBoundsChange(getBounds());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -27,17 +27,22 @@ import net.osmand.plus.settings.backend.OsmandSettings;
|
|||
import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.AlarmWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.DistanceToPointWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.NextTurnWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.RulerWidget;
|
||||
import net.osmand.plus.views.mapwidgets.widgets.TextInfoWidget;
|
||||
import net.osmand.router.TurnType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RouteInfoWidgetsFactory {
|
||||
|
||||
public NextTurnInfoWidget createNextInfoControl(final Activity activity,
|
||||
final OsmandApplication app, boolean horisontalMini) {
|
||||
public NextTurnWidget createNextInfoControl(final Activity activity,
|
||||
final OsmandApplication app, boolean horisontalMini) {
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
final RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
final NextTurnInfoWidget nextTurnInfo = new NextTurnInfoWidget(activity, app, horisontalMini) {
|
||||
final NextTurnWidget nextTurnInfo = new NextTurnWidget(activity, app, horisontalMini) {
|
||||
NextDirectionInfo calc1 = new NextDirectionInfo();
|
||||
|
||||
@Override
|
||||
|
@ -99,10 +104,10 @@ public class RouteInfoWidgetsFactory {
|
|||
return nextTurnInfo;
|
||||
}
|
||||
|
||||
public NextTurnInfoWidget createNextNextInfoControl(final Activity activity,
|
||||
final OsmandApplication app, boolean horisontalMini) {
|
||||
public NextTurnWidget createNextNextInfoControl(final Activity activity,
|
||||
final OsmandApplication app, boolean horisontalMini) {
|
||||
final RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
final NextTurnInfoWidget nextTurnInfo = new NextTurnInfoWidget(activity, app, horisontalMini) {
|
||||
final NextTurnWidget nextTurnInfo = new NextTurnWidget(activity, app, horisontalMini) {
|
||||
NextDirectionInfo calc1 = new NextDirectionInfo();
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings drawSettings) {
|
||||
|
@ -395,7 +400,7 @@ public class RouteInfoWidgetsFactory {
|
|||
}
|
||||
|
||||
public TextInfoWidget createDistanceControl(final MapActivity map) {
|
||||
DistanceToPointInfoControl distanceControl = new DistanceToPointInfoControl(map, R.drawable.widget_target_day,
|
||||
DistanceToPointWidget distanceControl = new DistanceToPointWidget(map, R.drawable.widget_target_day,
|
||||
R.drawable.widget_target_night) {
|
||||
@Override
|
||||
public LatLon getPointToNavigate() {
|
||||
|
@ -416,7 +421,7 @@ public class RouteInfoWidgetsFactory {
|
|||
|
||||
public TextInfoWidget createIntermediateDistanceControl(final MapActivity map) {
|
||||
final TargetPointsHelper targets = map.getMyApplication().getTargetPointsHelper();
|
||||
DistanceToPointInfoControl distanceControl = new DistanceToPointInfoControl(map, R.drawable.widget_intermediate_day,
|
||||
DistanceToPointWidget distanceControl = new DistanceToPointWidget(map, R.drawable.widget_intermediate_day,
|
||||
R.drawable.widget_intermediate_night) {
|
||||
|
||||
@Override
|
||||
|
@ -458,7 +463,7 @@ public class RouteInfoWidgetsFactory {
|
|||
private float MIN_SPEED_FOR_HEADING = 1f;
|
||||
|
||||
private LatLon getNextTargetPoint() {
|
||||
List<TargetPoint> points = getOsmandApplication().getTargetPointsHelper().getIntermediatePointsWithTarget();
|
||||
List<TargetPoint> points = getApplication().getTargetPointsHelper().getIntermediatePointsWithTarget();
|
||||
return points.isEmpty() ? null : points.get(0).point;
|
||||
}
|
||||
|
||||
|
@ -471,7 +476,7 @@ public class RouteInfoWidgetsFactory {
|
|||
if (isUpdateNeeded() || degreesChanged(cachedDegrees, b) || modeChanged) {
|
||||
cachedDegrees = b;
|
||||
if (b != -1000) {
|
||||
setText(OsmAndFormatter.getFormattedAzimuth(b, getOsmandApplication()) + (relative ? "" : " M"), null);
|
||||
setText(OsmAndFormatter.getFormattedAzimuth(b, getApplication()) + (relative ? "" : " M"), null);
|
||||
} else {
|
||||
setText(null, null);
|
||||
}
|
||||
|
@ -487,10 +492,10 @@ public class RouteInfoWidgetsFactory {
|
|||
|
||||
public int getBearing(boolean relative) {
|
||||
int d = -1000;
|
||||
Location myLocation = getOsmandApplication().getLocationProvider().getLastKnownLocation();
|
||||
Location myLocation = getApplication().getLocationProvider().getLastKnownLocation();
|
||||
LatLon l = getNextTargetPoint();
|
||||
if (l == null) {
|
||||
List<MapMarker> markers = getOsmandApplication().getMapMarkersHelper().getMapMarkers();
|
||||
List<MapMarker> markers = getApplication().getMapMarkersHelper().getMapMarkers();
|
||||
if (markers.size() > 0) {
|
||||
l = markers.get(0).point;
|
||||
}
|
||||
|
@ -505,7 +510,7 @@ public class RouteInfoWidgetsFactory {
|
|||
float bearingToDest = dest.getBearing() - destGf.getDeclination();
|
||||
if (relative) {
|
||||
float b = -1000;
|
||||
Float heading = getOsmandApplication().getLocationProvider().getHeading();
|
||||
Float heading = getApplication().getLocationProvider().getHeading();
|
||||
if ((myLocation.getSpeed() < MIN_SPEED_FOR_HEADING || !myLocation.hasBearing())
|
||||
&& heading != null) {
|
||||
b = heading;
|
||||
|
|
146
OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java
Normal file
146
OsmAnd/src/net/osmand/plus/views/mapwidgets/TurnDrawable.java
Normal file
|
@ -0,0 +1,146 @@
|
|||
package net.osmand.plus.views.mapwidgets;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextPaint;
|
||||
|
||||
import androidx.annotation.ColorRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.views.TurnPathHelper;
|
||||
import net.osmand.router.TurnType;
|
||||
|
||||
public class TurnDrawable extends Drawable {
|
||||
|
||||
protected Paint paintBlack;
|
||||
protected Paint paintRouteDirection;
|
||||
protected Path pathForTurn = new Path();
|
||||
protected Path pathForTurnOutlay = new Path();
|
||||
protected TurnType turnType = null;
|
||||
protected int turnImminent;
|
||||
protected boolean deviatedFromRoute;
|
||||
private Context ctx;
|
||||
private boolean mini;
|
||||
private PointF centerText;
|
||||
private TextPaint textPaint;
|
||||
private int clr;
|
||||
|
||||
public TurnDrawable(Context ctx, boolean mini) {
|
||||
this.ctx = ctx;
|
||||
this.mini = mini;
|
||||
centerText = new PointF();
|
||||
paintBlack = new Paint();
|
||||
paintBlack.setStyle(Paint.Style.STROKE);
|
||||
paintBlack.setColor(Color.BLACK);
|
||||
paintBlack.setAntiAlias(true);
|
||||
paintBlack.setStrokeWidth(2.5f);
|
||||
|
||||
paintRouteDirection = new Paint();
|
||||
paintRouteDirection.setStyle(Paint.Style.FILL);
|
||||
paintRouteDirection.setAntiAlias(true);
|
||||
setColor(R.color.nav_arrow);
|
||||
}
|
||||
|
||||
public void setColor(@ColorRes int clr) {
|
||||
if (clr != this.clr) {
|
||||
this.clr = clr;
|
||||
paintRouteDirection.setColor(ContextCompat.getColor(ctx, clr));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBoundsChange(Rect bounds) {
|
||||
Matrix m = new Matrix();
|
||||
float scaleX = bounds.width() / 72f;
|
||||
float scaleY = bounds.height() / 72f;
|
||||
m.setScale(scaleX, scaleY);
|
||||
pathForTurn.transform(m, pathForTurn);
|
||||
centerText.x = scaleX * centerText.x;
|
||||
centerText.y = scaleY * centerText.y;
|
||||
pathForTurnOutlay.transform(m, pathForTurnOutlay);
|
||||
}
|
||||
|
||||
public int getTurnImminent() {
|
||||
return turnImminent;
|
||||
}
|
||||
|
||||
public boolean isDeviatedFromRoute() {
|
||||
return deviatedFromRoute;
|
||||
}
|
||||
|
||||
public void setTurnImminent(int turnImminent, boolean deviatedFromRoute) {
|
||||
//if user deviates from route that we should draw grey arrow
|
||||
this.turnImminent = turnImminent;
|
||||
this.deviatedFromRoute = deviatedFromRoute;
|
||||
if (deviatedFromRoute) {
|
||||
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow_distant));
|
||||
} else if (turnImminent > 0) {
|
||||
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow));
|
||||
} else if (turnImminent == 0) {
|
||||
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow_imminent));
|
||||
} else {
|
||||
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow_distant));
|
||||
}
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
/// small indent
|
||||
// canvas.translate(0, 3 * scaleCoefficient);
|
||||
canvas.drawPath(pathForTurnOutlay, paintBlack);
|
||||
canvas.drawPath(pathForTurn, paintRouteDirection);
|
||||
canvas.drawPath(pathForTurn, paintBlack);
|
||||
if (textPaint != null) {
|
||||
if (turnType != null && !mini && turnType.getExitOut() > 0) {
|
||||
canvas.drawText(turnType.getExitOut() + "", centerText.x,
|
||||
centerText.y - (textPaint.descent() + textPaint.ascent()) / 2, textPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTextPaint(TextPaint textPaint) {
|
||||
this.textPaint = textPaint;
|
||||
this.textPaint.setTextAlign(Paint.Align.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
paintRouteDirection.setAlpha(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
paintRouteDirection.setColorFilter(cf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public TurnType getTurnType() {
|
||||
return turnType;
|
||||
}
|
||||
|
||||
public boolean setTurnType(TurnType turnType) {
|
||||
if (turnType != this.turnType) {
|
||||
this.turnType = turnType;
|
||||
TurnPathHelper.calcTurnPath(pathForTurn, pathForTurnOutlay, turnType, null,
|
||||
centerText, mini, false, true, false);
|
||||
onBoundsChange(getBounds());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package net.osmand.plus.views.mapwidgets;
|
||||
package net.osmand.plus.views.mapwidgets.widgets;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.view.View;
|
||||
|
@ -33,7 +33,7 @@ public class AlarmWidget {
|
|||
private TextView widgetText;
|
||||
private TextView widgetBottomText;
|
||||
private OsmandSettings settings;
|
||||
private RoutingHelper rh;
|
||||
private RoutingHelper routingHelper;
|
||||
private MapViewTrackingUtilities trackingUtilities;
|
||||
private OsmAndLocationProvider locationProvider;
|
||||
private WaypointHelper wh;
|
||||
|
@ -44,11 +44,11 @@ public class AlarmWidget {
|
|||
|
||||
public AlarmWidget(final OsmandApplication app, MapActivity ma) {
|
||||
layout = ma.findViewById(R.id.map_alarm_warning);
|
||||
icon = (ImageView) ma.findViewById(R.id.map_alarm_warning_icon);
|
||||
widgetText = (TextView) ma.findViewById(R.id.map_alarm_warning_text);
|
||||
widgetBottomText = (TextView) ma.findViewById(R.id.map_alarm_warning_text_bottom);
|
||||
icon = ma.findViewById(R.id.map_alarm_warning_icon);
|
||||
widgetText = ma.findViewById(R.id.map_alarm_warning_text);
|
||||
widgetBottomText = ma.findViewById(R.id.map_alarm_warning_text_bottom);
|
||||
settings = app.getSettings();
|
||||
rh = ma.getRoutingHelper();
|
||||
routingHelper = ma.getRoutingHelper();
|
||||
trackingUtilities = ma.getMapViewTrackingUtilities();
|
||||
locationProvider = app.getLocationProvider();
|
||||
wh = app.getWaypointHelper();
|
||||
|
@ -62,10 +62,10 @@ public class AlarmWidget {
|
|||
boolean tunnels = settings.SHOW_TUNNELS.get();
|
||||
boolean browseMap = settings.APPLICATION_MODE.get() == ApplicationMode.DEFAULT;
|
||||
boolean visible = false;
|
||||
if ((rh.isFollowingMode() || trackingUtilities.isMapLinkedToLocation() && !browseMap)
|
||||
if ((routingHelper.isFollowingMode() || trackingUtilities.isMapLinkedToLocation() && !browseMap)
|
||||
&& showRoutingAlarms && (trafficWarnings || cams)) {
|
||||
AlarmInfo alarm;
|
||||
if (rh.isFollowingMode() && !rh.isDeviatedFromRoute() && (rh.getCurrentGPXRoute() == null || rh.isCurrentGPXRouteV2())) {
|
||||
if (routingHelper.isFollowingMode() && !routingHelper.isDeviatedFromRoute() && (routingHelper.getCurrentGPXRoute() == null || routingHelper.isCurrentGPXRouteV2())) {
|
||||
alarm = wh.getMostImportantAlarm(settings.SPEED_SYSTEM.get(), cams);
|
||||
} else {
|
||||
RouteDataObject ro = locationProvider.getLastKnownRouteSegment();
|
||||
|
@ -188,6 +188,6 @@ public class AlarmWidget {
|
|||
}
|
||||
|
||||
public void setVisibility(boolean visibility) {
|
||||
layout.setVisibility(visibility ? View.VISIBLE : View.GONE);
|
||||
AndroidUiHelper.updateVisibility(layout, visibility);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package net.osmand.plus.views.mapwidgets;
|
||||
package net.osmand.plus.views.mapwidgets.widgets;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
|
@ -9,14 +9,15 @@ import net.osmand.plus.activities.MapActivity;
|
|||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory;
|
||||
|
||||
public abstract class DistanceToPointInfoControl extends TextInfoWidget {
|
||||
public abstract class DistanceToPointWidget extends TextInfoWidget {
|
||||
|
||||
private final OsmandMapTileView view;
|
||||
private float[] calculations = new float[1];
|
||||
private int cachedMeters;
|
||||
|
||||
public DistanceToPointInfoControl(MapActivity ma, int res, int resNight) {
|
||||
public DistanceToPointWidget(MapActivity ma, int res, int resNight) {
|
||||
super(ma);
|
||||
this.view = ma.getMapView();
|
||||
if (res != 0 && resNight != 0) {
|
||||
|
@ -36,7 +37,7 @@ public abstract class DistanceToPointInfoControl extends TextInfoWidget {
|
|||
AnimateDraggingMapThread thread = view.getAnimatedDraggingThread();
|
||||
LatLon pointToNavigate = getPointToNavigate();
|
||||
if (pointToNavigate != null) {
|
||||
int fZoom = view.getZoom() < 15 ? 15 : view.getZoom();
|
||||
int fZoom = Math.max(view.getZoom(), 15);
|
||||
thread.startMoving(pointToNavigate.getLatitude(), pointToNavigate.getLongitude(), fZoom, true);
|
||||
}
|
||||
}
|
||||
|
@ -79,4 +80,4 @@ public abstract class DistanceToPointInfoControl extends TextInfoWidget {
|
|||
}
|
||||
return d;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package net.osmand.plus.views.mapwidgets.widgets;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.routing.RouteCalculationResult;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory;
|
||||
import net.osmand.plus.views.mapwidgets.TurnDrawable;
|
||||
import net.osmand.router.TurnType;
|
||||
|
||||
public class NextTurnWidget extends TextInfoWidget {
|
||||
|
||||
protected boolean horizontalMini;
|
||||
|
||||
protected int deviatedPath = 0;
|
||||
protected int nextTurnDistance = 0;
|
||||
|
||||
private TurnDrawable turnDrawable;
|
||||
private OsmandApplication app;
|
||||
|
||||
public NextTurnWidget(Activity activity, OsmandApplication app, boolean horizontalMini) {
|
||||
super(activity);
|
||||
this.app = app;
|
||||
this.horizontalMini = horizontalMini;
|
||||
turnDrawable = new TurnDrawable(activity, horizontalMini);
|
||||
if (horizontalMini) {
|
||||
setImageDrawable(turnDrawable, false);
|
||||
setTopImageDrawable(null, null);
|
||||
} else {
|
||||
setImageDrawable(null, true);
|
||||
setTopImageDrawable(turnDrawable, "");
|
||||
}
|
||||
}
|
||||
|
||||
public TurnType getTurnType() {
|
||||
return turnDrawable.getTurnType();
|
||||
}
|
||||
|
||||
public void setTurnType(TurnType turnType) {
|
||||
boolean vis = updateVisibility(turnType != null);
|
||||
if (turnDrawable.setTurnType(turnType) || vis) {
|
||||
turnDrawable.setTextPaint(topTextView.getPaint());
|
||||
if (horizontalMini) {
|
||||
setImageDrawable(turnDrawable, false);
|
||||
} else {
|
||||
setTopImageDrawable(turnDrawable, "");
|
||||
// setTopImageDrawable(turnDrawable, turnType == null || turnType.getExitOut() == 0 ? "" :
|
||||
// turnType.getExitOut() + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTurnImminent(int turnImminent, boolean deviatedFromRoute) {
|
||||
if (turnDrawable.getTurnImminent() != turnImminent || turnDrawable.isDeviatedFromRoute() != deviatedFromRoute) {
|
||||
turnDrawable.setTurnImminent(turnImminent, deviatedFromRoute);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDeviatePath(int deviatePath) {
|
||||
if (RouteInfoWidgetsFactory.distChanged(deviatePath, this.deviatedPath)) {
|
||||
this.deviatedPath = deviatePath;
|
||||
updateDistance();
|
||||
}
|
||||
}
|
||||
|
||||
public void setTurnDistance(int nextTurnDistance) {
|
||||
if (RouteInfoWidgetsFactory.distChanged(nextTurnDistance, this.nextTurnDistance)) {
|
||||
this.nextTurnDistance = nextTurnDistance;
|
||||
updateDistance();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDistance() {
|
||||
int deviatePath = turnDrawable.isDeviatedFromRoute() ? deviatedPath : nextTurnDistance;
|
||||
String ds = OsmAndFormatter.getFormattedDistance(deviatePath, app);
|
||||
|
||||
TurnType turnType = getTurnType();
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if ((turnType != null) && (routingHelper != null)) {
|
||||
setContentDescription(ds + " " + RouteCalculationResult.toString(turnType, app, false));
|
||||
} else {
|
||||
setContentDescription(ds);
|
||||
}
|
||||
|
||||
int ls = ds.lastIndexOf(' ');
|
||||
if (ls == -1) {
|
||||
setTextNoUpdateVisibility(ds, null);
|
||||
} else {
|
||||
setTextNoUpdateVisibility(ds.substring(0, ls), ds.substring(ls + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateInfo(DrawSettings drawSettings) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package net.osmand.plus.views.mapwidgets;
|
||||
package net.osmand.plus.views.mapwidgets.widgets;
|
||||
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -12,7 +12,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
||||
public class RulerWidget {
|
||||
|
@ -21,7 +21,7 @@ public class RulerWidget {
|
|||
private ImageView icon;
|
||||
private TextView text;
|
||||
private TextView textShadow;
|
||||
private MapActivity ma;
|
||||
private MapActivity mapActivity;
|
||||
private String cacheRulerText;
|
||||
private int maxWidth;
|
||||
private float cacheMapDensity;
|
||||
|
@ -31,15 +31,15 @@ public class RulerWidget {
|
|||
private double cacheRulerTileY;
|
||||
private boolean orientationPortrait;
|
||||
|
||||
public RulerWidget(final OsmandApplication app, MapActivity ma) {
|
||||
this.ma = ma;
|
||||
layout = ma.findViewById(R.id.map_ruler_layout);
|
||||
icon = (ImageView) ma.findViewById(R.id.map_ruler_image);
|
||||
text = (TextView) ma.findViewById(R.id.map_ruler_text);
|
||||
textShadow = (TextView) ma.findViewById(R.id.map_ruler_text_shadow);
|
||||
maxWidth = ma.getResources().getDimensionPixelSize(R.dimen.map_ruler_width);
|
||||
orientationPortrait = AndroidUiHelper.isOrientationPortrait(ma);
|
||||
mapDensity = ma.getMyApplication().getSettings().MAP_DENSITY;
|
||||
public RulerWidget(OsmandApplication app, MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
layout = mapActivity.findViewById(R.id.map_ruler_layout);
|
||||
icon = mapActivity.findViewById(R.id.map_ruler_image);
|
||||
text = mapActivity.findViewById(R.id.map_ruler_text);
|
||||
textShadow = mapActivity.findViewById(R.id.map_ruler_text_shadow);
|
||||
maxWidth = mapActivity.getResources().getDimensionPixelSize(R.dimen.map_ruler_width);
|
||||
orientationPortrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
mapDensity = mapActivity.getMyApplication().getSettings().MAP_DENSITY;
|
||||
cacheMapDensity = mapDensity.get();
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,9 @@ public class RulerWidget {
|
|||
icon.setBackgroundResource(isNight ? R.drawable.ruler_night : R.drawable.ruler);
|
||||
}
|
||||
|
||||
public boolean updateInfo(RotatedTileBox tb, OsmandMapLayer.DrawSettings nightMode) {
|
||||
public boolean updateInfo(RotatedTileBox tb, DrawSettings nightMode) {
|
||||
boolean visible = true;
|
||||
OsmandMapTileView view = ma.getMapView();
|
||||
OsmandMapTileView view = mapActivity.getMapView();
|
||||
// update cache
|
||||
if (view.isZooming()) {
|
||||
visible = false;
|
||||
|
@ -79,6 +79,6 @@ public class RulerWidget {
|
|||
}
|
||||
|
||||
public void setVisibility(boolean visibility) {
|
||||
layout.setVisibility(visibility ? View.VISIBLE : View.GONE);
|
||||
AndroidUiHelper.updateVisibility(layout, visibility);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package net.osmand.plus.views.mapwidgets;
|
||||
package net.osmand.plus.views.mapwidgets.widgets;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Paint.Style;
|
||||
|
@ -19,7 +19,9 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
|
||||
public class TextInfoWidget {
|
||||
public class TextInfoWidget {
|
||||
|
||||
private OsmandApplication app;
|
||||
|
||||
private String contentTitle;
|
||||
private View view;
|
||||
|
@ -31,7 +33,6 @@ public class TextInfoWidget {
|
|||
private ImageView topImageView;
|
||||
protected TextView topTextView;
|
||||
private boolean explicitlyVisible;
|
||||
private OsmandApplication app;
|
||||
|
||||
private int dayIcon;
|
||||
private int nightIcon;
|
||||
|
@ -44,35 +45,34 @@ public class TextInfoWidget {
|
|||
public TextInfoWidget(Activity activity) {
|
||||
app = (OsmandApplication) activity.getApplication();
|
||||
view = UiUtilities.getInflater(activity, isNight).inflate(R.layout.map_hud_widget, null);
|
||||
bottomLayout = (ViewGroup) view.findViewById(R.id.widget_bottom_layout);
|
||||
topImageView = (ImageView) view.findViewById(R.id.widget_top_icon);
|
||||
topTextView = (TextView) view.findViewById(R.id.widget_top_icon_text);
|
||||
imageView = (ImageView) view.findViewById(R.id.widget_icon);
|
||||
textView = (TextView) view.findViewById(R.id.widget_text);
|
||||
textViewShadow = (TextView) view.findViewById(R.id.widget_text_shadow);
|
||||
smallTextViewShadow = (TextView) view.findViewById(R.id.widget_text_small_shadow);
|
||||
smallTextView = (TextView) view.findViewById(R.id.widget_text_small);
|
||||
bottomLayout = view.findViewById(R.id.widget_bottom_layout);
|
||||
topImageView = view.findViewById(R.id.widget_top_icon);
|
||||
topTextView = view.findViewById(R.id.widget_top_icon_text);
|
||||
imageView = view.findViewById(R.id.widget_icon);
|
||||
textView = view.findViewById(R.id.widget_text);
|
||||
textViewShadow = view.findViewById(R.id.widget_text_shadow);
|
||||
smallTextViewShadow = view.findViewById(R.id.widget_text_small_shadow);
|
||||
smallTextView = view.findViewById(R.id.widget_text_small);
|
||||
}
|
||||
|
||||
public OsmandApplication getOsmandApplication() {
|
||||
public OsmandApplication getApplication() {
|
||||
return app;
|
||||
}
|
||||
|
||||
public View getView() {
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
public void setImageDrawable(Drawable imageDrawable) {
|
||||
setImageDrawable(imageDrawable, false);
|
||||
}
|
||||
|
||||
|
||||
public void setImageDrawable(int res) {
|
||||
setImageDrawable(app.getUIUtilities().getIcon(res, 0), false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setImageDrawable(Drawable imageDrawable, boolean gone) {
|
||||
if(imageDrawable != null) {
|
||||
if (imageDrawable != null) {
|
||||
imageView.setImageDrawable(imageDrawable);
|
||||
Object anim = imageView.getDrawable();
|
||||
if (anim instanceof AnimationDrawable) {
|
||||
|
@ -84,9 +84,9 @@ public class TextInfoWidget {
|
|||
}
|
||||
imageView.invalidate();
|
||||
}
|
||||
|
||||
|
||||
public void setTopImageDrawable(Drawable imageDrawable, String topText) {
|
||||
if(imageDrawable != null) {
|
||||
if (imageDrawable != null) {
|
||||
topImageView.setImageDrawable(imageDrawable);
|
||||
topImageView.setVisibility(View.VISIBLE);
|
||||
LinearLayout.LayoutParams lp = (android.widget.LinearLayout.LayoutParams) bottomLayout.getLayoutParams();
|
||||
|
@ -96,17 +96,17 @@ public class TextInfoWidget {
|
|||
topTextView.setVisibility(View.VISIBLE);
|
||||
topTextView.setText(topText == null ? "" : topText);
|
||||
} else {
|
||||
topImageView.setVisibility(View.GONE );
|
||||
topTextView.setVisibility(View.GONE );
|
||||
topImageView.setVisibility(View.GONE);
|
||||
topTextView.setVisibility(View.GONE);
|
||||
LinearLayout.LayoutParams lp = (android.widget.LinearLayout.LayoutParams) bottomLayout.getLayoutParams();
|
||||
lp.gravity = Gravity.NO_GRAVITY;
|
||||
bottomLayout.setLayoutParams(lp);
|
||||
}
|
||||
|
||||
|
||||
topTextView.invalidate();
|
||||
topImageView.invalidate();
|
||||
}
|
||||
|
||||
|
||||
public boolean setIcons(int widgetDayIcon, int widgetNightIcon) {
|
||||
if (dayIcon != widgetDayIcon || nightIcon != widgetNightIcon) {
|
||||
dayIcon = widgetDayIcon;
|
||||
|
@ -134,7 +134,7 @@ public class TextInfoWidget {
|
|||
public void setContentDescription(CharSequence text) {
|
||||
view.setContentDescription(combine(contentTitle, text));
|
||||
}
|
||||
|
||||
|
||||
public void setContentTitle(int messageId) {
|
||||
setContentTitle(view.getContext().getString(messageId));
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ public class TextInfoWidget {
|
|||
contentTitle = text;
|
||||
setContentDescription(combine(textView.getText(), smallTextView.getText()));
|
||||
}
|
||||
|
||||
|
||||
public void setText(String text, String subtext) {
|
||||
setTextNoUpdateVisibility(text, subtext);
|
||||
updateVisibility(text != null);
|
||||
|
@ -154,14 +154,14 @@ public class TextInfoWidget {
|
|||
// if(this.text != null && this.text.length() > 7) {
|
||||
// this.text = this.text.substring(0, 6) +"..";
|
||||
// }
|
||||
if(text == null) {
|
||||
if (text == null) {
|
||||
textView.setText("");
|
||||
textViewShadow.setText("");
|
||||
} else {
|
||||
textView.setText(text);
|
||||
textViewShadow.setText(text);
|
||||
}
|
||||
if(subtext == null) {
|
||||
if (subtext == null) {
|
||||
smallTextView.setText("");
|
||||
smallTextViewShadow.setText("");
|
||||
} else {
|
||||
|
@ -169,7 +169,7 @@ public class TextInfoWidget {
|
|||
smallTextViewShadow.setText(subtext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected boolean updateVisibility(boolean visible) {
|
||||
if (visible != (view.getVisibility() == View.VISIBLE)) {
|
||||
if (visible) {
|
||||
|
@ -184,7 +184,7 @@ public class TextInfoWidget {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean isVisible() {
|
||||
return view.getVisibility() == View.VISIBLE && view.getParent() != null;
|
||||
}
|
||||
|
@ -223,15 +223,15 @@ public class TextInfoWidget {
|
|||
public void setExplicitlyVisible(boolean explicitlyVisible) {
|
||||
this.explicitlyVisible = explicitlyVisible;
|
||||
}
|
||||
|
||||
|
||||
public boolean isExplicitlyVisible() {
|
||||
return explicitlyVisible;
|
||||
}
|
||||
|
||||
|
||||
public void updateIconMode(boolean night) {
|
||||
isNight = night;
|
||||
if(dayIcon != 0) {
|
||||
setImageDrawable(!night? dayIcon : nightIcon);
|
||||
if (dayIcon != 0) {
|
||||
setImageDrawable(!night ? dayIcon : nightIcon);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,10 +240,10 @@ public class TextInfoWidget {
|
|||
updateTextColor(textView, textViewShadow, textColor, textShadowColor, bold, rad);
|
||||
updateTextColor(topTextView, null, textColor, textShadowColor, bold, rad);
|
||||
}
|
||||
|
||||
|
||||
public static void updateTextColor(TextView tv, TextView shadow, int textColor, int textShadowColor, boolean textBold, int rad) {
|
||||
if(shadow != null) {
|
||||
if(rad > 0) {
|
||||
if (shadow != null) {
|
||||
if (rad > 0) {
|
||||
shadow.setVisibility(View.VISIBLE);
|
||||
shadow.setTypeface(Typeface.DEFAULT, textBold ? Typeface.BOLD : Typeface.NORMAL);
|
||||
shadow.getPaint().setStrokeWidth(rad);
|
||||
|
@ -258,4 +258,4 @@ public class TextInfoWidget {
|
|||
tv.setTextColor(textColor);
|
||||
tv.setTypeface(Typeface.DEFAULT, textBold ? Typeface.BOLD : Typeface.NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package net.osmand.plus.views.mapwidgets;
|
||||
package net.osmand.plus.views.mapwidgets.widgetstates;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
|
||||
public class BearingWidgetState extends MapWidgetRegistry.WidgetState {
|
||||
public class BearingWidgetState extends WidgetState {
|
||||
|
||||
public static final int BEARING_WIDGET_STATE_RELATIVE_BEARING = R.id.bearing_widget_state_relative_bearing;
|
||||
public static final int BEARING_WIDGET_STATE_MAGNETIC_BEARING = R.id.bearing_widget_state_magnetic_bearing;
|
||||
|
@ -50,4 +50,4 @@ public class BearingWidgetState extends MapWidgetRegistry.WidgetState {
|
|||
public void changeState(int stateId) {
|
||||
showRelativeBearing.set(stateId == BEARING_WIDGET_STATE_RELATIVE_BEARING);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package net.osmand.plus.views.mapwidgets.widgetstates;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
|
||||
|
||||
public class CompassRulerWidgetState extends WidgetState {
|
||||
|
||||
public static final int COMPASS_CONTROL_WIDGET_STATE_SHOW = R.id.compass_ruler_control_widget_state_show;
|
||||
public static final int COMPASS_CONTROL_WIDGET_STATE_HIDE = R.id.compass_ruler_control_widget_state_hide;
|
||||
|
||||
private final OsmandPreference<Boolean> showCompass;
|
||||
|
||||
public CompassRulerWidgetState(OsmandApplication app) {
|
||||
super(app);
|
||||
showCompass = app.getSettings().SHOW_COMPASS_CONTROL_RULER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMenuTitleId() {
|
||||
return R.string.map_widget_ruler_control;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMenuIconId() {
|
||||
return R.drawable.ic_action_ruler_circle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMenuItemId() {
|
||||
return showCompass.get() ? COMPASS_CONTROL_WIDGET_STATE_SHOW : COMPASS_CONTROL_WIDGET_STATE_HIDE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getMenuTitleIds() {
|
||||
return new int[] {R.string.show_compass_ruler, R.string.hide_compass_ruler};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getMenuIconIds() {
|
||||
return new int[] {R.drawable.ic_action_compass_widget, R.drawable.ic_action_compass_widget_hide};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getMenuItemIds() {
|
||||
return new int[] {COMPASS_CONTROL_WIDGET_STATE_SHOW, COMPASS_CONTROL_WIDGET_STATE_HIDE};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeState(int stateId) {
|
||||
showCompass.set(stateId == COMPASS_CONTROL_WIDGET_STATE_SHOW);
|
||||
}
|
||||
}
|
|
@ -1,24 +1,24 @@
|
|||
package net.osmand.plus.views.mapwidgets;
|
||||
package net.osmand.plus.views.mapwidgets.widgetstates;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
|
||||
|
||||
public class TimeControlWidgetState extends MapWidgetRegistry.WidgetState {
|
||||
public class TimeWidgetState extends WidgetState {
|
||||
|
||||
public static final int TIME_CONTROL_WIDGET_STATE_ARRIVAL_TIME = R.id.time_control_widget_state_arrival_time;
|
||||
public static final int TIME_CONTROL_WIDGET_STATE_TIME_TO_GO = R.id.time_control_widget_state_time_to_go;
|
||||
|
||||
private final OsmandSettings.OsmandPreference<Boolean> showArrival;
|
||||
private final OsmandPreference<Boolean> showArrival;
|
||||
private final boolean intermediate;
|
||||
|
||||
public TimeControlWidgetState(OsmandApplication ctx, boolean intermediate) {
|
||||
super(ctx);
|
||||
public TimeWidgetState(OsmandApplication app, boolean intermediate) {
|
||||
super(app);
|
||||
this.intermediate = intermediate;
|
||||
if (intermediate) {
|
||||
showArrival = ctx.getSettings().SHOW_INTERMEDIATE_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME;
|
||||
showArrival = app.getSettings().SHOW_INTERMEDIATE_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME;
|
||||
} else {
|
||||
showArrival = ctx.getSettings().SHOW_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME;
|
||||
showArrival = app.getSettings().SHOW_ARRIVAL_TIME_OTHERWISE_EXPECTED_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,4 +68,4 @@ public class TimeControlWidgetState extends MapWidgetRegistry.WidgetState {
|
|||
public void changeState(int stateId) {
|
||||
showArrival.set(stateId == TIME_CONTROL_WIDGET_STATE_ARRIVAL_TIME);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package net.osmand.plus.views.mapwidgets.widgetstates;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
||||
public abstract class WidgetState {
|
||||
|
||||
private OsmandApplication ctx;
|
||||
|
||||
public OsmandApplication getCtx() {
|
||||
return ctx;
|
||||
}
|
||||
|
||||
public WidgetState(OsmandApplication ctx) {
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
public abstract int getMenuTitleId();
|
||||
|
||||
public abstract int getMenuIconId();
|
||||
|
||||
public abstract int getMenuItemId();
|
||||
|
||||
public abstract int[] getMenuTitleIds();
|
||||
|
||||
public abstract int[] getMenuIconIds();
|
||||
|
||||
public abstract int[] getMenuItemIds();
|
||||
|
||||
public abstract void changeState(int stateId);
|
||||
}
|
Loading…
Reference in a new issue