commit
13d47b2ed5
8 changed files with 258 additions and 12 deletions
129
OsmAnd/res/layout/recalculation_angle_dialog.xml
Normal file
129
OsmAnd/res/layout/recalculation_angle_dialog.xml
Normal file
|
@ -0,0 +1,129 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/content_padding"
|
||||
android:paddingRight="@dimen/content_padding"
|
||||
android:paddingTop="@dimen/content_padding"
|
||||
android:paddingBottom="@dimen/content_padding_half">
|
||||
|
||||
<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/recalc_angle_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"
|
||||
android:text="@string/recalc_angle_dialog_descr"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/angle_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/angle_title"
|
||||
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:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="@string/shared_string_angle" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/angle_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="end"
|
||||
android:maxLength="4"
|
||||
android:maxLines="1"
|
||||
android:paddingRight="4dp"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="60" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/angle_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="°" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/angle_seekbar_lane"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="@dimen/content_padding">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/angle_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"
|
||||
android:text="0°" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/angle_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"
|
||||
android:text="90°" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/angle_seekbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:max="90"
|
||||
android:paddingBottom="@dimen/content_padding" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
|
@ -11,6 +11,10 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="shared_string_angle_param">Angle: %s°</string>
|
||||
<string name="shared_string_angle">Angle</string>
|
||||
<string name="recalc_angle_dialog_descr">Extra straight segment between my location and calculated route will be displayed until the route is recalculated</string>
|
||||
<string name="recalc_angle_dialog_title">Minimum angle between my location and route</string>
|
||||
<string name="navigation_notification_desc">Show system notification while navigation with navigation instructions.</string>
|
||||
<string name="navigation_notification">Navigation notification</string>
|
||||
<string name="shared_string_app_default_w_val">App Default (%s)</string>
|
||||
|
|
|
@ -420,6 +420,14 @@ public class ApplicationMode {
|
|||
app.getSettings().MAX_SPEED.setModeValue(this, defaultSpeed);
|
||||
}
|
||||
|
||||
public float getStrAngle() {
|
||||
return app.getSettings().ROUTE_STRAIGHT_ANGLE.getModeValue(this);
|
||||
}
|
||||
|
||||
public void setStrAngle(float angle) {
|
||||
app.getSettings().ROUTE_STRAIGHT_ANGLE.setModeValue(this, angle);
|
||||
}
|
||||
|
||||
public String getUserProfileName() {
|
||||
return app.getSettings().USER_PROFILE_NAME.getModeValue(this);
|
||||
}
|
||||
|
|
|
@ -430,7 +430,13 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
|
||||
boolean osmandRouter = applicationMode.getRouteService() == RouteProvider.RouteService.OSMAND;
|
||||
if (!osmandRouter) {
|
||||
routingParameters = AppModeOptions.OTHER.routingParameters;
|
||||
if (applicationMode.getRouteService() == RouteProvider.RouteService.STRAIGHT) {
|
||||
routingParameters = AppModeOptions.STRAIGHT.routingParameters;
|
||||
} else if (applicationMode.getRouteService() == RouteProvider.RouteService.DIRECT_TO) {
|
||||
routingParameters = AppModeOptions.DIRECT_TO.routingParameters;
|
||||
} else {
|
||||
routingParameters = AppModeOptions.OTHER.routingParameters;
|
||||
}
|
||||
} else if (applicationMode.isDerivedRoutingFrom(ApplicationMode.CAR)) {
|
||||
routingParameters = AppModeOptions.CAR.routingParameters;
|
||||
} else if (applicationMode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
|
||||
|
@ -579,6 +585,22 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
DividerItem.KEY,
|
||||
GpxLocalRoutingParameter.KEY,
|
||||
OtherSettingsRoutingParameter.KEY,
|
||||
RouteSimulationItem.KEY),
|
||||
|
||||
STRAIGHT(MuteSoundRoutingParameter.KEY,
|
||||
DividerItem.KEY,
|
||||
ShowAlongTheRouteItem.KEY,
|
||||
DividerItem.KEY,
|
||||
GpxLocalRoutingParameter.KEY,
|
||||
OtherSettingsRoutingParameter.KEY,
|
||||
RouteSimulationItem.KEY),
|
||||
|
||||
DIRECT_TO(MuteSoundRoutingParameter.KEY,
|
||||
DividerItem.KEY,
|
||||
ShowAlongTheRouteItem.KEY,
|
||||
DividerItem.KEY,
|
||||
GpxLocalRoutingParameter.KEY,
|
||||
OtherSettingsRoutingParameter.KEY,
|
||||
RouteSimulationItem.KEY);
|
||||
|
||||
|
||||
|
|
|
@ -1240,7 +1240,6 @@ public class RouteProvider {
|
|||
}
|
||||
|
||||
private RouteCalculationResult findStraightRoute(RouteCalculationParams params) {
|
||||
Location currentLocation = params.currentLocation;
|
||||
LinkedList<Location> points = new LinkedList<>();
|
||||
List<Location> segments = new ArrayList<>();
|
||||
points.add(params.start);
|
||||
|
|
|
@ -430,7 +430,6 @@ public class RoutingHelper {
|
|||
// 0. Route empty or needs to be extended? Then re-calculate route.
|
||||
if(route.isEmpty()) {
|
||||
calculateRoute = true;
|
||||
//originalRoute = null;
|
||||
} else {
|
||||
// 1. Update current route position status according to latest received location
|
||||
boolean finished = updateCurrentRouteStatus(currentLocation, posTolerance);
|
||||
|
|
|
@ -1,14 +1,23 @@
|
|||
package net.osmand.plus.settings;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.support.v7.preference.PreferenceViewHolder;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
|
@ -17,6 +26,7 @@ import net.osmand.plus.OsmandApplication;
|
|||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.BooleanPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||
import net.osmand.plus.activities.SettingsNavigationActivity;
|
||||
import net.osmand.plus.routing.RouteProvider;
|
||||
|
@ -83,7 +93,6 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
routeParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString()));
|
||||
|
||||
setupRoutingPrefs();
|
||||
setupTimeConditionalRoutingPref();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -131,21 +140,19 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
}
|
||||
PreferenceScreen screen = getPreferenceScreen();
|
||||
|
||||
ApplicationMode am = getSelectedAppMode();
|
||||
|
||||
SwitchPreferenceEx fastRoute = createSwitchPreferenceEx(app.getSettings().FAST_ROUTE_MODE.getId(), R.string.fast_route_mode, R.layout.preference_with_descr_dialog_and_switch);
|
||||
fastRoute.setIcon(getRoutingPrefIcon(app.getSettings().FAST_ROUTE_MODE.getId()));
|
||||
fastRoute.setDescription(getString(R.string.fast_route_mode_descr));
|
||||
fastRoute.setSummaryOn(R.string.shared_string_on);
|
||||
fastRoute.setSummaryOff(R.string.shared_string_off);
|
||||
|
||||
|
||||
ApplicationMode am = getSelectedAppMode();
|
||||
float defaultAllowedDeviation = RoutingHelper.getDefaultAllowedDeviation(settings, am,
|
||||
RoutingHelper.getPosTolerance(0));
|
||||
if (am.getRouteService() != RouteProvider.RouteService.OSMAND) {
|
||||
screen.addPreference(fastRoute);
|
||||
setupSelectRouteRecalcDistance(screen, defaultAllowedDeviation);
|
||||
} else {
|
||||
setupSelectRouteRecalcDistance(screen, defaultAllowedDeviation);
|
||||
setupSelectRouteRecalcDistance(screen, defaultAllowedDeviation);
|
||||
|
||||
if (am.getRouteService() == RouteProvider.RouteService.OSMAND){
|
||||
GeneralRouter router = app.getRouter(am);
|
||||
clearParameters();
|
||||
if (router != null) {
|
||||
|
@ -231,9 +238,87 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
|||
}
|
||||
}
|
||||
}
|
||||
setupTimeConditionalRoutingPref();
|
||||
} else if (am.getRouteService() == RouteProvider.RouteService.BROUTER) {
|
||||
screen.addPreference(fastRoute);
|
||||
setupTimeConditionalRoutingPref();
|
||||
} else if (am.getRouteService() == RouteProvider.RouteService.STRAIGHT) {
|
||||
Preference straightAngle = new Preference(app.getApplicationContext());
|
||||
straightAngle.setPersistent(false);
|
||||
straightAngle.setKey(settings.ROUTE_STRAIGHT_ANGLE.getId());
|
||||
straightAngle.setTitle(getString(R.string.recalc_angle_dialog_title));
|
||||
straightAngle.setSummary(String.format(getString(R.string.shared_string_angle_param), (int) am.getStrAngle()));
|
||||
straightAngle.setLayoutResource(R.layout.preference_with_descr);
|
||||
straightAngle.setIcon(getRoutingPrefIcon("routing_recalc_distance")); //TODO change for appropriate icon when available
|
||||
getPreferenceScreen().addPreference(straightAngle);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
if (preference.getKey().equals(settings.ROUTE_STRAIGHT_ANGLE.getId())) {
|
||||
showSeekbarSettingsDialog(getActivity(), getSelectedAppMode());
|
||||
}
|
||||
return super.onPreferenceClick(preference);
|
||||
}
|
||||
|
||||
private void showSeekbarSettingsDialog(Activity activity, final ApplicationMode mode) {
|
||||
if (activity == null || mode == null) {
|
||||
return;
|
||||
}
|
||||
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
final float[] angleValue = new float[] {mode.getStrAngle()};
|
||||
boolean nightMode = !app.getSettings().isLightContentForMode(mode);
|
||||
Context themedContext = UiUtilities.getThemedContext(activity, nightMode);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(themedContext);
|
||||
View seekbarView = LayoutInflater.from(themedContext).inflate(R.layout.recalculation_angle_dialog, null, false);
|
||||
builder.setView(seekbarView);
|
||||
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mode.setStrAngle(angleValue[0]);
|
||||
updateAllSettings();
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (mode.equals(routingHelper.getAppMode()) && (routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated())) {
|
||||
routingHelper.recalculateRouteDueToSettingsChange();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
|
||||
int selectedModeColor = ContextCompat.getColor(app, mode.getIconColorInfo().getColor(nightMode));
|
||||
setupAngleSlider(angleValue, seekbarView, nightMode, selectedModeColor);
|
||||
builder.show();
|
||||
}
|
||||
|
||||
private static void setupAngleSlider(final float[] angleValue,
|
||||
View seekbarView,
|
||||
final boolean nightMode,
|
||||
final int activeColor) {
|
||||
|
||||
final SeekBar angleBar = seekbarView.findViewById(R.id.angle_seekbar);
|
||||
final TextView angleTv = seekbarView.findViewById(R.id.angle_text);
|
||||
|
||||
angleTv.setText(String.valueOf(angleValue[0]));
|
||||
angleBar.setProgress((int) angleValue[0]);
|
||||
angleBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
int value = progress - (progress % 5);
|
||||
angleValue[0] = value;
|
||||
angleTv.setText(String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {}
|
||||
});
|
||||
UiUtilities.setupSeekBar(angleBar, activeColor, nightMode);
|
||||
}
|
||||
|
||||
private void setupSelectRouteRecalcDistance(PreferenceScreen screen, float defaultAllowedDeviation) {
|
||||
Float[] entryValues;
|
||||
OsmandSettings settings = app.getSettings();
|
||||
|
|
|
@ -319,7 +319,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
|||
|
||||
private void drawProjectionPoint(Canvas canvas, double[] projectionXY) {
|
||||
if (projectionIcon == null) {
|
||||
projectionIcon = (LayerDrawable) view.getResources().getDrawable(helper.getSettings().getApplicationMode().getLocationIcon().getIconId());
|
||||
projectionIcon = (LayerDrawable) view.getResources().getDrawable(helper.getSettings().getApplicationMode().getLocationIcon().DEFAULT.getIconId());
|
||||
}
|
||||
int locationX = (int) projectionXY[0];
|
||||
int locationY = (int) projectionXY[1];
|
||||
|
|
Loading…
Reference in a new issue