From 7027ce98fdf1a395020896377df3262efcd5283d Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Sat, 29 Jul 2017 13:24:32 +0300 Subject: [PATCH] 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);