Introduced mix/max speed adjustment
This commit is contained in:
parent
87b0180fb4
commit
d378fe9e5a
8 changed files with 356 additions and 130 deletions
|
@ -1,89 +1,224 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/seekbar_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/list_content_padding">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/text_input_lane"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
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" />
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/speed_text"
|
||||
android:layout_width="0dp"
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="@dimen/content_padding_small"
|
||||
android:paddingLeft="@dimen/content_padding_small"
|
||||
android:text="@string/minmax_speed_dialog_title"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
app:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_list_text_size_large" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/content_padding_half"
|
||||
android:paddingStart="@dimen/content_padding_small"
|
||||
android:paddingLeft="@dimen/content_padding_small"
|
||||
android:paddingBottom="@dimen/content_padding_half"
|
||||
android:text="@string/default_speed_dialog_msg"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/min_speed_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="@dimen/content_padding">
|
||||
|
||||
<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_min_speed"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/min_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="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="60" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/min_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="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="km/h" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/min_speed_seekbar_lane"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="@dimen/content_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/min_speed_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:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="0" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/min_speed_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:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="100" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/min_speed_seekbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:max="100"
|
||||
android:paddingBottom="@dimen/content_padding" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
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" />
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingBottom="@dimen/content_padding">
|
||||
|
||||
<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/max_speed_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/seekbar_lane"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="24dp">
|
||||
<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_max_speed"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
|
||||
<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/max_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="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="60" />
|
||||
|
||||
<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" />
|
||||
<TextView
|
||||
android:id="@+id/max_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="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="km/h" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/max_speed_seekbar_lane"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="@dimen/content_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/max_speed_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:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="0" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/max_speed_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:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="100" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/max_speed_seekbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:max="100"
|
||||
android:paddingBottom="@dimen/content_padding" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</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>
|
||||
</ScrollView>
|
|
@ -11,10 +11,11 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="shared_string_speed">Speed</string>
|
||||
<string name="shared_string_min_speed">Min. speed</string>
|
||||
<string name="shared_string_max_speed">Max. 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="minmax_speed_dialog_title">Set min/max speed</string>
|
||||
<string name="default_speed_dialog_msg">Used for calculations of expected arrival time during routing</string>
|
||||
<string name="new_profile">New Profile</string>
|
||||
<string name="shared_string_crash">Crash</string>
|
||||
|
|
|
@ -1,34 +1,51 @@
|
|||
package net.osmand.plus;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.StringRes;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.sf.junidecode.App;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.*;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_ALTITUDE;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_BATTERY;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_BEARING;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_COMPASS;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_DISTANCE;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_GPS_INFO;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_INTERMEDIATE_DISTANCE;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_INTERMEDIATE_TIME;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_MARKER_1;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_MARKER_2;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_MAX_SPEED;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_NEXT_NEXT_TURN;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_NEXT_TURN;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_NEXT_TURN_SMALL;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_PLAIN_TIME;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_RULER;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_SPEED;
|
||||
import static net.osmand.plus.views.mapwidgets.MapWidgetRegistry.WIDGET_TIME;
|
||||
|
||||
public class ApplicationMode {
|
||||
|
||||
|
@ -57,6 +74,7 @@ public class ApplicationMode {
|
|||
|
||||
|
||||
private float defaultSpeed = 10f;
|
||||
private float initialDefaultSpeed = defaultSpeed;
|
||||
private int minDistanceForTurn = 50;
|
||||
private int arrivalDistance = 90;
|
||||
private int offRouteDistance = 350;
|
||||
|
@ -81,25 +99,25 @@ public class ApplicationMode {
|
|||
public static final ApplicationMode DEFAULT = createBase( R.string.app_mode_default, "default").speed(1.5f, 5).arrivalDistance(90).defLocation().
|
||||
icon(R.drawable.ic_world_globe_dark, "map_world_globe_dark").reg();
|
||||
|
||||
public static final ApplicationMode CAR = createBase( R.string.app_mode_car, "car").speed(15.3f, 35).carLocation().
|
||||
public static final ApplicationMode CAR = createBase( R.string.app_mode_car, "car").speed(12.5f, 35).carLocation().
|
||||
icon(R.drawable.ic_action_car_dark, "ic_action_car_dark").setRoutingProfile("car").reg();
|
||||
|
||||
public static final ApplicationMode BICYCLE = createBase( R.string.app_mode_bicycle, "bicycle").speed(5.5f, 15).arrivalDistance(60).offRouteDistance(50).bicycleLocation().
|
||||
public static final ApplicationMode BICYCLE = createBase( R.string.app_mode_bicycle, "bicycle").speed(2.77f, 15).arrivalDistance(60).offRouteDistance(50).bicycleLocation().
|
||||
icon(R.drawable.ic_action_bicycle_dark, "ic_action_bicycle_dark").setRoutingProfile("bicycle").reg();
|
||||
|
||||
public static final ApplicationMode PEDESTRIAN = createBase( R.string.app_mode_pedestrian, "pedestrian").speed(1.5f, 5).arrivalDistance(45).offRouteDistance(20).
|
||||
public static final ApplicationMode PEDESTRIAN = createBase( R.string.app_mode_pedestrian, "pedestrian").speed(1.11f, 5).arrivalDistance(45).offRouteDistance(20).
|
||||
icon(R.drawable.ic_action_pedestrian_dark, "ic_action_pedestrian_dark").setRoutingProfile("pedestrian").reg();
|
||||
|
||||
public static final ApplicationMode PUBLIC_TRANSPORT = createBase( R.string.app_mode_public_transport, "public_transport").
|
||||
icon(R.drawable.ic_action_bus_dark, "ic_action_bus_dark").setRoutingProfile("public_transport").reg();
|
||||
|
||||
public static final ApplicationMode BOAT = createBase( R.string.app_mode_boat, "boat").speed(5.5f, 20).nauticalLocation().
|
||||
public static final ApplicationMode BOAT = createBase( R.string.app_mode_boat, "boat").speed(1.38f, 20).nauticalLocation().
|
||||
icon(R.drawable.ic_action_sail_boat_dark, "ic_action_sail_boat_dark").setRoutingProfile("boat").reg();
|
||||
|
||||
public static final ApplicationMode AIRCRAFT = createBase( R.string.app_mode_aircraft, "aircraft").speed(40f, 100).carLocation().
|
||||
icon(R.drawable.ic_action_aircraft, "ic_action_aircraft").setRouteService(RouteService.STRAIGHT).setRoutingProfile("STRAIGHT_LINE_MODE").reg();
|
||||
|
||||
public static final ApplicationMode SKI = createBase( R.string.app_mode_skiing, "ski").speed(5.5f, 15).arrivalDistance(60).offRouteDistance(50).bicycleLocation().
|
||||
public static final ApplicationMode SKI = createBase( R.string.app_mode_skiing, "ski").speed(1.38f, 15).arrivalDistance(60).offRouteDistance(50).bicycleLocation().
|
||||
icon(R.drawable.ic_plugin_skimaps, "ic_plugin_skimaps").setRoutingProfile("ski").reg();
|
||||
|
||||
|
||||
|
@ -136,9 +154,9 @@ public class ApplicationMode {
|
|||
regWidgetVisibility(WIDGET_DISTANCE, all);
|
||||
regWidgetVisibility(WIDGET_TIME, all);
|
||||
regWidgetVisibility(WIDGET_INTERMEDIATE_TIME, all);
|
||||
regWidgetVisibility(WIDGET_SPEED, new ApplicationMode[]{CAR, BICYCLE, BOAT, SKI, PUBLIC_TRANSPORT, AIRCRAFT} );
|
||||
regWidgetVisibility(WIDGET_SPEED, CAR, BICYCLE, BOAT, SKI, PUBLIC_TRANSPORT, AIRCRAFT);
|
||||
regWidgetVisibility(WIDGET_MAX_SPEED, CAR);
|
||||
regWidgetVisibility(WIDGET_ALTITUDE, new ApplicationMode[] {PEDESTRIAN, BICYCLE});
|
||||
regWidgetVisibility(WIDGET_ALTITUDE, PEDESTRIAN, BICYCLE);
|
||||
regWidgetAvailability(WIDGET_INTERMEDIATE_DISTANCE, all);
|
||||
regWidgetAvailability(WIDGET_DISTANCE, all);
|
||||
regWidgetAvailability(WIDGET_TIME, all);
|
||||
|
@ -177,6 +195,7 @@ public class ApplicationMode {
|
|||
private ApplicationMode customReg() {
|
||||
ApplicationMode m = applicationMode;
|
||||
m.defaultSpeed = m.parentAppMode.defaultSpeed;
|
||||
m.initialDefaultSpeed = m.parentAppMode.initialDefaultSpeed;
|
||||
m.minDistanceForTurn = m.parentAppMode.minDistanceForTurn;
|
||||
m.arrivalDistance = m.parentAppMode.arrivalDistance;
|
||||
m.offRouteDistance = m.parentAppMode.offRouteDistance;
|
||||
|
@ -222,7 +241,6 @@ public class ApplicationMode {
|
|||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ApplicationModeBuilder carLocation() {
|
||||
applicationMode.bearingIconDay = R.drawable.map_car_bearing;
|
||||
applicationMode.bearingIconNight = R.drawable.map_car_bearing_night;
|
||||
|
@ -271,6 +289,7 @@ public class ApplicationMode {
|
|||
|
||||
public ApplicationModeBuilder speed(float defSpeed, int distForTurn) {
|
||||
applicationMode.defaultSpeed = defSpeed;
|
||||
applicationMode.initialDefaultSpeed = defSpeed;
|
||||
applicationMode.minDistanceForTurn = distForTurn;
|
||||
return this;
|
||||
}
|
||||
|
@ -522,6 +541,17 @@ public class ApplicationMode {
|
|||
return defaultSpeed;
|
||||
}
|
||||
|
||||
public void setDefaultSpeed(OsmandApplication app, float defaultSpeed) {
|
||||
this.defaultSpeed = defaultSpeed;
|
||||
app.getSettings().DEFAULT_SPEED.set(defaultSpeed);
|
||||
|
||||
}
|
||||
|
||||
public void resetDefaultSpeed(OsmandApplication app) {
|
||||
this.defaultSpeed = initialDefaultSpeed;
|
||||
app.getSettings().DEFAULT_SPEED.setModeValue(this, 0f);
|
||||
}
|
||||
|
||||
public int getMinDistanceForTurn() {
|
||||
return minDistanceForTurn;
|
||||
}
|
||||
|
|
|
@ -1015,6 +1015,12 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<Float> DEFAULT_SPEED = new FloatPreference(
|
||||
"default_speed", 0f).makeProfile().cache();
|
||||
|
||||
public final OsmandPreference<Float> MIN_SPEED = new FloatPreference(
|
||||
"min_speed", 0f).makeProfile().cache();
|
||||
|
||||
public final OsmandPreference<Float> MAX_SPEED = new FloatPreference(
|
||||
"max_speed", 0f).makeProfile().cache();
|
||||
|
||||
public final OsmandPreference<Float> SWITCH_MAP_DIRECTION_TO_COMPASS =
|
||||
new FloatPreference("speed_for_map_to_direction_of_movement", 0f).makeProfile();
|
||||
|
||||
|
|
|
@ -31,14 +31,14 @@ import net.osmand.plus.profiles.AppProfileArrayAdapter;
|
|||
import net.osmand.plus.profiles.ProfileDataObject;
|
||||
import net.osmand.plus.views.SeekBarPreference;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import net.osmand.util.Algorithms;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
|
||||
public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
||||
|
@ -374,7 +374,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
|
|||
}
|
||||
|
||||
final AppProfileArrayAdapter modeNames = new AppProfileArrayAdapter(
|
||||
SettingsBaseActivity.this, R.layout.bottom_sheet_item_with_descr_and_radio_btn, activeModes);
|
||||
SettingsBaseActivity.this, R.layout.bottom_sheet_item_with_descr_and_radio_btn, activeModes, isModeSelected);
|
||||
|
||||
singleSelectDialogBuilder.setNegativeButton(R.string.shared_string_cancel,
|
||||
new OnClickListener() {
|
||||
|
|
|
@ -17,6 +17,8 @@ import android.preference.PreferenceScreen;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
@ -250,7 +252,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
clearParameters();
|
||||
if (router != null) {
|
||||
GeneralRouterProfile routerProfile = router.getProfile();
|
||||
if (routerProfile == GeneralRouterProfile.PEDESTRIAN || routerProfile == GeneralRouterProfile.BICYCLE || routerProfile == GeneralRouterProfile.BOAT) {
|
||||
if (routerProfile != GeneralRouterProfile.PUBLIC_TRANSPORT) {
|
||||
defaultSpeed = new Preference(this);
|
||||
defaultSpeed.setTitle(R.string.default_speed_setting_title);
|
||||
defaultSpeed.setSummary(R.string.default_speed_setting_descr);
|
||||
|
@ -652,7 +654,8 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
}
|
||||
|
||||
private void showSeekbarSettingsDialog() {
|
||||
GeneralRouter router = getRouter(getMyApplication().getRoutingConfig(), settings.getApplicationMode());
|
||||
final ApplicationMode mode = settings.getApplicationMode();
|
||||
GeneralRouter router = getRouter(getMyApplication().getRoutingConfig(), mode);
|
||||
SpeedConstants units = settings.SPEED_SYSTEM.get();
|
||||
String speedUnits = units.toShortString(this);
|
||||
final float[] ratio = new float[1];
|
||||
|
@ -672,53 +675,59 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
break;
|
||||
}
|
||||
|
||||
final int min = (int) (router.getMinSpeed() * ratio[0]);
|
||||
final int[] def = new int[1];
|
||||
final int max = Math.round(router.getMaxSpeed() * ratio[0]);
|
||||
float settingsMinSpeed = settings.MIN_SPEED.get();
|
||||
float settingsMaxSpeed = settings.MAX_SPEED.get();
|
||||
|
||||
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]);
|
||||
}
|
||||
final int min = (int) ((settingsMinSpeed > 0 ? settingsMinSpeed : router.getMinSpeed()) * ratio[0]);
|
||||
final int[] defaultValue = { Math.round(mode.getDefaultSpeed() * ratio[0]) };
|
||||
final int[] maxValue = { Math.round((settingsMaxSpeed > 0 ? settingsMaxSpeed : router.getMaxSpeed()) * ratio[0]) };
|
||||
final int max = Math.round(router.getMaxSpeed() * ratio[0] * 1.5f);
|
||||
|
||||
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);
|
||||
boolean lightMode = getMyApplication().getSettings().isLightContent();
|
||||
int themeRes = lightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
||||
View seekbarView = LayoutInflater.from(new ContextThemeWrapper(this, themeRes))
|
||||
.inflate(R.layout.default_speed_dialog, null, false);
|
||||
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]);
|
||||
mode.setDefaultSpeed(getMyApplication(), defaultValue[0] / ratio[0]);
|
||||
settings.MAX_SPEED.set(maxValue[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);
|
||||
mode.resetDefaultSpeed(getMyApplication());
|
||||
settings.MIN_SPEED.set(0f);
|
||||
settings.MAX_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);
|
||||
final SeekBar minSpeedSeekBar = seekbarView.findViewById(R.id.min_speed_seekbar);
|
||||
final TextView minSpeedMinTv = seekbarView.findViewById(R.id.min_speed_seekbar_min_text);
|
||||
final TextView minSpeedMaxTv = seekbarView.findViewById(R.id.min_speed_seekbar_max_text);
|
||||
final TextView minSpeedUnitsTv = seekbarView.findViewById(R.id.min_speed_units);
|
||||
final TextView minSpeedTv = seekbarView.findViewById(R.id.min_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() {
|
||||
minSpeedMinTv.setText(String.valueOf(min));
|
||||
minSpeedMaxTv.setText(String.valueOf(max));
|
||||
minSpeedTv.setText(String.valueOf(defaultValue[0]));
|
||||
minSpeedUnitsTv.setText(speedUnits);
|
||||
minSpeedSeekBar.setMax(max - min);
|
||||
minSpeedSeekBar.setProgress(Math.max(defaultValue[0] - min, 0));
|
||||
minSpeedSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
def[0] = progress + min;
|
||||
speedTv.setText(String.valueOf(progress + min));
|
||||
int value = progress + min;
|
||||
if (value > maxValue[0]) {
|
||||
value = maxValue[0];
|
||||
minSpeedSeekBar.setProgress(Math.max(value - min, 0));
|
||||
}
|
||||
defaultValue[0] = value;
|
||||
minSpeedTv.setText(String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -730,7 +739,40 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
}
|
||||
});
|
||||
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
final SeekBar maxSpeedSeekBar = seekbarView.findViewById(R.id.max_speed_seekbar);
|
||||
final TextView maxSpeedMinTv = seekbarView.findViewById(R.id.max_speed_seekbar_min_text);
|
||||
final TextView maxSpeedMaxTv = seekbarView.findViewById(R.id.max_speed_seekbar_max_text);
|
||||
final TextView maxSpeedUnitsTv = seekbarView.findViewById(R.id.max_speed_units);
|
||||
final TextView maxSpeedTv = seekbarView.findViewById(R.id.max_speed_text);
|
||||
|
||||
maxSpeedMinTv.setText(String.valueOf(min));
|
||||
maxSpeedMaxTv.setText(String.valueOf(max));
|
||||
maxSpeedTv.setText(String.valueOf(maxValue[0]));
|
||||
maxSpeedUnitsTv.setText(speedUnits);
|
||||
maxSpeedSeekBar.setMax(max - min);
|
||||
maxSpeedSeekBar.setProgress(Math.max(maxValue[0] - min, 0));
|
||||
maxSpeedSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
int value = progress + min;
|
||||
if (value < defaultValue[0]) {
|
||||
value = defaultValue[0];
|
||||
maxSpeedSeekBar.setProgress(Math.max(value - min, 0));
|
||||
}
|
||||
maxValue[0] = value;
|
||||
maxSpeedTv.setText(String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
builder.show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,13 +22,15 @@ public class AppProfileArrayAdapter extends ArrayAdapter<ProfileDataObject> {
|
|||
private List<ProfileDataObject> modes;
|
||||
private int layout;
|
||||
private OsmandApplication app;
|
||||
private boolean isModeSelected;
|
||||
|
||||
public AppProfileArrayAdapter(@NonNull Activity context, int resource, @NonNull List<ProfileDataObject> objects) {
|
||||
public AppProfileArrayAdapter(@NonNull Activity context, int resource, @NonNull List<ProfileDataObject> objects, boolean isModeSelected) {
|
||||
super(context, resource, objects);
|
||||
this.context = context;
|
||||
this.modes = objects;
|
||||
this.layout = resource;
|
||||
app = (OsmandApplication) context.getApplication();
|
||||
this.app = (OsmandApplication) context.getApplication();
|
||||
this.isModeSelected = isModeSelected;
|
||||
}
|
||||
|
||||
public long getItemId(int position) {
|
||||
|
@ -71,7 +73,11 @@ public class AppProfileArrayAdapter extends ArrayAdapter<ProfileDataObject> {
|
|||
viewHolder.title.setText(mode.getName());
|
||||
viewHolder.description.setText(mode.getDescription());
|
||||
viewHolder.icon.setImageDrawable(iconDrawable);
|
||||
viewHolder.compoundButton.setChecked(mode.isSelected());
|
||||
if (isModeSelected) {
|
||||
viewHolder.compoundButton.setChecked(mode.isSelected());
|
||||
} else {
|
||||
viewHolder.compoundButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
return rowView;
|
||||
}
|
||||
|
|
|
@ -700,9 +700,15 @@ public class RouteProvider {
|
|||
if (defaultSpeed > 0) {
|
||||
paramsR.put(GeneralRouter.DEFAULT_SPEED, String.valueOf(defaultSpeed));
|
||||
}
|
||||
if (params.inSnapToRoadMode) {
|
||||
paramsR.put(GeneralRouter.ALLOW_PRIVATE, "true");
|
||||
Float minSpeed = settings.MIN_SPEED.getModeValue(params.mode);
|
||||
if (minSpeed > 0) {
|
||||
paramsR.put(GeneralRouter.MIN_SPEED, String.valueOf(minSpeed));
|
||||
}
|
||||
Float maxSpeed = settings.MAX_SPEED.getModeValue(params.mode);
|
||||
if (maxSpeed > 0) {
|
||||
paramsR.put(GeneralRouter.MAX_SPEED, String.valueOf(maxSpeed));
|
||||
}
|
||||
|
||||
float mb = (1 << 20);
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
// make visible
|
||||
|
|
Loading…
Reference in a new issue