Plan route config profile

This commit is contained in:
Dima-1 2020-12-07 10:11:10 +02:00
parent abbe0ccf95
commit 892ff7addb
12 changed files with 257 additions and 30 deletions

View file

@ -0,0 +1,10 @@
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="@dimen/map_button_inset_shadow"
android:insetTop="@dimen/map_button_inset_shadow"
android:insetRight="@dimen/map_button_inset_shadow"
android:insetBottom="@dimen/map_button_inset_shadow">
<shape android:shape="rectangle">
<solid android:color="@color/map_widget_dark" />
<corners android:radius="48dp" />
</shape>
</inset>

View file

@ -0,0 +1,10 @@
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="@dimen/map_button_inset_shadow"
android:insetTop="@dimen/map_button_inset_shadow"
android:insetRight="@dimen/map_button_inset_shadow"
android:insetBottom="@dimen/map_button_inset_shadow">
<shape android:shape="rectangle">
<solid android:color="@color/map_widget_light" />
<corners android:radius="48dp" />
</shape>
</inset>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="oval">
<solid android:color="@color/map_widget_dark_pressed" />
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="@color/color_transparent" />
</shape>
</item>
</selector>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="oval">
<solid android:color="@color/map_widget_light_pressed" />
</shape>
</item>
<item>
<shape android:shape="oval">
<solid android:color="@color/map_widget_light" />
</shape>
</item>
</selector>

View file

@ -112,6 +112,10 @@
android:contentDescription="@string/layer_route" android:contentDescription="@string/layer_route"
tools:src="@drawable/ic_action_remove_dark" /> tools:src="@drawable/ic_action_remove_dark" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageButton <ImageButton
android:id="@+id/snap_to_road_image_button" android:id="@+id/snap_to_road_image_button"
android:layout_width="@dimen/map_button_size" android:layout_width="@dimen/map_button_size"
@ -119,7 +123,18 @@
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:background="@drawable/btn_circle" android:background="@drawable/btn_circle"
android:visibility="gone" android:visibility="gone"
tools:src="@drawable/ic_action_remove_dark"/> tools:src="@drawable/ic_action_remove_dark"
android:contentDescription="@string/snap_to_road" />
<include
android:id="@+id/profile_with_config_btn"
android:layout_width="wrap_content"
android:layout_height="@dimen/map_button_size"
android:layout_gravity="bottom"
layout="@layout/profile_with_config_btn_layout"
android:visibility="gone" />
</FrameLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>

View file

@ -106,6 +106,10 @@
android:contentDescription="@string/layer_route" android:contentDescription="@string/layer_route"
tools:src="@drawable/ic_action_remove_dark"/> tools:src="@drawable/ic_action_remove_dark"/>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageButton <ImageButton
android:id="@+id/snap_to_road_image_button" android:id="@+id/snap_to_road_image_button"
android:layout_width="@dimen/map_button_size" android:layout_width="@dimen/map_button_size"
@ -116,6 +120,15 @@
tools:src="@drawable/ic_action_remove_dark" tools:src="@drawable/ic_action_remove_dark"
android:contentDescription="@string/snap_to_road" /> android:contentDescription="@string/snap_to_road" />
<include
android:id="@+id/profile_with_config_btn"
android:layout_width="wrap_content"
android:layout_height="@dimen/map_button_size"
android:layout_gravity="bottom"
layout="@layout/profile_with_config_btn_layout"
android:visibility="gone" />
</FrameLayout>
<LinearLayout <LinearLayout
android:id="@+id/map_ruler_container" android:id="@+id/map_ruler_container"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View file

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/btn_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="2dp">
<ImageButton
android:id="@+id/profile"
android:layout_width="@dimen/map_route_buttons_height_land"
android:layout_height="@dimen/map_route_buttons_height_land"
app:srcCompat="@drawable/ic_action_car_dark"
android:background="@color/color_transparent"
android:contentDescription="@string/app_modes_choose"/>
<View
android:id="@+id/divider"
android:layout_width="1dp"
android:layout_height="24dp"
android:background="?attr/divider_color"
android:layout_gravity="center_vertical"/>
<ImageButton
android:id="@+id/profile_config"
android:layout_width="@dimen/map_route_buttons_height_land"
android:layout_height="@dimen/map_route_buttons_height_land"
app:srcCompat="@drawable/ic_action_settings"
android:background="@color/color_transparent"
android:contentDescription="@string/configure_profile" />
</LinearLayout>
</LinearLayout>

View file

