Implemented default speed adjusting
This commit is contained in:
parent
b067b66aa6
commit
9ac93f824e
6 changed files with 215 additions and 13 deletions
|
@ -33,6 +33,7 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
public static final String PREFER_MOTORWAYS = "prefer_motorway";
|
public static final String PREFER_MOTORWAYS = "prefer_motorway";
|
||||||
public static final String ALLOW_PRIVATE = "allow_private";
|
public static final String ALLOW_PRIVATE = "allow_private";
|
||||||
public static final String ALLOW_MOTORWAYS = "allow_motorway";
|
public static final String ALLOW_MOTORWAYS = "allow_motorway";
|
||||||
|
public static final String DEFAULT_SPEED = "default_speed";
|
||||||
|
|
||||||
private final RouteAttributeContext[] objectAttributes;
|
private final RouteAttributeContext[] objectAttributes;
|
||||||
public final Map<String, String> attributes;
|
public final Map<String, String> attributes;
|
||||||
|
@ -61,6 +62,8 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
// speed in m/s
|
// speed in m/s
|
||||||
private float maxSpeed = 10f;
|
private float maxSpeed = 10f;
|
||||||
|
|
||||||
|
private float defaultSpeedRatio = 1f;
|
||||||
|
|
||||||
private TLongHashSet impassableRoads;
|
private TLongHashSet impassableRoads;
|
||||||
private GeneralRouterProfile profile;
|
private GeneralRouterProfile profile;
|
||||||
|
|
||||||
|
@ -165,7 +168,10 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
if(shortestRoute) {
|
if(shortestRoute) {
|
||||||
maxSpeed = Math.min(CAR_SHORTEST_DEFAULT_SPEED, maxSpeed);
|
maxSpeed = Math.min(CAR_SHORTEST_DEFAULT_SPEED, maxSpeed);
|
||||||
}
|
}
|
||||||
|
float userDefinedDefSpeed = params.containsKey(DEFAULT_SPEED) ? parseSilentFloat(params.get(DEFAULT_SPEED), defaultSpeed) : defaultSpeed;
|
||||||
|
if (userDefinedDefSpeed != defaultSpeed) {
|
||||||
|
defaultSpeedRatio = userDefinedDefSpeed / defaultSpeed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeneralRouterProfile getProfile() {
|
public GeneralRouterProfile getProfile() {
|
||||||
|
@ -390,7 +396,7 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float defineVehicleSpeed(RouteDataObject road) {
|
public float defineVehicleSpeed(RouteDataObject road) {
|
||||||
return getObjContext(RouteDataObjectAttribute.ROAD_SPEED) .evaluateFloat(road, getDefaultSpeed());
|
return getObjContext(RouteDataObjectAttribute.ROAD_SPEED).evaluateFloat(road, defaultSpeed) * defaultSpeedRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -400,7 +406,7 @@ public class GeneralRouter implements VehicleRouter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getDefaultSpeed() {
|
public float getDefaultSpeed() {
|
||||||
return defaultSpeed;
|
return defaultSpeed * defaultSpeedRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
89
OsmAnd/res/layout/default_speed_dialog.xml
Normal file
89
OsmAnd/res/layout/default_speed_dialog.xml
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/seekbar_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="@dimen/list_content_padding">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/text_input_lane"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="2"
|
||||||
|
android:paddingStart="@dimen/content_padding_small"
|
||||||
|
android:paddingLeft="@dimen/content_padding_small"
|
||||||
|
android:text="@string/shared_string_speed"
|
||||||
|
android:textColor="?attr/main_font_color_basic"
|
||||||
|
android:textSize="@dimen/default_list_text_size" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/speed_text"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="end"
|
||||||
|
android:maxLength="3"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingRight="4dp"
|
||||||
|
android:textColor="?attr/main_font_color_basic"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
tools:text="60" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/speed_units"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingEnd="@dimen/content_padding_small"
|
||||||
|
android:paddingRight="@dimen/content_padding_small"
|
||||||
|
android:textColor="?attr/dialog_text_description_color"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
tools:text="km/h" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/seekbar_lane"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingTop="24dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/seekbar_min_text"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="start"
|
||||||
|
android:paddingStart="@dimen/content_padding_small"
|
||||||
|
android:paddingLeft="@dimen/content_padding_small"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
tools:text="0" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/seekbar_max_text"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="end"
|
||||||
|
android:paddingEnd="@dimen/content_padding_small"
|
||||||
|
android:paddingRight="@dimen/content_padding_small"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
tools:text="100" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<SeekBar
|
||||||
|
|
||||||
|
android:id="@+id/speed_seekbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:max="100"
|
||||||
|
android:paddingBottom="@dimen/content_padding" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -11,13 +11,17 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="shared_string_speed">Speed</string>
|
||||||
|
<string name="default_speed_setting_title">Default speed</string>
|
||||||
|
<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="shared_string_crash">Crash</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="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>
|
<string name="press_again_to_change_the_map_orientation">Press again to change the map orientation</string>
|
||||||
<string name="process_downloading_service">OsmAnd downloading service</string>
|
<string name="process_downloading_service">OsmAnd downloading service</string>
|
||||||
<string name="shared_string_color_magenta">Magenta</string>
|
<string name="shared_string_color_magenta">Magenta</string>
|
||||||
<string name="shared_string_icon">Icon</string>
|
<string name="shared_string_icon">Icon</string>
|
||||||
<string name="app_profile_custom_nav_subtitle"></string>
|
|
||||||
<string name="rate_dialog_descr">Please give us 30 seconds, share feedback and rate our work on Google Play.</string>
|
<string name="rate_dialog_descr">Please give us 30 seconds, share feedback and rate our work on Google Play.</string>
|
||||||
<string name="button_rate">Rate</string>
|
<string name="button_rate">Rate</string>
|
||||||
<string name="shared_string_privacy_policy">Privacy Policy</string>
|
<string name="shared_string_privacy_policy">Privacy Policy</string>
|
||||||
|
|
|
@ -1012,6 +1012,9 @@ public class OsmandSettings {
|
||||||
public final OsmandPreference<Float> SPEED_LIMIT_EXCEED =
|
public final OsmandPreference<Float> SPEED_LIMIT_EXCEED =
|
||||||
new FloatPreference("speed_limit_exceed", 5f).makeProfile();
|
new FloatPreference("speed_limit_exceed", 5f).makeProfile();
|
||||||
|
|
||||||
|
public final OsmandPreference<Float> DEFAULT_SPEED = new FloatPreference(
|
||||||
|
"default_speed", 0f).makeProfile().cache();
|
||||||
|
|
||||||
public final OsmandPreference<Float> SWITCH_MAP_DIRECTION_TO_COMPASS =
|
public final OsmandPreference<Float> SWITCH_MAP_DIRECTION_TO_COMPASS =
|
||||||
new FloatPreference("speed_for_map_to_direction_of_movement", 0f).makeProfile();
|
new FloatPreference("speed_for_map_to_direction_of_movement", 0f).makeProfile();
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.activities;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.DialogInterface.OnClickListener;
|
||||||
import android.content.DialogInterface.OnMultiChoiceClickListener;
|
import android.content.DialogInterface.OnMultiChoiceClickListener;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
|
@ -19,12 +20,14 @@ import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.SeekBar;
|
||||||
|
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.PlatformUtil;
|
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.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.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.AutoZoomMap;
|
import net.osmand.plus.OsmandSettings.AutoZoomMap;
|
||||||
|
@ -39,6 +42,7 @@ import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper;
|
||||||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||||
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.RoutingParameter;
|
import net.osmand.router.GeneralRouter.RoutingParameter;
|
||||||
import net.osmand.router.GeneralRouter.RoutingParameterType;
|
import net.osmand.router.GeneralRouter.RoutingParameterType;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -47,7 +51,6 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
|
|
||||||
|
|
||||||
public class SettingsNavigationActivity extends SettingsBaseActivity {
|
public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
|
@ -59,6 +62,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
private Preference autoZoom;
|
private Preference autoZoom;
|
||||||
private Preference showAlarms;
|
private Preference showAlarms;
|
||||||
private Preference speakAlarms;
|
private Preference speakAlarms;
|
||||||
|
private Preference defaultSpeed;
|
||||||
private ListPreference routerServicePreference;
|
private ListPreference routerServicePreference;
|
||||||
private ListPreference speedLimitExceed;
|
private ListPreference speedLimitExceed;
|
||||||
|
|
||||||
|
@ -245,6 +249,15 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
GeneralRouter router = getRouter(getMyApplication().getRoutingConfig(), am);
|
GeneralRouter router = getRouter(getMyApplication().getRoutingConfig(), am);
|
||||||
clearParameters();
|
clearParameters();
|
||||||
if (router != null) {
|
if (router != null) {
|
||||||
|
GeneralRouterProfile routerProfile = router.getProfile();
|
||||||
|
if (routerProfile == GeneralRouterProfile.PEDESTRIAN || routerProfile == GeneralRouterProfile.BICYCLE || routerProfile == GeneralRouterProfile.BOAT) {
|
||||||
|
defaultSpeed = new Preference(this);
|
||||||
|
defaultSpeed.setTitle(R.string.default_speed_setting_title);
|
||||||
|
defaultSpeed.setSummary(R.string.default_speed_setting_descr);
|
||||||
|
defaultSpeed.setOnPreferenceClickListener(this);
|
||||||
|
cat.addPreference(defaultSpeed);
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, RoutingParameter> parameters = router.getParameters();
|
Map<String, RoutingParameter> parameters = router.getParameters();
|
||||||
if(parameters.containsKey(GeneralRouter.USE_SHORTEST_WAY)) {
|
if(parameters.containsKey(GeneralRouter.USE_SHORTEST_WAY)) {
|
||||||
cat.addPreference(fastRoute);
|
cat.addPreference(fastRoute);
|
||||||
|
@ -447,14 +460,14 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
};
|
};
|
||||||
|
|
||||||
final int[] selectedPosition = {selectedIndex};
|
final int[] selectedPosition = {selectedIndex};
|
||||||
builder.setSingleChoiceItems(listAdapter, selectedIndex, new DialogInterface.OnClickListener() {
|
builder.setSingleChoiceItems(listAdapter, selectedIndex, new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int position) {
|
public void onClick(DialogInterface dialog, int position) {
|
||||||
selectedPosition[0] = position;
|
selectedPosition[0] = position;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
builder.setTitle(R.string.auto_zoom_map)
|
builder.setTitle(R.string.auto_zoom_map)
|
||||||
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
@ -512,7 +525,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
};
|
};
|
||||||
|
|
||||||
final int[] selectedPosition = {selectedIndex};
|
final int[] selectedPosition = {selectedIndex};
|
||||||
builder.setSingleChoiceItems(listAdapter, selectedIndex, new DialogInterface.OnClickListener() {
|
builder.setSingleChoiceItems(listAdapter, selectedIndex, new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int position) {
|
public void onClick(DialogInterface dialog, int position) {
|
||||||
selectedPosition[0] = position;
|
selectedPosition[0] = position;
|
||||||
|
@ -520,7 +533,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
});
|
});
|
||||||
builder.setTitle(SettingsBaseActivity.getRoutingStringPropertyName(this, reliefFactorParameters.get(0).getGroup(),
|
builder.setTitle(SettingsBaseActivity.getRoutingStringPropertyName(this, reliefFactorParameters.get(0).getGroup(),
|
||||||
Algorithms.capitalizeFirstLetterAndLowercase(reliefFactorParameters.get(0).getGroup().replace('_', ' '))))
|
Algorithms.capitalizeFirstLetterAndLowercase(reliefFactorParameters.get(0).getGroup().replace('_', ' '))))
|
||||||
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
@ -583,6 +596,8 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
|
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
} else if (preference == defaultSpeed) {
|
||||||
|
showSeekbarSettingsDialog();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -590,7 +605,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
private void confirmSpeedCamerasDlg() {
|
private void confirmSpeedCamerasDlg() {
|
||||||
AlertDialog.Builder bld = new AlertDialog.Builder(this);
|
AlertDialog.Builder bld = new AlertDialog.Builder(this);
|
||||||
bld.setMessage(R.string.confirm_usage_speed_cameras);
|
bld.setMessage(R.string.confirm_usage_speed_cameras);
|
||||||
bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
bld.setPositiveButton(R.string.shared_string_yes, new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
@ -625,7 +640,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
|
|
||||||
bld.setNegativeButton(R.string.shared_string_cancel, null);
|
bld.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
|
|
||||||
bld.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
bld.setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
for (int i = 0; i < prefs.length; i++) {
|
for (int i = 0; i < prefs.length; i++) {
|
||||||
prefs[i].set(tempPrefs[i]);
|
prefs[i].set(tempPrefs[i]);
|
||||||
|
@ -636,5 +651,86 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
return bld.show();
|
return bld.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showSeekbarSettingsDialog() {
|
||||||
|
GeneralRouter router = getRouter(getMyApplication().getRoutingConfig(), settings.getApplicationMode());
|
||||||
|
SpeedConstants units = settings.SPEED_SYSTEM.get();
|
||||||
|
String speedUnits = units.toShortString(this);
|
||||||
|
final float[] ratio = new float[1];
|
||||||
|
switch (units) {
|
||||||
|
case MILES_PER_HOUR:
|
||||||
|
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_ONE_MILE;
|
||||||
|
break;
|
||||||
|
case KILOMETERS_PER_HOUR:
|
||||||
|
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_KILOMETER;
|
||||||
|
break;
|
||||||
|
case MINUTES_PER_KILOMETER:
|
||||||
|
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_KILOMETER;
|
||||||
|
speedUnits = getString(R.string.km_h);
|
||||||
|
break;
|
||||||
|
case NAUTICALMILES_PER_HOUR:
|
||||||
|
ratio[0] = 3600 / OsmAndFormatter.METERS_IN_ONE_NAUTICALMILE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
final int min = (int) (router.getMinSpeed() * ratio[0]);
|
||||||
|
final int[] def = new int[1];
|
||||||
|
final int max = Math.round(router.getMaxSpeed() * ratio[0]);
|
||||||
|
|
||||||
|
if (settings.DEFAULT_SPEED.get() > 0) {
|
||||||
|
def[0] = Math.round(settings.DEFAULT_SPEED.get() * ratio[0]);
|
||||||
|
} else {
|
||||||
|
def[0] = Math.round(router.getDefaultSpeed() * ratio[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle(R.string.default_speed_dialog_title);
|
||||||
|
builder.setMessage(R.string.default_speed_dialog_msg);
|
||||||
|
|
||||||
|
View seekbarView = getLayoutInflater().inflate(R.layout.default_speed_dialog, null);
|
||||||
|
builder.setView(seekbarView);
|
||||||
|
builder.setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
settings.DEFAULT_SPEED.set(def[0] / ratio[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
|
builder.setNeutralButton("Revert", new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
settings.DEFAULT_SPEED.set(0f);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final SeekBar seekBar = seekbarView.findViewById(R.id.speed_seekbar);
|
||||||
|
final TextView speedMinTv = seekbarView.findViewById(R.id.seekbar_min_text);
|
||||||
|
final TextView speedMaxTv = seekbarView.findViewById(R.id.seekbar_max_text);
|
||||||
|
final TextView speedUnitsTv = seekbarView.findViewById(R.id.speed_units);
|
||||||
|
final TextView speedTv = seekbarView.findViewById(R.id.speed_text);
|
||||||
|
|
||||||
|
speedMinTv.setText(String.valueOf(min));
|
||||||
|
speedMaxTv.setText(String.valueOf(max));
|
||||||
|
speedTv.setText(String.valueOf(def[0]));
|
||||||
|
speedUnitsTv.setText(speedUnits);
|
||||||
|
seekBar.setMax(max - min);
|
||||||
|
seekBar.setProgress(Math.max(def[0] - min, 0));
|
||||||
|
seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
|
def[0] = progress + min;
|
||||||
|
speedTv.setText(String.valueOf(progress + min));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AlertDialog dialog = builder.create();
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -698,6 +698,10 @@ public class RouteProvider {
|
||||||
paramsR.put(key, vl);
|
paramsR.put(key, vl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Float defaultSpeed = settings.DEFAULT_SPEED.getModeValue(params.mode);
|
||||||
|
if (defaultSpeed > 0) {
|
||||||
|
paramsR.put(GeneralRouter.DEFAULT_SPEED, String.valueOf(defaultSpeed));
|
||||||
|
}
|
||||||
if (params.inSnapToRoadMode) {
|
if (params.inSnapToRoadMode) {
|
||||||
paramsR.put(GeneralRouter.ALLOW_PRIVATE, "true");
|
paramsR.put(GeneralRouter.ALLOW_PRIVATE, "true");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue