This commit is contained in:
crimean 2019-06-25 13:42:25 +03:00
commit 164760e0df
31 changed files with 399 additions and 368 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 664 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 371 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 801 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -16,6 +16,7 @@
<string name="default_speed_setting_descr">Change default speed settings</string>
<string name="default_speed_dialog_title">Set default speed</string>
<string name="default_speed_dialog_msg">Used for calculations of expected arrival time during routing</string>
<string name="new_profile">New Profile</string>
<string name="shared_string_crash">Crash</string>
<string name="last_launch_crashed">The last launch of OsmAnd failed. Help us improve OsmAnd. Please send us an error message.</string>
<string name="press_again_to_change_the_map_orientation">Press again to change the map orientation</string>

View file

@ -192,7 +192,7 @@ public class AppInitializer implements IProgress {
}
app.getSettings().SHOW_TRAVEL_UPDATE_CARD.set(true);
app.getSettings().SHOW_TRAVEL_NEEDED_MAPS_CARD.set(true);
ApplicationMode.initCustomModes(app.getSettings());
ApplicationMode.onApplicationStart(app);
initSettings = true;
}

View file

@ -25,117 +25,195 @@ import java.util.Set;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.Log;
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.*;
public class ApplicationMode {
private static final Log LOG = PlatformUtil.getLog(ApplicationMode.class);
private static Map<String, Set<ApplicationMode>> widgetsVisibilityMap = new LinkedHashMap<>();
private static Map<String, Set<ApplicationMode>> widgetsAvailabilityMap = new LinkedHashMap<>();
private static List<ApplicationMode> defaultValues = new ArrayList<>();
private static List<ApplicationMode> values = new ArrayList<>();
private static List<ApplicationMode> cachedFilteredValues = new ArrayList<>();
private static StateChangedListener<String> listener;
private static OsmAndAppCustomization.OsmAndAppCustomizationListener customizationListener;
private final int keyName;
private final String stringKey;
private String userProfileName;
private ApplicationMode parentAppMode;
private String iconResName = "ic_world_globe_dark";
private int iconRes = R.drawable.ic_world_globe_dark;
private ProfileIconColors iconColor = ProfileIconColors.DEFAULT;
private String routingProfile = null;
private RouteService routeService = RouteService.OSMAND;
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 ApplicationMode(int key, String stringKey) {
this.keyName = key;
this.stringKey = stringKey;
}
/*
* 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().
icon(R.drawable.map_world_globe_dark, R.drawable.ic_world_globe_dark, "map_world_globe_dark").reg();
public static final ApplicationMode DEFAULT = createBase( R.string.app_mode_default, "default").speed(1.5f, 5).arrivalDistance(90).defLocation().
icon(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().
icon(R.drawable.map_action_car_dark, R.drawable.ic_action_car_dark, "ic_action_car_dark").setRoutingProfile("car").reg();
public static final ApplicationMode CAR = createBase( R.string.app_mode_car, "car").speed(15.3f, 35).carLocation().
icon(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().
icon(R.drawable.map_action_bicycle_dark, R.drawable.ic_action_bicycle_dark, "ic_action_bicycle_dark").setRoutingProfile("bicycle").reg();
public static final ApplicationMode BICYCLE = createBase( R.string.app_mode_bicycle, "bicycle").speed(5.5f, 15).arrivalDistance(60).offRouteDistance(50).bicycleLocation().
icon(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).
icon(R.drawable.map_action_pedestrian_dark, R.drawable.ic_action_pedestrian_dark, "ic_action_pedestrian_dark").setRoutingProfile("pedestrian").reg();
public static final ApplicationMode PEDESTRIAN = createBase( R.string.app_mode_pedestrian, "pedestrian").speed(1.5f, 5).arrivalDistance(45).offRouteDistance(20).
icon(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").
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 PUBLIC_TRANSPORT = createBase( R.string.app_mode_public_transport, "public_transport").
icon(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().
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 BOAT = createBase( R.string.app_mode_boat, "boat").speed(5.5f, 20).nauticalLocation().
icon(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().
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 AIRCRAFT = createBase( R.string.app_mode_aircraft, "aircraft").speed(40f, 100).carLocation().
icon(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().
icon(R.drawable.ic_plugin_skimaps, R.drawable.ic_plugin_skimaps, "ic_plugin_skimaps").setRoutingProfile("ski").reg();
public static final ApplicationMode SKI = createBase( R.string.app_mode_skiing, "ski").speed(5.5f, 15).arrivalDistance(60).offRouteDistance(50).bicycleLocation().
icon(R.drawable.ic_plugin_skimaps, "ic_plugin_skimaps").setRoutingProfile("ski").reg();
static {
ApplicationMode[] exceptDefault = new ApplicationMode[]{CAR, PEDESTRIAN, BICYCLE, BOAT, AIRCRAFT, PUBLIC_TRANSPORT, 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};
private static class ApplicationModeBean {
@Expose String stringKey;
@Expose String userProfileName;
@Expose String parent;
@Expose String iconName = "map_world_globe_dark";
@Expose ProfileIconColors iconColor = ProfileIconColors.DEFAULT;
@Expose String routingProfile = null;
@Expose RouteService routeService = RouteService.OSMAND;
}
private static void initRegVisibility() {
// DEFAULT, CAR, BICYCLE, PEDESTRIAN, PUBLIC_TRANSPORT, BOAT, AIRCRAFT, SKI
ApplicationMode[] exceptDefault = new ApplicationMode[]{CAR, BICYCLE, PEDESTRIAN, PUBLIC_TRANSPORT, BOAT, AIRCRAFT, SKI};
ApplicationMode[] all = null;
ApplicationMode[] none = new ApplicationMode[]{};
// left
regWidgetVisibility("next_turn", exceptPedestrianAndDefault);
regWidgetVisibility("next_turn_small", pedestrian);
regWidgetVisibility("next_next_turn", exceptPedestrianAndDefault);
regWidgetAvailability("next_turn", exceptDefault);
regWidgetAvailability("next_turn_small", exceptDefault);
regWidgetAvailability("next_next_turn", exceptDefault);
ApplicationMode[] navigationSet1 = new ApplicationMode[]{CAR, BICYCLE, BOAT, SKI};
ApplicationMode[] navigationSet2 = new ApplicationMode[]{PEDESTRIAN, PUBLIC_TRANSPORT, AIRCRAFT};
regWidgetVisibility(WIDGET_NEXT_TURN, navigationSet1);
regWidgetVisibility(WIDGET_NEXT_TURN, navigationSet2);
regWidgetVisibility(WIDGET_NEXT_NEXT_TURN, navigationSet1);
regWidgetAvailability(WIDGET_NEXT_TURN, exceptDefault);
regWidgetAvailability(WIDGET_NEXT_TURN_SMALL, exceptDefault);
regWidgetAvailability(WIDGET_NEXT_NEXT_TURN, exceptDefault);
// right
regWidgetVisibility("intermediate_distance", all);
regWidgetVisibility("distance", all);
regWidgetVisibility("time", all);
regWidgetVisibility("intermediate_time", all);
regWidgetVisibility("speed", exceptPedestrianAndDefault);
regWidgetVisibility("max_speed", CAR);
regWidgetVisibility("altitude", pedestrianBicycle);
regWidgetVisibility("gps_info", none);
regWidgetAvailability("intermediate_distance", all);
regWidgetAvailability("distance", all);
regWidgetAvailability("time", all);
regWidgetAvailability("intermediate_time", all);
regWidgetAvailability("map_marker_1st", none);
regWidgetAvailability("map_marker_2nd", none);
regWidgetVisibility(WIDGET_INTERMEDIATE_DISTANCE, all);
regWidgetVisibility(WIDGET_DISTANCE, all);
regWidgetVisibility(WIDGET_TIME, all);
regWidgetVisibility(WIDGET_INTERMEDIATE_TIME, all);
regWidgetVisibility(WIDGET_SPEED, new ApplicationMode[]{CAR, BICYCLE, BOAT, SKI, PUBLIC_TRANSPORT, AIRCRAFT} );
regWidgetVisibility(WIDGET_MAX_SPEED, CAR);
regWidgetVisibility(WIDGET_ALTITUDE, new ApplicationMode[] {PEDESTRIAN, BICYCLE});
regWidgetAvailability(WIDGET_INTERMEDIATE_DISTANCE, all);
regWidgetAvailability(WIDGET_DISTANCE, all);
regWidgetAvailability(WIDGET_TIME, all);
regWidgetAvailability(WIDGET_INTERMEDIATE_TIME, all);
regWidgetAvailability(WIDGET_SPEED, all);
regWidgetAvailability(WIDGET_MAX_SPEED, CAR);
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
regWidgetVisibility("config", none);
regWidgetVisibility("layers", none);
regWidgetVisibility("compass", none);
regWidgetVisibility("street_name", exceptAirBoatDefault);
regWidgetVisibility("back_to_location", all);
regWidgetVisibility("monitoring_services", none);
regWidgetVisibility("bgService", none);
// settings.SHOW_STREET_NAME
// regWidgetVisibility(WIDGET_STREET_NAME, new ApplicationMode[]{CAR, BICYCLE, PEDESTRIAN, PUBLIC_TRANSPORT});
// regWidgetAvailability(WIDGET_STREET_NAME, all);
}
public static class ApplicationModeBuilder {
private ApplicationMode applicationMode;
public ApplicationMode reg() {
private ApplicationMode reg() {
values.add(applicationMode);
defaultValues.add(applicationMode);
return applicationMode;
}
public ApplicationMode customReg() {
private ApplicationMode customReg() {
ApplicationMode m = applicationMode;
m.defaultSpeed = m.parentAppMode.defaultSpeed;
m.minDistanceForTurn = m.parentAppMode.minDistanceForTurn;
m.arrivalDistance = m.parentAppMode.arrivalDistance;
m.offRouteDistance = m.parentAppMode.offRouteDistance;
m.bearingIconDay = m.parentAppMode.bearingIconDay;
m.bearingIconNight = m.parentAppMode.bearingIconNight;
m.headingIconDay = m.parentAppMode.headingIconDay;
m.headingIconNight = m.parentAppMode.headingIconNight;
m.locationIconDay = m.parentAppMode.locationIconDay;
m.locationIconNight = m.parentAppMode.locationIconNight;
m.locationIconDayLost = m.parentAppMode.locationIconDayLost;
m.locationIconNightLost = m.parentAppMode.locationIconNightLost;
values.add(applicationMode);
return applicationMode;
}
public ApplicationModeBuilder icon(int mapIcon, int smallIconDark, String iconName) {
applicationMode.mapIconId = mapIcon;
applicationMode.smallIconDark = smallIconDark;
applicationMode.iconName = iconName;
public ApplicationModeBuilder icon(int iconRes, String iconResName) {
applicationMode.iconResName = iconResName;
applicationMode.iconRes = iconRes;
return this;
}
public ApplicationModeBuilder icon(Context app, String iconResName) {
try {
applicationMode.iconResName = iconResName;
applicationMode.iconRes = app.getResources().getIdentifier(iconResName, "drawable", app.getPackageName());
} catch (Exception e) {
// return R.drawable.map_world_globe_dark;
}
return this;
}
public ApplicationModeBuilder parent(ApplicationMode parent) {
applicationMode.parent = parent;
String parentTypeName = parent.getStringKey();
if (parentTypeName.equals("car") || parentTypeName.equals("aircraft")) {
applicationMode.parentAppMode = parent;
if (parent == CAR || parent == AIRCRAFT) {
this.carLocation();
} else if (parentTypeName.equals("bicycle")) {
} else if (parent == BICYCLE || parent == SKI) {
this.bicycleLocation();
} else if (parentTypeName.equals("boat")) {
} else if (parent == BOAT) {
this.nauticalLocation();
} else {
this.defLocation();
@ -153,7 +231,6 @@ public class ApplicationMode {
applicationMode.locationIconNight = R.drawable.map_car_location_night;
applicationMode.locationIconDayLost = R.drawable.map_car_location_lost;
applicationMode.locationIconNightLost = R.drawable.map_car_location_lost_night;
applicationMode.locationIconsSet = LocationIconsSet.CAR;
return this;
}
@ -166,7 +243,6 @@ public class ApplicationMode {
applicationMode.locationIconNight = R.drawable.map_bicycle_location_night;
applicationMode.locationIconDayLost = R.drawable.map_bicycle_location_lost;
applicationMode.locationIconNightLost = R.drawable.map_bicycle_location_lost_night;
applicationMode.locationIconsSet = LocationIconsSet.BICYCLE;
return this;
}
@ -179,7 +255,6 @@ public class ApplicationMode {
applicationMode.locationIconNight = R.drawable.map_pedestrian_location_night;
applicationMode.locationIconDayLost = R.drawable.map_pedestrian_location_lost;
applicationMode.locationIconNightLost = R.drawable.map_pedestrian_location_lost_night;
applicationMode.locationIconsSet = LocationIconsSet.DEFAULT;
return this;
}
@ -190,7 +265,6 @@ public class ApplicationMode {
applicationMode.headingIconNight = R.drawable.map_nautical_location_view_angle_night;
applicationMode.locationIconDay = R.drawable.map_nautical_location;
applicationMode.locationIconNight = R.drawable.map_nautical_location_night;
applicationMode.locationIconsSet = LocationIconsSet.NAUTICAL;
return this;
}
@ -231,20 +305,23 @@ 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();
builder.applicationMode = new ApplicationMode(key, stringKey);
builder.parent(parent);
return builder;
}
private static ApplicationModeBuilder createBase(int key, String stringKey) {
ApplicationModeBuilder builder = new ApplicationModeBuilder();
builder.applicationMode = new ApplicationMode(key, stringKey);
return builder;
}
public static ApplicationModeBuilder createCustomMode(String userProfileTitle, String stringKey) {
return create(-1, stringKey).userProfileTitle(userProfileTitle);
public static ApplicationModeBuilder createCustomMode(ApplicationMode parent, String userProfileTitle, String stringKey) {
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) {
if (customizationListener == null) {
@ -257,6 +334,7 @@ public class ApplicationMode {
app.getAppCustomization().addListener(customizationListener);
}
if (cachedFilteredValues.isEmpty()) {
OsmandSettings settings = app.getSettings();
if (listener == null) {
listener = new StateChangedListener<String>() {
@ -279,11 +357,11 @@ public class ApplicationMode {
}
public static List<ApplicationMode> allPossibleValues() {
return new ArrayList<>(values);
return values;
}
public static List<ApplicationMode> getDefaultValues() {
return new ArrayList<>(defaultValues);
return defaultValues;
}
// returns modifiable ! Set<ApplicationMode> to exclude non-wanted derived
@ -357,12 +435,12 @@ public class ApplicationMode {
return list;
}
public ApplicationMode getParent() {
return parent;
public boolean isCustomProfile() {
return parentAppMode != null;
}
public int getSmallIconDark() {
return smallIconDark;
public ApplicationMode getParent() {
return parentAppMode;
}
public boolean hasFastSpeed() {
@ -405,26 +483,18 @@ public class ApplicationMode {
return stringKey;
}
public int getMapIconId() {
return mapIconId;
public int getNameKeyResource() {
return keyName;
}
public int getStringResource() {
return key;
}
public String toHumanString(Context ctx) {
if (Algorithms.isEmpty(userProfileName) && key != -1) {
return ctx.getString(key);
} else {
public String getCustomProfileName() {
return userProfileName;
}
}
public String toHumanStringCtx(Context ctx) {
if (Algorithms.isEmpty(userProfileName)) {
return ctx.getString(key);
public String toHumanString(Context ctx) {
if (Algorithms.isEmpty(userProfileName) && keyName != -1) {
return ctx.getString(keyName);
} else {
return userProfileName;
}
@ -444,7 +514,7 @@ public class ApplicationMode {
}
public String getIconName() {
return iconName;
return iconResName;
}
public float getDefaultSpeed() {
@ -471,41 +541,57 @@ public class ApplicationMode {
return routingProfile;
}
public String getUserProfileName() {
return userProfileName;
@DrawableRes public int getIconRes() {
return iconRes;
}
@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 OsmAndAppCustomization.OsmAndAppCustomizationListener customizationListener;
public ProfileIconColors getIconColorInfo() {
if (iconColor != null) {
return iconColor;
} else {
return ProfileIconColors.DEFAULT;
}
}
public static void saveCustomModeToSettings(OsmandSettings settings){
List<ApplicationMode> customModes = new ArrayList<>();
public static void onApplicationStart(OsmandApplication app) {
initCustomModes(app);
initRegVisibility();
}
private static void initCustomModes(OsmandApplication app){
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
Type t = new TypeToken<ArrayList<ApplicationModeBean>>() {}.getType();
List<ApplicationModeBean> customProfiles = gson.fromJson(app.getSettings().CUSTOM_APP_PROFILES.get(), t);
if (!Algorithms.isEmpty(customProfiles)) {
for (ApplicationModeBean m : customProfiles) {
ApplicationModeBuilder b = createCustomMode(valueOfStringKey(m.parent, CAR),
m.userProfileName, m.stringKey);
b.setRouteService(m.routeService).setRoutingProfile(m.routingProfile);
b.icon(app, m.iconName);
b.setColor(m.iconColor);
b.customReg();
}
}
}
private static void saveCustomModeToSettings(OsmandSettings settings){
List<ApplicationModeBean> customModes = new ArrayList<>();
for (ApplicationMode mode : values) {
if (mode.parent != null) {
customModes.add(mode);
if (mode.parentAppMode != null) {
ApplicationModeBean mb = new ApplicationModeBean();
mb.userProfileName = mode.userProfileName;
mb.iconColor = mode.iconColor;
mb.iconName = mode.iconResName;
mb.parent = mode.parentAppMode.getStringKey();
mb.stringKey = mode.stringKey;
mb.routeService = mode.routeService;
mb.routingProfile = mode.routingProfile;
customModes.add(mb);
}
}
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
@ -513,80 +599,42 @@ public class ApplicationMode {
settings.CUSTOM_APP_PROFILES.set(profiles);
}
public static void initCustomModes(OsmandSettings settings){
Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
Type t = new TypeToken<ArrayList<ApplicationMode>>() {}.getType();
List<ApplicationMode> customProfiles = gson.fromJson(settings.CUSTOM_APP_PROFILES.get(), t);
public static ApplicationMode saveCustomProfile(ApplicationModeBuilder builder, OsmandApplication app) {
ApplicationMode mode = null;
for(ApplicationMode m : values) {
if(m.stringKey.equals(builder.applicationMode.stringKey)) {
mode = m;
mode.iconResName = builder.applicationMode.iconResName;
mode.iconRes = builder.applicationMode.iconRes;
mode.userProfileName = builder.applicationMode.userProfileName;
mode.parentAppMode = builder.applicationMode.parentAppMode;
mode.routingProfile = builder.applicationMode.routingProfile;
mode.routeService = builder.applicationMode.routeService;
mode.iconColor = builder.applicationMode.iconColor;
break;
}
}
if(mode == null) {
mode = builder.customReg();
initRegVisibility();
}
saveCustomModeToSettings(app.getSettings());
if (!Algorithms.isEmpty(customProfiles)) {
for (ApplicationMode m : customProfiles) {
if (!values.contains(m)) {
if (m.locationIconsSet != null) {
values.add(ApplicationMode.setBearingIconsSet(m));
} else {
values.add(m);
}
}
}
}
}
private static ApplicationMode setBearingIconsSet(ApplicationMode mode) {
switch (mode.locationIconsSet) {
case CAR:
mode.bearingIconDay = R.drawable.map_car_bearing;
mode.bearingIconNight = R.drawable.map_car_bearing_night;
mode.headingIconDay = R.drawable.map_car_location_view_angle;
mode.headingIconNight = R.drawable.map_car_location_view_angle_night;
mode.locationIconDay = R.drawable.map_car_location;
mode.locationIconNight = R.drawable.map_car_location_night;
mode.locationIconDayLost = R.drawable.map_car_location_lost;
mode.locationIconNightLost = R.drawable.map_car_location_lost_night;
break;
case BICYCLE:
mode.bearingIconDay = R.drawable.map_bicycle_bearing;
mode.bearingIconNight = R.drawable.map_bicycle_bearing_night;
mode.headingIconDay = R.drawable.map_bicycle_location_view_angle;
mode.headingIconNight = R.drawable.map_bicycle_location_view_angle_night;
mode.locationIconDay = R.drawable.map_bicycle_location;
mode.locationIconNight = R.drawable.map_bicycle_location_night;
mode.locationIconDayLost = R.drawable.map_bicycle_location_lost;
mode.locationIconNightLost = R.drawable.map_bicycle_location_lost_night;
break;
case DEFAULT:
mode.bearingIconDay = R.drawable.map_pedestrian_bearing;
mode.bearingIconNight = R.drawable.map_pedestrian_bearing_night;
mode.headingIconDay = R.drawable.map_default_location_view_angle;
mode.headingIconNight = R.drawable.map_default_location_view_angle_night;
mode.locationIconDay = R.drawable.map_pedestrian_location;
mode.locationIconNight = R.drawable.map_pedestrian_location_night;
mode.locationIconDayLost = R.drawable.map_pedestrian_location_lost;
mode.locationIconNightLost = R.drawable.map_pedestrian_location_lost_night;
break;
case NAUTICAL:
mode.bearingIconDay = R.drawable.map_nautical_bearing;
mode.bearingIconNight = R.drawable.map_nautical_bearing_night;
mode.headingIconDay = R.drawable.map_nautical_location_view_angle;
mode.headingIconNight = R.drawable.map_nautical_location_view_angle_night;
mode.locationIconDay = R.drawable.map_nautical_location;
mode.locationIconNight = R.drawable.map_nautical_location_night;
break;
}
return mode;
}
public static void deleteCustomMode(String userModeTitle, OsmandApplication app) {
public static void deleteCustomMode(ApplicationMode md, OsmandApplication app) {
Iterator<ApplicationMode> it = values.iterator();
while (it.hasNext()) {
ApplicationMode m = it.next();
if (m.userProfileName != null && m.userProfileName.equals(userModeTitle)) {
if (m == md) {
it.remove();
}
}
ApplicationMode.saveCustomModeToSettings(app.getSettings());
saveCustomModeToSettings(app.getSettings());
}
public static boolean changeProfileStatus(ApplicationMode mode, boolean isSelected, OsmandApplication app) {
public static boolean changeProfileAvailability(ApplicationMode mode, boolean isSelected, OsmandApplication app) {
Set<ApplicationMode> selectedModes = new LinkedHashSet<>(ApplicationMode.values(app));
StringBuilder vls = new StringBuilder(ApplicationMode.DEFAULT.getStringKey() + ",");
if (allPossibleValues().contains(mode)) {
@ -607,23 +655,7 @@ public class ApplicationMode {
return false;
}
@DrawableRes public int getIconRes(Context app) {
try {
return app.getResources().getIdentifier(iconName, "drawable", app.getPackageName());
} catch (Exception e) {
return R.drawable.map_world_globe_dark;
}
}
public ProfileIconColors getIconColorInfo() {
if (iconColor != null) {
return iconColor;
} else {
return ProfileIconColors.DEFAULT;
}
}
public enum ProfileIconColors{
public enum ProfileIconColors {
DEFAULT(R.string.rendering_value_default_name, R.color.profile_icon_color_blue_light_default, R.color.profile_icon_color_blue_dark_default),
PURPLE(R.string.rendering_value_purple_name, R.color.profile_icon_color_purple_light, R.color.profile_icon_color_purple_dark),
GREEN(R.string.rendering_value_green_name, R.color.profile_icon_color_green_light, R.color.profile_icon_color_green_dark),
@ -655,10 +687,4 @@ public class ApplicationMode {
}
}
public enum LocationIconsSet {
DEFAULT,
CAR,
NAUTICAL,
BICYCLE
}
}

View file

@ -1154,11 +1154,6 @@ public class OsmandSettings {
DAYNIGHT_MODE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, DayNightMode.DAY);
}
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<RouteService> ROUTER_SERVICE =
new EnumIntPreference<RouteService>("router_service", RouteService.OSMAND,
RouteService.values()).makeProfile();
// this value string is synchronized with settings_pref.xml preference name
public final CommonPreference<Boolean> AUTO_ZOOM_MAP = new BooleanPreference("auto_zoom_map_on_off", false).makeProfile().cache();
{
@ -2755,8 +2750,6 @@ public class OsmandSettings {
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();
@ -2778,7 +2771,7 @@ public class OsmandSettings {
.makeGlobal();
public final CommonPreference<String> CUSTOM_APP_PROFILES =
new StringPreference("custom_profiles", "").makeGlobal().cache();
new StringPreference("custom_app_profiles", "").makeGlobal().cache();
public enum DayNightMode {

View file

@ -647,7 +647,7 @@ public class TargetPointsHelper {
public boolean hasTooLongDistanceToNavigate() {
if (settings.ROUTER_SERVICE.getModeValue(routingHelper.getAppMode()) != RouteService.OSMAND) {
if (routingHelper.getAppMode().getRouteService() != RouteService.OSMAND) {
return false;
}
Location current = routingHelper.getLastProjection();

View file

@ -366,7 +366,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
am.toHumanString(getMyApplication()),
getAppModeDescription(am),
am.getStringKey(),
am.getIconRes(getMyApplication()),
am.getIconRes(),
isSelected,
am.getIconColorInfo()
));
@ -405,15 +405,13 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
void updateModeButton(ApplicationMode mode) {
boolean nightMode = !getMyApplication().getSettings().isLightContent();
String title = Algorithms.isEmpty(mode.getUserProfileName())
? mode.toHumanString(SettingsBaseActivity.this)
: mode.getUserProfileName();
String title = mode.toHumanString(SettingsBaseActivity.this);
getModeTitleTV().setText(title);
getModeSubTitleTV().setText(getAppModeDescription(mode));
settings.APPLICATION_MODE.set(mode);
previousAppMode = mode;
getModeIconIV().setImageDrawable(getMyApplication().getUIUtilities().getIcon(mode.getIconRes(this),
getModeIconIV().setImageDrawable(getMyApplication().getUIUtilities().getIcon(mode.getIconRes(),
mode.getIconColorInfo().getColor(nightMode)));
getDropDownArrow().setImageDrawable(getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down,
R.color.icon_color));
@ -423,7 +421,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
private String getAppModeDescription(ApplicationMode mode) {
String descr;
if (mode.getParent() == null) {
if (!mode.isCustomProfile()) {
descr = getString(R.string.profile_type_base_string);
} else {
descr = String.format(getString(R.string.profile_type_descr_string),

View file

@ -242,7 +242,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
PreferenceCategory cat = (PreferenceCategory) screen.findPreference("routing_preferences");
cat.removeAll();
CheckBoxPreference fastRoute = createCheckBoxPreference(settings.FAST_ROUTE_MODE, R.string.fast_route_mode, R.string.fast_route_mode_descr);
if(settings.ROUTER_SERVICE.get() != RouteService.OSMAND) {
if(settings.getApplicationMode().getRouteService() != RouteService.OSMAND) {
cat.addPreference(fastRoute);
} else {
ApplicationMode am = settings.getApplicationMode();

View file

@ -86,15 +86,15 @@ public class AppModeDialog {
final boolean checked = selected.contains(mode);
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
if (checked) {
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), mode.getIconColorInfo().getColor(nightMode)));
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_checked)));
tb.findViewById(R.id.selection).setVisibility(View.VISIBLE);
} else {
if (useMapTheme) {
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), mode.getIconColorInfo().getColor(nightMode)));
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
iv.setBackgroundResource(AndroidUtils.resolveAttribute(ctx, android.R.attr.selectableItemBackground));
} else {
iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getIconRes(ctx)));
iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getIconRes()));
}
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_unchecked)));
tb.findViewById(R.id.selection).setVisibility(View.INVISIBLE);
@ -136,7 +136,7 @@ public class AppModeDialog {
final boolean checked = selected.contains(mode);
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
View selection = tb.findViewById(R.id.selection);
Drawable drawable = ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), mode.getIconColorInfo().getColor(nightMode));
Drawable drawable = ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode));
if (checked) {
iv.setImageDrawable(drawable);
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_checked)));
@ -149,7 +149,7 @@ public class AppModeDialog {
} else {
if (useMapTheme) {
if (Build.VERSION.SDK_INT >= 21) {
Drawable active = ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), mode.getIconColorInfo().getColor(nightMode));
Drawable active = ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode));
drawable = AndroidUtils.createPressedStateListDrawable(drawable, active);
}
iv.setImageDrawable(drawable);
@ -160,7 +160,7 @@ public class AppModeDialog {
AndroidUtils.setBackground(ctx, selection, nightMode, R.drawable.btn_border_pressed_trans_light, R.drawable.btn_border_pressed_trans_dark);
}
} else {
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), mode.getIconColorInfo().getColor(nightMode)));
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
}
iv.setContentDescription(String.format("%s %s", mode.toHumanString(ctx), ctx.getString(R.string.item_unchecked)));
}
@ -197,7 +197,7 @@ public class AppModeDialog {
int metricsY = (int) ctx.getResources().getDimension(R.dimen.route_info_modes_height);
View tb = layoutInflater.inflate(layoutId, null);
ImageView iv = (ImageView) tb.findViewById(R.id.app_mode_icon);
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(ctx), mode.getIconColorInfo().getColor(isNightMode(ctx, useMapTheme))));
iv.setImageDrawable(ctx.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(isNightMode(ctx, useMapTheme))));
iv.setContentDescription(mode.toHumanString(ctx));
// tb.setCompoundDrawablesWithIntrinsicBounds(null, ctx.getIconsCache().getIcon(mode.getIconId(), R.color.app_mode_icon_color), null, null);
LayoutParams lp = new LinearLayout.LayoutParams(metricsX, metricsY);

View file

@ -77,7 +77,7 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
ApplicationMode appMode = settings.APPLICATION_MODE.get();
appModeTv.setText(appMode.toHumanString(getContext()));
appModeTv.setCompoundDrawablesWithIntrinsicBounds(null, null, getIconsCache().getIcon(
appMode.getIconRes(getMyApplication())), null);
appMode.getIconRes()), null);
if (AndroidUiHelper.isOrientationPortrait(getActivity())) {
((ObservableScrollView) mainView.findViewById(R.id.scroll_view)).setScrollViewCallbacks(new ObservableScrollViewCallbacks() {

View file

@ -661,7 +661,7 @@ public class PlanRouteFragment extends BaseOsmAndFragment implements OsmAndLocat
if (mapActivity != null) {
final ImageButton appModesBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
appModesBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle);
appModesBtn.setImageDrawable(getActiveIcon(planRouteContext.getSnappedMode().getIconRes(getMyApplication())));
appModesBtn.setImageDrawable(getActiveIcon(planRouteContext.getSnappedMode().getIconRes()));
appModesBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View file

@ -805,7 +805,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
ImageButton snapToRoadBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
snapToRoadBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle);
snapToRoadBtn.setImageDrawable(getActiveIcon(appMode.getIconRes(getMyApplication())));
snapToRoadBtn.setImageDrawable(getActiveIcon(appMode.getIconRes()));
snapToRoadBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

View file

@ -96,7 +96,7 @@ public class SnapToRoadBottomSheetDialogFragment extends android.support.design.
ApplicationMode mode = modes.get(i);
View row = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.list_item_icon_and_title, null);
((ImageView) row.findViewById(R.id.icon)).setImageDrawable(
getContentIcon(mode.getIconRes(getMyApplication())));
getContentIcon(mode.getIconRes()));
((TextView) row.findViewById(R.id.title)).setText(mode.toHumanString(getContext()));
row.setOnClickListener(onClickListener);
row.setTag(i);

View file

@ -48,6 +48,8 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import gnu.trove.list.array.TLongArrayList;
public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
private static final long NO_CHANGESET_ID = -1;
@ -242,6 +244,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
}
ser.attribute(null, "changeset", changeSetId + ""); //$NON-NLS-1$ //$NON-NLS-2$
writeNodesIds(way, ser);
writeTags(way, ser);
ser.endTag(null, "way"); //$NON-NLS-1$
}
@ -260,6 +263,18 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
}
}
private void writeNodesIds(Way way, XmlSerializer ser)
throws IllegalArgumentException, IllegalStateException, IOException {
for (int i = 0; i < way.getNodeIds().size(); i++) {
long nodeId = way.getNodeIds().get(i);
if (nodeId != 0) {
ser.startTag(null, "nd"); //$NON-NLS-1$
ser.attribute(null, "ref", String.valueOf(nodeId)); //$NON-NLS-1$
ser.endTag(null, "nd"); //$NON-NLS-1$
}
}
}
private boolean isNewChangesetRequired() {
// first commit
if (changeSetId == NO_CHANGESET_ID) {
@ -383,7 +398,19 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
}
}
n.replaceTags(updatedTags);
if (!isWay && MapUtils.getDistance(n.getLatLon(), entity.getLatLon()) < 10) {
if (isWay) {
Way foundWay = (Way) entity;
Way currentWay = (Way) n;
TLongArrayList nodeIds = foundWay.getNodeIds();
if (nodeIds != null) {
for (int i = 0; i < nodeIds.size(); i++) {
long nodeId = nodeIds.get(i);
if (nodeId != 0) {
currentWay.addNode(nodeId);
}
}
}
} else if (MapUtils.getDistance(n.getLatLon(), entity.getLatLon()) < 10) {
// avoid shifting due to round error
n.setLatitude(entity.getLatitude());
n.setLongitude(entity.getLongitude());

View file

@ -6,15 +6,11 @@ import static net.osmand.plus.profiles.SettingsProfileFragment.PROFILE_STRING_KE
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
@ -27,7 +23,6 @@ import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.profiles.ProfileMenuAdapter.ProfileMenuAdapterListener;
import net.osmand.util.Algorithms;
public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
@ -68,14 +63,14 @@ public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
} else {
selectedModes.remove(item);
}
ApplicationMode.changeProfileStatus(item, selected, getMyApplication());
ApplicationMode.changeProfileAvailability(item, selected, getMyApplication());
}
@Override
public void onProfilePressed(ApplicationMode item) {
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
intent.putExtra(PROFILE_STRING_KEY, item.getStringKey());
if (!Algorithms.isEmpty(item.getUserProfileName())) {
if (item.isCustomProfile()) {
intent.putExtra(IS_USER_PROFILE, true);
}
startActivity(intent);
@ -91,7 +86,7 @@ public class AppModesBottomSheetDialogFragment extends MenuBottomSheetDialogFrag
};
}
adapter.setListener(listener);
allModes = ApplicationMode.allPossibleValues();
allModes = new ArrayList<>(ApplicationMode.allPossibleValues());
allModes.remove(ApplicationMode.DEFAULT);
adapter.updateItemsList(allModes,
new LinkedHashSet<>(ApplicationMode.values(getMyApplication())));

View file

@ -16,7 +16,6 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
@ -168,32 +167,30 @@ public class EditProfileFragment extends BaseOsmAndFragment {
profileNameEt.setFocusable(true);
profileNameEt.setSelectAllOnFocus(true);
String title = "New Profile";
String title = getResources().getString(R.string.new_profile);
int startIconId = R.drawable.map_world_globe_dark;
int startIconId = profile.iconId;
if (isNew) {
isDataChanged = true;
startIconId = profile.parent.getSmallIconDark();
startIconId = profile.parent.getIconRes();
profile.iconId = startIconId;
profile.iconStringName = profile.parent.getIconName();
} else if (isUserProfile) {
title = profile.userProfileTitle;
profileNameEt.setText(title);
startIconId = profile.iconId;
isDataChanged = false;
} else if (profile.key != -1) {
title = getResources().getString(profile.key);
profileNameEt.setText(profile.key);
startIconId = profile.iconId;
} else if (profile.stringKeyName != -1) {
title = getResources().getString(profile.stringKeyName);
profileNameEt.setText(title);
clickBlockLayout.setClickable(true);
}
profile.userProfileTitle = title;
if (profile.parent != null) {
setupBaseProfileView(profile.parent.getStringKey());
} else if (profile.key != -1) {
baseModeTitle.setText(profile.key);
} else if (profile.stringKeyName != -1) {
baseModeTitle.setText(profile.stringKeyName);
baseModeIcon.setImageDrawable(
app.getUIUtilities().getIcon(profile.iconId, R.color.icon_color));
}
@ -556,7 +553,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
void activateMode(ApplicationMode mode) {
if (!ApplicationMode.values(app).contains(mode)) {
ApplicationMode.changeProfileStatus(mode, true, getMyApplication());
ApplicationMode.changeProfileAvailability(mode, true, getMyApplication());
}
}
@ -564,7 +561,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
for (ApplicationMode am : ApplicationMode.getDefaultValues()) {
if (am.getStringKey().equals(stringKey)) {
baseModeIcon.setImageDrawable(
app.getUIUtilities().getIcon(am.getSmallIconDark(), R.color.icon_color));
app.getUIUtilities().getIcon(am.getIconRes(), R.color.icon_color));
baseModeTitle.setText(Algorithms.capitalizeFirstLetter(am.toHumanString(app)));
isDataChanged = false;
}
@ -599,10 +596,8 @@ public class EditProfileFragment extends BaseOsmAndFragment {
}
for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
if (m.getUserProfileName() != null && getActivity() != null) {
if (m.getUserProfileName().equals(profile.userProfileTitle)) {
if (isNew || !Algorithms.isEmpty(mode.getUserProfileName())
&& !mode.getUserProfileName().equals(profile.userProfileTitle)) {
if (m.getCustomProfileName() != null && getActivity() != null &&
m.getCustomProfileName().equals(profile.userProfileTitle) && isNew) {
AlertDialog.Builder bld = new AlertDialog.Builder(getActivity());
bld.setTitle(R.string.profile_alert_duplicate_name_title);
bld.setMessage(R.string.profile_alert_duplicate_name_msg);
@ -617,47 +612,30 @@ public class EditProfileFragment extends BaseOsmAndFragment {
return false;
}
}
}
}
if (isUserProfile && !isNew) {
ApplicationMode.deleteCustomMode(mode.getUserProfileName(), getMyApplication());
}
String customStringKey = profile.stringKey;
if (isNew && profile.parent != null) {
if (isNew) {
customStringKey =
profile.parent.getStringKey() + "_" + System.currentTimeMillis();
}
ApplicationMode.ApplicationModeBuilder builder = ApplicationMode
.createCustomMode(profile.userProfileTitle.trim(), customStringKey)
.parent(profile.parent)
.icon(profile.iconId, profile.iconId, profile.iconStringName);
.createCustomMode(profile.parent, profile.userProfileTitle.trim(), customStringKey)
.icon(profile.iconId, profile.iconStringName);
if (profile.routingProfileDataObject != null) {
if(profile.routingProfileDataObject.getStringKey().equals(
RoutingProfilesResources.STRAIGHT_LINE_MODE.name())) {
builder.setRouteService(RouteService.STRAIGHT);
} else if(profile.routingProfileDataObject.getStringKey().equals(
RoutingProfilesResources.BROUTER_MODE.name())) {
builder.setRouteService(RouteService.BROUTER);
} else if (profile.routingProfileDataObject != null) {
builder.setRoutingProfile(profile.routingProfileDataObject.getStringKey());
}
builder.setColor(profile.iconColor);
ApplicationMode mode = builder.customReg();
ApplicationMode.saveCustomModeToSettings(getSettings());
mode = ApplicationMode.saveCustomProfile(builder, getMyApplication());
if (!ApplicationMode.values(app).contains(mode)) {
boolean save = ApplicationMode.changeProfileStatus(mode, true, getMyApplication());
if (save && getSettings() != null) {
if (profile.routingProfileDataObject.getStringKey()
.equals(RoutingProfilesResources.STRAIGHT_LINE_MODE.toString())) {
getSettings().ROUTER_SERVICE.setModeValue(mode, RouteService.STRAIGHT);
} else if (profile.routingProfileDataObject.getStringKey()
.equals(RoutingProfilesResources.BROUTER_MODE.toString())) {
getSettings().ROUTER_SERVICE.setModeValue(mode, RouteService.BROUTER);
} else {
getSettings().ROUTER_SERVICE.setModeValue(mode, RouteService.OSMAND);
}
}
ApplicationMode.changeProfileAvailability(mode, true, getMyApplication());
}
isDataChanged = false;
isCancelAllowed = true;
@ -711,7 +689,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationMode
.deleteCustomMode(profile.userProfileTitle, getMyApplication());
.deleteCustomMode(mode, getMyApplication());
if (getActivity() != null) {
getActivity().onBackPressed();
}
@ -730,14 +708,14 @@ public class EditProfileFragment extends BaseOsmAndFragment {
static List<RoutingProfileDataObject> getRoutingProfiles(OsmandApplication context) {
List<RoutingProfileDataObject> profilesObjects = new ArrayList<>();
profilesObjects.add(new RoutingProfileDataObject(
RoutingProfilesResources.STRAIGHT_LINE_MODE.toString(),
RoutingProfilesResources.STRAIGHT_LINE_MODE.name(),
context.getString(RoutingProfilesResources.STRAIGHT_LINE_MODE.getStringRes()),
context.getString(R.string.special_routing_type),
RoutingProfilesResources.STRAIGHT_LINE_MODE.getIconRes(),
false, null));
if (context.getBRouterService() != null) {
profilesObjects.add(new RoutingProfileDataObject(
RoutingProfilesResources.BROUTER_MODE.toString(),
RoutingProfilesResources.BROUTER_MODE.name(),
context.getString(RoutingProfilesResources.BROUTER_MODE.getStringRes()),
context.getString(R.string.third_party_routing_type),
RoutingProfilesResources.BROUTER_MODE.getIconRes(),
@ -765,7 +743,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
}
public enum RoutingProfilesResources {
STRAIGHT_LINE_MODE(R.string.routing_profile_straightline,R.drawable.ic_action_split_interval),
STRAIGHT_LINE_MODE(R.string.routing_profile_straightline, R.drawable.ic_action_split_interval),
BROUTER_MODE(R.string.routing_profile_broutrer, R.drawable.ic_action_split_interval),
CAR(R.string.rendering_value_car_name, R.drawable.ic_action_car_dark),
PEDESTRIAN(R.string.rendering_value_pedestrian_name, R.drawable.map_action_pedestrian_dark),
@ -806,7 +784,7 @@ public class EditProfileFragment extends BaseOsmAndFragment {
private class ApplicationProfileObject {
int key = -1;
int stringKeyName = -1;
String stringKey;
String userProfileTitle = "";
ApplicationMode parent = null;
@ -823,15 +801,15 @@ public class EditProfileFragment extends BaseOsmAndFragment {
} else if (isUserProfile) {
stringKey = mode.getStringKey();
parent = mode.getParent();
iconId = mode.getIconRes(getMyApplication());
iconStringName = Algorithms.isEmpty(mode.getIconName())? "map_world_globe_dark" : mode.getIconName();
iconId = mode.getIconRes();
iconStringName = mode.getIconName();
iconColor = mode.getIconColorInfo() == null ? ProfileIconColors.DEFAULT : mode.getIconColorInfo();
userProfileTitle = mode.getUserProfileName();
userProfileTitle = mode.getCustomProfileName();
} else {
key = mode.getStringResource();
stringKeyName = mode.getNameKeyResource();
stringKey = mode.getStringKey();
iconId = mode.getSmallIconDark();
iconStringName = Algorithms.isEmpty(mode.getIconName())? "map_world_globe_dark" : mode.getIconName();
iconId = mode.getIconRes();
iconStringName = mode.getIconName();
}
}
}

View file

@ -103,14 +103,11 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
? app.getResources().getColor(R.color.divider_dark)
: app.getResources().getColor(R.color.divider_light));
}
if (item.getParent() != null) {
holder.title.setText(item.getUserProfileName());
holder.title.setText(item.toHumanString(app));
if (item.isCustomProfile()) {
holder.descr.setText(String.format(app.getString(R.string.profile_type_descr_string),
Algorithms.capitalizeFirstLetterAndLowercase(
item.getParent().getStringKey().replace("_", " "))));
Algorithms.capitalizeFirstLetterAndLowercase(item.getParent().toHumanString(app))));
} else {
holder.title.setText(item.getStringResource());
holder.descr.setText(R.string.profile_type_base_string);
}
@ -142,7 +139,7 @@ public class ProfileMenuAdapter extends RecyclerView.Adapter<ProfileViewHolder>
}
private void updateViewHolder(ProfileViewHolder holder, ApplicationMode mode) {
int iconRes = mode.getIconRes(app);
int iconRes = mode.getIconRes();
if (iconRes == 0 || iconRes == -1) {
iconRes = R.drawable.ic_action_world_globe;
}

View file

@ -27,7 +27,7 @@ import net.osmand.plus.R;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.profiles.ProfileMenuAdapter.ProfileMenuAdapterListener;
import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SelectProfileListener;
import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
public class SettingsProfileFragment extends BaseOsmAndFragment {
@ -53,7 +53,7 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
allAppModes = ApplicationMode.allPossibleValues();
allAppModes = new ArrayList<>(ApplicationMode.allPossibleValues());
allAppModes.remove(ApplicationMode.DEFAULT);
availableAppModes = new LinkedHashSet<>(ApplicationMode.values(getMyApplication()));
availableAppModes.remove(ApplicationMode.DEFAULT);
@ -103,14 +103,14 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
} else {
availableAppModes.remove(am);
}
ApplicationMode.changeProfileStatus(am, selected, getMyApplication());
ApplicationMode.changeProfileAvailability(am, selected, getMyApplication());
}
@Override
public void onProfilePressed(ApplicationMode item) {
Intent intent = new Intent(getActivity(), EditProfileActivity.class);
intent.putExtra(PROFILE_STRING_KEY, item.getStringKey());
if (!Algorithms.isEmpty(item.getUserProfileName())) {
if (item.isCustomProfile()) {
intent.putExtra(IS_USER_PROFILE, true);
}
startActivity(intent);
@ -125,7 +125,7 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
getBaseProfileListener();
allAppModes = ApplicationMode.allPossibleValues();
allAppModes = new ArrayList<>(ApplicationMode.allPossibleValues());
allAppModes.remove(ApplicationMode.DEFAULT);
adapter.updateItemsList(allAppModes, new LinkedHashSet<>(ApplicationMode.values(getMyApplication())));
}
@ -152,7 +152,7 @@ public class SettingsProfileFragment extends BaseOsmAndFragment {
if (mode != ApplicationMode.DEFAULT) {
profiles.add(new ProfileDataObject( mode.toHumanString(ctx),
ctx.getString(BaseProfilesDescr.valueOf(mode.getStringKey().toUpperCase()).getDescrRes()),
mode.getStringKey(), mode.getSmallIconDark(), false, mode.getIconColorInfo()));
mode.getStringKey(), mode.getIconRes(), false, mode.getIconColorInfo()));
}
}
return profiles;

View file

@ -83,9 +83,9 @@ public class NavStartStopAction extends QuickAction {
if (context instanceof MapActivity) {
RoutingHelper helper = ((MapActivity) context).getRoutingHelper();
if (!helper.isRoutePlanningMode() && !helper.isFollowingMode()) {
return ((MapActivity) context).getMapActions().getRouteMode(null).getIconRes(context);
return ((MapActivity) context).getMapActions().getRouteMode(null).getIconRes();
}
return helper.getAppMode().getIconRes(context);
return helper.getAppMode().getIconRes();
}
return super.getIconRes(context);
}

View file

@ -422,7 +422,7 @@ public class RoutingOptionsHelper {
final OsmandSettings settings = app.getSettings();
List<LocalRoutingParameter> list = new ArrayList<LocalRoutingParameter>();
RouteProvider.GPXRouteParamsBuilder rparams = app.getRoutingHelper().getCurrentGPXRoute();
boolean osmandRouter = settings.ROUTER_SERVICE.getModeValue(am) == RouteProvider.RouteService.OSMAND;
boolean osmandRouter = am.getRouteService() == RouteProvider.RouteService.OSMAND;
if (!osmandRouter) {
list.add(new OtherLocalRoutingParameter(R.string.calculate_osmand_route_without_internet,
app.getString(R.string.calculate_osmand_route_without_internet), settings.GPX_ROUTE_CALC_OSMAND_PARTS

View file

@ -22,7 +22,6 @@ public class RouteCalculationParams {
public OsmandApplication ctx;
public RoutingContext cachedRoutingContext;
public ApplicationMode mode;
public RouteService type;
public GPXRouteParams gpxRoute;
public RouteCalculationResult previousToRecalculate;
public boolean onlyStartPointChanged;

View file

@ -296,22 +296,22 @@ public class RouteProvider {
if (params.start != null && params.end != null) {
if(log.isInfoEnabled()){
log.info("Start finding route from " + params.start + " to " + params.end +" using " +
params.type.getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
params.mode.getRouteService().getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
try {
RouteCalculationResult res;
boolean calcGPXRoute = params.gpxRoute != null && !params.gpxRoute.points.isEmpty();
if(calcGPXRoute && !params.gpxRoute.calculateOsmAndRoute){
res = calculateGpxRoute(params);
} else if (params.type == RouteService.OSMAND) {
} else if (params.mode.getRouteService() == RouteService.OSMAND) {
res = findVectorMapsRoute(params, calcGPXRoute);
} else if (params.type == RouteService.BROUTER) {
} else if (params.mode.getRouteService() == RouteService.BROUTER) {
res = findBROUTERRoute(params);
// } else if (params.type == RouteService.ORS) {
// res = findORSRoute(params);
// } else if (params.type == RouteService.OSRM) {
// res = findOSRMRoute(params);
} else if (params.type == RouteService.STRAIGHT){
} else if (params.mode.getRouteService() == RouteService.STRAIGHT){
res = findStraightRoute(params);
}
else {
@ -410,7 +410,6 @@ public class RouteProvider {
rp.start = routeParams.start;
rp.end = routeParams.end;
rp.leftSide = routeParams.leftSide;
rp.type = routeParams.type;
rp.fast = routeParams.fast;
rp.onlyStartPointChanged = routeParams.onlyStartPointChanged;
rp.previousToRecalculate = routeParams.previousToRecalculate;
@ -533,7 +532,6 @@ public class RouteProvider {
newParams.ctx = rParams.ctx;
newParams.calculationProgress = rParams.calculationProgress;
newParams.mode = rParams.mode;
newParams.type = RouteService.OSMAND;
newParams.leftSide = rParams.leftSide;
RouteCalculationResult newRes = null;
try {
@ -780,7 +778,7 @@ public class RouteProvider {
}
private RouteCalculationResult applicationModeNotSupported(RouteCalculationParams params) {
return new RouteCalculationResult("Application mode '"+ params.mode.toHumanStringCtx(params.ctx)+ "' is not supported.");
return new RouteCalculationResult("Application mode '"+ params.mode.toHumanString(params.ctx)+ "' is not supported.");
}
private RouteCalculationResult interrupted() {

View file

@ -942,7 +942,8 @@ public class RoutingHelper {
}
return;
}
final boolean onlineSourceWithoutInternet = !res.isCalculated() && params.type.isOnline() && !settings.isInternetConnectionAvailable();
final boolean onlineSourceWithoutInternet = !res.isCalculated() &&
params.mode.getRouteService().isOnline() && !settings.isInternetConnectionAvailable();
if (onlineSourceWithoutInternet && settings.GPX_ROUTE_CALC_OSMAND_PARTS.get()) {
if (params.previousToRecalculate != null && params.previousToRecalculate.isCalculated()) {
res = provider.recalculatePartOfflineRoute(res, params);
@ -1034,11 +1035,10 @@ public class RoutingHelper {
}
params.leftSide = settings.DRIVING_REGION.get().leftHandDriving;
params.fast = settings.FAST_ROUTE_MODE.getModeValue(mode);
params.type = settings.ROUTER_SERVICE.getModeValue(mode);
params.mode = mode;
params.ctx = app;
boolean updateProgress = false;
if (params.type == RouteService.OSMAND) {
if (params.mode.getRouteService() == RouteService.OSMAND) {
params.calculationProgress = new RouteCalculationProgress();
updateProgress = true;
}
@ -1112,7 +1112,6 @@ public class RoutingHelper {
public static void applyApplicationSettings(RouteCalculationParams params, OsmandSettings settings, ApplicationMode mode) {
params.leftSide = settings.DRIVING_REGION.get().leftHandDriving;
params.fast = settings.FAST_ROUTE_MODE.getModeValue(mode);
params.type = settings.ROUTER_SERVICE.getModeValue(mode);
}
public void setProgressBar(RouteCalculationProgressCallback progressRoute) {

View file

@ -796,7 +796,7 @@ public class MapControlsLayer extends OsmandMapLayer {
compassHud.forceHideCompass = forceHideCompass;
compassHud.updateVisibility(!forceHideCompass && shouldShowCompass());
if (layersHud.setIconResId(settings.getApplicationMode().getIconRes(app))) {
if (layersHud.setIconResId(settings.getApplicationMode().getIconRes())) {
layersHud.update(app, isNight);
}
layersHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode()

View file

@ -11,6 +11,7 @@ import android.widget.ImageButton;
import android.widget.LinearLayout;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
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 java.lang.reflect.Field;
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.*;
public class MapInfoLayer extends OsmandMapLayer {
private final MapActivity map;
@ -159,49 +161,49 @@ public class MapInfoLayer extends OsmandMapLayer {
rulerControl.setVisibility(false);
// 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);
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);
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, WIDGET_NEXT_TURN_SMALL, true, 6);
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
// 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);
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);
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);
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);
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);
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);
registerSideWidget(bearing, new BearingWidgetState(app), "bearing", false, 18);
registerSideWidget(bearing, new BearingWidgetState(app), WIDGET_BEARING, false, 18);
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);
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);
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);
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);
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);
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);
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);
registerSideWidget(ruler, new CompassRulerControlWidgetState(app), "ruler", false, 43);
registerSideWidget(ruler, new CompassRulerControlWidgetState(app), WIDGET_RULER, false, 43);
}
public void recreateControls() {

View file

@ -42,6 +42,29 @@ public class MapWidgetRegistry {
public static final String HIDE_PREFIX = "-";
public static final String SHOW_PREFIX = "";
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> rightWidgetSet = new TreeSet<>();
private Map<ApplicationMode, Set<String>> visibleElementsFromSettings = new LinkedHashMap<>();
@ -309,7 +332,6 @@ public class MapWidgetRegistry {
}
private void resetDefaultAppearance(ApplicationMode appMode) {
// settings.SHOW_RULER.resetToDefault();
settings.TRANSPARENT_MAP_THEME.resetToDefault();
settings.SHOW_STREET_NAME.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) {
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) {
addControlId(map, cm, R.string.map_widget_top_text, settings.SHOW_STREET_NAME);
}
@ -344,6 +364,8 @@ public class MapWidgetRegistry {
return false;
}
}).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) {

View file

@ -162,10 +162,6 @@ public abstract class AbstractPrologCommandPlayer implements CommandPlayer, Stat
config = new FileInputStream(new File(voiceDir, configFile)); //$NON-NLS-1$
// }
MetricsConstants mc = settings.METRIC_SYSTEM.get();
ApplicationMode m = settings.getApplicationMode();
if(m.getParent() != null) {
m = m.getParent();
}
settings.APPLICATION_MODE.addListener(this);
prologSystem.getTheoryManager()
.assertA(