Reset default app mode speed in settings
This commit is contained in:
parent
a2facffc5c
commit
13b61b061e
2 changed files with 23 additions and 21 deletions
|
@ -73,7 +73,6 @@ public class ApplicationMode {
|
||||||
private RouteService routeService = RouteService.OSMAND;
|
private RouteService routeService = RouteService.OSMAND;
|
||||||
|
|
||||||
private float defaultSpeed = 10f;
|
private float defaultSpeed = 10f;
|
||||||
private float initialDefaultSpeed = defaultSpeed;
|
|
||||||
private int minDistanceForTurn = 50;
|
private int minDistanceForTurn = 50;
|
||||||
private int arrivalDistance = 90;
|
private int arrivalDistance = 90;
|
||||||
private int offRouteDistance = 350;
|
private int offRouteDistance = 350;
|
||||||
|
@ -223,7 +222,6 @@ public class ApplicationMode {
|
||||||
private ApplicationMode customReg() {
|
private ApplicationMode customReg() {
|
||||||
ApplicationMode m = applicationMode;
|
ApplicationMode m = applicationMode;
|
||||||
m.defaultSpeed = m.parentAppMode.defaultSpeed;
|
m.defaultSpeed = m.parentAppMode.defaultSpeed;
|
||||||
m.initialDefaultSpeed = m.parentAppMode.initialDefaultSpeed;
|
|
||||||
m.minDistanceForTurn = m.parentAppMode.minDistanceForTurn;
|
m.minDistanceForTurn = m.parentAppMode.minDistanceForTurn;
|
||||||
m.arrivalDistance = m.parentAppMode.arrivalDistance;
|
m.arrivalDistance = m.parentAppMode.arrivalDistance;
|
||||||
m.offRouteDistance = m.parentAppMode.offRouteDistance;
|
m.offRouteDistance = m.parentAppMode.offRouteDistance;
|
||||||
|
@ -253,17 +251,7 @@ public class ApplicationMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationModeBuilder icon(Context app, String iconResName) {
|
public ApplicationModeBuilder icon(Context app, String iconResName) {
|
||||||
try {
|
updateAppModeIcon(app, iconResName, applicationMode);
|
||||||
int iconRes = app.getResources().getIdentifier(iconResName, "drawable", app.getPackageName());
|
|
||||||
int iconMapRes = app.getResources().getIdentifier(iconResName.replace("ic_", "map_"), "drawable", app.getPackageName());
|
|
||||||
if (iconRes != 0 && iconMapRes != 0) {
|
|
||||||
applicationMode.iconResName = iconResName;
|
|
||||||
applicationMode.iconRes = iconRes;
|
|
||||||
applicationMode.iconMapRes = iconMapRes;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// return R.drawable.map_world_globe_dark;
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +272,6 @@ public class ApplicationMode {
|
||||||
|
|
||||||
public ApplicationModeBuilder speed(float defSpeed, int distForTurn) {
|
public ApplicationModeBuilder speed(float defSpeed, int distForTurn) {
|
||||||
applicationMode.defaultSpeed = defSpeed;
|
applicationMode.defaultSpeed = defSpeed;
|
||||||
applicationMode.initialDefaultSpeed = defSpeed;
|
|
||||||
applicationMode.minDistanceForTurn = distForTurn;
|
applicationMode.minDistanceForTurn = distForTurn;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -325,6 +312,20 @@ public class ApplicationMode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void updateAppModeIcon(Context app, String iconResName, ApplicationMode mode) {
|
||||||
|
try {
|
||||||
|
int iconRes = app.getResources().getIdentifier(iconResName, "drawable", app.getPackageName());
|
||||||
|
int iconMapRes = app.getResources().getIdentifier(iconResName.replace("ic_", "map_"), "drawable", app.getPackageName());
|
||||||
|
if (iconRes != 0 && iconMapRes != 0) {
|
||||||
|
mode.iconResName = iconResName;
|
||||||
|
mode.iconRes = iconRes;
|
||||||
|
mode.iconMapRes = iconMapRes;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// return R.drawable.map_world_globe_dark;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static ApplicationModeBuilder create(ApplicationMode parent, 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);
|
||||||
|
@ -544,8 +545,9 @@ public class ApplicationMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetDefaultSpeed(OsmandApplication app) {
|
public void resetDefaultSpeed(OsmandApplication app) {
|
||||||
this.defaultSpeed = initialDefaultSpeed;
|
OsmandSettings settings = app.getSettings();
|
||||||
app.getSettings().DEFAULT_SPEED.setModeValue(this, 0f);
|
settings.DEFAULT_SPEED.resetModeToDefault(this);
|
||||||
|
this.defaultSpeed = settings.DEFAULT_SPEED.getModeValue(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMinDistanceForTurn() {
|
public int getMinDistanceForTurn() {
|
||||||
|
|
|
@ -1489,11 +1489,11 @@ public class OsmandSettings {
|
||||||
|
|
||||||
{
|
{
|
||||||
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.DEFAULT, "ic_world_globe_dark");
|
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.DEFAULT, "ic_world_globe_dark");
|
||||||
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.CAR, "ic_action_car");
|
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.CAR, "ic_action_car_dark");
|
||||||
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.BICYCLE, "ic_action_bicycle");
|
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.BICYCLE, "ic_action_bicycle_dark");
|
||||||
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.PEDESTRIAN, "ic_action_pedestrian");
|
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.PEDESTRIAN, "ic_action_pedestrian_dark");
|
||||||
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.PUBLIC_TRANSPORT, "ic_action_bus");
|
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.PUBLIC_TRANSPORT, "ic_action_bus_dark");
|
||||||
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.BOAT, "ic_action_sail_boat");
|
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.BOAT, "ic_action_sail_boat_dark");
|
||||||
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.AIRCRAFT, "ic_action_aircraft");
|
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.AIRCRAFT, "ic_action_aircraft");
|
||||||
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.SKI, "ic_action_skiing");
|
ICON_RES_NAME.setModeDefaultValue(ApplicationMode.SKI, "ic_action_skiing");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue