Merge pull request #9508 from osmandapp/fix_default_speed

Fix_9484
This commit is contained in:
vshcherb 2020-07-24 11:44:02 +02:00 committed by GitHub
commit de452bf350
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,15 +30,10 @@ import androidx.core.content.ContextCompat;
import com.google.android.material.slider.Slider; import com.google.android.material.slider.Slider;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; 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.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.Version; 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.routepreparationmenu.RoutingOptionsHelper;
import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.routing.RoutingHelper; 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.plus.voice.CommandPlayer;
import net.osmand.router.GeneralRouter; import net.osmand.router.GeneralRouter;
import net.osmand.router.GeneralRouter.GeneralRouterProfile; import net.osmand.router.GeneralRouter.GeneralRouterProfile;
@ -749,22 +749,26 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
float settingsMinSpeed = mode.getMinSpeed(); float settingsMinSpeed = mode.getMinSpeed();
float settingsMaxSpeed = mode.getMaxSpeed(); 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[] minValue = new int[1];
final int[] maxValue = new int[1]; final int[] maxValue = new int[1];
final int min; final int min;
final int max; final int max;
if (defaultSpeedOnly) { if (defaultSpeedOnly) {
minValue[0] = Math.round(1 * ratio[0]); minValue[0] = Math.round(Math.min(1, settingsDefaultSpeed) * ratio[0]);
maxValue[0] = Math.round(300 * ratio[0]); maxValue[0] = Math.round(Math.max(300, settingsDefaultSpeed) * ratio[0]);
min = minValue[0]; min = minValue[0];
max = maxValue[0]; max = maxValue[0];
} else { } else {
minValue[0] = Math.round((settingsMinSpeed > 0 ? settingsMinSpeed : router.getMinSpeed()) * ratio[0]); float minSpeedValue = settingsMinSpeed > 0 ? settingsMinSpeed : router.getMinSpeed();
maxValue[0] = Math.round((settingsMaxSpeed > 0 ? settingsMaxSpeed : router.getMaxSpeed()) * ratio[0]); float maxSpeedValue = settingsMaxSpeed > 0 ? settingsMaxSpeed : router.getMaxSpeed();
min = Math.round(router.getMinSpeed() * ratio[0] / 2f); minValue[0] = Math.round(Math.min(minSpeedValue, settingsDefaultSpeed) * ratio[0]);
max = Math.round(router.getMaxSpeed() * ratio[0] * 1.5f); 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); boolean nightMode = !app.getSettings().isLightContentForMode(mode);