Fix speed dialog prefs for different app modes
This commit is contained in:
parent
0ac801f8f2
commit
32b3f24865
2 changed files with 8 additions and 10 deletions
|
@ -562,8 +562,7 @@ public class ApplicationMode {
|
||||||
|
|
||||||
public void setDefaultSpeed(OsmandApplication app, float defaultSpeed) {
|
public void setDefaultSpeed(OsmandApplication app, float defaultSpeed) {
|
||||||
this.defaultSpeed = defaultSpeed;
|
this.defaultSpeed = defaultSpeed;
|
||||||
app.getSettings().DEFAULT_SPEED.set(defaultSpeed);
|
app.getSettings().DEFAULT_SPEED.setModeValue(this, defaultSpeed);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetDefaultSpeed(OsmandApplication app) {
|
public void resetDefaultSpeed(OsmandApplication app) {
|
||||||
|
|
|
@ -19,7 +19,6 @@ import android.preference.PreferenceScreen;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.ContextThemeWrapper;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -729,7 +728,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
final OsmandSettings settings = app.getSettings();
|
final OsmandSettings settings = app.getSettings();
|
||||||
|
|
||||||
GeneralRouter router = getRouter(app.getRoutingConfig(), mode);
|
GeneralRouter router = getRouter(app.getRoutingConfig(), mode);
|
||||||
SpeedConstants units = settings.SPEED_SYSTEM.get();
|
SpeedConstants units = settings.SPEED_SYSTEM.getModeValue(mode);
|
||||||
String speedUnits = units.toShortString(activity);
|
String speedUnits = units.toShortString(activity);
|
||||||
final float[] ratio = new float[1];
|
final float[] ratio = new float[1];
|
||||||
switch (units) {
|
switch (units) {
|
||||||
|
@ -755,8 +754,8 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
float settingsMinSpeed = settings.MIN_SPEED.get();
|
float settingsMinSpeed = settings.MIN_SPEED.getModeValue(mode);
|
||||||
float settingsMaxSpeed = settings.MAX_SPEED.get();
|
float settingsMaxSpeed = settings.MAX_SPEED.getModeValue(mode);
|
||||||
|
|
||||||
final int[] defaultValue = {Math.round(mode.getDefaultSpeed() * ratio[0])};
|
final int[] defaultValue = {Math.round(mode.getDefaultSpeed() * ratio[0])};
|
||||||
final int[] minValue = new int[1];
|
final int[] minValue = new int[1];
|
||||||
|
@ -785,8 +784,8 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
mode.setDefaultSpeed(app, defaultValue[0] / ratio[0]);
|
mode.setDefaultSpeed(app, defaultValue[0] / ratio[0]);
|
||||||
if (!defaultSpeedOnly) {
|
if (!defaultSpeedOnly) {
|
||||||
settings.MIN_SPEED.set(minValue[0] / ratio[0]);
|
settings.MIN_SPEED.setModeValue(mode, minValue[0] / ratio[0]);
|
||||||
settings.MAX_SPEED.set(maxValue[0] / ratio[0]);
|
settings.MAX_SPEED.setModeValue(mode, maxValue[0] / ratio[0]);
|
||||||
}
|
}
|
||||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||||
if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) {
|
if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) {
|
||||||
|
@ -800,8 +799,8 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
mode.resetDefaultSpeed(app);
|
mode.resetDefaultSpeed(app);
|
||||||
if (!defaultSpeedOnly) {
|
if (!defaultSpeedOnly) {
|
||||||
settings.MIN_SPEED.set(0f);
|
settings.MIN_SPEED.setModeValue(mode,0f);
|
||||||
settings.MAX_SPEED.set(0f);
|
settings.MAX_SPEED.setModeValue(mode,0f);
|
||||||
}
|
}
|
||||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||||
if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) {
|
if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) {
|
||||||
|
|
Loading…
Reference in a new issue