@ -23,6 +23,7 @@
<attr name="btn_round" format="reference" /> <attr name="btn_round" format="reference" />
<attr name="btn_round_border" format="reference" /> <attr name="btn_round_border" format="reference" />
<attr name="btn_round_border_2" format="reference" /> <attr name="btn_round_border_2" format="reference" />
<attr name="bg_round_btn" format="reference" />
<attr name="bg_card" format="reference" /> <attr name="bg_card" format="reference" />
<attr name="context_menu_card" format="reference" /> <attr name="context_menu_card" format="reference" />
<attr name="ctx_menu_card_btn" format="reference" /> <attr name="ctx_menu_card_btn" format="reference" />

View file

@ -96,6 +96,7 @@
<item name="btn_round">@drawable/btn_round_light</item> <item name="btn_round">@drawable/btn_round_light</item>
<item name="btn_round_border">@drawable/btn_round_border_light</item> <item name="btn_round_border">@drawable/btn_round_border_light</item>
<item name="btn_round_border_2">@drawable/btn_round_border_light_2</item> <item name="btn_round_border_2">@drawable/btn_round_border_light_2</item>
<item name="bg_round_btn">@drawable/bg_round_btn_light</item>
<item name="bg_card">@drawable/bg_card_light</item> <item name="bg_card">@drawable/bg_card_light</item>
<item name="context_menu_card">@drawable/context_menu_card_light</item> <item name="context_menu_card">@drawable/context_menu_card_light</item>
<item name="bg_map_context_menu">@drawable/bg_map_context_menu_light</item> <item name="bg_map_context_menu">@drawable/bg_map_context_menu_light</item>
@ -400,6 +401,7 @@
<item name="btn_round">@drawable/btn_round_dark</item> <item name="btn_round">@drawable/btn_round_dark</item>
<item name="btn_round_border">@drawable/btn_round_border_dark</item> <item name="btn_round_border">@drawable/btn_round_border_dark</item>
<item name="btn_round_border_2">@drawable/btn_round_border_dark_2</item> <item name="btn_round_border_2">@drawable/btn_round_border_dark_2</item>
<item name="bg_round_btn">@drawable/bg_round_btn_dark</item>
<item name="bg_card">@drawable/bg_card_dark</item> <item name="bg_card">@drawable/bg_card_dark</item>
<item name="context_menu_card">@drawable/context_menu_card_dark</item> <item name="context_menu_card">@drawable/context_menu_card_dark</item>
<item name="bg_map_context_menu">@drawable/bg_map_context_menu_dark</item> <item name="bg_map_context_menu">@drawable/bg_map_context_menu_dark</item>

View file

