Fix profiles

This commit is contained in:
Victor Shcherb 2019-06-25 01:09:01 +02:00
parent f78bad9761
commit 7052019ab4
7 changed files with 148 additions and 115 deletions

View file

@ -25,11 +25,46 @@ import java.util.Set;
import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log; import net.sf.junidecode.App;
import org.apache.commons.logging.Log;
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.*;
public class ApplicationMode { public class ApplicationMode {
@Expose private final String stringKey;
@Expose private String userProfileName;
@Expose private String parent;
@Expose private String iconName = "map_world_globe_dark";
@Expose private ProfileIconColors iconColor = ProfileIconColors.DEFAULT;''
@Expose private String routingProfile = null;
@Expose private RouteService routeService = RouteService.OSMAND;
private final int keyName;
private ApplicationMode parentAppMode;
private int mapIconId = R.drawable.map_world_globe_dark;
private int smallIconDark = R.drawable.ic_world_globe_dark;
private float defaultSpeed = 10f;
private int minDistanceForTurn = 50;
private int arrivalDistance = 90;
private int offRouteDistance = 350;
private int bearingIconDay = R.drawable.map_pedestrian_bearing;
private int bearingIconNight = R.drawable.map_pedestrian_bearing_night;
private int headingIconDay = R.drawable.map_pedestrian_location_view_angle;
private int headingIconNight = R.drawable.map_pedestrian_location_view_angle_night;
private int locationIconDay = R.drawable.map_pedestrian_location;
private int locationIconNight = R.drawable.map_pedestrian_location_night;
private int locationIconDayLost = R.drawable.map_pedestrian_location_lost;
private int locationIconNightLost = R.drawable.map_pedestrian_location_lost_night;
private LocationIconsSet locationIconsSet = LocationIconsSet.DEFAULT;
private ApplicationMode(int key, String stringKey) {
this.keyName = key;
this.stringKey = stringKey;
}
private static final Log LOG = PlatformUtil.getLog(ApplicationMode.class); private static final Log LOG = PlatformUtil.getLog(ApplicationMode.class);
private static Map<String, Set<ApplicationMode>> widgetsVisibilityMap = new LinkedHashMap<>(); private static Map<String, Set<ApplicationMode>> widgetsVisibilityMap = new LinkedHashMap<>();
private static Map<String, Set<ApplicationMode>> widgetsAvailabilityMap = new LinkedHashMap<>(); private static Map<String, Set<ApplicationMode>> widgetsAvailabilityMap = new LinkedHashMap<>();
@ -39,73 +74,79 @@ public class ApplicationMode {
/* /*
* DEFAULT("Browse map"), CAR("Car"), BICYCLE("Bicycle"), PEDESTRIAN("Pedestrian"); NAUTICAL("boat"); PUBLIC_TRANSPORT("Public transport"); AIRCRAFT("Aircraft") * DEFAULT("Browse map"), CAR("Car"), BICYCLE("Bicycle"), PEDESTRIAN("Pedestrian"); NAUTICAL("boat"); PUBLIC_TRANSPORT("Public transport"); AIRCRAFT("Aircraft")
*/ */
public static final ApplicationMode DEFAULT = create(R.string.app_mode_default, "default").speed(1.5f, 5).arrivalDistance(90).defLocation(). public static final ApplicationMode DEFAULT = create(null, R.string.app_mode_default, "default").speed(1.5f, 5).arrivalDistance(90).defLocation().
icon(R.drawable.map_world_globe_dark, R.drawable.ic_world_globe_dark, "map_world_globe_dark").reg(); icon(R.drawable.map_world_globe_dark, R.drawable.ic_world_globe_dark, "map_world_globe_dark").reg();
public static final ApplicationMode CAR = create(R.string.app_mode_car, "car").speed(15.3f, 35).carLocation(). public static final ApplicationMode CAR = create(null, R.string.app_mode_car, "car").speed(15.3f, 35).carLocation().
icon(R.drawable.map_action_car_dark, R.drawable.ic_action_car_dark, "ic_action_car_dark").setRoutingProfile("car").reg(); icon(R.drawable.map_action_car_dark, R.drawable.ic_action_car_dark, "ic_action_car_dark").setRoutingProfile("car").reg();
public static final ApplicationMode BICYCLE = create(R.string.app_mode_bicycle, "bicycle").speed(5.5f, 15).arrivalDistance(60).offRouteDistance(50).bicycleLocation(). public static final ApplicationMode BICYCLE = create(null, R.string.app_mode_bicycle, "bicycle").speed(5.5f, 15).arrivalDistance(60).offRouteDistance(50).bicycleLocation().
icon(R.drawable.map_action_bicycle_dark, R.drawable.ic_action_bicycle_dark, "ic_action_bicycle_dark").setRoutingProfile("bicycle").reg(); icon(R.drawable.map_action_bicycle_dark, R.drawable.ic_action_bicycle_dark, "ic_action_bicycle_dark").setRoutingProfile("bicycle").reg();
public static final ApplicationMode PEDESTRIAN = create(R.string.app_mode_pedestrian, "pedestrian").speed(1.5f, 5).arrivalDistance(45).offRouteDistance(20). public static final ApplicationMode PEDESTRIAN = create(null, R.string.app_mode_pedestrian, "pedestrian").speed(1.5f, 5).arrivalDistance(45).offRouteDistance(20).
icon(R.drawable.map_action_pedestrian_dark, R.drawable.ic_action_pedestrian_dark, "ic_action_pedestrian_dark").setRoutingProfile("pedestrian").reg(); icon(R.drawable.map_action_pedestrian_dark, R.drawable.ic_action_pedestrian_dark, "ic_action_pedestrian_dark").setRoutingProfile("pedestrian").reg();
public static final ApplicationMode PUBLIC_TRANSPORT = create(R.string.app_mode_public_transport, "public_transport"). public static final ApplicationMode PUBLIC_TRANSPORT = create(null, R.string.app_mode_public_transport, "public_transport").
icon(R.drawable.map_action_bus_dark, R.drawable.ic_action_bus_dark, "ic_action_bus_dark").setRoutingProfile("public_transport").reg(); icon(R.drawable.map_action_bus_dark, R.drawable.ic_action_bus_dark, "ic_action_bus_dark").setRoutingProfile("public_transport").reg();
public static final ApplicationMode BOAT = create(R.string.app_mode_boat, "boat").speed(5.5f, 20).nauticalLocation(). public static final ApplicationMode BOAT = create(null, R.string.app_mode_boat, "boat").speed(5.5f, 20).nauticalLocation().
icon(R.drawable.map_action_sail_boat_dark, R.drawable.ic_action_sail_boat_dark, "ic_action_sail_boat_dark").setRoutingProfile("boat").reg(); icon(R.drawable.map_action_sail_boat_dark, R.drawable.ic_action_sail_boat_dark, "ic_action_sail_boat_dark").setRoutingProfile("boat").reg();
public static final ApplicationMode AIRCRAFT = create(R.string.app_mode_aircraft, "aircraft").speed(40f, 100).carLocation(). public static final ApplicationMode AIRCRAFT = create(null, R.string.app_mode_aircraft, "aircraft").speed(40f, 100).carLocation().
icon(R.drawable.map_action_aircraft, R.drawable.ic_action_aircraft, "ic_action_aircraft").setRouteService(RouteService.STRAIGHT).setRoutingProfile("STRAIGHT_LINE_MODE").reg(); icon(R.drawable.map_action_aircraft, R.drawable.ic_action_aircraft, "ic_action_aircraft").setRouteService(RouteService.STRAIGHT).setRoutingProfile("STRAIGHT_LINE_MODE").reg();
public static final ApplicationMode SKI = create(R.string.app_mode_skiing, "ski").speed(5.5f, 15).arrivalDistance(60).offRouteDistance(50).bicycleLocation(). public static final ApplicationMode SKI = create(null, R.string.app_mode_skiing, "ski").speed(5.5f, 15).arrivalDistance(60).offRouteDistance(50).bicycleLocation().
icon(R.drawable.ic_plugin_skimaps, R.drawable.ic_plugin_skimaps, "ic_plugin_skimaps").setRoutingProfile("ski").reg(); icon(R.drawable.ic_plugin_skimaps, R.drawable.ic_plugin_skimaps, "ic_plugin_skimaps").setRoutingProfile("ski").reg();
public static void initRegVisibility() { public static void initRegVisibility() {
// DEFAULT, CAR, BICYCLE, PEDESTRIAN, PUBLIC_TRANSPORT, BOAT, AIRCRAFT, SKI
ApplicationMode[] exceptDefault = new ApplicationMode[]{CAR, PEDESTRIAN, BICYCLE, BOAT, AIRCRAFT, PUBLIC_TRANSPORT, SKI}; ApplicationMode[] exceptDefault = new ApplicationMode[]{CAR, BICYCLE, PEDESTRIAN, PUBLIC_TRANSPORT, BOAT, AIRCRAFT, SKI};
ApplicationMode[] exceptPedestrianAndDefault = new ApplicationMode[]{CAR, BICYCLE, BOAT, AIRCRAFT, PUBLIC_TRANSPORT, SKI};
ApplicationMode[] exceptAirBoatDefault = new ApplicationMode[]{CAR, BICYCLE, PEDESTRIAN, SKI};
ApplicationMode[] pedestrian = new ApplicationMode[]{PEDESTRIAN};
ApplicationMode[] pedestrianBicycle = new ApplicationMode[]{PEDESTRIAN, BICYCLE};
ApplicationMode[] all = null; ApplicationMode[] all = null;
ApplicationMode[] none = new ApplicationMode[]{}; ApplicationMode[] none = new ApplicationMode[]{};
// left // left
regWidgetVisibility("next_turn", exceptPedestrianAndDefault); ApplicationMode[] navigationSet1 = new ApplicationMode[]{CAR, BICYCLE, BOAT, SKI};
regWidgetVisibility("next_turn_small", pedestrian); ApplicationMode[] navigationSet2 = new ApplicationMode[]{PEDESTRIAN, PUBLIC_TRANSPORT, AIRCRAFT};
regWidgetVisibility("next_next_turn", exceptPedestrianAndDefault);
regWidgetAvailability("next_turn", exceptDefault); regWidgetVisibility(WIDGET_NEXT_TURN, navigationSet1);
regWidgetAvailability("next_turn_small", exceptDefault); regWidgetVisibility(WIDGET_NEXT_TURN, navigationSet2);
regWidgetAvailability("next_next_turn", exceptDefault); regWidgetVisibility(WIDGET_NEXT_NEXT_TURN, navigationSet1);
regWidgetAvailability(WIDGET_NEXT_TURN, exceptDefault);
regWidgetAvailability(WIDGET_NEXT_TURN_SMALL, exceptDefault);
regWidgetAvailability(WIDGET_NEXT_NEXT_TURN, exceptDefault);
// right // right
regWidgetVisibility("intermediate_distance", all); regWidgetVisibility(WIDGET_INTERMEDIATE_DISTANCE, all);
regWidgetVisibility("distance", all); regWidgetVisibility(WIDGET_DISTANCE, all);
regWidgetVisibility("time", all); regWidgetVisibility(WIDGET_TIME, all);
regWidgetVisibility("intermediate_time", all); regWidgetVisibility(WIDGET_INTERMEDIATE_TIME, all);
regWidgetVisibility("speed", exceptPedestrianAndDefault); regWidgetVisibility(WIDGET_SPEED, new ApplicationMode[]{CAR, BICYCLE, BOAT, SKI, PUBLIC_TRANSPORT, AIRCRAFT} );
regWidgetVisibility("max_speed", CAR); regWidgetVisibility(WIDGET_MAX_SPEED, CAR);
regWidgetVisibility("altitude", pedestrianBicycle); regWidgetVisibility(WIDGET_ALTITUDE, new ApplicationMode[] {PEDESTRIAN, BICYCLE});
regWidgetVisibility("gps_info", none); regWidgetAvailability(WIDGET_INTERMEDIATE_DISTANCE, all);
regWidgetAvailability("intermediate_distance", all); regWidgetAvailability(WIDGET_DISTANCE, all);
regWidgetAvailability("distance", all); regWidgetAvailability(WIDGET_TIME, all);
regWidgetAvailability("time", all); regWidgetAvailability(WIDGET_INTERMEDIATE_TIME, all);
regWidgetAvailability("intermediate_time", all); regWidgetAvailability(WIDGET_SPEED, all);
regWidgetAvailability("map_marker_1st", none); regWidgetAvailability(WIDGET_MAX_SPEED, CAR);
regWidgetAvailability("map_marker_2nd", none); regWidgetAvailability(WIDGET_ALTITUDE, all);
// all = null everything
regWidgetAvailability(WIDGET_COMPASS, all);
regWidgetAvailability(WIDGET_MARKER_1, none);
regWidgetAvailability(WIDGET_MARKER_2, none);
regWidgetAvailability(WIDGET_GPS_INFO, all);
regWidgetAvailability(WIDGET_BATTERY, all);
regWidgetAvailability(WIDGET_BEARING, all);
regWidgetAvailability(WIDGET_RULER, all);
regWidgetAvailability(WIDGET_PLAIN_TIME, all);
// top // top
regWidgetVisibility("config", none); // settings.SHOW_STREET_NAME
regWidgetVisibility("layers", none); // regWidgetVisibility(WIDGET_STREET_NAME, new ApplicationMode[]{CAR, BICYCLE, PEDESTRIAN, PUBLIC_TRANSPORT});
regWidgetVisibility("compass", none); // regWidgetAvailability(WIDGET_STREET_NAME, all);
regWidgetVisibility("street_name", exceptAirBoatDefault);
regWidgetVisibility("back_to_location", all);
regWidgetVisibility("monitoring_services", none);
regWidgetVisibility("bgService", none);
} }
public static class ApplicationModeBuilder { public static class ApplicationModeBuilder {
@ -130,13 +171,14 @@ public class ApplicationMode {
} }
public ApplicationModeBuilder parent(ApplicationMode parent) { public ApplicationModeBuilder parent(ApplicationMode parent) {
applicationMode.parent = parent; applicationMode.parentAppMode = parent;
applicationMode.parent = parent.stringKey;
String parentTypeName = parent.getStringKey(); String parentTypeName = parent.getStringKey();
if (parentTypeName.equals("car") || parentTypeName.equals("aircraft")) { if (parent == CAR || parent == AIRCRAFT) {
this.carLocation(); this.carLocation();
} else if (parentTypeName.equals("bicycle")) { } else if (parent == BICYCLE || parent == SKI) {
this.bicycleLocation(); this.bicycleLocation();
} else if (parentTypeName.equals("boat")) { } else if (parent == BOAT) {
this.nauticalLocation(); this.nauticalLocation();
} else { } else {
this.defLocation(); this.defLocation();
@ -232,20 +274,17 @@ public class ApplicationMode {
} }
} }
private static ApplicationModeBuilder create(int key, String stringKey) { private static ApplicationModeBuilder create(ApplicationMode parent, int key, String stringKey) {
ApplicationModeBuilder builder = new ApplicationModeBuilder(); ApplicationModeBuilder builder = new ApplicationModeBuilder();
builder.applicationMode = new ApplicationMode(key, stringKey); builder.applicationMode = new ApplicationMode(key, stringKey);
builder.parent(parent);
return builder; return builder;
} }
public static ApplicationModeBuilder createCustomMode(String userProfileTitle, String stringKey) { public static ApplicationModeBuilder createCustomMode(ApplicationMode parent, String userProfileTitle, String stringKey) {
return create(-1, stringKey).userProfileTitle(userProfileTitle); return create(parent,-1, stringKey).userProfileTitle(userProfileTitle);
} }
private ApplicationMode(int key, String stringKey) {
this.key = key;
this.stringKey = stringKey;
}
public static List<ApplicationMode> values(OsmandApplication app) { public static List<ApplicationMode> values(OsmandApplication app) {
if (customizationListener == null) { if (customizationListener == null) {
@ -281,11 +320,11 @@ public class ApplicationMode {
} }
public static List<ApplicationMode> allPossibleValues() { public static List<ApplicationMode> allPossibleValues() {
return new ArrayList<>(values); return values;
} }
public static List<ApplicationMode> getDefaultValues() { public static List<ApplicationMode> getDefaultValues() {
return new ArrayList<>(defaultValues); return defaultValues;
} }
// returns modifiable ! Set<ApplicationMode> to exclude non-wanted derived // returns modifiable ! Set<ApplicationMode> to exclude non-wanted derived
@ -360,7 +399,7 @@ public class ApplicationMode {
} }
public ApplicationMode getParent() { public ApplicationMode getParent() {
return parent; return parentAppMode;
} }
public int getSmallIconDark() { public int getSmallIconDark() {
@ -411,13 +450,9 @@ public class ApplicationMode {
return mapIconId; return mapIconId;
} }
public int getStringResource() {
return key;
}
public String toHumanString(Context ctx) { public String toHumanString(Context ctx) {
if (Algorithms.isEmpty(userProfileName) && key != -1) { if (Algorithms.isEmpty(userProfileName) && keyName != -1) {
return ctx.getString(key); return ctx.getString(keyName);
} else { } else {
return userProfileName; return userProfileName;
} }
@ -426,7 +461,7 @@ public class ApplicationMode {
public String toHumanStringCtx(Context ctx) { public String toHumanStringCtx(Context ctx) {
if (Algorithms.isEmpty(userProfileName)) { if (Algorithms.isEmpty(userProfileName)) {
return ctx.getString(key); return ctx.getString(keyName);
} else { } else {
return userProfileName; return userProfileName;
} }
@ -477,29 +512,6 @@ public class ApplicationMode {
return userProfileName; return userProfileName;
} }
@Expose private final int key;
@Expose private final String stringKey;
@Expose private String userProfileName;
@Expose private ApplicationMode parent;
@Expose private String iconName = "map_world_globe_dark";
@Expose private ProfileIconColors iconColor = ProfileIconColors.DEFAULT;
@Expose private int mapIconId = R.drawable.map_world_globe_dark;
@Expose private int smallIconDark = R.drawable.ic_world_globe_dark;
@Expose private float defaultSpeed = 10f;
@Expose private int minDistanceForTurn = 50;
@Expose private int arrivalDistance = 90;
@Expose private int offRouteDistance = 350;
@Expose private int bearingIconDay = R.drawable.map_pedestrian_bearing;
@Expose private int bearingIconNight = R.drawable.map_pedestrian_bearing_night;
@Expose private int headingIconDay = R.drawable.map_pedestrian_location_view_angle;
@Expose private int headingIconNight = R.drawable.map_pedestrian_location_view_angle_night;
@Expose private int locationIconDay = R.drawable.map_pedestrian_location;
@Expose private int locationIconNight = R.drawable.map_pedestrian_location_night;
@Expose private int locationIconDayLost = R.drawable.map_pedestrian_location_lost;
@Expose private int locationIconNightLost = R.drawable.map_pedestrian_location_lost_night;
@Expose private LocationIconsSet locationIconsSet = LocationIconsSet.DEFAULT;
@Expose private String routingProfile = null;
@Expose private RouteService routeService = RouteService.OSMAND;
private static StateChangedListener<String> listener; private static StateChangedListener<String> listener;
private static OsmAndAppCustomization.OsmAndAppCustomizationListener customizationListener; private static OsmAndAppCustomization.OsmAndAppCustomizationListener customizationListener;

View file

@ -2752,8 +2752,6 @@ public class OsmandSettings {
new BooleanPreference("fluorescent_overlays", false).makeGlobal().cache(); new BooleanPreference("fluorescent_overlays", false).makeGlobal().cache();
public final CommonPreference<Boolean> SHOW_RULER =
new BooleanPreference("show_ruler", true).makeProfile().cache();
// public final OsmandPreference<Integer> NUMBER_OF_FREE_DOWNLOADS_V2 = new IntPreference("free_downloads_v2", 0).makeGlobal(); // public final OsmandPreference<Integer> NUMBER_OF_FREE_DOWNLOADS_V2 = new IntPreference("free_downloads_v2", 0).makeGlobal();

View file

@ -91,7 +91,7 @@ public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
}; };
} }
adapter.setListener(listener); adapter.setListener(listener);
allModes = ApplicationMode.allPossibleValues(); allModes = new ArrayList<>(ApplicationMode.allPossibleValues());
allModes.remove(ApplicationMode.DEFAULT); allModes.remove(ApplicationMode.DEFAULT);
adapter.updateItemsList(allModes, adapter.updateItemsList(allModes,
new LinkedHashSet<>(ApplicationMode.values(getMyApplication()))); new LinkedHashSet<>(ApplicationMode.values(getMyApplication())));

View file

@ -631,8 +631,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
} }
ApplicationMode.ApplicationModeBuilder builder = ApplicationMode ApplicationMode.ApplicationModeBuilder builder = ApplicationMode
.createCustomMode(profile.userProfileTitle.trim(), customStringKey) .createCustomMode(profile.parent, profile.userProfileTitle.trim(), customStringKey)
.parent(profile.parent)
.icon(profile.iconId, profile.iconId, profile.iconStringName); .icon(profile.iconId, profile.iconId, profile.iconStringName);
if (profile.routingProfileDataObject != null) { if (profile.routingProfileDataObject != null) {

View file

@ -53,7 +53,7 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
allAppModes = ApplicationMode.allPossibleValues(); allAppModes = new ArrayList<>(ApplicationMode.allPossibleValues());
allAppModes.remove(ApplicationMode.DEFAULT); allAppModes.remove(ApplicationMode.DEFAULT);
availableAppModes = new LinkedHashSet<>(ApplicationMode.values(getMyApplication())); availableAppModes = new LinkedHashSet<>(ApplicationMode.values(getMyApplication()));
availableAppModes.remove(ApplicationMode.DEFAULT); availableAppModes.remove(ApplicationMode.DEFAULT);
@ -125,7 +125,7 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
getBaseProfileListener(); getBaseProfileListener();
allAppModes = ApplicationMode.allPossibleValues(); allAppModes = new ArrayList<>(ApplicationMode.allPossibleValues());
allAppModes.remove(ApplicationMode.DEFAULT); allAppModes.remove(ApplicationMode.DEFAULT);
adapter.updateItemsList(allAppModes, new LinkedHashSet<>(ApplicationMode.values(getMyApplication()))); adapter.updateItemsList(allAppModes, new LinkedHashSet<>(ApplicationMode.values(getMyApplication())));
} }

View file

@ -11,6 +11,7 @@ import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -38,6 +39,7 @@ import net.osmand.plus.views.mapwidgets.RouteInfoWidgetsFactory.TimeControlWidge
import net.osmand.plus.views.mapwidgets.TextInfoWidget; import net.osmand.plus.views.mapwidgets.TextInfoWidget;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.*;
public class MapInfoLayer extends OsmandMapLayer { public class MapInfoLayer extends OsmandMapLayer {
private final MapActivity map; private final MapActivity map;
@ -159,49 +161,49 @@ public class MapInfoLayer extends OsmandMapLayer {
rulerControl.setVisibility(false); rulerControl.setVisibility(false);
// register left stack // register left stack
registerSideWidget(null, R.drawable.ic_action_compass, R.string.map_widget_compass, "compass", true, 4); registerSideWidget(null, R.drawable.ic_action_compass, R.string.map_widget_compass, WIDGET_COMPASS, true, 4);
NextTurnInfoWidget bigInfoControl = ric.createNextInfoControl(map, app, false); NextTurnInfoWidget bigInfoControl = ric.createNextInfoControl(map, app, false);
registerSideWidget(bigInfoControl, R.drawable.ic_action_next_turn, R.string.map_widget_next_turn, "next_turn", true, 5); 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); NextTurnInfoWidget smallInfoControl = ric.createNextInfoControl(map, app, true);
registerSideWidget(smallInfoControl, R.drawable.ic_action_next_turn, R.string.map_widget_next_turn_small, "next_turn_small", true, 6); registerSideWidget(smallInfoControl, R.drawable.ic_action_next_turn, R.string.map_widget_next_turn_small, ApplicationMode.WIDGET_NEXT_TURN_SMALL, true, 6);
NextTurnInfoWidget nextNextInfoControl = ric.createNextNextInfoControl(map, app, true); NextTurnInfoWidget nextNextInfoControl = ric.createNextNextInfoControl(map, app, true);
registerSideWidget(nextNextInfoControl, R.drawable.ic_action_next_turn, R.string.map_widget_next_next_turn, "next_next_turn",true, 7); registerSideWidget(nextNextInfoControl, R.drawable.ic_action_next_turn, R.string.map_widget_next_next_turn, WIDGET_NEXT_NEXT_TURN,true, 7);
// register right stack // register right stack
// priorityOrder: 10s navigation-related, 20s position-related, 30s recording- and other plugin-related, 40s general device information, 50s debugging-purpose // priorityOrder: 10s navigation-related, 20s position-related, 30s recording- and other plugin-related, 40s general device information, 50s debugging-purpose
TextInfoWidget intermediateDist = ric.createIntermediateDistanceControl(map); TextInfoWidget intermediateDist = ric.createIntermediateDistanceControl(map);
registerSideWidget(intermediateDist, R.drawable.ic_action_intermediate, R.string.map_widget_intermediate_distance, "intermediate_distance", false, 13); registerSideWidget(intermediateDist, R.drawable.ic_action_intermediate, R.string.map_widget_intermediate_distance, WIDGET_INTERMEDIATE_DISTANCE, false, 13);
TextInfoWidget intermediateTime = ric.createTimeControl(map, true); TextInfoWidget intermediateTime = ric.createTimeControl(map, true);
registerSideWidget(intermediateTime, new TimeControlWidgetState(app, true), "intermediate_time", false, 14); registerSideWidget(intermediateTime, new TimeControlWidgetState(app, true), WIDGET_INTERMEDIATE_TIME, false, 14);
TextInfoWidget dist = ric.createDistanceControl(map); TextInfoWidget dist = ric.createDistanceControl(map);
registerSideWidget(dist, R.drawable.ic_action_target, R.string.map_widget_distance, "distance", false, 15); registerSideWidget(dist, R.drawable.ic_action_target, R.string.map_widget_distance, WIDGET_DISTANCE, false, 15);
TextInfoWidget time = ric.createTimeControl(map, false); TextInfoWidget time = ric.createTimeControl(map, false);
registerSideWidget(time, new TimeControlWidgetState(app, false), "time", false, 16); registerSideWidget(time, new TimeControlWidgetState(app, false), WIDGET_TIME, false, 16);
TextInfoWidget marker = mwf.createMapMarkerControl(map, true); TextInfoWidget marker = mwf.createMapMarkerControl(map, true);
registerSideWidget(marker, R.drawable.ic_action_flag_dark, R.string.map_marker_1st, "map_marker_1st", false, 17); registerSideWidget(marker, R.drawable.ic_action_flag_dark, R.string.map_marker_1st, WIDGET_MARKER_1, false, 17);
TextInfoWidget bearing = ric.createBearingControl(map); TextInfoWidget bearing = ric.createBearingControl(map);
registerSideWidget(bearing, new BearingWidgetState(app), "bearing", false, 18); registerSideWidget(bearing, new BearingWidgetState(app), WIDGET_BEARING, false, 18);
TextInfoWidget marker2nd = mwf.createMapMarkerControl(map, false); TextInfoWidget marker2nd = mwf.createMapMarkerControl(map, false);
registerSideWidget(marker2nd, R.drawable.ic_action_flag_dark, R.string.map_marker_2nd, "map_marker_2nd", false, 19); registerSideWidget(marker2nd, R.drawable.ic_action_flag_dark, R.string.map_marker_2nd, WIDGET_MARKER_2, false, 19);
TextInfoWidget speed = ric.createSpeedControl(map); TextInfoWidget speed = ric.createSpeedControl(map);
registerSideWidget(speed, R.drawable.ic_action_speed, R.string.map_widget_speed, "speed", false, 20); registerSideWidget(speed, R.drawable.ic_action_speed, R.string.map_widget_speed, WIDGET_SPEED, false, 20);
TextInfoWidget maxspeed = ric.createMaxSpeedControl(map); TextInfoWidget maxspeed = ric.createMaxSpeedControl(map);
registerSideWidget(maxspeed, R.drawable.ic_action_speed_limit, R.string.map_widget_max_speed, "max_speed", false, 21); registerSideWidget(maxspeed, R.drawable.ic_action_speed_limit, R.string.map_widget_max_speed, WIDGET_MAX_SPEED, false, 21);
TextInfoWidget alt = mic.createAltitudeControl(map); TextInfoWidget alt = mic.createAltitudeControl(map);
registerSideWidget(alt, R.drawable.ic_action_altitude, R.string.map_widget_altitude, "altitude", false, 23); registerSideWidget(alt, R.drawable.ic_action_altitude, R.string.map_widget_altitude, WIDGET_ALTITUDE, false, 23);
TextInfoWidget gpsInfo = mic.createGPSInfoControl(map); TextInfoWidget gpsInfo = mic.createGPSInfoControl(map);
registerSideWidget(gpsInfo, R.drawable.ic_action_gps_info, R.string.map_widget_gps_info, "gps_info", false, 28); registerSideWidget(gpsInfo, R.drawable.ic_action_gps_info, R.string.map_widget_gps_info, WIDGET_GPS_INFO, false, 28);
TextInfoWidget plainTime = ric.createPlainTimeControl(map); TextInfoWidget plainTime = ric.createPlainTimeControl(map);
registerSideWidget(plainTime, R.drawable.ic_action_time, R.string.map_widget_plain_time, "plain_time", false, 41); registerSideWidget(plainTime, R.drawable.ic_action_time, R.string.map_widget_plain_time, WIDGET_PLAIN_TIME, false, 41);
TextInfoWidget battery = ric.createBatteryControl(map); TextInfoWidget battery = ric.createBatteryControl(map);
registerSideWidget(battery, R.drawable.ic_action_battery, R.string.map_widget_battery, "battery", false, 42); registerSideWidget(battery, R.drawable.ic_action_battery, R.string.map_widget_battery, WIDGET_BATTERY, false, 42);
TextInfoWidget ruler = mic.createRulerControl(map); TextInfoWidget ruler = mic.createRulerControl(map);
registerSideWidget(ruler, new CompassRulerControlWidgetState(app), "ruler", false, 43); registerSideWidget(ruler, new CompassRulerControlWidgetState(app), WIDGET_RULER, false, 43);
} }
public void recreateControls() { public void recreateControls() {

View file

@ -42,6 +42,29 @@ public class MapWidgetRegistry {
public static final String HIDE_PREFIX = "-"; public static final String HIDE_PREFIX = "-";
public static final String SHOW_PREFIX = ""; public static final String SHOW_PREFIX = "";
public static final String SETTINGS_SEPARATOR = ";"; public static final String SETTINGS_SEPARATOR = ";";
public static String WIDGET_NEXT_TURN = "next_turn";
public static String WIDGET_NEXT_TURN_SMALL = "next_turn_small";
public static String WIDGET_NEXT_NEXT_TURN = "next_next_turn";
public static String WIDGET_COMPASS = "compass";
public static String WIDGET_DISTANCE = "distance";
public static String WIDGET_INTERMEDIATE_DISTANCE = "intermediate_distance";
public static String WIDGET_TIME = "time";
public static String WIDGET_INTERMEDIATE_TIME = "intermediate_time";
public static String WIDGET_MAX_SPEED = "max_speed";
public static String WIDGET_SPEED = "speed";
public static String WIDGET_ALTITUDE = "altitude";
public static String WIDGET_GPS_INFO = "gps_info";
public static String WIDGET_MARKER_1 = "map_marker_1st";
public static String WIDGET_MARKER_2 = "map_marker_2nd";
public static String WIDGET_BEARING = "bearing";
public static String WIDGET_PLAIN_TIME = "plain_time";
public static String WIDGET_BATTERY = "battery";
public static String WIDGET_RULER = "ruler";
public static String WIDGET_STREET_NAME = "street_name";
private Set<MapWidgetRegInfo> leftWidgetSet = new TreeSet<>(); private Set<MapWidgetRegInfo> leftWidgetSet = new TreeSet<>();
private Set<MapWidgetRegInfo> rightWidgetSet = new TreeSet<>(); private Set<MapWidgetRegInfo> rightWidgetSet = new TreeSet<>();
private Map<ApplicationMode, Set<String>> visibleElementsFromSettings = new LinkedHashMap<>(); private Map<ApplicationMode, Set<String>> visibleElementsFromSettings = new LinkedHashMap<>();
@ -309,7 +332,6 @@ public class MapWidgetRegistry {
} }
private void resetDefaultAppearance(ApplicationMode appMode) { private void resetDefaultAppearance(ApplicationMode appMode) {
// settings.SHOW_RULER.resetToDefault();
settings.TRANSPARENT_MAP_THEME.resetToDefault(); settings.TRANSPARENT_MAP_THEME.resetToDefault();
settings.SHOW_STREET_NAME.resetToDefault(); settings.SHOW_STREET_NAME.resetToDefault();
settings.CENTER_POSITION_ON_MAP.resetToDefault(); settings.CENTER_POSITION_ON_MAP.resetToDefault();
@ -317,8 +339,6 @@ public class MapWidgetRegistry {
} }
public void addControlsAppearance(final MapActivity map, final ContextMenuAdapter cm, ApplicationMode mode) { public void addControlsAppearance(final MapActivity map, final ContextMenuAdapter cm, ApplicationMode mode) {
addControlId(map, cm, R.string.map_widget_transparent, settings.TRANSPARENT_MAP_THEME);
addControlId(map, cm, R.string.always_center_position_on_map, settings.CENTER_POSITION_ON_MAP);
if (mode != ApplicationMode.DEFAULT) { if (mode != ApplicationMode.DEFAULT) {
addControlId(map, cm, R.string.map_widget_top_text, settings.SHOW_STREET_NAME); addControlId(map, cm, R.string.map_widget_top_text, settings.SHOW_STREET_NAME);
} }
@ -344,6 +364,8 @@ public class MapWidgetRegistry {
return false; return false;
} }
}).setLayout(R.layout.list_item_text_button).createItem()); }).setLayout(R.layout.list_item_text_button).createItem());
addControlId(map, cm, R.string.map_widget_transparent, settings.TRANSPARENT_MAP_THEME);
addControlId(map, cm, R.string.always_center_position_on_map, settings.CENTER_POSITION_ON_MAP);
} }
public void updateMapMarkersMode(MapActivity mapActivity) { public void updateMapMarkersMode(MapActivity mapActivity) {