Fix back to context menu from gpx menu

This commit is contained in:
Vitaliy 2021-01-28 14:33:31 +02:00
parent 1b1ed6e02f
commit d2aa6c331e
2 changed files with 9 additions and 7 deletions

View file

@ -42,9 +42,7 @@ public class SelectedGpxMenuController extends MenuController {
leftTitleButtonController = new TitleButtonController() { leftTitleButtonController = new TitleButtonController() {
@Override @Override
public void buttonPressed() { public void buttonPressed() {
SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile(); TrackMenuFragment.showInstance(mapActivity, selectedGpxPoint.getSelectedGpxFile());
mapActivity.getContextMenu().hide(false);
TrackMenuFragment.showInstance(mapActivity, selectedGpxFile.getGpxFile().path, selectedGpxFile.isShowCurrentTrack());
} }
}; };
leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track); leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track);

View file

@ -227,11 +227,15 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
FragmentActivity activity = requireMyActivity(); FragmentActivity activity = requireMyActivity();
activity.getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) { activity.getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
public void handleOnBackPressed() { public void handleOnBackPressed() {
MapActivity mapActivity = getMapActivity(); if (getCurrentMenuState() != MenuState.HEADER_ONLY && isPortrait()) {
if (mapActivity != null) { openMenuHeaderOnly();
mapActivity.launchPrevActivityIntent(); } else {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null && mapActivity.getSupportFragmentManager().getBackStackEntryCount() == 1) {
mapActivity.launchPrevActivityIntent();
}
dismiss();
} }
dismiss();
} }
}); });
} }