From ec9076dc2babddd7ac8806351f5a58cff14f04bc Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 12 Mar 2021 13:00:21 +0200 Subject: [PATCH 1/3] Use correct gpx title in search history --- OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java index c9a3d1d5e9..7afc51de6c 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListAdapter.java @@ -416,7 +416,8 @@ public class QuickSearchListAdapter extends ArrayAdapter { LinearLayout view = getLinearLayout(convertView, R.layout.search_gpx_list_item); SearchResult sr = listItem.getSearchResult(); setupCheckBox(position, view, listItem); - GpxUiHelper.updateGpxInfoView(app, view, sr.localeName, listItem.getIcon(), gpxInfo); + String gpxTitle = GpxUiHelper.getGpxTitle(sr.localeName); + GpxUiHelper.updateGpxInfoView(app, view, gpxTitle, listItem.getIcon(), gpxInfo); return view; } From a0386129df212c00b33f7c584e42d0c3cd184ebc Mon Sep 17 00:00:00 2001 From: nazar-kutz Date: Fri, 12 Mar 2021 13:17:42 +0200 Subject: [PATCH 2/3] Don't show fragment name on back button, but return after back button was pressed --- .../net/osmand/plus/helpers/IntentHelper.java | 2 +- .../SelectedGpxMenuController.java | 2 +- .../controllers/WptPtMenuController.java | 2 +- .../plus/search/QuickSearchListFragment.java | 2 +- .../osmand/plus/track/TrackMenuFragment.java | 27 ++++++++++++++----- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java b/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java index 1d6f5dc862..f02b5b0961 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java @@ -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); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java index 487689d22d..5fc74c9db9 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java index 8442f93334..d9ad62cad9 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/WptPtMenuController.java @@ -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); } } } diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java index 410f011154..89e918284c 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchListFragment.java @@ -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(); } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 357ea3ba8a..bb738a8e00 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -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 mapActivityRef = new WeakReference<>(mapActivity); loadSelectedGpxFile(mapActivity, path, showCurrentTrack, new CallbackWithObject() { @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); From 5bfbda1e0f178535276abad5476b947620cfe759 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 12 Mar 2021 17:49:39 +0100 Subject: [PATCH 3/3] Formatting --- OsmAnd-java/src/main/java/net/osmand/data/Multipolygon.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/data/Multipolygon.java b/OsmAnd-java/src/main/java/net/osmand/data/Multipolygon.java index 6fb6db0f3c..adab2035ff 100644 --- a/OsmAnd-java/src/main/java/net/osmand/data/Multipolygon.java +++ b/OsmAnd-java/src/main/java/net/osmand/data/Multipolygon.java @@ -163,9 +163,7 @@ public class Multipolygon { * @return true if this multipolygon is correct and contains the point */ public boolean containsPoint(LatLon point) { - return containsPoint(point.getLatitude(), point.getLongitude()); - } public int countOuterPolygons() {