Don't show fragment name on back button, but return after back button was pressed
This commit is contained in:
parent
ec9076dc2b
commit
a0386129df
5 changed files with 24 additions and 11 deletions
|
@ -259,7 +259,7 @@ public class IntentHelper {
|
|||
String path = intent.getStringExtra(TRACK_FILE_NAME);
|
||||
String name = intent.getStringExtra(RETURN_SCREEN_NAME);
|
||||
boolean currentRecording = intent.getBooleanExtra(CURRENT_RECORDING, false);
|
||||
TrackMenuFragment.showInstance(mapActivity, path, currentRecording, null, name);
|
||||
TrackMenuFragment.showInstance(mapActivity, path, currentRecording, null, name, null);
|
||||
mapActivity.setIntent(null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class SelectedGpxMenuController extends MenuController {
|
|||
LatLon latLon = new LatLon(wptPt.lat, wptPt.lon);
|
||||
SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile();
|
||||
String path = selectedGpxFile.getGpxFile().path;
|
||||
TrackMenuFragment.showInstance(mapActivity, path, selectedGpxFile.isShowCurrentTrack(), latLon, null);
|
||||
TrackMenuFragment.showInstance(mapActivity, path, selectedGpxFile.isShowCurrentTrack(), latLon, null, null);
|
||||
}
|
||||
};
|
||||
leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track);
|
||||
|
|
|
@ -50,7 +50,7 @@ public class WptPtMenuController extends MenuController {
|
|||
SelectedGpxFile selectedGpxFile = selectionHelper.getSelectedGPXFile(wpt);
|
||||
if (selectedGpxFile != null) {
|
||||
String path = selectedGpxFile.getGpxFile().path;
|
||||
TrackMenuFragment.showInstance(mapActivity, path, selectedGpxFile.isShowCurrentTrack(), new LatLon(wpt.lon, wpt.lat), null);
|
||||
TrackMenuFragment.showInstance(mapActivity, path, selectedGpxFile.isShowCurrentTrack(), new LatLon(wpt.lon, wpt.lat), null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -306,7 +306,7 @@ public abstract class QuickSearchListFragment extends OsmAndListFragment {
|
|||
SearchHistoryHelper.getInstance(app).addNewItemToHistory(gpxInfo);
|
||||
File file = new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), gpxInfo.getFileName());
|
||||
String path = file.getAbsolutePath();
|
||||
TrackMenuFragment.showInstance(mapActivity, path, false, null, QuickSearchDialogFragment.TAG);
|
||||
TrackMenuFragment.showInstance(mapActivity, path, false, null, null, QuickSearchDialogFragment.TAG);
|
||||
dialogFragment.dismiss();
|
||||
}
|
||||
|
||||
|
|
|
@ -154,6 +154,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
|
||||
private String gpxTitle;
|
||||
private String returnScreenName;
|
||||
private String callingFragmentTag;
|
||||
private TrackChartPoints trackChartPoints;
|
||||
|
||||
private Float heading;
|
||||
|
@ -272,7 +273,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
if (contextMenu.isActive() && contextMenu.getPointDescription() != null
|
||||
&& contextMenu.getPointDescription().isGpxPoint()) {
|
||||
contextMenu.show();
|
||||
} else if (Algorithms.objectEquals(returnScreenName, QuickSearchDialogFragment.TAG)) {
|
||||
} else if (Algorithms.objectEquals(callingFragmentTag, QuickSearchDialogFragment.TAG)) {
|
||||
mapActivity.showQuickSearch(ShowQuickSearchMode.CURRENT, false);
|
||||
} else {
|
||||
mapActivity.launchPrevActivityIntent();
|
||||
|
@ -311,6 +312,10 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
this.returnScreenName = returnScreenName;
|
||||
}
|
||||
|
||||
public void setCallingFragmentTag(String callingFragmentTag) {
|
||||
this.callingFragmentTag = callingFragmentTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
@ -1259,7 +1264,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
boolean currentRecording = file == null;
|
||||
String path = file != null ? file.getAbsolutePath() : null;
|
||||
if (context instanceof MapActivity) {
|
||||
TrackMenuFragment.showInstance((MapActivity) context, path, currentRecording, null, null);
|
||||
TrackMenuFragment.showInstance((MapActivity) context, path, currentRecording, null, null, null);
|
||||
} else {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(TRACK_FILE_NAME, path);
|
||||
|
@ -1307,23 +1312,30 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
}
|
||||
}
|
||||
|
||||
public static void showInstance(@NonNull MapActivity mapActivity, @Nullable String path,
|
||||
boolean showCurrentTrack, @Nullable final LatLon latLon, @Nullable final String returnScreenName) {
|
||||
public static void showInstance(@NonNull MapActivity mapActivity,
|
||||
@Nullable String path,
|
||||
boolean showCurrentTrack,
|
||||
@Nullable final LatLon latLon,
|
||||
@Nullable final String returnScreenName,
|
||||
@Nullable final String callingFragmentTag) {
|
||||
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
||||
loadSelectedGpxFile(mapActivity, path, showCurrentTrack, new CallbackWithObject<SelectedGpxFile>() {
|
||||
@Override
|
||||
public boolean processResult(SelectedGpxFile selectedGpxFile) {
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
if (mapActivity != null && selectedGpxFile != null) {
|
||||
showInstance(mapActivity, selectedGpxFile, latLon, returnScreenName);
|
||||
showInstance(mapActivity, selectedGpxFile, latLon, returnScreenName, callingFragmentTag);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean showInstance(@NonNull MapActivity mapActivity, @NonNull SelectedGpxFile selectedGpxFile,
|
||||
@Nullable LatLon latLon, @Nullable String returnScreenName) {
|
||||
public static boolean showInstance(@NonNull MapActivity mapActivity,
|
||||
@NonNull SelectedGpxFile selectedGpxFile,
|
||||
@Nullable LatLon latLon,
|
||||
@Nullable String returnScreenName,
|
||||
@Nullable String callingFragmentTag) {
|
||||
try {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HEADER_ONLY);
|
||||
|
@ -1333,6 +1345,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
|||
fragment.setRetainInstance(true);
|
||||
fragment.setSelectedGpxFile(selectedGpxFile);
|
||||
fragment.setReturnScreenName(returnScreenName);
|
||||
fragment.setCallingFragmentTag(callingFragmentTag);
|
||||
|
||||
if (latLon != null) {
|
||||
fragment.setLatLon(latLon);
|
||||
|
|
Loading…
Reference in a new issue