@ -22,6 +22,7 @@ import androidx.activity.OnBackPressedCallback;
import androidx.annotation.DrawableRes; import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.widget.TextViewCompat; import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
@ -68,6 +69,7 @@ import net.osmand.plus.measurementtool.command.MovePointCommand;
import net.osmand.plus.measurementtool.command.RemovePointCommand; import net.osmand.plus.measurementtool.command.RemovePointCommand;
import net.osmand.plus.measurementtool.command.ReorderPointCommand; import net.osmand.plus.measurementtool.command.ReorderPointCommand;
import net.osmand.plus.measurementtool.command.ReversePointsCommand; import net.osmand.plus.measurementtool.command.ReversePointsCommand;
import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet;
import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;
@ -230,7 +232,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
return null; return null;
} }
final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer(); final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
OsmandApplication app = mapActivity.getMyApplication(); final OsmandApplication app = mapActivity.getMyApplication();
editingCtx.setApplication(mapActivity.getMyApplication()); editingCtx.setApplication(mapActivity.getMyApplication());
editingCtx.setProgressListener(new SnapToRoadProgressListener() { editingCtx.setProgressListener(new SnapToRoadProgressListener() {
@ -432,7 +434,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
@Override @Override
public void onMeasure(float distance, float bearing) { public void onMeasure(float distance, float bearing) {
String distStr = OsmAndFormatter.getFormattedDistance(distance, mapActivity.getMyApplication()); String distStr = OsmAndFormatter.getFormattedDistance(distance, mapActivity.getMyApplication());
String azimuthStr = OsmAndFormatter.getFormattedAzimuth(bearing, getMyApplication()); String azimuthStr = OsmAndFormatter.getFormattedAzimuth(bearing, app);
distanceToCenterTv.setText(String.format("%1$s • %2$s", distStr, azimuthStr)); distanceToCenterTv.setText(String.format("%1$s • %2$s", distStr, azimuthStr));
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration( TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(
distanceToCenterTv, 14, 18, 2, distanceToCenterTv, 14, 18, 2,
@ -496,7 +498,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
final GpxData gpxData = editingCtx.getGpxData(); final GpxData gpxData = editingCtx.getGpxData();
ImageButton snapToRoadBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button); ImageButton snapToRoadBtn = mapActivity.findViewById(R.id.snap_to_road_image_button);
snapToRoadBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle); snapToRoadBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle);
snapToRoadBtn.setOnClickListener(new OnClickListener() { snapToRoadBtn.setOnClickListener(new OnClickListener() {
@Override @Override
@ -505,6 +507,31 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
} }
}); });
snapToRoadBtn.setVisibility(View.VISIBLE); snapToRoadBtn.setVisibility(View.VISIBLE);
LinearLayout profileWithConfig = mapActivity.findViewById(R.id.profile_with_config_btn);
View background = profileWithConfig.findViewById(R.id.btn_background);
AndroidUtils.setBackground(background, AppCompatResources.getDrawable(view.getContext(),
AndroidUtils.resolveAttribute(view.getContext(), R.attr.bg_round_btn)));
View divider = profileWithConfig.findViewById(R.id.divider);
divider.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), R.attr.divider_color));
ImageButton profileBtn = profileWithConfig.findViewById(R.id.profile);
profileBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night_no_shadow : R.drawable.btn_circle_no_shadow);
profileBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
startSnapToRoad(false);
}
});
ImageButton configBtn = profileWithConfig.findViewById(R.id.profile_config);
configBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night_no_shadow : R.drawable.btn_circle_no_shadow);
configBtn.setImageDrawable(getContentIcon(R.drawable.ic_action_settings));
configBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
RouteOptionsBottomSheet.showInstance(mapActivity.getSupportFragmentManager(),
editingCtx.getAppMode().getStringKey());
}
});
initMeasurementMode(gpxData, savedInstanceState == null); initMeasurementMode(gpxData, savedInstanceState == null);
@ -1251,17 +1278,24 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
final ApplicationMode appMode = editingCtx.getAppMode(); final ApplicationMode appMode = editingCtx.getAppMode();
if (mapActivity != null) { if (mapActivity != null) {
Drawable icon; Drawable icon;
ImageButton snapToRoadBtn = mapActivity.findViewById(R.id.snap_to_road_image_button);
LinearLayout profileWithConfig = mapActivity.findViewById(R.id.profile_with_config_btn);
ImageButton configBtn = profileWithConfig.findViewById(R.id.profile);
if (isTrackReadyToCalculate()) { if (isTrackReadyToCalculate()) {
if (appMode == MeasurementEditingContext.DEFAULT_APP_MODE) { if (appMode == MeasurementEditingContext.DEFAULT_APP_MODE) {
icon = getActiveIcon(R.drawable.ic_action_split_interval); icon = getActiveIcon(R.drawable.ic_action_split_interval);
snapToRoadBtn.setVisibility(View.VISIBLE);
profileWithConfig.setVisibility(View.GONE);
} else { } else {
icon = getIcon(appMode.getIconRes(), appMode.getIconColorInfo().getColor(nightMode)); icon = getIcon(appMode.getIconRes(), appMode.getIconColorInfo().getColor(nightMode));
snapToRoadBtn.setVisibility(View.GONE);
profileWithConfig.setVisibility(View.VISIBLE);
} }
} else { } else {
icon = getContentIcon(R.drawable.ic_action_help); icon = getContentIcon(R.drawable.ic_action_help);
} }
ImageButton snapToRoadBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
snapToRoadBtn.setImageDrawable(icon); snapToRoadBtn.setImageDrawable(icon);
configBtn.setImageDrawable(icon);
mapActivity.refreshMap(); mapActivity.refreshMap();
} }
} }
@ -1274,6 +1308,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { if (mapActivity != null) {
mapActivity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.GONE); mapActivity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.GONE);
mapActivity.findViewById(R.id.profile_with_config_btn).setVisibility(View.GONE);
} }
} }

View file

