diff --git a/OsmAnd/res/drawable/bg_round_btn_dark.xml b/OsmAnd/res/drawable/bg_round_btn_dark.xml
new file mode 100644
index 0000000000..e73b696dd0
--- /dev/null
+++ b/OsmAnd/res/drawable/bg_round_btn_dark.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
diff --git a/OsmAnd/res/drawable/bg_round_btn_light.xml b/OsmAnd/res/drawable/bg_round_btn_light.xml
new file mode 100644
index 0000000000..b6a1875aa5
--- /dev/null
+++ b/OsmAnd/res/drawable/bg_round_btn_light.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
diff --git a/OsmAnd/res/drawable/btn_circle_night_no_shadow.xml b/OsmAnd/res/drawable/btn_circle_night_no_shadow.xml
new file mode 100644
index 0000000000..f3b4395849
--- /dev/null
+++ b/OsmAnd/res/drawable/btn_circle_night_no_shadow.xml
@@ -0,0 +1,13 @@
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/drawable/btn_circle_no_shadow.xml b/OsmAnd/res/drawable/btn_circle_no_shadow.xml
new file mode 100644
index 0000000000..6ba74f9ec9
--- /dev/null
+++ b/OsmAnd/res/drawable/btn_circle_no_shadow.xml
@@ -0,0 +1,13 @@
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/layout-land/map_hud_bottom.xml b/OsmAnd/res/layout-land/map_hud_bottom.xml
index c591d05eda..ec9b4e0c4a 100644
--- a/OsmAnd/res/layout-land/map_hud_bottom.xml
+++ b/OsmAnd/res/layout-land/map_hud_bottom.xml
@@ -110,16 +110,31 @@
android:layout_marginStart="@dimen/map_button_spacing_land"
android:background="@drawable/btn_round"
android:contentDescription="@string/layer_route"
- tools:src="@drawable/ic_action_remove_dark"/>
+ tools:src="@drawable/ic_action_remove_dark" />
+
+
+
+
+
+
+
-
diff --git a/OsmAnd/res/layout/map_hud_bottom.xml b/OsmAnd/res/layout/map_hud_bottom.xml
index dc4be05d64..629f9350a1 100644
--- a/OsmAnd/res/layout/map_hud_bottom.xml
+++ b/OsmAnd/res/layout/map_hud_bottom.xml
@@ -106,15 +106,28 @@
android:contentDescription="@string/layer_route"
tools:src="@drawable/ic_action_remove_dark"/>
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/attrs.xml b/OsmAnd/res/values/attrs.xml
index ae88075cb7..fbcfe713fb 100644
--- a/OsmAnd/res/values/attrs.xml
+++ b/OsmAnd/res/values/attrs.xml
@@ -23,6 +23,7 @@
+
diff --git a/OsmAnd/res/values/styles.xml b/OsmAnd/res/values/styles.xml
index 50432d35a9..330dda3311 100644
--- a/OsmAnd/res/values/styles.xml
+++ b/OsmAnd/res/values/styles.xml
@@ -96,6 +96,7 @@
- @drawable/btn_round_light
- @drawable/btn_round_border_light
- @drawable/btn_round_border_light_2
+ - @drawable/bg_round_btn_light
- @drawable/bg_card_light
- @drawable/context_menu_card_light
- @drawable/bg_map_context_menu_light
@@ -400,6 +401,7 @@
- @drawable/btn_round_dark
- @drawable/btn_round_border_dark
- @drawable/btn_round_border_dark_2
+ - @drawable/bg_round_btn_dark
- @drawable/bg_card_dark
- @drawable/context_menu_card_dark
- @drawable/bg_map_context_menu_dark
diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
index 3102ba3f67..f56eab9797 100644
--- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
+++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java
@@ -22,6 +22,7 @@ import androidx.activity.OnBackPressedCallback;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
+import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;
import androidx.core.widget.TextViewCompat;
import androidx.fragment.app.FragmentManager;
@@ -69,6 +70,7 @@ import net.osmand.plus.measurementtool.command.MovePointCommand;
import net.osmand.plus.measurementtool.command.RemovePointCommand;
import net.osmand.plus.measurementtool.command.ReorderPointCommand;
import net.osmand.plus.measurementtool.command.ReversePointsCommand;
+import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet;
import net.osmand.plus.measurementtool.command.SplitPointsCommand;
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.settings.backend.ApplicationMode;
@@ -232,7 +234,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
return null;
}
final MeasurementToolLayer measurementLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
- OsmandApplication app = mapActivity.getMyApplication();
+ final OsmandApplication app = mapActivity.getMyApplication();
editingCtx.setApplication(mapActivity.getMyApplication());
editingCtx.setProgressListener(new SnapToRoadProgressListener() {
@@ -435,7 +437,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
@Override
public void onMeasure(float distance, float bearing) {
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));
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(
distanceToCenterTv, 14, 18, 2,
@@ -499,7 +501,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
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.setOnClickListener(new OnClickListener() {
@Override
@@ -508,6 +510,31 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
}
});
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);
@@ -1292,17 +1319,24 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
final ApplicationMode appMode = editingCtx.getAppMode();
if (mapActivity != null) {
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 (appMode == MeasurementEditingContext.DEFAULT_APP_MODE) {
icon = getActiveIcon(R.drawable.ic_action_split_interval);
+ snapToRoadBtn.setVisibility(View.VISIBLE);
+ profileWithConfig.setVisibility(View.GONE);
} else {
icon = getIcon(appMode.getIconRes(), appMode.getIconColorInfo().getColor(nightMode));
+ snapToRoadBtn.setVisibility(View.GONE);
+ profileWithConfig.setVisibility(View.VISIBLE);
}
} else {
icon = getContentIcon(R.drawable.ic_action_help);
}
- ImageButton snapToRoadBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
snapToRoadBtn.setImageDrawable(icon);
+ configBtn.setImageDrawable(icon);
mapActivity.refreshMap();
}
}
@@ -1315,6 +1349,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.GONE);
+ mapActivity.findViewById(R.id.profile_with_config_btn).setVisibility(View.GONE);
}
}
diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java
index 04a5d75ba5..6355cf65db 100644
--- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java
+++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java
@@ -1,6 +1,7 @@
package net.osmand.plus.routepreparationmenu;
import android.app.Activity;
+import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Build;
@@ -12,12 +13,15 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.ColorRes;
+import androidx.annotation.NonNull;
import androidx.appcompat.widget.SwitchCompat;
import androidx.core.content.ContextCompat;
+import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import net.osmand.AndroidUtils;
import net.osmand.GPXUtilities.GPXFile;
+import net.osmand.PlatformUtil;
import net.osmand.StateChangedListener;
import net.osmand.plus.OsmAndLocationSimulation;
import net.osmand.plus.OsmandApplication;
@@ -32,6 +36,7 @@ import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerStartItem;
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.AvoidRoadsRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.DividerItem;
@@ -54,12 +59,16 @@ import net.osmand.router.GeneralRouter;
import net.osmand.router.GeneralRouter.RoutingParameter;
import net.osmand.util.Algorithms;
+import org.apache.commons.logging.Log;
+
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
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.settings.fragments.RouteParametersFragment.RELIEF_SMOOTHNESS_FACTOR;
import static net.osmand.plus.settings.fragments.RouteParametersFragment.getRoutingParameterTitle;
@@ -68,7 +77,10 @@ import static net.osmand.router.GeneralRouter.USE_HEIGHT_OBSTACLES;
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 OsmandSettings settings;
@@ -83,17 +95,28 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private CommonPreference useHeightPref;
private StateChangedListener voiceMuteChangeListener;
private StateChangedListener useHeightChangeListener;
+ private boolean planRouteMode;
private List reliefParameters = new ArrayList<>();
@Override
public void onCreate(Bundle 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);
+ planRouteMode = true;
+ }
+ }
app = requiredMyApplication();
settings = app.getSettings();
routingHelper = app.getRoutingHelper();
routingOptionsHelper = app.getRoutingOptionsHelper();
mapActivity = getMapActivity();
- applicationMode = routingHelper.getAppMode();
+ if (applicationMode == null) {
+ applicationMode = routingHelper.getAppMode();
+ }
selectedModeColorId = applicationMode.getIconColorInfo().getColor(nightMode);
voiceMuteChangeListener = new StateChangedListener() {
@Override
@@ -121,17 +144,23 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
if (optionsItem instanceof DividerItem) {
items.add(new DividerStartItem(app));
} else if (optionsItem instanceof MuteSoundRoutingParameter) {
- items.add(createMuteSoundItem(optionsItem));
+ if (!planRouteMode) {
+ items.add(createMuteSoundItem(optionsItem));
+ }
} else if (optionsItem instanceof ShowAlongTheRouteItem) {
items.add(createShowAlongTheRouteItem(optionsItem));
} else if (optionsItem instanceof RouteSimulationItem) {
- items.add(createRouteSimulationItem(optionsItem));
+ if (!planRouteMode) {
+ items.add(createRouteSimulationItem(optionsItem));
+ }
} else if (optionsItem instanceof AvoidPTTypesRoutingParameter) {
items.add(createAvoidPTTypesItem(optionsItem));
} else if (optionsItem instanceof AvoidRoadsRoutingParameter) {
items.add(createAvoidRoadsItem(optionsItem));
} else if (optionsItem instanceof GpxLocalRoutingParameter) {
- items.add(createGpxRoutingItem(optionsItem));
+ if (!planRouteMode) {
+ items.add(createGpxRoutingItem(optionsItem));
+ }
} else if (optionsItem instanceof TimeConditionalRoutingItem) {
items.add(createTimeConditionalRoutingItem(optionsItem));
} else if (optionsItem instanceof OtherSettingsRoutingParameter) {
@@ -478,8 +507,10 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
@Override
public void onClick(View view) {
dismiss();
+ Bundle args = new Bundle();
+ args.putBoolean(PLANE_ROUTE, planRouteMode);
BaseSettingsFragment.showInstance(mapActivity, BaseSettingsFragment.SettingsScreenType.NAVIGATION,
- mapActivity.getRoutingHelper().getAppMode());
+ applicationMode, args);
}
})
.create();
@@ -576,6 +607,23 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
if (mapActivity != null) {
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);
+ if (fragment != null) {
+ ((MeasurementToolFragment) fragment).onChangeApplicationMode(applicationMode, WHOLE_ROUTE_CALCULATION, ALL);
+ }
+ }
}
private List getRoutingParameters(ApplicationMode applicationMode) {
@@ -610,8 +658,21 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
}
public static void showInstance(FragmentManager fragmentManager) {
- RouteOptionsBottomSheet f = new RouteOptionsBottomSheet();
- f.show(fragmentManager, RouteOptionsBottomSheet.TAG);
+ showInstance(fragmentManager, null);
+ }
+
+ 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() {
diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/NavigationFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/NavigationFragment.java
index cb9aba42dd..08ea81a092 100644
--- a/OsmAnd/src/net/osmand/plus/settings/fragments/NavigationFragment.java
+++ b/OsmAnd/src/net/osmand/plus/settings/fragments/NavigationFragment.java
@@ -3,9 +3,11 @@ package net.osmand.plus.settings.fragments;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
+import androidx.activity.OnBackPressedCallback;
import androidx.preference.Preference;
import androidx.preference.SwitchPreferenceCompat;
+import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet;
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.OsmandApplication;
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.SELECTED_KEY;
import static net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment.TYPE_NAV_PROFILE;
+import static net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet.PLANE_ROUTE;
public class NavigationFragment extends BaseSettingsFragment {
@@ -48,6 +51,16 @@ public class NavigationFragment extends BaseSettingsFragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
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();
+ }
+ });
}
@Override