From 7027ce98fdf1a395020896377df3262efcd5283d Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Sat, 29 Jul 2017 13:24:32 +0300 Subject: [PATCH 1/3] Open waypoint by click on fab --- OsmAnd/res/layout/points_tree.xml | 32 +++++++++++++++++ .../plus/myplaces/TrackPointFragment.java | 35 ++++++++++++++++++- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 OsmAnd/res/layout/points_tree.xml diff --git a/OsmAnd/res/layout/points_tree.xml b/OsmAnd/res/layout/points_tree.xml new file mode 100644 index 0000000000..aaae2efb47 --- /dev/null +++ b/OsmAnd/res/layout/points_tree.xml @@ -0,0 +1,32 @@ + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java index b94efce8b5..29ac87ddc3 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java @@ -8,6 +8,7 @@ import android.os.Bundle; import android.os.Handler; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.design.widget.FloatingActionButton; import android.support.v4.view.MenuItemCompat; import android.support.v7.app.AlertDialog; import android.support.v7.view.ActionMode; @@ -89,6 +90,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment { private Set selectedGroups = new LinkedHashSet<>(); private ActionMode actionMode; private SearchView searchView; + private FloatingActionButton fab; @Override public void onCreate(@Nullable Bundle savedInstanceState) { @@ -106,10 +108,41 @@ public class TrackPointFragment extends OsmandExpandableListFragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.favorites_tree, container, false); + View view = inflater.inflate(R.layout.points_tree, container, false); ExpandableListView listView = (ExpandableListView) view.findViewById(android.R.id.list); setHasOptionsMenu(true); + fab = (FloatingActionButton) view.findViewById(R.id.fabButton); + + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + GpxDisplayItem item = null; + int groupCount = adapter.getGroupCount(); + for (int i = 0; i < groupCount; i++) { + GpxDisplayGroup group = adapter.getGroup(i); + if (group.getType() == GpxDisplayItemType.TRACK_POINTS) { + int childrenCount = adapter.getChildrenCount(i); + item = adapter.getChild(i, childrenCount - 1); + } + } + if (item != null) { + if (item.group.getGpx() != null) { + app.getSelectedGpxHelper().setGpxFileToDisplay(item.group.getGpx()); + } + final OsmandSettings settings = app.getSettings(); + LatLon location = new LatLon(item.locationStart.lat, item.locationStart.lon); + settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), + settings.getLastKnownMapZoom(), + new PointDescription(PointDescription.POINT_TYPE_WPT, item.name), + false, + item.locationStart); + + MapActivity.launchMapActivityMoveToTop(getActivity()); + } + } + }); + TextView tv = new TextView(getActivity()); tv.setText(R.string.none_selected_gpx); tv.setTextSize(24); From 3d60e37765c56d9871d286f3796473b34b2017f9 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Mon, 31 Jul 2017 10:22:29 +0300 Subject: [PATCH 2/3] Fix toShow --- OsmAnd/src/net/osmand/plus/GPXUtilities.java | 15 ++++++++++ .../osmand/plus/activities/MapActivity.java | 6 +++- .../plus/myplaces/TrackPointFragment.java | 28 ++++++++----------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/GPXUtilities.java b/OsmAnd/src/net/osmand/plus/GPXUtilities.java index c30620b199..94774cd6f5 100644 --- a/OsmAnd/src/net/osmand/plus/GPXUtilities.java +++ b/OsmAnd/src/net/osmand/plus/GPXUtilities.java @@ -102,6 +102,21 @@ public class GPXUtilities { public float speed; } + public static class CreatedGpxWaypoint { + private WptPt point; + + public CreatedGpxWaypoint() { + } + + public WptPt getPoint() { + return point; + } + + public void setPoint(WptPt point) { + this.point = point; + } + } + public static class WptPt extends GPXExtensions implements LocationPoint { public boolean firstPoint = false; public boolean lastPoint = false; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 5fd14c9016..19a9674209 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -57,6 +57,7 @@ import net.osmand.plus.AppInitializer; import net.osmand.plus.AppInitializer.AppInitializeListener; import net.osmand.plus.AppInitializer.InitEvents; import net.osmand.plus.ApplicationMode; +import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener; @@ -912,7 +913,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven } else if (toShow instanceof QuadRect) { QuadRect qr = (QuadRect) toShow; mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0); - } else { + } else if (toShow instanceof WptPt) { + WptPt createdGpxWaypoint = (WptPt) toShow; + } + else { mapContextMenu.show(latLonToShow, mapLabelToShow, toShow); } if (editToShow) { diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java index 29ac87ddc3..143234cb1b 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java @@ -36,7 +36,9 @@ import net.osmand.data.PointDescription; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.GPXUtilities; +import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GPXUtilities.GPXFile; +import net.osmand.plus.GPXUtilities.CreatedGpxWaypoint; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; @@ -91,11 +93,13 @@ public class TrackPointFragment extends OsmandExpandableListFragment { private ActionMode actionMode; private SearchView searchView; private FloatingActionButton fab; + private CreatedGpxWaypoint createdGpxWaypoint; @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.app = getMyApplication(); + this.createdGpxWaypoint = new CreatedGpxWaypoint(); } @Override @@ -117,26 +121,16 @@ public class TrackPointFragment extends OsmandExpandableListFragment { fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - GpxDisplayItem item = null; - int groupCount = adapter.getGroupCount(); - for (int i = 0; i < groupCount; i++) { - GpxDisplayGroup group = adapter.getGroup(i); - if (group.getType() == GpxDisplayItemType.TRACK_POINTS) { - int childrenCount = adapter.getChildrenCount(i); - item = adapter.getChild(i, childrenCount - 1); - } - } - if (item != null) { - if (item.group.getGpx() != null) { - app.getSelectedGpxHelper().setGpxFileToDisplay(item.group.getGpx()); - } - final OsmandSettings settings = app.getSettings(); - LatLon location = new LatLon(item.locationStart.lat, item.locationStart.lon); + final OsmandSettings settings = app.getSettings(); + GPXFile gpx = getGpx(); + WptPt pointToShow = gpx != null ? gpx.findPointToShow() : null; + if (pointToShow != null) { + LatLon location = new LatLon(pointToShow.lat, pointToShow.lon); settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), - new PointDescription(PointDescription.POINT_TYPE_WPT, item.name), + new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.context_menu_item_add_waypoint)), false, - item.locationStart); + createdGpxWaypoint); MapActivity.launchMapActivityMoveToTop(getActivity()); } From 560fca06ff8ee6c09f2127cbc10dcafe145bdfd2 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Tue, 1 Aug 2017 17:21:51 +0300 Subject: [PATCH 3/3] Modify fab in trackPointsFragment --- .../add_gpx_waypoint_bottom_sheet.xml | 66 +++++++++++ OsmAnd/res/layout-land/map_hud_bottom.xml | 7 ++ .../layout/add_gpx_waypoint_bottom_sheet.xml | 68 +++++++++++ OsmAnd/res/layout/map_hud_bottom.xml | 3 + OsmAnd/res/values/strings.xml | 2 + OsmAnd/src/net/osmand/plus/GPXUtilities.java | 15 +-- .../osmand/plus/activities/MapActivity.java | 11 +- .../plus/myplaces/TrackPointFragment.java | 12 +- .../views/AddWaypointBottomSheetHelper.java | 102 +++++++++++++++++ .../osmand/plus/views/ContextMenuLayer.java | 108 +++++++++++++++++- .../osmand/plus/views/MapControlsLayer.java | 8 +- .../plus/views/MapQuickActionLayer.java | 14 +-- 12 files changed, 379 insertions(+), 37 deletions(-) create mode 100644 OsmAnd/res/layout-land/add_gpx_waypoint_bottom_sheet.xml create mode 100644 OsmAnd/res/layout/add_gpx_waypoint_bottom_sheet.xml create mode 100644 OsmAnd/src/net/osmand/plus/views/AddWaypointBottomSheetHelper.java diff --git a/OsmAnd/res/layout-land/add_gpx_waypoint_bottom_sheet.xml b/OsmAnd/res/layout-land/add_gpx_waypoint_bottom_sheet.xml new file mode 100644 index 0000000000..541d8c347f --- /dev/null +++ b/OsmAnd/res/layout-land/add_gpx_waypoint_bottom_sheet.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout-land/map_hud_bottom.xml b/OsmAnd/res/layout-land/map_hud_bottom.xml index 72be926e0d..ffa987a0f6 100644 --- a/OsmAnd/res/layout-land/map_hud_bottom.xml +++ b/OsmAnd/res/layout-land/map_hud_bottom.xml @@ -261,4 +261,11 @@ android:layout_gravity="bottom|left" tools:visibility="visible"/> + + \ No newline at end of file diff --git a/OsmAnd/res/layout/add_gpx_waypoint_bottom_sheet.xml b/OsmAnd/res/layout/add_gpx_waypoint_bottom_sheet.xml new file mode 100644 index 0000000000..a57d63a9a5 --- /dev/null +++ b/OsmAnd/res/layout/add_gpx_waypoint_bottom_sheet.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + +