Add route toolbar options
This commit is contained in:
parent
aa1e2f8738
commit
d008958585
6 changed files with 760 additions and 180 deletions
|
@ -406,79 +406,47 @@
|
||||||
tools:background="@color/dashboard_divider_dark" />
|
tools:background="@color/dashboard_divider_dark" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
android:id="@+id/map_route_options"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/list_item_height">
|
android:layout_height="@dimen/list_item_height">
|
||||||
|
|
||||||
<LinearLayout
|
<HorizontalScrollView
|
||||||
android:id="@+id/map_route_options"
|
android:id="@+id/route_options_scroll_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="bottom">
|
android:layout_gravity="start"
|
||||||
|
android:paddingBottom="@dimen/bottom_sheet_content_margin_small"
|
||||||
|
android:paddingTop="@dimen/bottom_sheet_content_margin_small">
|
||||||
|
|
||||||
<FrameLayout
|
<LinearLayout
|
||||||
android:id="@+id/sound_setting_button"
|
android:id="@+id/route_options_container"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="@dimen/route_info_settings_buttons_height"
|
|
||||||
android:layout_marginBottom="@dimen/bottom_sheet_content_margin_small"
|
|
||||||
android:layout_marginLeft="@dimen/bottom_sheet_content_margin_small"
|
|
||||||
android:layout_marginRight="@dimen/bottom_sheet_content_margin_small"
|
|
||||||
android:layout_marginTop="@dimen/bottom_sheet_content_margin_small"
|
|
||||||
tools:background="@drawable/btn_border_trans_light"
|
|
||||||
tools:foreground="@drawable/ripple_light">
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
|
||||||
android:id="@+id/sound_setting_button_descr"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:drawablePadding="@dimen/content_padding_small"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:gravity="center"
|
|
||||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:paddingBottom="3dp"
|
|
||||||
android:paddingEnd="4dp"
|
|
||||||
android:paddingLeft="3dp"
|
|
||||||
android:paddingRight="4dp"
|
|
||||||
android:paddingStart="3dp"
|
|
||||||
android:paddingTop="3dp"
|
|
||||||
android:textSize="@dimen/text_button_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:background="@drawable/btn_border_trans_dark"
|
|
||||||
tools:drawableLeft="@drawable/ic_action_volume_up"
|
|
||||||
tools:drawableStart="@drawable/ic_action_volume_up"
|
|
||||||
tools:ignore="UnusedAttribute"
|
|
||||||
tools:text="@string/menu_mute_on"
|
|
||||||
tools:textColor="?attr/wikivoyage_active_color" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/old_options"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:background="?attr/selectableItemBackground" />
|
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
|
||||||
android:id="@+id/map_options_route_button"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:gravity="start"
|
||||||
android:drawablePadding="@dimen/content_padding_small"
|
android:orientation="horizontal">
|
||||||
android:ellipsize="end"
|
|
||||||
android:gravity="center"
|
|
||||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:paddingLeft="@dimen/route_info_buttons_padding_top_bottom"
|
|
||||||
android:paddingRight="@dimen/route_info_buttons_padding_top_bottom"
|
|
||||||
android:text="@string/shared_string_options"
|
|
||||||
android:textSize="@dimen/text_button_text_size"
|
|
||||||
osmand:typeface="@string/font_roboto_medium"
|
|
||||||
tools:ignore="UnusedAttribute"
|
|
||||||
tools:textColor="?attr/wikivoyage_active_color" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</HorizontalScrollView>
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/map_options_route_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:drawablePadding="@dimen/content_padding_small"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingLeft="@dimen/route_info_buttons_padding_top_bottom"
|
||||||
|
android:paddingRight="@dimen/route_info_buttons_padding_top_bottom"
|
||||||
|
android:text="@string/shared_string_options"
|
||||||
|
android:textSize="@dimen/text_button_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:ignore="UnusedAttribute"
|
||||||
|
tools:textColor="?attr/wikivoyage_active_color" />
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progress_bar"
|
android:id="@+id/progress_bar"
|
||||||
|
|
61
OsmAnd/res/layout/route_option_btn.xml
Normal file
61
OsmAnd/res/layout/route_option_btn.xml
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/route_option_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/route_info_settings_buttons_height"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/route_option_container"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:visibility="visible"
|
||||||
|
tools:background="@drawable/btn_border_trans_dark">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/route_option_image_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingBottom="@dimen/route_info_icon_vertical_padding"
|
||||||
|
android:paddingLeft="@dimen/route_info_icon_vertical_padding"
|
||||||
|
android:paddingRight="@dimen/route_info_icon_vertical_padding"
|
||||||
|
android:paddingTop="@dimen/route_info_icon_vertical_padding"
|
||||||
|
android:src="@drawable/ic_action_edit_dark"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/route_option_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingBottom="3dp"
|
||||||
|
android:paddingEnd="4dp"
|
||||||
|
android:paddingLeft="3dp"
|
||||||
|
android:paddingRight="4dp"
|
||||||
|
android:paddingStart="3dp"
|
||||||
|
android:paddingTop="3dp"
|
||||||
|
android:text="@string/routing_attr_avoid_motorway_name"
|
||||||
|
android:textSize="@dimen/text_button_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:ignore="UnusedAttribute"
|
||||||
|
tools:textColor="?attr/wikivoyage_active_color" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/avoid_route_options_container"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:visibility="visible"
|
||||||
|
tools:background="@drawable/btn_border_trans_dark" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
82
OsmAnd/res/layout/route_options_container.xml
Normal file
82
OsmAnd/res/layout/route_options_container.xml
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/route_option_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/route_info_settings_buttons_height"
|
||||||
|
tools:background="@drawable/btn_border_trans_dark">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/options_divider_start"
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginBottom="@dimen/list_item_button_padding"
|
||||||
|
android:layout_marginTop="@dimen/list_item_button_padding"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/removable_option"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:visibility="visible">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/route_removable_option_container"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/route_removable_option_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingBottom="3dp"
|
||||||
|
android:paddingEnd="4dp"
|
||||||
|
android:paddingLeft="3dp"
|
||||||
|
android:paddingRight="4dp"
|
||||||
|
android:paddingStart="3dp"
|
||||||
|
android:paddingTop="3dp"
|
||||||
|
android:text="@string/routing_attr_avoid_motorway_name"
|
||||||
|
android:textSize="@dimen/text_button_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:ignore="UnusedAttribute"
|
||||||
|
tools:textColor="?attr/wikivoyage_active_color" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/title_divider"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginLeft="2dp"
|
||||||
|
android:layout_marginRight="2dp"
|
||||||
|
android:background="@color/recording_color" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/removable_option_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end|center_vertical"
|
||||||
|
android:paddingBottom="3dp"
|
||||||
|
android:paddingLeft="@dimen/route_info_icon_vertical_padding"
|
||||||
|
android:paddingRight="@dimen/route_info_icon_vertical_padding"
|
||||||
|
android:paddingTop="3dp"
|
||||||
|
tools:src="@drawable/ic_action_remove_dark" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/options_divider_end"
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginBottom="@dimen/list_item_button_padding"
|
||||||
|
android:layout_marginTop="@dimen/list_item_button_padding" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -14,6 +14,7 @@ import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.ListPopupWindow;
|
import android.support.v7.widget.ListPopupWindow;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -27,6 +28,7 @@ import android.widget.LinearLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.github.mikephil.charting.charts.LineChart;
|
import com.github.mikephil.charting.charts.LineChart;
|
||||||
import com.github.mikephil.charting.data.LineData;
|
import com.github.mikephil.charting.data.LineData;
|
||||||
|
@ -36,6 +38,7 @@ import net.osmand.AndroidUtils;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.StateChangedListener;
|
import net.osmand.StateChangedListener;
|
||||||
import net.osmand.ValueHolder;
|
import net.osmand.ValueHolder;
|
||||||
|
import net.osmand.binary.RouteDataObject;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
|
@ -54,9 +57,12 @@ import net.osmand.plus.TargetPointsHelper;
|
||||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||||
import net.osmand.plus.UiUtilities;
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.activities.SettingsBaseActivity;
|
||||||
import net.osmand.plus.activities.ShowRouteInfoDialogFragment;
|
import net.osmand.plus.activities.ShowRouteInfoDialogFragment;
|
||||||
import net.osmand.plus.activities.actions.AppModeDialog;
|
import net.osmand.plus.activities.actions.AppModeDialog;
|
||||||
|
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
|
import net.osmand.plus.helpers.AvoidSpecificRoads;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper;
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
import net.osmand.plus.helpers.MapMarkerDialogHelper;
|
import net.osmand.plus.helpers.MapMarkerDialogHelper;
|
||||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||||
|
@ -67,15 +73,20 @@ import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
||||||
import net.osmand.plus.views.MapControlsLayer;
|
import net.osmand.plus.views.MapControlsLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
import net.osmand.router.GeneralRouter;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DRIVING_STYLE;
|
||||||
|
|
||||||
public class MapRouteInfoMenu implements IRouteInformationListener {
|
public class MapRouteInfoMenu implements IRouteInformationListener {
|
||||||
|
|
||||||
public static class MenuState {
|
public static class MenuState {
|
||||||
|
@ -88,6 +99,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
||||||
public static boolean controlVisible = false;
|
public static boolean controlVisible = false;
|
||||||
private final MapContextMenu contextMenu;
|
private final MapContextMenu contextMenu;
|
||||||
private final RoutingHelper routingHelper;
|
private final RoutingHelper routingHelper;
|
||||||
|
private final RoutingOptionsHelper routingOptionsHelper;
|
||||||
private OsmandMapTileView mapView;
|
private OsmandMapTileView mapView;
|
||||||
private GeocodingLookupService geocodingLookupService;
|
private GeocodingLookupService geocodingLookupService;
|
||||||
private boolean selectFromMapTouch;
|
private boolean selectFromMapTouch;
|
||||||
|
@ -143,6 +155,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
||||||
this.mapControlsLayer = mapControlsLayer;
|
this.mapControlsLayer = mapControlsLayer;
|
||||||
contextMenu = mapActivity.getContextMenu();
|
contextMenu = mapActivity.getContextMenu();
|
||||||
routingHelper = mapActivity.getRoutingHelper();
|
routingHelper = mapActivity.getRoutingHelper();
|
||||||
|
routingOptionsHelper = app.getRoutingOptionsHelper();
|
||||||
mapView = mapActivity.getMapView();
|
mapView = mapActivity.getMapView();
|
||||||
routingHelper.addListener(this);
|
routingHelper.addListener(this);
|
||||||
portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||||
|
@ -339,7 +352,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
||||||
updateToSpinner(main);
|
updateToSpinner(main);
|
||||||
updateApplicationModes(main);
|
updateApplicationModes(main);
|
||||||
updateApplicationModesOptions(main);
|
updateApplicationModesOptions(main);
|
||||||
updateControlsButtons(main);
|
updateOptionsButtons(main);
|
||||||
|
|
||||||
if (isRouteCalculated()) {
|
if (isRouteCalculated()) {
|
||||||
makeGpx();
|
makeGpx();
|
||||||
|
@ -411,8 +424,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateApplicationModes(final View parentView) {
|
private void updateApplicationModes(final View parentView) {
|
||||||
//final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
|
|
||||||
//ApplicationMode am = settings.APPLICATION_MODE.get();
|
|
||||||
final ApplicationMode am = routingHelper.getAppMode();
|
final ApplicationMode am = routingHelper.getAppMode();
|
||||||
final Set<ApplicationMode> selected = new HashSet<>();
|
final Set<ApplicationMode> selected = new HashSet<>();
|
||||||
selected.add(am);
|
selected.add(am);
|
||||||
|
@ -425,6 +436,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
||||||
ApplicationMode next = selected.iterator().next();
|
ApplicationMode next = selected.iterator().next();
|
||||||
updateApplicationMode(am, next);
|
updateApplicationMode(am, next);
|
||||||
}
|
}
|
||||||
|
updateOptionsButtons(mainView);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
final List<ApplicationMode> values = new ArrayList<ApplicationMode>(ApplicationMode.values(mapActivity.getMyApplication()));
|
final List<ApplicationMode> values = new ArrayList<ApplicationMode>(ApplicationMode.values(mapActivity.getMyApplication()));
|
||||||
|
@ -465,8 +477,9 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
||||||
gpx = GPXUtilities.makeGpxFromRoute(routingHelper.getRoute());
|
gpx = GPXUtilities.makeGpxFromRoute(routingHelper.getRoute());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateControlsButtons(View main) {
|
private void updateOptionsButtons(View main) {
|
||||||
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
final boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||||
|
final OsmandSettings settings = app.getSettings();
|
||||||
|
|
||||||
View startButton = main.findViewById(R.id.start_button);
|
View startButton = main.findViewById(R.id.start_button);
|
||||||
if (isRouteCalculated()) {
|
if (isRouteCalculated()) {
|
||||||
|
@ -510,41 +523,324 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
FrameLayout soundButton = mainView.findViewById(R.id.sound_setting_button);
|
AndroidUtils.setBackground(app, mainView.findViewById(R.id.map_options_route_button), nightMode,
|
||||||
final TextView soundOptionDescription = (TextView) main.findViewById(R.id.sound_setting_button_descr);
|
R.drawable.route_info_trans_gradient_light, R.drawable.route_info_trans_gradient_dark);
|
||||||
|
|
||||||
AndroidUtils.setBackground(app, soundButton, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
|
HorizontalScrollView scrollView = mainView.findViewById(R.id.route_options_scroll_container);
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
|
scrollView.setVerticalScrollBarEnabled(false);
|
||||||
AndroidUtils.setBackground(app, soundOptionDescription, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
|
scrollView.setHorizontalScrollBarEnabled(false);
|
||||||
} else {
|
|
||||||
AndroidUtils.setBackground(app, soundOptionDescription, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
|
final ApplicationMode applicationMode = routingHelper.getAppMode();
|
||||||
|
|
||||||
|
final RoutingOptionsHelper.RouteMenuAppModes mode = routingOptionsHelper.modes.get(applicationMode);
|
||||||
|
LinearLayout optionsContainer = (LinearLayout) main.findViewById(R.id.route_options_container);
|
||||||
|
optionsContainer.removeAllViews();
|
||||||
|
if (mode == null) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String text = app.getString(R.string.sound_is, (app.getText(app.getRoutingHelper().getVoiceRouter().isMute() ? R.string.shared_string_off : R.string.shared_string_on)));
|
for (final RoutingOptionsHelper.LocalRoutingParameter parameter : mode.parameters) {
|
||||||
soundOptionDescription.setText(text);
|
final LinearLayout item = (LinearLayout) mapActivity.getLayoutInflater().inflate(R.layout.route_option_btn, null);
|
||||||
Drawable sound = app.getUIUtilities().getIcon(R.drawable.ic_action_volume_up, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
|
final TextView textView = (TextView) item.findViewById(R.id.route_option_title);
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
final ImageView imageView = (ImageView) item.findViewById(R.id.route_option_image_view);
|
||||||
Drawable active = app.getUIUtilities().getIcon(R.drawable.ic_action_volume_up, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
|
final int colorActive = ContextCompat.getColor(app, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
|
||||||
sound = AndroidUtils.createPressedStateListDrawable(sound, active);
|
final int colorDisabled = ContextCompat.getColor(app, R.color.description_font_and_bottom_sheet_icons);
|
||||||
}
|
|
||||||
soundOptionDescription.setCompoundDrawablesWithIntrinsicBounds(sound, null, null, null);
|
|
||||||
|
|
||||||
soundButton.setOnClickListener(new View.OnClickListener() {
|
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, app.getResources().getDimensionPixelSize(R.dimen.route_info_settings_buttons_height));
|
||||||
@Override
|
int margin = app.getResources().getDimensionPixelSize(R.dimen.text_margin_small);
|
||||||
public void onClick(View v) {
|
lp.setMargins(margin, 0, margin, 0);
|
||||||
boolean mt = !app.getRoutingHelper().getVoiceRouter().isMute();
|
|
||||||
app.getSettings().VOICE_MUTE.set(mt);
|
AndroidUtils.setBackground(app, item, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
|
||||||
app.getRoutingHelper().getVoiceRouter().setMute(mt);
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
|
||||||
String text = app.getString(R.string.sound_is, (app.getText(app.getRoutingHelper().getVoiceRouter().isMute() ? R.string.shared_string_off : R.string.shared_string_on)));
|
AndroidUtils.setBackground(app, item.findViewById(R.id.route_option_container), nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
|
||||||
soundOptionDescription.setText(text);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
main.findViewById(R.id.old_options).setOnClickListener(new View.OnClickListener() {
|
if (parameter instanceof RoutingOptionsHelper.MuteSoundRoutingParameter) {
|
||||||
@Override
|
Drawable itemDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_volume_up, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
|
||||||
public void onClick(View v) {
|
final Drawable activeItemDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_volume_up, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
|
||||||
mapActivity.getMapActions().openRoutePreferencesDialog();
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
itemDrawable = AndroidUtils.createPressedStateListDrawable(itemDrawable, activeItemDrawable);
|
||||||
|
}
|
||||||
|
imageView.setImageDrawable(app.getRoutingHelper().getVoiceRouter().isMute() ? itemDrawable : activeItemDrawable);
|
||||||
|
|
||||||
|
if (mode.parameters.size() > 2) {
|
||||||
|
textView.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
textView.setVisibility(View.VISIBLE);
|
||||||
|
textView.setTextColor(app.getRoutingHelper().getVoiceRouter().isMute() ? colorDisabled : colorActive);
|
||||||
|
String text = app.getString(R.string.sound_is, (app.getText(app.getRoutingHelper().getVoiceRouter().isMute() ? R.string.shared_string_off : R.string.shared_string_on)));
|
||||||
|
textView.setText(text);
|
||||||
|
}
|
||||||
|
item.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
routingOptionsHelper.switchSound();
|
||||||
|
|
||||||
|
Drawable itemDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_volume_up, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
itemDrawable = AndroidUtils.createPressedStateListDrawable(itemDrawable, activeItemDrawable);
|
||||||
|
}
|
||||||
|
imageView.setImageDrawable(app.getRoutingHelper().getVoiceRouter().isMute() ? itemDrawable : activeItemDrawable);
|
||||||
|
|
||||||
|
String text = app.getString(R.string.sound_is, (app.getText(app.getRoutingHelper().getVoiceRouter().isMute() ? R.string.shared_string_off : R.string.shared_string_on)));
|
||||||
|
textView.setText(text);
|
||||||
|
textView.setTextColor(app.getRoutingHelper().getVoiceRouter().isMute() && mode.parameters.size() <= 2 ? colorDisabled : colorActive);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
optionsContainer.addView(item, lp);
|
||||||
|
|
||||||
|
} else if (parameter instanceof RoutingOptionsHelper.ShowAlongTheRouteItem) {
|
||||||
|
Drawable itemDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_snap_to_road, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
Drawable activeItemDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_snap_to_road, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
|
||||||
|
itemDrawable = AndroidUtils.createPressedStateListDrawable(itemDrawable, activeItemDrawable);
|
||||||
|
}
|
||||||
|
imageView.setImageDrawable(itemDrawable);
|
||||||
|
textView.setText(R.string.show_along_the_route);
|
||||||
|
item.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Toast.makeText(app, app.getText(R.string.show_along_the_route), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
optionsContainer.addView(item, lp);
|
||||||
|
} else if (parameter instanceof RoutingOptionsHelper.AvoidRoadsTypesRoutingParameter) {
|
||||||
|
|
||||||
|
List<GeneralRouter.RoutingParameter> avoidParameters = routingOptionsHelper.getAvoidRoutingPrefsForAppMode(applicationMode);
|
||||||
|
List<GeneralRouter.RoutingParameter> avoidedParameters = new ArrayList<GeneralRouter.RoutingParameter>();
|
||||||
|
|
||||||
|
String[] propertyNames = new String[avoidParameters.size()];
|
||||||
|
for (int i = 0; i < avoidParameters.size(); i++) {
|
||||||
|
GeneralRouter.RoutingParameter p = avoidParameters.get(i);
|
||||||
|
propertyNames[i] = SettingsBaseActivity.getRoutingStringPropertyName(app, p.getId(), p.getName());
|
||||||
|
OsmandSettings.CommonPreference<Boolean> preference = settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean());
|
||||||
|
if (preference != null && preference.get()) {
|
||||||
|
avoidedParameters.add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (avoidedParameters.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Drawable itemDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_road_works_dark, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
Drawable activeItemDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_road_works_dark, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
|
||||||
|
itemDrawable = AndroidUtils.createPressedStateListDrawable(itemDrawable, activeItemDrawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (avoidedParameters.size() > 2) {
|
||||||
|
imageView.setImageDrawable(itemDrawable);
|
||||||
|
textView.setText(R.string.impassable_road);
|
||||||
|
|
||||||
|
item.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, parameter);
|
||||||
|
List<GeneralRouter.RoutingParameter> avoidParameters = routingOptionsHelper.getAvoidRoutingPrefsForAppMode(applicationMode);
|
||||||
|
String[] vals = new String[avoidParameters.size()];
|
||||||
|
OsmandSettings.OsmandPreference[] bls = new OsmandSettings.OsmandPreference[avoidParameters.size()];
|
||||||
|
for (int i = 0; i < avoidParameters.size(); i++) {
|
||||||
|
GeneralRouter.RoutingParameter p = avoidParameters.get(i);
|
||||||
|
vals[i] = SettingsBaseActivity.getRoutingStringPropertyName(app, p.getId(), p.getName());
|
||||||
|
bls[i] = settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean());
|
||||||
|
}
|
||||||
|
RouteOptionsBottomSheet.showBooleanSettings(vals, bls, app.getString(R.string.impassable_road), mapActivity);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
item.findViewById(R.id.route_option_container).setVisibility(View.GONE);
|
||||||
|
for (int i = 0; i < avoidedParameters.size(); i++) {
|
||||||
|
final GeneralRouter.RoutingParameter routingParameter = avoidedParameters.get(i);
|
||||||
|
final LinearLayout container = (LinearLayout) mapActivity.getLayoutInflater().inflate(R.layout.route_options_container, null);
|
||||||
|
final TextView routeOptionTV = (TextView) container.findViewById(R.id.route_removable_option_title);
|
||||||
|
final ImageView routeOptionImageView = (ImageView) container.findViewById(R.id.removable_option_icon);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
AndroidUtils.setBackground(app, container, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
|
||||||
|
} else {
|
||||||
|
AndroidUtils.setBackground(app, container, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == avoidedParameters.size() - 1) {
|
||||||
|
container.findViewById(R.id.options_divider_end).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
AndroidUtils.setBackground(app, container.findViewById(R.id.options_divider_end), nightMode,
|
||||||
|
R.color.divider_light, R.color.divider_dark);
|
||||||
|
AndroidUtils.setBackground(app, container.findViewById(R.id.options_divider_start), nightMode,
|
||||||
|
R.color.divider_light, R.color.divider_dark);
|
||||||
|
|
||||||
|
Drawable active = app.getUIUtilities().getIcon(R.drawable.ic_action_remove_dark, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
|
||||||
|
routeOptionImageView.setImageDrawable(active);
|
||||||
|
|
||||||
|
AndroidUtils.setBackground(app, routeOptionImageView, nightMode, R.drawable.route_info_trans_gradient_light, R.drawable.route_info_trans_gradient_dark);
|
||||||
|
routeOptionTV.setText(SettingsBaseActivity.getRoutingStringPropertyName(app, routingParameter.getId(), routingParameter.getName()));
|
||||||
|
|
||||||
|
container.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
OsmandSettings.CommonPreference<Boolean> preference = settings.getCustomRoutingBooleanProperty(routingParameter.getId(), routingParameter.getDefaultBoolean());
|
||||||
|
preference.set(false);
|
||||||
|
Toast.makeText(app, SettingsBaseActivity.getRoutingStringPropertyName(app, routingParameter.getId(), routingParameter.getName()), Toast.LENGTH_LONG).show();
|
||||||
|
updateOptionsButtons(mainView);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
item.addView(container);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
optionsContainer.addView(item, lp);
|
||||||
|
} else if (parameter instanceof RoutingOptionsHelper.AvoidRoadsRoutingParameter) {
|
||||||
|
|
||||||
|
AvoidSpecificRoads avoidSpecificRoads = app.getAvoidSpecificRoads();
|
||||||
|
Map<LatLon, RouteDataObject> impassableRoads = avoidSpecificRoads.getImpassableRoads();
|
||||||
|
|
||||||
|
if (impassableRoads.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Drawable itemDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_road_works_dark, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
Drawable activeItemDrawable = app.getUIUtilities().getIcon(R.drawable.ic_action_road_works_dark, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
|
||||||
|
itemDrawable = AndroidUtils.createPressedStateListDrawable(itemDrawable, activeItemDrawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (impassableRoads.size() > 2) {
|
||||||
|
|
||||||
|
imageView.setImageDrawable(itemDrawable);
|
||||||
|
textView.setText(R.string.impassable_road);
|
||||||
|
item.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
mapActivity.getDashboard().setDashboardVisibility(false, DashboardOnMap.DashboardType.ROUTE_PREFERENCES);
|
||||||
|
mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide();
|
||||||
|
app.getAvoidSpecificRoads().showDialog(mapActivity);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
imageView.setImageDrawable(itemDrawable);
|
||||||
|
textView.setText(R.string.impassable_road);
|
||||||
|
} else {
|
||||||
|
item.findViewById(R.id.route_option_container).setVisibility(View.GONE);
|
||||||
|
Iterator<Map.Entry<LatLon, RouteDataObject>> it = impassableRoads.entrySet().iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Map.Entry<LatLon, RouteDataObject> pair = it.next();
|
||||||
|
|
||||||
|
final LatLon latLon = pair.getKey();
|
||||||
|
final RouteDataObject routeDataObject = pair.getValue();
|
||||||
|
final LinearLayout container = (LinearLayout) mapActivity.getLayoutInflater().inflate(R.layout.route_options_container, null);
|
||||||
|
final TextView routeOptionTV = (TextView) container.findViewById(R.id.route_removable_option_title);
|
||||||
|
final ImageView routeOptionImageView = (ImageView) container.findViewById(R.id.removable_option_icon);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
AndroidUtils.setBackground(app, container, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
|
||||||
|
} else {
|
||||||
|
AndroidUtils.setBackground(app, container, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!it.hasNext()) {
|
||||||
|
container.findViewById(R.id.options_divider_end).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
AndroidUtils.setBackground(app, container.findViewById(R.id.options_divider_end), nightMode,
|
||||||
|
R.color.divider_light, R.color.divider_dark);
|
||||||
|
AndroidUtils.setBackground(app, container.findViewById(R.id.options_divider_start), nightMode,
|
||||||
|
R.color.divider_light, R.color.divider_dark);
|
||||||
|
|
||||||
|
Drawable active = app.getUIUtilities().getIcon(R.drawable.ic_action_remove_dark, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
|
||||||
|
routeOptionImageView.setImageDrawable(active);
|
||||||
|
|
||||||
|
AndroidUtils.setBackground(app, routeOptionImageView, nightMode, R.drawable.route_info_trans_gradient_light, R.drawable.route_info_trans_gradient_dark);
|
||||||
|
routeOptionTV.setText(getText(routeDataObject));
|
||||||
|
|
||||||
|
container.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
app.getAvoidSpecificRoads().removeImpassableRoad(routeDataObject);
|
||||||
|
Toast.makeText(app, getText(routeDataObject), Toast.LENGTH_LONG).show();
|
||||||
|
updateOptionsButtons(mainView);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
item.addView(container);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
optionsContainer.addView(item, lp);
|
||||||
|
} else if (parameter instanceof RoutingOptionsHelper.LocalRoutingParameterGroup) {
|
||||||
|
|
||||||
|
Drawable itemDrawable = app.getUIUtilities().getIcon(R.drawable.mx_amenity_fuel, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
Drawable activeItemDrawable = app.getUIUtilities().getIcon(R.drawable.mx_amenity_fuel, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
|
||||||
|
itemDrawable = AndroidUtils.createPressedStateListDrawable(itemDrawable, activeItemDrawable);
|
||||||
|
}
|
||||||
|
|
||||||
|
imageView.setImageDrawable(itemDrawable);
|
||||||
|
RoutingOptionsHelper.LocalRoutingParameter selected = ((RoutingOptionsHelper.LocalRoutingParameterGroup) parameter).getSelected(settings);
|
||||||
|
if (selected != null) {
|
||||||
|
textView.setText(((RoutingOptionsHelper.LocalRoutingParameterGroup) parameter).getText(mapActivity));
|
||||||
|
}
|
||||||
|
|
||||||
|
item.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
routingOptionsHelper.showDialog((RoutingOptionsHelper.LocalRoutingParameterGroup) parameter, mapActivity, new RoutingOptionsHelper.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(String text) {
|
||||||
|
Toast.makeText(app, text, Toast.LENGTH_LONG).show();
|
||||||
|
updateOptionsButtons(mainView);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
optionsContainer.addView(item, lp);
|
||||||
|
} else {
|
||||||
|
if (parameter.routingParameter != null) {
|
||||||
|
boolean checked;
|
||||||
|
if (parameter.routingParameter.getId().equals("short_way")) {
|
||||||
|
// if short route settings - it should be inverse of fast_route_mode
|
||||||
|
checked = !settings.FAST_ROUTE_MODE.getModeValue(routingHelper.getAppMode());
|
||||||
|
} else {
|
||||||
|
checked = parameter.isSelected(settings);
|
||||||
|
}
|
||||||
|
textView.setTextColor(checked ? colorActive : colorDisabled);
|
||||||
|
textView.setText(parameter.getText(mapActivity));
|
||||||
|
}
|
||||||
|
Drawable itemDrawable = app.getUIUtilities().getIcon(R.drawable.mx_amenity_fuel, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light);
|
||||||
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
|
Drawable activeItemDrawable = app.getUIUtilities().getIcon(R.drawable.mx_amenity_fuel, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
|
||||||
|
itemDrawable = AndroidUtils.createPressedStateListDrawable(itemDrawable, activeItemDrawable);
|
||||||
|
}
|
||||||
|
imageView.setImageDrawable(itemDrawable);
|
||||||
|
item.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (parameter.routingParameter != null) {
|
||||||
|
boolean selected = parameter.isSelected(settings);
|
||||||
|
routingOptionsHelper.applyRoutingParameter(parameter, !selected);
|
||||||
|
textView.setTextColor(parameter.isSelected(settings) ? colorActive : colorDisabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
optionsContainer.addView(item, lp);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
optionsContainer.setPadding(optionsContainer.getPaddingLeft(), optionsContainer.getPaddingTop(), options.getWidth(), optionsContainer.getPaddingBottom());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getText(@Nullable RouteDataObject obj) {
|
||||||
|
if (obj != null) {
|
||||||
|
String locale = app.getSettings().MAP_PREFERRED_LOCALE.get();
|
||||||
|
boolean transliterate = app.getSettings().MAP_TRANSLITERATE_NAMES.get();
|
||||||
|
String name = RoutingHelper.formatStreetName(
|
||||||
|
obj.getName(locale, transliterate),
|
||||||
|
obj.getRef(locale, transliterate, true),
|
||||||
|
obj.getDestinationName(locale, transliterate, true),
|
||||||
|
app.getString(R.string.towards)
|
||||||
|
);
|
||||||
|
if (!TextUtils.isEmpty(name)) {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return app.getString(R.string.shared_string_road);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clickRouteGo() {
|
private void clickRouteGo() {
|
||||||
|
@ -1450,4 +1746,19 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
||||||
return getListItemView(position, convertView, parent);
|
return getListItemView(position, convertView, parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum PermanentAppModeOptions {
|
||||||
|
|
||||||
|
CAR(RoutingOptionsHelper.MuteSoundRoutingParameter.KEY, RoutingOptionsHelper.AvoidRoadsRoutingParameter.KEY),
|
||||||
|
|
||||||
|
BICYCLE(RoutingOptionsHelper.MuteSoundRoutingParameter.KEY, DRIVING_STYLE, GeneralRouter.USE_HEIGHT_OBSTACLES),
|
||||||
|
|
||||||
|
PEDESTRIAN(RoutingOptionsHelper.MuteSoundRoutingParameter.KEY, GeneralRouter.USE_HEIGHT_OBSTACLES);
|
||||||
|
|
||||||
|
List<String> routingParameters;
|
||||||
|
|
||||||
|
PermanentAppModeOptions(String... routingParameters) {
|
||||||
|
this.routingParameters = Arrays.asList(routingParameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -51,10 +51,10 @@ import net.osmand.plus.views.MapControlsLayer;
|
||||||
import net.osmand.router.GeneralRouter;
|
import net.osmand.router.GeneralRouter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static net.osmand.plus.activities.SettingsNavigationActivity.getRouter;
|
import static net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DRIVING_STYLE;
|
||||||
|
|
||||||
public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
|
|
||||||
|
@ -68,7 +68,6 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
private RoutingOptionsHelper routingOptionsHelper;
|
private RoutingOptionsHelper routingOptionsHelper;
|
||||||
private ApplicationMode applicationMode;
|
private ApplicationMode applicationMode;
|
||||||
|
|
||||||
private List<GeneralRouter.RoutingParameter> avoidParameters = new ArrayList<GeneralRouter.RoutingParameter>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -80,21 +79,28 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
mapActivity = getMapActivity();
|
mapActivity = getMapActivity();
|
||||||
controlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
|
controlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
|
||||||
applicationMode = routingHelper.getAppMode();
|
applicationMode = routingHelper.getAppMode();
|
||||||
prepareRoutingPrefs();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createMenuItems(Bundle savedInstanceState) {
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
items.add(new TitleItem(app.getString(R.string.shared_string_settings), nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light));
|
items.add(new TitleItem(app.getString(R.string.shared_string_settings), nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light));
|
||||||
|
|
||||||
List<LocalRoutingParameter> list = routingOptionsHelper.getRoutingParameters(applicationMode);
|
List<LocalRoutingParameter> list = new ArrayList<>();
|
||||||
for (LocalRoutingParameter optionsItem : list) {
|
if (applicationMode.equals(ApplicationMode.CAR)) {
|
||||||
|
list = routingOptionsHelper.getRoutingParameters(applicationMode, AppModeOptions.CAR.routingParameters);
|
||||||
|
} else if (applicationMode.equals(ApplicationMode.BICYCLE)) {
|
||||||
|
list = routingOptionsHelper.getRoutingParameters(applicationMode, AppModeOptions.BICYCLE.routingParameters);
|
||||||
|
} else if (applicationMode.equals(ApplicationMode.PEDESTRIAN)) {
|
||||||
|
list = routingOptionsHelper.getRoutingParameters(applicationMode, AppModeOptions.PEDESTRIAN.routingParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final LocalRoutingParameter optionsItem : list) {
|
||||||
|
|
||||||
if (optionsItem instanceof DividerItem) {
|
if (optionsItem instanceof DividerItem) {
|
||||||
items.add(new DividerHalfItem(app));
|
items.add(new DividerHalfItem(app));
|
||||||
} else if (optionsItem instanceof MuteSoundRoutingParameter) {
|
} else if (optionsItem instanceof MuteSoundRoutingParameter) {
|
||||||
final BottomSheetItemWithCompoundButton[] MuteSoundRoutingParameter = new BottomSheetItemWithCompoundButton[1];
|
final BottomSheetItemWithCompoundButton[] muteSoundRoutingParameter = new BottomSheetItemWithCompoundButton[1];
|
||||||
MuteSoundRoutingParameter[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
muteSoundRoutingParameter[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||||
.setChecked(!routingHelper.getVoiceRouter().isMute())
|
.setChecked(!routingHelper.getVoiceRouter().isMute())
|
||||||
.setDescription(getString(R.string.voice_announcements))
|
.setDescription(getString(R.string.voice_announcements))
|
||||||
.setIcon(getContentIcon(R.drawable.ic_action_volume_up))
|
.setIcon(getContentIcon(R.drawable.ic_action_volume_up))
|
||||||
|
@ -103,30 +109,32 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
|
||||||
boolean mt = !routingHelper.getVoiceRouter().isMute();
|
boolean mt = !routingHelper.getVoiceRouter().isMute();
|
||||||
settings.VOICE_MUTE.set(mt);
|
settings.VOICE_MUTE.set(mt);
|
||||||
routingHelper.getVoiceRouter().setMute(mt);
|
routingHelper.getVoiceRouter().setMute(mt);
|
||||||
MuteSoundRoutingParameter[0].setChecked(!routingHelper.getVoiceRouter().isMute());
|
muteSoundRoutingParameter[0].setChecked(!routingHelper.getVoiceRouter().isMute());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.create();
|
.create();
|
||||||
items.add(MuteSoundRoutingParameter[0]);
|
items.add(muteSoundRoutingParameter[0]);
|
||||||
|
|
||||||
} else if (optionsItem instanceof ShowAlongTheRouteItem) {
|
} else if (optionsItem instanceof ShowAlongTheRouteItem) {
|
||||||
BaseBottomSheetItem ShowAlongTheRouteItem = new SimpleBottomSheetItem.Builder()
|
BaseBottomSheetItem showAlongTheRouteItem = new SimpleBottomSheetItem.Builder()
|
||||||
.setIcon(getContentIcon(R.drawable.ic_action_snap_to_road))
|
.setIcon(getContentIcon(R.drawable.ic_action_snap_to_road))
|
||||||
.setTitle(getString(R.string.show_along_the_route))
|
.setTitle(getString(R.string.show_along_the_route))
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
|
||||||
Toast.makeText(app, getText(R.string.show_along_the_route), Toast.LENGTH_LONG).show();
|
Toast.makeText(app, getText(R.string.show_along_the_route), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.create();
|
.create();
|
||||||
items.add(ShowAlongTheRouteItem);
|
items.add(showAlongTheRouteItem);
|
||||||
} else if (optionsItem instanceof RouteSimulationItem) {
|
} else if (optionsItem instanceof RouteSimulationItem) {
|
||||||
BaseBottomSheetItem RouteSimulationItem = new SimpleBottomSheetItem.Builder()
|
BaseBottomSheetItem routeSimulationItem = new SimpleBottomSheetItem.Builder()
|
||||||
.setIcon(getContentIcon(R.drawable.ic_action_start_navigation))
|
.setIcon(getContentIcon(R.drawable.ic_action_start_navigation))
|
||||||
.setTitle(getString(R.string.simulate_navigation))
|
.setTitle(getString(R.string.simulate_navigation))
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||||
|
@ -139,15 +147,17 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.create();
|
.create();
|
||||||
items.add(RouteSimulationItem);
|
items.add(routeSimulationItem);
|
||||||
} else if (optionsItem instanceof AvoidRoadsTypesRoutingParameter) {
|
} else if (optionsItem instanceof AvoidRoadsTypesRoutingParameter) {
|
||||||
BaseBottomSheetItem AvoidRoadsRoutingParameter = new SimpleBottomSheetItem.Builder()
|
BaseBottomSheetItem avoidRoadsRoutingParameter = new SimpleBottomSheetItem.Builder()
|
||||||
.setIcon(getContentIcon(R.drawable.ic_action_road_works_dark))
|
.setIcon(getContentIcon(R.drawable.ic_action_road_works_dark))
|
||||||
.setTitle(getString(R.string.impassable_road))
|
.setTitle(getString(R.string.impassable_road))
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
|
||||||
|
List<GeneralRouter.RoutingParameter> avoidParameters = routingOptionsHelper.getAvoidRoutingPrefsForAppMode(applicationMode);
|
||||||
String[] vals = new String[avoidParameters.size()];
|
String[] vals = new String[avoidParameters.size()];
|
||||||
OsmandSettings.OsmandPreference[] bls = new OsmandSettings.OsmandPreference[avoidParameters.size()];
|
OsmandSettings.OsmandPreference[] bls = new OsmandSettings.OsmandPreference[avoidParameters.size()];
|
||||||
for (int i = 0; i < avoidParameters.size(); i++) {
|
for (int i = 0; i < avoidParameters.size(); i++) {
|
||||||
|
@ -155,19 +165,20 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
vals[i] = SettingsBaseActivity.getRoutingStringPropertyName(app, p.getId(), p.getName());
|
vals[i] = SettingsBaseActivity.getRoutingStringPropertyName(app, p.getId(), p.getName());
|
||||||
bls[i] = settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean());
|
bls[i] = settings.getCustomRoutingBooleanProperty(p.getId(), p.getDefaultBoolean());
|
||||||
}
|
}
|
||||||
showBooleanSettings(vals, bls, getString(R.string.impassable_road));
|
showBooleanSettings(vals, bls, getString(R.string.impassable_road), mapActivity);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.create();
|
.create();
|
||||||
items.add(AvoidRoadsRoutingParameter);
|
items.add(avoidRoadsRoutingParameter);
|
||||||
} else if (optionsItem instanceof AvoidRoadsRoutingParameter) {
|
} else if (optionsItem instanceof AvoidRoadsRoutingParameter) {
|
||||||
BaseBottomSheetItem AvoidRoadsRoutingParameter = new SimpleBottomSheetItem.Builder()
|
BaseBottomSheetItem avoidRoadsRoutingParameter = new SimpleBottomSheetItem.Builder()
|
||||||
.setIcon(getContentIcon(R.drawable.ic_action_road_works_dark))
|
.setIcon(getContentIcon(R.drawable.ic_action_road_works_dark))
|
||||||
.setTitle(getString(R.string.impassable_road))
|
.setTitle(getString(R.string.impassable_road))
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
|
||||||
mapActivity.getDashboard().setDashboardVisibility(false, DashboardOnMap.DashboardType.ROUTE_PREFERENCES);
|
mapActivity.getDashboard().setDashboardVisibility(false, DashboardOnMap.DashboardType.ROUTE_PREFERENCES);
|
||||||
controlsLayer.getMapRouteInfoMenu().hide();
|
controlsLayer.getMapRouteInfoMenu().hide();
|
||||||
app.getAvoidSpecificRoads().showDialog(mapActivity);
|
app.getAvoidSpecificRoads().showDialog(mapActivity);
|
||||||
|
@ -175,7 +186,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.create();
|
.create();
|
||||||
items.add(AvoidRoadsRoutingParameter);
|
items.add(avoidRoadsRoutingParameter);
|
||||||
|
|
||||||
} else if (optionsItem instanceof GpxLocalRoutingParameter) {
|
} else if (optionsItem instanceof GpxLocalRoutingParameter) {
|
||||||
View v = mapActivity.getLayoutInflater().inflate(R.layout.plan_route_gpx, null);
|
View v = mapActivity.getLayoutInflater().inflate(R.layout.plan_route_gpx, null);
|
||||||
|
@ -186,7 +197,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
((ImageView) v.findViewById(R.id.dropDownIcon))
|
((ImageView) v.findViewById(R.id.dropDownIcon))
|
||||||
.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, !nightMode));
|
.setImageDrawable(app.getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down, !nightMode));
|
||||||
|
|
||||||
BaseBottomSheetItem GpxLocalRoutingParameter = new BottomSheetItemWithDescription.Builder()
|
BaseBottomSheetItem gpxLocalRoutingParameter = new BottomSheetItemWithDescription.Builder()
|
||||||
.setDescription(getString(R.string.choose_track_file_to_follow))
|
.setDescription(getString(R.string.choose_track_file_to_follow))
|
||||||
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
|
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
|
||||||
.setTitle(getString(R.string.shared_string_gpx_route))
|
.setTitle(getString(R.string.shared_string_gpx_route))
|
||||||
|
@ -198,10 +209,10 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.create();
|
.create();
|
||||||
items.add(GpxLocalRoutingParameter);
|
items.add(gpxLocalRoutingParameter);
|
||||||
|
|
||||||
} else if (optionsItem instanceof OtherSettingsRoutingParameter) {
|
} else if (optionsItem instanceof OtherSettingsRoutingParameter) {
|
||||||
BaseBottomSheetItem OtherSettingsRoutingParameter = new SimpleBottomSheetItem.Builder()
|
BaseBottomSheetItem otherSettingsRoutingParameter = new SimpleBottomSheetItem.Builder()
|
||||||
.setIcon(getContentIcon(R.drawable.map_action_settings))
|
.setIcon(getContentIcon(R.drawable.map_action_settings))
|
||||||
.setTitle(getString(R.string.routing_settings_2))
|
.setTitle(getString(R.string.routing_settings_2))
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||||
|
@ -215,7 +226,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.create();
|
.create();
|
||||||
items.add(OtherSettingsRoutingParameter);
|
items.add(otherSettingsRoutingParameter);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
inflateRoutingParameter(optionsItem);
|
inflateRoutingParameter(optionsItem);
|
||||||
|
@ -228,20 +239,8 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
return R.string.shared_string_close;
|
return R.string.shared_string_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareRoutingPrefs() {
|
|
||||||
GeneralRouter router = getRouter(app.getDefaultRoutingConfig(), applicationMode);
|
|
||||||
if (router != null) {
|
|
||||||
for (Map.Entry<String, GeneralRouter.RoutingParameter> e : router.getParameters().entrySet()) {
|
|
||||||
String param = e.getKey();
|
|
||||||
GeneralRouter.RoutingParameter routingParameter = e.getValue();
|
|
||||||
if (param.startsWith("avoid_")) {
|
|
||||||
avoidParameters.add(routingParameter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public AlertDialog showBooleanSettings(String[] vals, final OsmandSettings.OsmandPreference<Boolean>[] prefs, final CharSequence title) {
|
public static AlertDialog showBooleanSettings(String[] vals, final OsmandSettings.OsmandPreference<Boolean>[] prefs, final CharSequence title, MapActivity mapActivity) {
|
||||||
AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity);
|
AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity);
|
||||||
boolean[] checkedItems = new boolean[prefs.length];
|
boolean[] checkedItems = new boolean[prefs.length];
|
||||||
for (int i = 0; i < prefs.length; i++) {
|
for (int i = 0; i < prefs.length; i++) {
|
||||||
|
@ -296,6 +295,8 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
builder.setOnClickListener(new View.OnClickListener() {
|
builder.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, parameter);
|
||||||
|
|
||||||
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int selectedIndex = -1;
|
int selectedIndex = -1;
|
||||||
|
@ -377,6 +378,8 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
builder.setOnClickListener(new View.OnClickListener() {
|
builder.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, parameter);
|
||||||
|
|
||||||
boolean selected = parameter.isSelected(settings);
|
boolean selected = parameter.isSelected(settings);
|
||||||
routingOptionsHelper.applyRoutingParameter(parameter, !selected);
|
routingOptionsHelper.applyRoutingParameter(parameter, !selected);
|
||||||
item[0].setChecked(!selected);
|
item[0].setChecked(!selected);
|
||||||
|
@ -409,4 +412,46 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum AppModeOptions {
|
||||||
|
|
||||||
|
CAR(MuteSoundRoutingParameter.KEY,
|
||||||
|
DividerItem.KEY,
|
||||||
|
AvoidRoadsRoutingParameter.KEY,
|
||||||
|
ShowAlongTheRouteItem.KEY,
|
||||||
|
GeneralRouter.ALLOW_PRIVATE,
|
||||||
|
GeneralRouter.USE_SHORTEST_WAY,
|
||||||
|
DividerItem.KEY,
|
||||||
|
GpxLocalRoutingParameter.KEY,
|
||||||
|
OtherSettingsRoutingParameter.KEY,
|
||||||
|
RouteSimulationItem.KEY),
|
||||||
|
|
||||||
|
BICYCLE(MuteSoundRoutingParameter.KEY,
|
||||||
|
DRIVING_STYLE,
|
||||||
|
GeneralRouter.USE_HEIGHT_OBSTACLES,
|
||||||
|
DividerItem.KEY,
|
||||||
|
AvoidRoadsTypesRoutingParameter.KEY,
|
||||||
|
ShowAlongTheRouteItem.KEY,
|
||||||
|
DividerItem.KEY,
|
||||||
|
GpxLocalRoutingParameter.KEY,
|
||||||
|
OtherSettingsRoutingParameter.KEY,
|
||||||
|
RouteSimulationItem.KEY),
|
||||||
|
|
||||||
|
PEDESTRIAN(MuteSoundRoutingParameter.KEY,
|
||||||
|
GeneralRouter.USE_HEIGHT_OBSTACLES,
|
||||||
|
DividerItem.KEY,
|
||||||
|
AvoidRoadsTypesRoutingParameter.KEY,
|
||||||
|
ShowAlongTheRouteItem.KEY,
|
||||||
|
DividerItem.KEY,
|
||||||
|
GpxLocalRoutingParameter.KEY,
|
||||||
|
OtherSettingsRoutingParameter.KEY,
|
||||||
|
RouteSimulationItem.KEY);
|
||||||
|
|
||||||
|
|
||||||
|
List<String> routingParameters;
|
||||||
|
|
||||||
|
AppModeOptions(String... routingParameters) {
|
||||||
|
this.routingParameters = Arrays.asList(routingParameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,13 @@ import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.CallbackWithObject;
|
import net.osmand.CallbackWithObject;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
|
@ -25,6 +31,7 @@ import net.osmand.plus.dashboard.DashboardOnMap;
|
||||||
import net.osmand.plus.download.DownloadActivity;
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
import net.osmand.plus.download.DownloadActivityType;
|
import net.osmand.plus.download.DownloadActivityType;
|
||||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||||
|
import net.osmand.plus.mapcontextmenu.TransportStopRouteAdapter;
|
||||||
import net.osmand.plus.routing.RouteProvider;
|
import net.osmand.plus.routing.RouteProvider;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.voice.JSMediaCommandPlayerImpl;
|
import net.osmand.plus.voice.JSMediaCommandPlayerImpl;
|
||||||
|
@ -37,7 +44,7 @@ import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -47,18 +54,38 @@ import static net.osmand.plus.activities.SettingsNavigationActivity.getRouter;
|
||||||
|
|
||||||
public class RoutingOptionsHelper {
|
public class RoutingOptionsHelper {
|
||||||
|
|
||||||
|
|
||||||
|
public static final String MORE_VALUE = "MORE_VALUE";
|
||||||
|
public static final String DRIVING_STYLE = "driving_style";
|
||||||
|
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
private RoutingHelper routingHelper;
|
private RoutingHelper routingHelper;
|
||||||
|
|
||||||
|
Map<ApplicationMode, RouteMenuAppModes> modes = new HashMap<>();
|
||||||
|
|
||||||
public RoutingOptionsHelper(OsmandApplication application) {
|
public RoutingOptionsHelper(OsmandApplication application) {
|
||||||
app = application;
|
app = application;
|
||||||
settings = app.getSettings();
|
settings = app.getSettings();
|
||||||
routingHelper = app.getRoutingHelper();
|
routingHelper = app.getRoutingHelper();
|
||||||
|
|
||||||
|
modes.put(ApplicationMode.CAR, new RouteMenuAppModes(ApplicationMode.CAR, getRoutingParameters(ApplicationMode.CAR, MapRouteInfoMenu.PermanentAppModeOptions.CAR.routingParameters)));
|
||||||
|
modes.put(ApplicationMode.BICYCLE, new RouteMenuAppModes(ApplicationMode.BICYCLE, getRoutingParameters(ApplicationMode.BICYCLE, MapRouteInfoMenu.PermanentAppModeOptions.BICYCLE.routingParameters)));
|
||||||
|
modes.put(ApplicationMode.PEDESTRIAN, new RouteMenuAppModes(ApplicationMode.PEDESTRIAN, getRoutingParameters(ApplicationMode.PEDESTRIAN, MapRouteInfoMenu.PermanentAppModeOptions.PEDESTRIAN.routingParameters)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String MORE_VALUE = "MORE_VALUE";
|
public void addNewRouteMenuParameter(ApplicationMode applicationMode, LocalRoutingParameter parameter) {
|
||||||
|
RouteMenuAppModes mode = modes.get(applicationMode);
|
||||||
|
if (mode != null) {
|
||||||
|
if (parameter.canAddToRouteMenu() && mode.am.equals(applicationMode) && !mode.containsParameter(parameter)) {
|
||||||
|
mode.parameters.add(parameter);
|
||||||
|
}
|
||||||
|
} else if (parameter.canAddToRouteMenu()) {
|
||||||
|
List<LocalRoutingParameter> list = new ArrayList<>();
|
||||||
|
list.add(parameter);
|
||||||
|
modes.put(applicationMode, new RouteMenuAppModes(applicationMode, list));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void switchSound() {
|
public void switchSound() {
|
||||||
boolean mt = !routingHelper.getVoiceRouter().isMute();
|
boolean mt = !routingHelper.getVoiceRouter().isMute();
|
||||||
|
@ -233,15 +260,9 @@ public class RoutingOptionsHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LocalRoutingParameter> getRoutingParameters(ApplicationMode am) {
|
public List<LocalRoutingParameter> getRoutingParameters(ApplicationMode am, List<String> routingParameters) {
|
||||||
List<LocalRoutingParameter> list = new ArrayList<>();
|
List<LocalRoutingParameter> list = new ArrayList<>();
|
||||||
if (am.equals(ApplicationMode.CAR)) {
|
getAppModeItems(am, list, routingParameters);
|
||||||
getAppModeItems(am, list, AppModeOptions.CAR.routingParameters);
|
|
||||||
} else if (am.equals(ApplicationMode.BICYCLE)) {
|
|
||||||
getAppModeItems(am, list, AppModeOptions.BICYCLE.routingParameters);
|
|
||||||
} else if (am.equals(ApplicationMode.PEDESTRIAN)) {
|
|
||||||
getAppModeItems(am, list, AppModeOptions.PEDESTRIAN.routingParameters);
|
|
||||||
}
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,6 +276,79 @@ public class RoutingOptionsHelper {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface OnClickListener {
|
||||||
|
void onClick(String text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showDialog(final LocalRoutingParameterGroup group, final MapActivity mapActivity, final OnClickListener listener) {
|
||||||
|
final ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||||
|
int i = 0;
|
||||||
|
int selectedIndex = -1;
|
||||||
|
for (LocalRoutingParameter p : group.getRoutingParameters()) {
|
||||||
|
adapter.addItem(ContextMenuItem.createBuilder(p.getText(mapActivity))
|
||||||
|
.setSelected(false).createItem());
|
||||||
|
if (p.isSelected(settings)) {
|
||||||
|
selectedIndex = i;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (selectedIndex == -1) {
|
||||||
|
selectedIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
|
||||||
|
final int layout = R.layout.list_menu_item_native_singlechoice;
|
||||||
|
|
||||||
|
final ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(mapActivity, layout, R.id.text1,
|
||||||
|
adapter.getItemNames()) {
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||||
|
// User super class to create the View
|
||||||
|
View v = convertView;
|
||||||
|
if (v == null) {
|
||||||
|
v = mapActivity.getLayoutInflater().inflate(layout, null);
|
||||||
|
}
|
||||||
|
final ContextMenuItem item = adapter.getItem(position);
|
||||||
|
TextView tv = (TextView) v.findViewById(R.id.text1);
|
||||||
|
tv.setText(item.getTitle());
|
||||||
|
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f);
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
final int[] selectedPosition = {selectedIndex};
|
||||||
|
builder.setSingleChoiceItems(listAdapter, selectedIndex, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int position) {
|
||||||
|
selectedPosition[0] = position;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setTitle(group.getText(mapActivity))
|
||||||
|
.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
int position = selectedPosition[0];
|
||||||
|
if (position >= 0 && position < group.getRoutingParameters().size()) {
|
||||||
|
for (int i = 0; i < group.getRoutingParameters().size(); i++) {
|
||||||
|
LocalRoutingParameter rp = group.getRoutingParameters().get(i);
|
||||||
|
rp.setSelected(settings, i == position);
|
||||||
|
}
|
||||||
|
mapActivity.getRoutingHelper().recalculateRouteDueToSettingsChange();
|
||||||
|
LocalRoutingParameter selected = group.getSelected(settings);
|
||||||
|
if (selected != null&&listener != null) {
|
||||||
|
listener.onClick(selected.getText(mapActivity));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
|
|
||||||
|
builder.create().show();
|
||||||
|
}
|
||||||
|
|
||||||
public LocalRoutingParameter getItem(ApplicationMode am, String parameter) {
|
public LocalRoutingParameter getItem(ApplicationMode am, String parameter) {
|
||||||
switch (parameter) {
|
switch (parameter) {
|
||||||
case MuteSoundRoutingParameter.KEY:
|
case MuteSoundRoutingParameter.KEY:
|
||||||
|
@ -385,6 +479,22 @@ public class RoutingOptionsHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<GeneralRouter.RoutingParameter> getAvoidRoutingPrefsForAppMode(ApplicationMode applicationMode) {
|
||||||
|
List<GeneralRouter.RoutingParameter> avoidParameters = new ArrayList<GeneralRouter.RoutingParameter>();
|
||||||
|
GeneralRouter router = getRouter(app.getDefaultRoutingConfig(), routingHelper.getAppMode());
|
||||||
|
if (router != null) {
|
||||||
|
for (Map.Entry<String, GeneralRouter.RoutingParameter> e : router.getParameters().entrySet()) {
|
||||||
|
String param = e.getKey();
|
||||||
|
GeneralRouter.RoutingParameter routingParameter = e.getValue();
|
||||||
|
if (param.startsWith("avoid_")) {
|
||||||
|
avoidParameters.add(routingParameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return avoidParameters;
|
||||||
|
}
|
||||||
|
|
||||||
public static class LocalRoutingParameter {
|
public static class LocalRoutingParameter {
|
||||||
|
|
||||||
public static final String KEY = "LocalRoutingParameter";
|
public static final String KEY = "LocalRoutingParameter";
|
||||||
|
@ -393,6 +503,10 @@ public class RoutingOptionsHelper {
|
||||||
|
|
||||||
private ApplicationMode am;
|
private ApplicationMode am;
|
||||||
|
|
||||||
|
public boolean canAddToRouteMenu() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public LocalRoutingParameter(ApplicationMode am) {
|
public LocalRoutingParameter(ApplicationMode am) {
|
||||||
this.am = am;
|
this.am = am;
|
||||||
}
|
}
|
||||||
|
@ -491,6 +605,10 @@ public class RoutingOptionsHelper {
|
||||||
|
|
||||||
public static final String KEY = "DividerItem";
|
public static final String KEY = "DividerItem";
|
||||||
|
|
||||||
|
public boolean canAddToRouteMenu() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public DividerItem() {
|
public DividerItem() {
|
||||||
super(null);
|
super(null);
|
||||||
}
|
}
|
||||||
|
@ -500,6 +618,10 @@ public class RoutingOptionsHelper {
|
||||||
|
|
||||||
public static final String KEY = "RouteSimulationItem";
|
public static final String KEY = "RouteSimulationItem";
|
||||||
|
|
||||||
|
public boolean canAddToRouteMenu() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public RouteSimulationItem() {
|
public RouteSimulationItem() {
|
||||||
super(null);
|
super(null);
|
||||||
}
|
}
|
||||||
|
@ -538,6 +660,10 @@ public class RoutingOptionsHelper {
|
||||||
|
|
||||||
public static final String KEY = "GpxLocalRoutingParameter";
|
public static final String KEY = "GpxLocalRoutingParameter";
|
||||||
|
|
||||||
|
public boolean canAddToRouteMenu() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public GpxLocalRoutingParameter() {
|
public GpxLocalRoutingParameter() {
|
||||||
super(null);
|
super(null);
|
||||||
}
|
}
|
||||||
|
@ -547,6 +673,10 @@ public class RoutingOptionsHelper {
|
||||||
|
|
||||||
public static final String KEY = "OtherSettingsRoutingParameter";
|
public static final String KEY = "OtherSettingsRoutingParameter";
|
||||||
|
|
||||||
|
public boolean canAddToRouteMenu() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public OtherSettingsRoutingParameter() {
|
public OtherSettingsRoutingParameter() {
|
||||||
super(null);
|
super(null);
|
||||||
}
|
}
|
||||||
|
@ -556,6 +686,10 @@ public class RoutingOptionsHelper {
|
||||||
|
|
||||||
public static final String KEY = "OtherLocalRoutingParameter";
|
public static final String KEY = "OtherLocalRoutingParameter";
|
||||||
|
|
||||||
|
public boolean canAddToRouteMenu() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public String text;
|
public String text;
|
||||||
public boolean selected;
|
public boolean selected;
|
||||||
public int id;
|
public int id;
|
||||||
|
@ -601,45 +735,24 @@ public class RoutingOptionsHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum AppModeOptions {
|
public static class RouteMenuAppModes {
|
||||||
|
|
||||||
CAR(MuteSoundRoutingParameter.KEY,
|
public ApplicationMode am;
|
||||||
DividerItem.KEY,
|
|
||||||
AvoidRoadsRoutingParameter.KEY,
|
|
||||||
ShowAlongTheRouteItem.KEY,
|
|
||||||
GeneralRouter.ALLOW_PRIVATE,
|
|
||||||
GeneralRouter.USE_SHORTEST_WAY,
|
|
||||||
DividerItem.KEY,
|
|
||||||
GpxLocalRoutingParameter.KEY,
|
|
||||||
OtherSettingsRoutingParameter.KEY,
|
|
||||||
RouteSimulationItem.KEY),
|
|
||||||
|
|
||||||
BICYCLE(MuteSoundRoutingParameter.KEY,
|
public List<LocalRoutingParameter> parameters;
|
||||||
"driving_style",
|
|
||||||
GeneralRouter.USE_HEIGHT_OBSTACLES,
|
|
||||||
DividerItem.KEY,
|
|
||||||
AvoidRoadsTypesRoutingParameter.KEY,
|
|
||||||
ShowAlongTheRouteItem.KEY,
|
|
||||||
DividerItem.KEY,
|
|
||||||
GpxLocalRoutingParameter.KEY,
|
|
||||||
OtherSettingsRoutingParameter.KEY,
|
|
||||||
RouteSimulationItem.KEY),
|
|
||||||
|
|
||||||
PEDESTRIAN(MuteSoundRoutingParameter.KEY,
|
public RouteMenuAppModes(ApplicationMode am, List<LocalRoutingParameter> parameters) {
|
||||||
GeneralRouter.USE_HEIGHT_OBSTACLES,
|
this.am = am;
|
||||||
DividerItem.KEY,
|
this.parameters = parameters;
|
||||||
AvoidRoadsTypesRoutingParameter.KEY,
|
}
|
||||||
ShowAlongTheRouteItem.KEY,
|
|
||||||
DividerItem.KEY,
|
|
||||||
GpxLocalRoutingParameter.KEY,
|
|
||||||
OtherSettingsRoutingParameter.KEY,
|
|
||||||
RouteSimulationItem.KEY);
|
|
||||||
|
|
||||||
|
public boolean containsParameter(LocalRoutingParameter parameter) {
|
||||||
List<String> routingParameters;
|
for (LocalRoutingParameter p : parameters) {
|
||||||
|
if (p.getClass().equals(parameter.getClass())) {
|
||||||
AppModeOptions(String... routingParameters) {
|
return true;
|
||||||
this.routingParameters = Arrays.asList(routingParameters);
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue