diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java index 427e0cce35..acdce38b90 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java @@ -42,9 +42,7 @@ public class SelectedGpxMenuController extends MenuController { leftTitleButtonController = new TitleButtonController() { @Override public void buttonPressed() { - SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile(); - mapActivity.getContextMenu().hide(false); - TrackMenuFragment.showInstance(mapActivity, selectedGpxFile.getGpxFile().path, selectedGpxFile.isShowCurrentTrack()); + TrackMenuFragment.showInstance(mapActivity, selectedGpxPoint.getSelectedGpxFile()); } }; leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track); diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 533268fd62..b145fc903d 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -227,11 +227,15 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card FragmentActivity activity = requireMyActivity(); activity.getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) { public void handleOnBackPressed() { - MapActivity mapActivity = getMapActivity(); - if (mapActivity != null) { - mapActivity.launchPrevActivityIntent(); + if (getCurrentMenuState() != MenuState.HEADER_ONLY && isPortrait()) { + openMenuHeaderOnly(); + } else { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null && mapActivity.getSupportFragmentManager().getBackStackEntryCount() == 1) { + mapActivity.launchPrevActivityIntent(); + } + dismiss(); } - dismiss(); } }); }