diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 8b9cc664f9..6a08cbc4fb 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -54,6 +54,7 @@ import net.osmand.AndroidUtils; import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.data.PointDescription; +import net.osmand.plus.GPXUtilities; import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; @@ -80,14 +81,18 @@ import java.util.Locale; import static android.content.ClipDescription.MIMETYPE_TEXT_PLAIN; import static android.content.Context.CLIPBOARD_SERVICE; import static net.osmand.plus.MapMarkersHelper.MAP_MARKERS_COLORS_COUNT; +import static net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.COORDINATE_INPUT_MODE_KEY; public class CoordinateInputDialogFragment extends DialogFragment implements OsmAndCompassListener, OsmAndLocationListener { public static final String TAG = "CoordinateInputDialogFragment"; public static final String ADDED_MARKERS_NUMBER_KEY = "added_markers_number_key"; + public static final String WAYPOINTS_MODE_KEY = "waypoints_mode_key"; private final List mapMarkers = new ArrayList<>(); + private List waypoints; private MapMarker selectedMarker; + private GPXUtilities.GPXFile gpxFile; private OnMapMarkersSavedListener listener; private View mainView; @@ -100,6 +105,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm private boolean hasUnsavedChanges; private boolean isSoftKeyboardShown; + private boolean isWptMode; private boolean north = true; private boolean east = true; @@ -118,6 +124,17 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm super.onCreate(savedInstanceState); lightTheme = getMyApplication().getSettings().isLightContent(); setStyle(STYLE_NO_FRAME, lightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme); + Bundle args = getArguments(); + if (args != null) { + isWptMode = args.getBoolean(WAYPOINTS_MODE_KEY); + if (isWptMode && gpxFile != null) { + waypoints = gpxFile.getPoints(); + } + } + } + + public void setGpxFile(GPXUtilities.GPXFile gpxFile) { + this.gpxFile = gpxFile; } private void quit() { @@ -134,6 +151,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm SaveAsTrackBottomSheetDialogFragment fragment = new SaveAsTrackBottomSheetDialogFragment(); Bundle args = new Bundle(); args.putInt(ADDED_MARKERS_NUMBER_KEY, mapMarkers.size()); + args.putBoolean(COORDINATE_INPUT_MODE_KEY, true); fragment.setArguments(args); fragment.setListener(createSaveAsTrackFragmentListener()); fragment.show(getChildFragmentManager(), SaveAsTrackBottomSheetDialogFragment.TAG); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java index c57e08f0eb..772fb54134 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java @@ -36,6 +36,7 @@ import static net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.ADDED_MAR public class SaveAsTrackBottomSheetDialogFragment extends BottomSheetDialogFragment { public final static String TAG = "SaveAsTrackBottomSheetDialogFragment"; + public static final String COORDINATE_INPUT_MODE_KEY = "coordinate_input_mode_key"; private boolean portrait; private MarkerSaveAsTrackFragmentListener listener; @@ -52,9 +53,10 @@ public class SaveAsTrackBottomSheetDialogFragment extends BottomSheetDialogFragm int number = 0; Bundle args = getArguments(); if (args != null) { - number = args.getInt(ADDED_MARKERS_NUMBER_KEY); - if (number != 0) - isCoordInput = true; + isCoordInput = args.getBoolean(COORDINATE_INPUT_MODE_KEY); + if (isCoordInput) { + number = args.getInt(ADDED_MARKERS_NUMBER_KEY); + } } portrait = AndroidUiHelper.isOrientationPortrait(getActivity()); final boolean nightMode = !app.getSettings().isLightContent(); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java index fa71cbbfde..b4e98db740 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java @@ -65,6 +65,7 @@ import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.base.FavoriteImageDrawable; import net.osmand.plus.base.OsmandExpandableListFragment; +import net.osmand.plus.mapmarkers.CoordinateInputDialogFragment; import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener; import net.osmand.plus.widgets.TextViewEx; import net.osmand.util.Algorithms; @@ -83,6 +84,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import static net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.WAYPOINTS_MODE_KEY; + public class TrackPointFragment extends OsmandExpandableListFragment implements TrackBitmapDrawerListener { public static final int SEARCH_ID = -1; @@ -90,6 +93,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements public static final int DELETE_ACTION_ID = 3; public static final int SHARE_ID = 4; public static final int SELECT_MAP_MARKERS_ID = 5; + public static final int COORDINATE_INPUT_ID = 6; //public static final int SELECT_MAP_MARKERS_ACTION_MODE_ID = 6; public static final int SELECT_FAVORITES_ID = 7; public static final int SELECT_FAVORITES_ACTION_MODE_ID = 8; @@ -274,6 +278,9 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements } else if (item.getItemId() == DELETE_ID) { enterDeleteMode(); return true; + } else if (item.getItemId() == COORDINATE_INPUT_ID) { + openCoordinatesInput(); + return true; } else { return super.onOptionsItemSelected(item); } @@ -301,6 +308,16 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements } } + private void openCoordinatesInput() { + Bundle args = new Bundle(); + args.putBoolean(WAYPOINTS_MODE_KEY, true); + CoordinateInputDialogFragment fragment = new CoordinateInputDialogFragment(); + fragment.setRetainInstance(true); + fragment.setArguments(args); + fragment.setGpxFile(getGpx()); + fragment.show(getChildFragmentManager(), CoordinateInputDialogFragment.TAG); + } + @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.clear(); @@ -367,6 +384,8 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements R.drawable.ic_action_fav_dark, MenuItem.SHOW_AS_ACTION_NEVER); createMenuItem(menu, DELETE_ID, R.string.shared_string_delete, R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_dark, MenuItem.SHOW_AS_ACTION_NEVER); + createMenuItem(menu, COORDINATE_INPUT_ID, R.string.coordinate_input, R.drawable.ic_action_coordinates_longitude, + R.drawable.ic_action_coordinates_longitude, MenuItem.SHOW_AS_ACTION_NEVER); } this.optionsMenu = menu; }