From 198be0c573d19c7160cd84ad8f347e199a4ff0cd Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 26 Jan 2021 14:07:56 +0200 Subject: [PATCH 1/5] Change group color --- .../plus/myplaces/EditTrackGroupDialogFragment.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java index a38c9e993c..19c398685c 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java @@ -81,11 +81,15 @@ public class EditTrackGroupDialogFragment extends MenuBottomSheetDialogFragment } items.add(new TitleItem(getCategoryName(app, group.getName()))); + boolean trackPoints = group.getType() == GpxDisplayItemType.TRACK_POINTS; SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(group.getGpx().path); - if (group.getType() == GpxDisplayItemType.TRACK_POINTS && selectedGpxFile != null) { + if (trackPoints && selectedGpxFile != null) { items.add(createShowOnMapItem(selectedGpxFile)); } items.add(createEditNameItem()); + if (trackPoints) { + items.add(createChangeColorItem()); + } items.add(new OptionsDividerItem(app)); // items.add(createCopyToMarkersItem()); @@ -272,8 +276,10 @@ public class EditTrackGroupDialogFragment extends MenuBottomSheetDialogFragment final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; final View changeColorView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.change_fav_color, null); - ((ImageView) changeColorView.findViewById(R.id.change_color_icon)) - .setImageDrawable(getContentIcon(R.drawable.ic_action_appearance)); + ImageView icon = ((ImageView) changeColorView.findViewById(R.id.change_color_icon)); + icon.setImageDrawable(getContentIcon(R.drawable.ic_action_appearance)); + int margin = getResources().getDimensionPixelSize(R.dimen.bottom_sheet_icon_margin_large); + UiUtilities.setMargins(icon, 0, 0, margin, 0); updateColorView((ImageView) changeColorView.findViewById(R.id.colorImage)); return new BaseBottomSheetItem.Builder() .setCustomView(changeColorView) From 40638958a3ef3f3abef7a4836c81dd384ce5f043 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 26 Jan 2021 14:23:47 +0200 Subject: [PATCH 2/5] AvailableGPXFragment --- .../plus/myplaces/AvailableGPXFragment.java | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index 06a38d3ef2..6b404cd842 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -13,8 +13,6 @@ import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.os.Handler; -import android.text.Editable; -import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -27,7 +25,6 @@ import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; -import android.widget.EditText; import android.widget.ExpandableListView; import android.widget.Filter; import android.widget.Filterable; @@ -103,14 +100,12 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.regex.Pattern; import static net.osmand.plus.GpxSelectionHelper.CURRENT_TRACK; import static net.osmand.plus.myplaces.FavoritesActivity.GPX_TAB; -import static net.osmand.plus.myplaces.FavoritesActivity.OPEN_GPX_REQUEST; import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID; +import static net.osmand.plus.track.TrackMenuFragment.OPEN_TRACK_MENU; import static net.osmand.util.Algorithms.capitalizeFirstLetter; -import static net.osmand.util.Algorithms.collectDirs; import static net.osmand.util.Algorithms.formatDuration; import static net.osmand.util.Algorithms.objectEquals; import static net.osmand.util.Algorithms.removeAllFiles; @@ -348,10 +343,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement currentGpxView.findViewById(R.id.current_track_info).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Intent newIntent = new Intent(getActivity(), getMyApplication().getAppCustomization().getTrackActivity()); - newIntent.putExtra(TrackActivity.CURRENT_RECORDING, true); - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(newIntent); + FragmentActivity activity = getActivity(); + if (activity != null) { + openTrack(activity, null); + } } }); listView.addHeaderView(currentGpxView); @@ -419,16 +414,15 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement updateCurrentTrack(); } - public static void openTrack(Activity a, final File f) { - Intent newIntent = new Intent(a, ((OsmandApplication) a.getApplication()).getAppCustomization().getTrackActivity()); - // causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + public static void openTrack(Activity activity, final File f) { + Bundle bundle = new Bundle(); + bundle.putBoolean(OPEN_TRACK_MENU, true); if (f == null) { - newIntent.putExtra(TrackActivity.CURRENT_RECORDING, true); + bundle.putBoolean(TrackActivity.CURRENT_RECORDING, true); } else { - newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, f.getAbsolutePath()); + bundle.putString(TrackActivity.TRACK_FILE_NAME, f.getAbsolutePath()); } - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - a.startActivityForResult(newIntent, OPEN_GPX_REQUEST); + MapActivity.launchMapActivityMoveToTop(activity, null, null, bundle); } public void reloadTracks() { From 34ecacb9fc7c4992df140a4ee8acc401ac0ff59f Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 26 Jan 2021 14:36:18 +0200 Subject: [PATCH 3/5] Open track menu fragment initial commit --- .../net/osmand/plus/helpers/IntentHelper.java | 9 +++++++++ .../osmand/plus/importfiles/ImportHelper.java | 6 ++---- .../builders/WptPtMenuBuilder.java | 14 ++++---------- .../SelectedGpxMenuController.java | 19 ++----------------- .../CoordinateInputDialogFragment.java | 7 ++----- .../mapmarkers/MapMarkersDialogFragment.java | 8 +++----- .../MeasurementToolFragment.java | 7 ++----- .../SavedTrackBottomSheetDialogFragment.java | 8 +++----- .../plus/myplaces/AvailableGPXFragment.java | 8 ++++---- .../backend/OsmAndAppCustomization.java | 4 ---- .../osmand/plus/track/TrackMenuFragment.java | 4 +++- .../views/AddGpxPointBottomSheetHelper.java | 16 +++++----------- .../WikivoyageArticleDialogFragment.java | 10 +++------- 13 files changed, 42 insertions(+), 78 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java b/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java index e4e6fac9dd..0d569ba880 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/IntentHelper.java @@ -27,6 +27,7 @@ import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.fragments.BaseSettingsFragment; import net.osmand.plus.settings.fragments.BaseSettingsFragment.SettingsScreenType; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.util.Algorithms; import org.apache.commons.logging.Log; @@ -37,6 +38,8 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static net.osmand.plus.activities.TrackActivity.CURRENT_RECORDING; +import static net.osmand.plus.activities.TrackActivity.TRACK_FILE_NAME; import static net.osmand.plus.osmedit.oauth.OsmOAuthHelper.OsmAuthorizationListener; public class IntentHelper { @@ -250,6 +253,12 @@ public class IntentHelper { } mapActivity.setIntent(null); } + if (intent.hasExtra(TrackMenuFragment.OPEN_TRACK_MENU)) { + String path = intent.getStringExtra(TRACK_FILE_NAME); + boolean currentRecording = intent.getBooleanExtra(CURRENT_RECORDING, false); + TrackMenuFragment.showInstance(mapActivity, path, currentRecording); + mapActivity.setIntent(null); + } } } diff --git a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java index a46ae659b8..05b84cdd58 100644 --- a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java @@ -66,6 +66,7 @@ import static net.osmand.IndexConstants.SQLITE_CHART_FILE_EXT; import static net.osmand.IndexConstants.SQLITE_EXT; import static net.osmand.IndexConstants.WPT_CHART_FILE_EXT; import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE; +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; import static net.osmand.plus.myplaces.FavoritesActivity.GPX_TAB; import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID; import static net.osmand.plus.settings.backend.backup.SettingsHelper.REPLACE_KEY; @@ -596,10 +597,7 @@ public class ImportHelper { private void showGpxInDetailsActivity(String gpxFilePath) { if (!Algorithms.isEmpty(gpxFilePath)) { - Intent newIntent = new Intent(activity, app.getAppCustomization().getTrackActivity()); - newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxFilePath); - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - activity.startActivity(newIntent); + openTrack(activity, new File(gpxFilePath)); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java index 2a4912f232..9231ca53b0 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java @@ -1,7 +1,6 @@ package net.osmand.plus.mapcontextmenu.builders; import android.content.Context; -import android.content.Intent; import android.view.View; import android.widget.LinearLayout; @@ -16,13 +15,11 @@ import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.settings.backend.OsmAndAppCustomization; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.TrackActivity; -import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.CollapsableView; +import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.views.layers.POIMapLayer; import net.osmand.plus.widgets.TextViewEx; import net.osmand.util.Algorithms; @@ -32,6 +29,8 @@ import java.text.DateFormat; import java.util.Date; import java.util.List; +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; + public class WptPtMenuBuilder extends MenuBuilder { private final WptPt wpt; @@ -181,12 +180,7 @@ public class WptPtMenuBuilder extends MenuBuilder { button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - OsmAndAppCustomization appCustomization = app.getAppCustomization(); - final Intent intent = new Intent(context, appCustomization.getTrackActivity()); - intent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxFile.path); - intent.putExtra(TrackActivity.OPEN_POINTS_TAB, true); - intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); - context.startActivity(intent); + openTrack(mapActivity, new File(gpxFile.path)); } }); view.addView(button); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java index 8a86fbe134..427e0cce35 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/SelectedGpxMenuController.java @@ -1,7 +1,6 @@ package net.osmand.plus.mapcontextmenu.controllers; import android.app.ProgressDialog; -import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.AsyncTask; @@ -17,9 +16,7 @@ import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; -import net.osmand.plus.Version; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.builders.SelectedGpxMenuBuilder; @@ -45,21 +42,9 @@ public class SelectedGpxMenuController extends MenuController { leftTitleButtonController = new TitleButtonController() { @Override public void buttonPressed() { - OsmandApplication app = mapActivity.getMyApplication(); SelectedGpxFile selectedGpxFile = selectedGpxPoint.getSelectedGpxFile(); - if (Version.isDeveloperVersion(app)) { - mapActivity.getContextMenu().hide(false); - TrackMenuFragment.showInstance(mapActivity, selectedGpxFile.getGpxFile().path, selectedGpxFile.isShowCurrentTrack()); - } else { - Intent intent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getTrackActivity()); - if (selectedGpxFile.isShowCurrentTrack()) { - intent.putExtra(TrackActivity.CURRENT_RECORDING, true); - } else { - intent.putExtra(TrackActivity.TRACK_FILE_NAME, selectedGpxFile.getGpxFile().path); - } - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - mapActivity.startActivity(intent); - } + mapActivity.getContextMenu().hide(false); + TrackMenuFragment.showInstance(mapActivity, selectedGpxFile.getGpxFile().path, selectedGpxFile.isShowCurrentTrack()); } }; leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_open_track); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 09eef3d06c..33a1220629 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -92,6 +92,7 @@ import java.util.Locale; import static android.content.ClipDescription.MIMETYPE_TEXT_PLAIN; import static android.content.Context.CLIPBOARD_SERVICE; +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; public class CoordinateInputDialogFragment extends DialogFragment implements OsmAndCompassListener, OsmAndLocationListener { @@ -1097,11 +1098,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm .setAction(R.string.shared_string_show, new View.OnClickListener() { @Override public void onClick(View view) { - Intent intent = new Intent(app, app.getAppCustomization().getTrackActivity()); - intent.putExtra(TrackActivity.OPEN_POINTS_TAB, true); - intent.putExtra(TrackActivity.TRACK_FILE_NAME, getGpx().path); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); + openTrack(app, new File(getGpx().path)); } }); UiUtilities.setupSnackbar(snackbar, !lightTheme); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java index 2a50192d03..7a19141567 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java @@ -42,12 +42,14 @@ import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptions import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener; import net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener; +import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import static net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.GROUPS_MARKERS_MENU; import static net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.HISTORY_MARKERS_MENU; +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; public class MapMarkersDialogFragment extends DialogFragment implements OnGroupSyncedListener { @@ -486,11 +488,7 @@ public class MapMarkersDialogFragment extends DialogFragment implements OnGroupS .setAction(R.string.shared_string_show, new View.OnClickListener() { @Override public void onClick(View view) { - Intent intent = new Intent(mapActivity, getMyApplication().getAppCustomization().getTrackActivity()); - intent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxPath); - intent.putExtra(TrackActivity.OPEN_POINTS_TAB, true); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); + openTrack(mapActivity, new File(gpxPath)); } }); UiUtilities.setupSnackbar(snackbar, !lightTheme); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 6fb7aa7cab..01a39ce793 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -104,6 +104,7 @@ import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCo import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.AFTER; import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.ALL; import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.BEFORE; +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; public class MeasurementToolFragment extends BaseOsmAndFragment implements RouteBetweenPointsFragmentListener, OptionsFragmentListener, GpxApproximationFragmentListener, SelectedPointFragmentListener, @@ -1914,11 +1915,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route GpxData gpxData = editingCtx.getGpxData(); GPXFile gpx = gpxData != null ? gpxData.getGpxFile() : null; if (gpx != null) { - Intent newIntent = new Intent(mapActivity, app.getAppCustomization().getTrackActivity()); - newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, gpx.path); - newIntent.putExtra(TrackActivity.OPEN_TRACKS_LIST, true); - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(newIntent); + openTrack(mapActivity, new File(gpx.path)); } } editingCtx.resetRouteSettingsListener(); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java index fc4f5aeece..c7d5eb67da 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java @@ -24,6 +24,8 @@ import net.osmand.util.Algorithms; import java.io.File; +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; + public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { public static final String TAG = SavedTrackBottomSheetDialogFragment.class.getSimpleName(); @@ -60,11 +62,7 @@ public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFr public void onClick(View v) { FragmentActivity activity = getActivity(); if (activity != null && !Algorithms.isEmpty(fileName)) { - OsmandApplication app = ((OsmandApplication) activity.getApplication()); - Intent newIntent = new Intent(activity, app.getAppCustomization().getTrackActivity()); - newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, fileName); - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - activity.startActivity(newIntent); + openTrack(activity, new File(fileName)); } dismiss(); } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index 6b404cd842..e7d04884bc 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -414,15 +414,15 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement updateCurrentTrack(); } - public static void openTrack(Activity activity, final File f) { + public static void openTrack(Context context, File file) { Bundle bundle = new Bundle(); bundle.putBoolean(OPEN_TRACK_MENU, true); - if (f == null) { + if (file == null) { bundle.putBoolean(TrackActivity.CURRENT_RECORDING, true); } else { - bundle.putString(TrackActivity.TRACK_FILE_NAME, f.getAbsolutePath()); + bundle.putString(TrackActivity.TRACK_FILE_NAME, file.getAbsolutePath()); } - MapActivity.launchMapActivityMoveToTop(activity, null, null, bundle); + MapActivity.launchMapActivityMoveToTop(context, null, null, bundle); } public void reloadTracks() { diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndAppCustomization.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndAppCustomization.java index 2a7158ac11..485ada9072 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndAppCustomization.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmAndAppCustomization.java @@ -178,10 +178,6 @@ public class OsmAndAppCustomization { return MapActivity.class; } - public Class getTrackActivity() { - return TrackActivity.class; - } - public Class getFavoritesActivity() { return FavoritesActivity.class; } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index f169248511..5d1d64192c 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -110,6 +110,8 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card SegmentActionsListener, RenameCallback, OnTrackFileMoveListener, OnPointsDeleteListener, OsmAndLocationListener, OsmAndCompassListener { + public static final String OPEN_TRACK_MENU = "open_track_menu"; + public static final String TAG = TrackMenuFragment.class.getName(); private static final Log log = PlatformUtil.getLog(TrackMenuFragment.class); @@ -199,7 +201,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(Bundle savedInstanceState) {// super.onCreate(savedInstanceState); app = requireMyApplication(); GpxDbHelper gpxDbHelper = app.getGpxDbHelper(); diff --git a/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java b/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java index a317fece3f..c1f20a4ea0 100644 --- a/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java +++ b/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java @@ -1,6 +1,5 @@ package net.osmand.plus.views; -import android.content.Intent; import android.graphics.PointF; import android.view.View; import android.widget.ImageView; @@ -14,7 +13,6 @@ import net.osmand.data.RotatedTileBox; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.editors.RtePtEditor; import net.osmand.plus.mapcontextmenu.editors.WptPtEditor; @@ -22,6 +20,10 @@ import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener; import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.views.layers.ContextMenuLayer; +import java.io.File; + +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; + public class AddGpxPointBottomSheetHelper implements OnDismissListener { private final View view; private final TextView title; @@ -149,18 +151,10 @@ public class AddGpxPointBottomSheetHelper implements OnDismissListener { if (fragment != null) { fragment.show(); } else { - openTrackActivity(); + openTrack(mapActivity, new File(newGpxPoint.getGpx().path)); } } - private void openTrackActivity() { - Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getTrackActivity()); - newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, newGpxPoint.getGpx().path); - newIntent.putExtra(TrackActivity.OPEN_POINTS_TAB, true); - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - mapActivity.startActivity(newIntent); - } - public static class NewGpxPoint { private PointDescription pointDescription; private GPXFile gpx; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 9e2339f3ee..5354d90ec9 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -27,14 +27,12 @@ import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager.BackStackEntry; import net.osmand.AndroidUtils; -import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; import net.osmand.IndexConstants; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.settings.backend.OsmandSettings; @@ -53,6 +51,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; import static net.osmand.plus.wikipedia.WikiArticleShowImages.OFF; @@ -151,11 +150,8 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme return; } TravelHelper travelHelper = getMyApplication().getTravelHelper(); - File path = travelHelper.createGpxFile(article); - Intent newIntent = new Intent(activity, getMyApplication().getAppCustomization().getTrackActivity()); - newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, path.getAbsolutePath()); - newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(newIntent); + File file = travelHelper.createGpxFile(article); + openTrack(activity, new File(file.getAbsolutePath())); } }); From 5503a32c993a39b3764d163c2865cd6c50ab495f Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 26 Jan 2021 15:57:23 +0200 Subject: [PATCH 4/5] Fix opening gpx files --- .../net/osmand/plus/GpxSelectionHelper.java | 4 +- .../osmand/plus/activities/MapActivity.java | 4 +- .../osmand/plus/importfiles/ImportHelper.java | 5 +- .../builders/WptPtMenuBuilder.java | 5 +- .../CoordinateInputDialogFragment.java | 7 +- .../mapmarkers/MapMarkersDialogFragment.java | 12 +-- .../MeasurementToolFragment.java | 5 +- .../SavedTrackBottomSheetDialogFragment.java | 8 +- .../plus/monitoring/DashTrackFragment.java | 11 +- .../SaveGPXBottomSheetFragment.java | 3 +- .../plus/myplaces/AvailableGPXFragment.java | 20 +--- .../net/osmand/plus/track/OverviewCard.java | 67 ++++++------ .../osmand/plus/track/TrackMenuFragment.java | 100 ++++++++++++++---- .../views/AddGpxPointBottomSheetHelper.java | 4 +- .../WikivoyageArticleDialogFragment.java | 4 +- 15 files changed, 150 insertions(+), 109 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index f23320d091..5dd44bf989 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -153,12 +153,12 @@ public class GpxSelectionHelper { return followTrackListener; } - private static class GpxFileLoaderTask extends AsyncTask { + public static class GpxFileLoaderTask extends AsyncTask { private File fileToLoad; private CallbackWithObject callback; - GpxFileLoaderTask(File fileToLoad, CallbackWithObject callback) { + public GpxFileLoaderTask(File fileToLoad, CallbackWithObject callback) { this.fileToLoad = fileToLoad; this.callback = callback; } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index eb6dcbfbb7..316d5c36b2 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1628,8 +1628,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven launchMapActivityMoveToTop(activity, null); } - public static void launchMapActivityMoveToTop(Context activity, Bundle intentParams) { - launchMapActivityMoveToTop(activity, intentParams, null, null); + public static void launchMapActivityMoveToTop(Context activity, Bundle prevIntentParams) { + launchMapActivityMoveToTop(activity, prevIntentParams, null, null); } public static void clearPrevActivityIntent() { diff --git a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java index 05b84cdd58..3f1456a659 100644 --- a/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java +++ b/OsmAnd/src/net/osmand/plus/importfiles/ImportHelper.java @@ -29,7 +29,6 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.ActivityResultListener; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.dialogs.ImportGpxBottomSheetDialogFragment; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; @@ -37,6 +36,7 @@ import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.settings.backend.ExportSettingsType; import net.osmand.plus.settings.backend.backup.SettingsHelper; import net.osmand.plus.settings.backend.backup.SettingsItem; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.util.Algorithms; @@ -66,7 +66,6 @@ import static net.osmand.IndexConstants.SQLITE_CHART_FILE_EXT; import static net.osmand.IndexConstants.SQLITE_EXT; import static net.osmand.IndexConstants.WPT_CHART_FILE_EXT; import static net.osmand.data.FavouritePoint.DEFAULT_BACKGROUND_TYPE; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; import static net.osmand.plus.myplaces.FavoritesActivity.GPX_TAB; import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID; import static net.osmand.plus.settings.backend.backup.SettingsHelper.REPLACE_KEY; @@ -597,7 +596,7 @@ public class ImportHelper { private void showGpxInDetailsActivity(String gpxFilePath) { if (!Algorithms.isEmpty(gpxFilePath)) { - openTrack(activity, new File(gpxFilePath)); + TrackMenuFragment.openTrack(activity, new File(gpxFilePath), null); } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java index 9231ca53b0..c6a287f86b 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/WptPtMenuBuilder.java @@ -20,6 +20,7 @@ import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.mapcontextmenu.CollapsableView; import net.osmand.plus.mapcontextmenu.MenuBuilder; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.views.layers.POIMapLayer; import net.osmand.plus.widgets.TextViewEx; import net.osmand.util.Algorithms; @@ -29,8 +30,6 @@ import java.text.DateFormat; import java.util.Date; import java.util.List; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; - public class WptPtMenuBuilder extends MenuBuilder { private final WptPt wpt; @@ -180,7 +179,7 @@ public class WptPtMenuBuilder extends MenuBuilder { button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - openTrack(mapActivity, new File(gpxFile.path)); + TrackMenuFragment.openTrack(mapActivity, new File(gpxFile.path), null); } }); view.addView(button); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 33a1220629..32e045948d 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -5,7 +5,6 @@ import android.app.Dialog; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; -import android.content.Intent; import android.content.res.ColorStateList; import android.graphics.Rect; import android.graphics.drawable.Drawable; @@ -66,7 +65,6 @@ import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.settings.backend.OsmandPreference; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.Version; @@ -78,6 +76,8 @@ import net.osmand.plus.mapmarkers.CoordinateInputFormats.DDM; import net.osmand.plus.mapmarkers.CoordinateInputFormats.DMS; import net.osmand.plus.mapmarkers.CoordinateInputFormats.Format; import net.osmand.plus.mapmarkers.adapters.CoordinateInputAdapter; +import net.osmand.plus.settings.backend.OsmandPreference; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.widgets.EditTextEx; import net.osmand.util.Algorithms; import net.osmand.util.LocationParser; @@ -92,7 +92,6 @@ import java.util.Locale; import static android.content.ClipDescription.MIMETYPE_TEXT_PLAIN; import static android.content.Context.CLIPBOARD_SERVICE; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; public class CoordinateInputDialogFragment extends DialogFragment implements OsmAndCompassListener, OsmAndLocationListener { @@ -1098,7 +1097,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm .setAction(R.string.shared_string_show, new View.OnClickListener() { @Override public void onClick(View view) { - openTrack(app, new File(getGpx().path)); + TrackMenuFragment.openTrack(app, new File(getGpx().path), null); } }); UiUtilities.setupSnackbar(snackbar, !lightTheme); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java index 7a19141567..f0b226dd1e 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java @@ -1,7 +1,6 @@ package net.osmand.plus.mapmarkers; import android.app.Dialog; -import android.content.Intent; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; @@ -29,18 +28,18 @@ import net.osmand.AndroidUtils; import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.plus.LockableViewPager; -import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersSortByDef; -import net.osmand.plus.mapmarkers.MapMarkersHelper.OnGroupSyncedListener; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.OnPointsSavedListener; import net.osmand.plus.mapmarkers.DirectionIndicationDialogFragment.DirectionIndicationFragmentListener; +import net.osmand.plus.mapmarkers.MapMarkersHelper.MapMarkersSortByDef; +import net.osmand.plus.mapmarkers.MapMarkersHelper.OnGroupSyncedListener; import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener; import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener; import net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener; +import net.osmand.plus.track.TrackMenuFragment; import java.io.File; import java.util.ArrayList; @@ -49,7 +48,6 @@ import java.util.List; import static net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.GROUPS_MARKERS_MENU; import static net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.HISTORY_MARKERS_MENU; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; public class MapMarkersDialogFragment extends DialogFragment implements OnGroupSyncedListener { @@ -169,7 +167,7 @@ public class MapMarkersDialogFragment extends DialogFragment implements OnGroupS viewPager.setAdapter(adapter); progressBar = (ProgressBar) mainView.findViewById(R.id.progress_bar); - + TextView toolbarTitle = mainView.findViewById(R.id.map_markers_toolbar_title); bottomNav = mainView.findViewById(R.id.map_markers_bottom_navigation); toolbarTitle.setTextColor(ContextCompat.getColor(getContext(), lightTheme ? R.color.active_buttons_and_links_text_light : R.color.text_color_primary_dark)); @@ -488,7 +486,7 @@ public class MapMarkersDialogFragment extends DialogFragment implements OnGroupS .setAction(R.string.shared_string_show, new View.OnClickListener() { @Override public void onClick(View view) { - openTrack(mapActivity, new File(gpxPath)); + TrackMenuFragment.openTrack(mapActivity, new File(gpxPath), null); } }); UiUtilities.setupSnackbar(snackbar, !lightTheme); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 01a39ce793..cc17d2ac9f 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -47,7 +47,6 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.Version; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivityActions; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.base.ContextMenuFragment.MenuState; import net.osmand.plus.helpers.AndroidUiHelper; @@ -76,6 +75,7 @@ import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet.DialogMode; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.views.layers.MapControlsLayer.MapControlsThemeInfoProvider; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; @@ -104,7 +104,6 @@ import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCo import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.AFTER; import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.ALL; import static net.osmand.plus.measurementtool.command.ClearPointsCommand.ClearCommandMode.BEFORE; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; public class MeasurementToolFragment extends BaseOsmAndFragment implements RouteBetweenPointsFragmentListener, OptionsFragmentListener, GpxApproximationFragmentListener, SelectedPointFragmentListener, @@ -1915,7 +1914,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route GpxData gpxData = editingCtx.getGpxData(); GPXFile gpx = gpxData != null ? gpxData.getGpxFile() : null; if (gpx != null) { - openTrack(mapActivity, new File(gpx.path)); + TrackMenuFragment.openTrack(mapActivity, new File(gpx.path), null); } } editingCtx.resetRouteSettingsListener(); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java index c7d5eb67da..8a2b558c60 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/SavedTrackBottomSheetDialogFragment.java @@ -1,7 +1,6 @@ package net.osmand.plus.measurementtool; import android.app.Activity; -import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.TextView; @@ -10,22 +9,19 @@ import androidx.annotation.NonNull; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; -import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemButton; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerItem; import net.osmand.plus.helpers.GpxUiHelper; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.util.Algorithms; import java.io.File; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; - public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { public static final String TAG = SavedTrackBottomSheetDialogFragment.class.getSimpleName(); @@ -62,7 +58,7 @@ public class SavedTrackBottomSheetDialogFragment extends MenuBottomSheetDialogFr public void onClick(View v) { FragmentActivity activity = getActivity(); if (activity != null && !Algorithms.isEmpty(fileName)) { - openTrack(activity, new File(fileName)); + TrackMenuFragment.openTrack(activity, new File(fileName), null); } dismiss(); } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java index 7b1a4cb26a..28211e5682 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java @@ -13,16 +13,14 @@ import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; -import net.osmand.IndexConstants; import net.osmand.GPXUtilities; import net.osmand.GPXUtilities.GPXFile; +import net.osmand.IndexConstants; import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; -import net.osmand.plus.settings.backend.OsmAndAppCustomization; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.SavingTrackHelper; @@ -33,6 +31,9 @@ import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; import net.osmand.plus.myplaces.AvailableGPXFragment; import net.osmand.plus.myplaces.FavoritesActivity; +import net.osmand.plus.settings.backend.OsmAndAppCustomization; +import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.plus.track.TrackMenuFragment; import java.io.File; import java.util.ArrayList; @@ -153,7 +154,7 @@ public class DashTrackFragment extends DashBaseFragment { view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - AvailableGPXFragment.openTrack(getActivity(), null); + TrackMenuFragment.openTrack(getActivity(), null, null); } }); view.findViewById(R.id.divider_dash).setVisibility(View.VISIBLE); @@ -172,7 +173,7 @@ public class DashTrackFragment extends DashBaseFragment { v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - AvailableGPXFragment.openTrack(getActivity(), f); + TrackMenuFragment.openTrack(getActivity(), f, null); } }); ImageButton showOnMap = ((ImageButton) v.findViewById(R.id.show_on_map)); diff --git a/OsmAnd/src/net/osmand/plus/monitoring/SaveGPXBottomSheetFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/SaveGPXBottomSheetFragment.java index 0b38cb6853..4bd5e6bcda 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/SaveGPXBottomSheetFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/SaveGPXBottomSheetFragment.java @@ -29,6 +29,7 @@ import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem; import net.osmand.plus.myplaces.AvailableGPXFragment; +import net.osmand.plus.track.TrackMenuFragment; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.widgets.OsmandTextFieldBoxes; import net.osmand.util.Algorithms; @@ -167,7 +168,7 @@ public class SaveGPXBottomSheetFragment extends MenuBottomSheetDialogFragment { } FragmentActivity activity = getActivity(); if (openTrack && activity != null) { - AvailableGPXFragment.openTrack(activity, file); + TrackMenuFragment.openTrack(activity, file, null); } } } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index e7d04884bc..1bde2f3c61 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -72,7 +72,6 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; import net.osmand.plus.activities.SavingTrackHelper; -import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.base.OsmandExpandableListFragment; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType; @@ -104,7 +103,7 @@ import java.util.Set; import static net.osmand.plus.GpxSelectionHelper.CURRENT_TRACK; import static net.osmand.plus.myplaces.FavoritesActivity.GPX_TAB; import static net.osmand.plus.myplaces.FavoritesActivity.TAB_ID; -import static net.osmand.plus.track.TrackMenuFragment.OPEN_TRACK_MENU; +import static net.osmand.plus.track.TrackMenuFragment.openTrack; import static net.osmand.util.Algorithms.capitalizeFirstLetter; import static net.osmand.util.Algorithms.formatDuration; import static net.osmand.util.Algorithms.objectEquals; @@ -345,7 +344,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement public void onClick(View v) { FragmentActivity activity = getActivity(); if (activity != null) { - openTrack(activity, null); + openTrack(activity, null, storeState()); } } }); @@ -414,17 +413,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement updateCurrentTrack(); } - public static void openTrack(Context context, File file) { - Bundle bundle = new Bundle(); - bundle.putBoolean(OPEN_TRACK_MENU, true); - if (file == null) { - bundle.putBoolean(TrackActivity.CURRENT_RECORDING, true); - } else { - bundle.putString(TrackActivity.TRACK_FILE_NAME, file.getAbsolutePath()); - } - MapActivity.launchMapActivityMoveToTop(context, null, null, bundle); - } - public void reloadTracks() { asyncLoader = new LoadGpxTask(); asyncLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, getActivity()); @@ -834,7 +822,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement app.showToastMessage(R.string.file_can_not_be_moved); } } - + public void renamedTo(File file) { reloadTracks(); } @@ -1609,7 +1597,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement GpxInfo item = allGpxAdapter.getChild(groupPosition, childPosition); if (!selectionMode) { - openTrack(getActivity(), item.file); + openTrack(getActivity(), item.file, storeState()); } else { if (!selectedItems.contains(item)) { selectedItems.add(item); diff --git a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java index d5d8e44ce4..a13e140916 100644 --- a/OsmAnd/src/net/osmand/plus/track/OverviewCard.java +++ b/OsmAnd/src/net/osmand/plus/track/OverviewCard.java @@ -24,11 +24,13 @@ import androidx.recyclerview.widget.RecyclerView.ItemDecoration; import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXTrackAnalysis; +import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType; import net.osmand.plus.myplaces.SegmentActionsListener; import net.osmand.plus.routepreparationmenu.cards.BaseCard; @@ -93,38 +95,43 @@ public class OverviewCard extends BaseCard { } void initStatBlocks() { - GpxDisplayItem gpxItem = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes)).get(0); - GPXTrackAnalysis analysis = gpxItem.analysis; - boolean joinSegments = displayHelper.isJoinSegments(); - float totalDistance = !joinSegments && gpxItem.isGeneralTrack() ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; - float timeSpan = !joinSegments && gpxItem.isGeneralTrack() ? analysis.timeSpanWithoutGaps : analysis.timeSpan; - String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app); - String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app); - String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app); - String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); + List groups = displayHelper.getOriginalGroups(filterTypes); + if (!Algorithms.isEmpty(groups)) { + GpxDisplayItem gpxItem = TrackDisplayHelper.flatten(groups).get(0); + GPXTrackAnalysis analysis = gpxItem.analysis; + boolean joinSegments = displayHelper.isJoinSegments(); + float totalDistance = !joinSegments && gpxItem.isGeneralTrack() ? analysis.totalDistanceWithoutGaps : analysis.totalDistance; + float timeSpan = !joinSegments && gpxItem.isGeneralTrack() ? analysis.timeSpanWithoutGaps : analysis.timeSpan; + String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app); + String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app); + String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app); + String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); - StatBlock sDistance = new StatBlock(app.getString(R.string.distance), OsmAndFormatter.getFormattedDistance(totalDistance, app), - R.drawable.ic_action_track_16, R.color.icon_color_default_light, GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED); - StatBlock sAscent = new StatBlock(app.getString(R.string.altitude_ascent), asc, - R.drawable.ic_action_arrow_up_16, R.color.gpx_chart_red, GPXDataSetType.SLOPE, null); - StatBlock sDescent = new StatBlock(app.getString(R.string.altitude_descent), desc, - R.drawable.ic_action_arrow_down_16, R.color.gpx_pale_green, GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE); - StatBlock sAvSpeed = new StatBlock(app.getString(R.string.average_speed), avg, - R.drawable.ic_action_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null); - StatBlock sMaxSpeed = new StatBlock(app.getString(R.string.max_speed), max, - R.drawable.ic_action_max_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null); - StatBlock sTimeSpan = new StatBlock(app.getString(R.string.shared_string_time_span), - Algorithms.formatDuration((int) (timeSpan / 1000), app.accessibilityEnabled()), - R.drawable.ic_action_time_span_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null); + StatBlock sDistance = new StatBlock(app.getString(R.string.distance), OsmAndFormatter.getFormattedDistance(totalDistance, app), + R.drawable.ic_action_track_16, R.color.icon_color_default_light, GPXDataSetType.ALTITUDE, GPXDataSetType.SPEED); + StatBlock sAscent = new StatBlock(app.getString(R.string.altitude_ascent), asc, + R.drawable.ic_action_arrow_up_16, R.color.gpx_chart_red, GPXDataSetType.SLOPE, null); + StatBlock sDescent = new StatBlock(app.getString(R.string.altitude_descent), desc, + R.drawable.ic_action_arrow_down_16, R.color.gpx_pale_green, GPXDataSetType.ALTITUDE, GPXDataSetType.SLOPE); + StatBlock sAvSpeed = new StatBlock(app.getString(R.string.average_speed), avg, + R.drawable.ic_action_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null); + StatBlock sMaxSpeed = new StatBlock(app.getString(R.string.max_speed), max, + R.drawable.ic_action_max_speed_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null); + StatBlock sTimeSpan = new StatBlock(app.getString(R.string.shared_string_time_span), + Algorithms.formatDuration((int) (timeSpan / 1000), app.accessibilityEnabled()), + R.drawable.ic_action_time_span_16, R.color.icon_color_default_light, GPXDataSetType.SPEED, null); - LinearLayoutManager llManager = new LinearLayoutManager(app); - llManager.setOrientation(LinearLayoutManager.HORIZONTAL); - rvOverview.setLayoutManager(llManager); - rvOverview.setItemAnimator(new DefaultItemAnimator()); - List items = Arrays.asList(sDistance, sAscent, sDescent, sAvSpeed, sMaxSpeed, sTimeSpan); - final StatBlockAdapter siAdapter = new StatBlockAdapter(items); - rvOverview.setAdapter(siAdapter); - rvOverview.addItemDecoration(new HorizontalDividerDecoration(app)); + LinearLayoutManager llManager = new LinearLayoutManager(app); + llManager.setOrientation(LinearLayoutManager.HORIZONTAL); + rvOverview.setLayoutManager(llManager); + rvOverview.setItemAnimator(new DefaultItemAnimator()); + List items = Arrays.asList(sDistance, sAscent, sDescent, sAvSpeed, sMaxSpeed, sTimeSpan); + final StatBlockAdapter siAdapter = new StatBlockAdapter(items); + rvOverview.setAdapter(siAdapter); + rvOverview.addItemDecoration(new HorizontalDividerDecoration(app)); + } else { + AndroidUiHelper.updateVisibility(rvOverview, false); + } } private void initShowButton(final int iconColorDef, final int iconColorPres) { diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index 5d1d64192c..8bcfb411ef 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -2,6 +2,8 @@ package net.osmand.plus.track; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.app.ProgressDialog; +import android.content.Context; import android.content.DialogInterface; import android.content.res.ColorStateList; import android.os.AsyncTask; @@ -22,6 +24,7 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; +import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; @@ -32,6 +35,7 @@ import androidx.fragment.app.FragmentManager; import com.google.android.material.bottomnavigation.BottomNavigationView; import net.osmand.AndroidUtils; +import net.osmand.CallbackWithObject; import net.osmand.FileUtils; import net.osmand.FileUtils.RenameCallback; import net.osmand.GPXUtilities.GPXFile; @@ -42,10 +46,10 @@ import net.osmand.data.LatLon; import net.osmand.data.PointDescription; import net.osmand.data.QuadRect; import net.osmand.data.RotatedTileBox; -import net.osmand.plus.GpxDbHelper; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; +import net.osmand.plus.GpxSelectionHelper.GpxFileLoaderTask; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; @@ -56,6 +60,7 @@ import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities.UpdateLocationViewCache; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivityActions; +import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.base.ContextMenuFragment; import net.osmand.plus.base.ContextMenuScrollFragment; import net.osmand.plus.helpers.AndroidUiHelper; @@ -86,6 +91,7 @@ import net.osmand.util.MapUtils; import org.apache.commons.logging.Log; import java.io.File; +import java.lang.ref.WeakReference; import java.util.List; import static net.osmand.plus.activities.TrackActivity.CURRENT_RECORDING; @@ -201,36 +207,42 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } @Override - public void onCreate(Bundle savedInstanceState) {// + public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); app = requireMyApplication(); - GpxDbHelper gpxDbHelper = app.getGpxDbHelper(); displayHelper = new TrackDisplayHelper(app); updateLocationViewCache = app.getUIUtilities().getUpdateLocationViewCache(); - Bundle arguments = getArguments(); - if (arguments != null) { - String gpxFilePath = arguments.getString(TRACK_FILE_NAME); - boolean currentRecording = arguments.getBoolean(CURRENT_RECORDING, false); - if (currentRecording) { - selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); - } else { - File file = new File(gpxFilePath); - displayHelper.setFile(file); - displayHelper.setGpxDataItem(gpxDbHelper.getItem(file)); - selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath); - } - displayHelper.setGpx(selectedGpxFile.getGpxFile()); - String fileName = Algorithms.getFileWithoutDirs(getGpx().path); - gpxTitle = GpxUiHelper.getGpxTitle(fileName); + if (!selectedGpxFile.isShowCurrentTrack()) { + File file = new File(selectedGpxFile.getGpxFile().path); + displayHelper.setFile(file); + displayHelper.setGpxDataItem(app.getGpxDbHelper().getItem(file)); } + displayHelper.setGpx(selectedGpxFile.getGpxFile()); + String fileName = Algorithms.getFileWithoutDirs(getGpx().path); + gpxTitle = GpxUiHelper.getGpxTitle(fileName); toolbarHeightPx = getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar); + + FragmentActivity activity = requireMyActivity(); + activity.getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) { + public void handleOnBackPressed() { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + mapActivity.launchPrevActivityIntent(); + } + dismiss(); + } + }); } public GPXFile getGpx() { return displayHelper.getGpx(); } + public void setSelectedGpxFile(SelectedGpxFile selectedGpxFile) { + this.selectedGpxFile = selectedGpxFile; + } + @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); @@ -998,7 +1010,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card @Override public void gpxSavingFinished(Exception errorMessage) { if (selectedGpxFile != null) { - List groups = displayHelper.getDisplayGroups(new GpxDisplayItemType[]{GpxDisplayItemType.TRACK_SEGMENT}); + List groups = displayHelper.getDisplayGroups(new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_SEGMENT}); selectedGpxFile.setDisplayGroups(groups, app); selectedGpxFile.processPoints(app); } @@ -1031,16 +1043,60 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card } } - public static boolean showInstance(@NonNull MapActivity mapActivity, String path, boolean showCurrentTrack) { + public static void openTrack(@NonNull Context context, @Nullable File file, Bundle prevIntentParams) { + Bundle bundle = new Bundle(); + bundle.putBoolean(OPEN_TRACK_MENU, true); + if (file == null) { + bundle.putBoolean(TrackActivity.CURRENT_RECORDING, true); + } else { + bundle.putString(TrackActivity.TRACK_FILE_NAME, file.getAbsolutePath()); + } + MapActivity.launchMapActivityMoveToTop(context, prevIntentParams, null, bundle); + } + + public static void showInstance(@NonNull final MapActivity mapActivity, @Nullable String path, boolean showCurrentTrack) { + OsmandApplication app = mapActivity.getMyApplication(); + SelectedGpxFile selectedGpxFile; + if (showCurrentTrack) { + selectedGpxFile = app.getSavingTrackHelper().getCurrentTrack(); + } else { + selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(path); + } + if (selectedGpxFile != null) { + showInstance(mapActivity, selectedGpxFile); + } else if (!Algorithms.isEmpty(path)) { + String title = app.getString(R.string.loading_smth, ""); + final ProgressDialog progress = ProgressDialog.show(mapActivity, title, app.getString(R.string.loading_data)); + final WeakReference mapActivityRef = new WeakReference<>(mapActivity); + + GpxFileLoaderTask gpxFileLoaderTask = new GpxFileLoaderTask(new File(path), new CallbackWithObject() { + @Override + public boolean processResult(GPXFile result) { + MapActivity mapActivity = mapActivityRef.get(); + if (mapActivity != null) { + OsmandApplication app = mapActivity.getMyApplication(); + SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().selectGpxFile(result, true, false); + showInstance(mapActivity, selectedGpxFile); + } + if (progress != null && AndroidUtils.isActivityNotDestroyed(mapActivity)) { + progress.dismiss(); + } + return true; + } + }); + gpxFileLoaderTask.execute(); + } + } + + public static boolean showInstance(@NonNull MapActivity mapActivity, SelectedGpxFile selectedGpxFile) { try { Bundle args = new Bundle(); - args.putString(TRACK_FILE_NAME, path); - args.putBoolean(CURRENT_RECORDING, showCurrentTrack); args.putInt(ContextMenuFragment.MENU_STATE_KEY, MenuState.HEADER_ONLY); TrackMenuFragment fragment = new TrackMenuFragment(); fragment.setArguments(args); fragment.setRetainInstance(true); + fragment.setSelectedGpxFile(selectedGpxFile); mapActivity.getSupportFragmentManager() .beginTransaction() diff --git a/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java b/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java index c1f20a4ea0..f525c60fbd 100644 --- a/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java +++ b/OsmAnd/src/net/osmand/plus/views/AddGpxPointBottomSheetHelper.java @@ -22,8 +22,6 @@ import net.osmand.plus.views.layers.ContextMenuLayer; import java.io.File; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; - public class AddGpxPointBottomSheetHelper implements OnDismissListener { private final View view; private final TextView title; @@ -151,7 +149,7 @@ public class AddGpxPointBottomSheetHelper implements OnDismissListener { if (fragment != null) { fragment.show(); } else { - openTrack(mapActivity, new File(newGpxPoint.getGpx().path)); + TrackMenuFragment.openTrack(mapActivity, new File(newGpxPoint.getGpx().path), null); } } diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 5354d90ec9..2f9cfa3587 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -51,7 +51,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import static net.osmand.plus.myplaces.AvailableGPXFragment.openTrack; +import static net.osmand.plus.track.TrackMenuFragment.openTrack; import static net.osmand.plus.wikipedia.WikiArticleShowImages.OFF; @@ -151,7 +151,7 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme } TravelHelper travelHelper = getMyApplication().getTravelHelper(); File file = travelHelper.createGpxFile(article); - openTrack(activity, new File(file.getAbsolutePath())); + openTrack(activity, new File(file.getAbsolutePath()), null); } }); From 8378a91f05906f3918653a3c5c0edf0c94a930ea Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 26 Jan 2021 16:37:50 +0200 Subject: [PATCH 5/5] Fix back to travel from gpx menu --- .../wikivoyage/article/WikivoyageArticleDialogFragment.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java index 2f9cfa3587..e3964b4c1a 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/article/WikivoyageArticleDialogFragment.java @@ -44,6 +44,7 @@ import net.osmand.plus.wikivoyage.data.TravelArticle; import net.osmand.plus.wikivoyage.data.TravelArticle.TravelArticleIdentifier; import net.osmand.plus.wikivoyage.data.TravelHelper; import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper; +import net.osmand.plus.wikivoyage.explore.WikivoyageExploreActivity; import net.osmand.util.Algorithms; import java.io.File; @@ -149,6 +150,10 @@ public class WikivoyageArticleDialogFragment extends WikiArticleBaseDialogFragme if (article == null || activity == null || fm == null) { return; } + if (activity instanceof WikivoyageExploreActivity) { + WikivoyageExploreActivity exploreActivity = (WikivoyageExploreActivity) activity; + exploreActivity.setArticle(article); + } TravelHelper travelHelper = getMyApplication().getTravelHelper(); File file = travelHelper.createGpxFile(article); openTrack(activity, new File(file.getAbsolutePath()), null);