@ -1,6 +1,7 @@
package net.osmand.plus.routepreparationmenu; package net.osmand.plus.routepreparationmenu;
import android.app.Activity; import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
@ -12,11 +13,14 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.ColorRes; import androidx.annotation.ColorRes;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXFile;
import net.osmand.PlatformUtil;
import net.osmand.StateChangedListener; import net.osmand.StateChangedListener;
import net.osmand.plus.OsmAndLocationSimulation; import net.osmand.plus.OsmAndLocationSimulation;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -31,6 +35,7 @@ import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerStartItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerStartItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.measurementtool.MeasurementToolFragment;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidPTTypesRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.AvoidRoadsRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DividerItem; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DividerItem;
@ -53,18 +58,25 @@ import net.osmand.router.GeneralRouter;
import net.osmand.router.GeneralRouter.RoutingParameter; import net.osmand.router.GeneralRouter.RoutingParameter;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static net.osmand.plus.measurementtool.RouteBetweenPointsBottomSheetDialogFragment.RouteBetweenPointsDialogMode.ALL;
import static net.osmand.plus.measurementtool.RouteBetweenPointsBottomSheetDialogFragment.RouteBetweenPointsDialogType.WHOLE_ROUTE_CALCULATION;
import static net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DRIVING_STYLE; import static net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DRIVING_STYLE;
import static net.osmand.plus.settings.fragments.RouteParametersFragment.RELIEF_SMOOTHNESS_FACTOR; import static net.osmand.plus.settings.fragments.RouteParametersFragment.RELIEF_SMOOTHNESS_FACTOR;
import static net.osmand.router.GeneralRouter.USE_HEIGHT_OBSTACLES; import static net.osmand.router.GeneralRouter.USE_HEIGHT_OBSTACLES;
public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
public static final String TAG = "RouteOptionsBottomSheet"; public static final String TAG = RouteOptionsBottomSheet.class.getSimpleName();
private static final Log LOG = PlatformUtil.getLog(RouteOptionsBottomSheet.class);
public static final String APP_MODE_KEY = "APP_MODE_KEY";
public static final String PLANE_ROUTE = "PLANE_ROUTE";
private OsmandApplication app; private OsmandApplication app;
private OsmandSettings settings; private OsmandSettings settings;
@ -79,16 +91,27 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private CommonPreference<Boolean> useHeightPref; private CommonPreference<Boolean> useHeightPref;
private StateChangedListener<Boolean> voiceMuteChangeListener; private StateChangedListener<Boolean> voiceMuteChangeListener;
private StateChangedListener<Boolean> useHeightChangeListener; private StateChangedListener<Boolean> useHeightChangeListener;
private boolean planeRouteMode;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Bundle args = getArguments();
if (args != null) {
String appMode = args.getString(APP_MODE_KEY, null);
if (appMode != null) {
applicationMode = ApplicationMode.valueOfStringKey(appMode, null);
planeRouteMode = true;
}
}
app = requiredMyApplication(); app = requiredMyApplication();
settings = app.getSettings(); settings = app.getSettings();
routingHelper = app.getRoutingHelper(); routingHelper = app.getRoutingHelper();
routingOptionsHelper = app.getRoutingOptionsHelper(); routingOptionsHelper = app.getRoutingOptionsHelper();
mapActivity = getMapActivity(); mapActivity = getMapActivity();
if (applicationMode == null) {
applicationMode = routingHelper.getAppMode(); applicationMode = routingHelper.getAppMode();
}
selectedModeColorId = applicationMode.getIconColorInfo().getColor(nightMode); selectedModeColorId = applicationMode.getIconColorInfo().getColor(nightMode);
voiceMuteChangeListener = new StateChangedListener<Boolean>() { voiceMuteChangeListener = new StateChangedListener<Boolean>() {
@Override @Override
@ -115,17 +138,29 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
if (optionsItem instanceof DividerItem) { if (optionsItem instanceof DividerItem) {
items.add(new DividerStartItem(app)); items.add(new DividerStartItem(app));
} else if (optionsItem instanceof MuteSoundRoutingParameter) { } else if (optionsItem instanceof MuteSoundRoutingParameter) {
if (!planeRouteMode) {
items.add(createMuteSoundItem(optionsItem)); items.add(createMuteSoundItem(optionsItem));
} else {
continue;
}
} else if (optionsItem instanceof ShowAlongTheRouteItem) { } else if (optionsItem instanceof ShowAlongTheRouteItem) {
items.add(createShowAlongTheRouteItem(optionsItem)); items.add(createShowAlongTheRouteItem(optionsItem));
} else if (optionsItem instanceof RouteSimulationItem) { } else if (optionsItem instanceof RouteSimulationItem) {
if (!planeRouteMode) {
items.add(createRouteSimulationItem(optionsItem)); items.add(createRouteSimulationItem(optionsItem));
} else {
continue;
}
} else if (optionsItem instanceof AvoidPTTypesRoutingParameter) { } else if (optionsItem instanceof AvoidPTTypesRoutingParameter) {
items.add(createAvoidPTTypesItem(optionsItem)); items.add(createAvoidPTTypesItem(optionsItem));
} else if (optionsItem instanceof AvoidRoadsRoutingParameter) { } else if (optionsItem instanceof AvoidRoadsRoutingParameter) {
items.add(createAvoidRoadsItem(optionsItem)); items.add(createAvoidRoadsItem(optionsItem));
} else if (optionsItem instanceof GpxLocalRoutingParameter) { } else if (optionsItem instanceof GpxLocalRoutingParameter) {
if (!planeRouteMode) {
items.add(createGpxRoutingItem(optionsItem)); items.add(createGpxRoutingItem(optionsItem));
} else {
continue;
}
} else if (optionsItem instanceof TimeConditionalRoutingItem) { } else if (optionsItem instanceof TimeConditionalRoutingItem) {
items.add(createTimeConditionalRoutingItem(optionsItem)); items.add(createTimeConditionalRoutingItem(optionsItem));
} else if (optionsItem instanceof OtherSettingsRoutingParameter) { } else if (optionsItem instanceof OtherSettingsRoutingParameter) {
@ -415,8 +450,10 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
dismiss(); dismiss();
Bundle args = new Bundle();
args.putBoolean(PLANE_ROUTE, true);
BaseSettingsFragment.showInstance(mapActivity, BaseSettingsFragment.SettingsScreenType.NAVIGATION, BaseSettingsFragment.showInstance(mapActivity, BaseSettingsFragment.SettingsScreenType.NAVIGATION,
mapActivity.getRoutingHelper().getAppMode()); applicationMode, args);
} }
}) })
.create(); .create();
@ -515,6 +552,21 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
if (mapActivity != null) { if (mapActivity != null) {
mapActivity.getMapRouteInfoMenu().updateMenu(); mapActivity.getMapRouteInfoMenu().updateMenu();
} }
}
@Override
public void onDismiss(@NonNull DialogInterface dialog) {
super.onDismiss(dialog);
updatePlanRoute();
}
private void updatePlanRoute() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
Fragment fragment = mapActivity.getSupportFragmentManager().findFragmentByTag(MeasurementToolFragment.TAG);
((MeasurementToolFragment) fragment).onChangeApplicationMode(applicationMode, WHOLE_ROUTE_CALCULATION, ALL);
}
} }
private List<LocalRoutingParameter> getRoutingParameters(ApplicationMode applicationMode) { private List<LocalRoutingParameter> getRoutingParameters(ApplicationMode applicationMode) {
@ -549,8 +601,21 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
} }
public static void showInstance(FragmentManager fragmentManager) { public static void showInstance(FragmentManager fragmentManager) {
RouteOptionsBottomSheet f = new RouteOptionsBottomSheet(); showInstance(fragmentManager, null);
f.show(fragmentManager, RouteOptionsBottomSheet.TAG); }
public static void showInstance(FragmentManager fm, String appModeKey) {
try {
if (!fm.isStateSaved()) {
RouteOptionsBottomSheet fragment = new RouteOptionsBottomSheet();
Bundle args = new Bundle();
args.putString(APP_MODE_KEY, appModeKey);
fragment.setArguments(args);
fragment.show(fm, TAG);
}
} catch (RuntimeException e) {
LOG.error("showInstance", e);
}
} }
public void updateParameters() { public void updateParameters() {

View file

@ -3,9 +3,11 @@ package net.osmand.plus.settings.fragments;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import androidx.activity.OnBackPressedCallback;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.SwitchPreferenceCompat; import androidx.preference.SwitchPreferenceCompat;
import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
@ -33,6 +35,7 @@ import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.IS
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.PROFILE_KEY_ARG; import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.PROFILE_KEY_ARG;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SELECTED_KEY; import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.SELECTED_KEY;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_NAV_PROFILE; import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_NAV_PROFILE;
import static net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet.PLANE_ROUTE;
public class NavigationFragment extends BaseSettingsFragment { public class NavigationFragment extends BaseSettingsFragment {
@ -48,6 +51,18 @@ public class NavigationFragment extends BaseSettingsFragment {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
routingProfileDataObjects = getRoutingProfiles(app); routingProfileDataObjects = getRoutingProfiles(app);
requireMyActivity().getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
public void handleOnBackPressed() {
Bundle args = getArguments();
if (args != null && args.getBoolean(PLANE_ROUTE, false)) {
RouteOptionsBottomSheet.showInstance(getMapActivity().getSupportFragmentManager(),
getSelectedAppMode().getStringKey());
dismiss();
} else {
getActivity().onBackPressed();
}
}
});
} }
@Override @Override