Fix default speed slider

This commit is contained in:
Vitaliy 2020-07-23 14:28:28 +03:00
parent ad3011a802
commit 8ad6f937b6

View file

@ -30,15 +30,10 @@ import androidx.core.content.ContextCompat;
import com.google.android.material.slider.Slider;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.backend.OsmandSettings.AutoZoomMap;
import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
import net.osmand.plus.settings.backend.OsmandSettings.SpeedConstants;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.Version;
@ -48,6 +43,11 @@ import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.backend.OsmandSettings.AutoZoomMap;
import net.osmand.plus.settings.backend.OsmandSettings.OsmandPreference;
import net.osmand.plus.settings.backend.OsmandSettings.SpeedConstants;
import net.osmand.plus.voice.CommandPlayer;
import net.osmand.router.GeneralRouter;
import net.osmand.router.GeneralRouter.GeneralRouterProfile;
@ -749,8 +749,9 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
float settingsMinSpeed = mode.getMinSpeed();
float settingsMaxSpeed = mode.getMaxSpeed();
float settingsDefaultSpeed = mode.getDefaultSpeed();
final int[] defaultValue = {Math.round(mode.getDefaultSpeed() * ratio[0])};
final int[] defaultValue = {Math.round(settingsDefaultSpeed * ratio[0])};
final int[] minValue = new int[1];
final int[] maxValue = new int[1];
final int min;
@ -761,10 +762,13 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
min = minValue[0];
max = maxValue[0];
} else {
minValue[0] = Math.round((settingsMinSpeed > 0 ? settingsMinSpeed : router.getMinSpeed()) * ratio[0]);
maxValue[0] = Math.round((settingsMaxSpeed > 0 ? settingsMaxSpeed : router.getMaxSpeed()) * ratio[0]);
min = Math.round(router.getMinSpeed() * ratio[0] / 2f);
max = Math.round(router.getMaxSpeed() * ratio[0] * 1.5f);
float minSpeedValue = settingsMinSpeed > 0 ? settingsMinSpeed : router.getMinSpeed();
float maxSpeedValue = settingsMaxSpeed > 0 ? settingsMaxSpeed : router.getMaxSpeed();
minValue[0] = Math.round(Math.min(minSpeedValue, settingsDefaultSpeed) * ratio[0]);
maxValue[0] = Math.round(Math.max(maxSpeedValue, settingsDefaultSpeed) * ratio[0]);
min = Math.round(Math.min(router.getMinSpeed(), settingsDefaultSpeed) * ratio[0] / 2f);
max = Math.round(Math.max(router.getMaxSpeed(), settingsDefaultSpeed) * ratio[0] * 1.5f);
}
boolean nightMode = !app.getSettings().isLightContentForMode(mode);