From fa2cdf4f28e7b2603da8436b862081bcd7e0e622 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 18 Jun 2014 17:16:33 +0300 Subject: [PATCH] Added on click listener to Gpx name --- OsmAnd/res/values/routepoints.xml | 3 + .../RoutePointsActivity.java | 96 ++++++++++++++----- .../RoutePointsPlugin.java | 27 +++--- 3 files changed, 88 insertions(+), 38 deletions(-) diff --git a/OsmAnd/res/values/routepoints.xml b/OsmAnd/res/values/routepoints.xml index e9856756a1..9e148c84b1 100644 --- a/OsmAnd/res/values/routepoints.xml +++ b/OsmAnd/res/values/routepoints.xml @@ -6,4 +6,7 @@ Current route: Done Marking as unvisited... + Select gpx + Save gpx + Start route \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java index a798b49597..763f76615a 100644 --- a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java +++ b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsActivity.java @@ -14,8 +14,6 @@ import android.view.ActionMode; import android.view.Menu; import android.view.MenuItem; import android.widget.*; -import com.actionbarsherlock.app.SherlockFragmentActivity; -import com.actionbarsherlock.view.*; import net.osmand.CallbackWithObject; import net.osmand.plus.*; import net.osmand.plus.activities.OsmandListActivity; @@ -53,7 +51,7 @@ public class RoutePointsActivity extends OsmandListActivity { super.setContentView(R.layout.route_steps_main); this.app = (OsmandApplication) getApplication(); getPlugin(); - getGpx(); + getGpx(false); if (gpx != null) { prepareView(); @@ -73,26 +71,33 @@ public class RoutePointsActivity extends OsmandListActivity { } - private void getGpx() { - if (plugin.getGpx() != null) { + private void getGpx(boolean forced) { + if (plugin.getGpx() != null && !forced) { this.gpx = plugin.getGpx(); - } else { - GpxUiHelper.selectGPXFile(this, false, false, new CallbackWithObject() { - @Override - public boolean processResult(GPXUtilities.GPXFile[] result) { - gpx = result[0]; - plugin.setGpx(gpx); - prepareView(); - return false; - } - }); } + + GpxUiHelper.selectGPXFile(this, false, false, new CallbackWithObject() { + @Override + public boolean processResult(GPXUtilities.GPXFile[] result) { + gpx = result[0]; + plugin.setGpx(gpx); + prepareView(); + return false; + } + }); + } private void prepareView() { TextView gpxName = (TextView) findViewById(R.id.gpx_name); String fileName = getString(R.string.current_route) + " " + gpx.path.substring(gpx.path.lastIndexOf("/") + 1, gpx.path.lastIndexOf(".")); gpxName.setText(fileName); + gpxName.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + actionMode = getActivity().startActionMode(mGpxActionModeCallback); + } + }); TextView visited = (TextView) findViewById(R.id.points_count); visited.setText("(" + plugin.getVisitedAllString() + ")"); @@ -141,7 +146,7 @@ public class RoutePointsActivity extends OsmandListActivity { public void onItemClick(AdapterView adapterView, View view, int i, long l) { selectedItemIndex = i; view.setSelected(true); - actionMode = getActivity().startActionMode(mActionModeCallback); + actionMode = getActivity().startActionMode(mPointActionModeCallback); } }); } @@ -178,7 +183,7 @@ public class RoutePointsActivity extends OsmandListActivity { List indexItemsAtTheEnd = new ArrayList(); pointsIndex = new ArrayList(); int curPointInd = plugin.getCurrentPointIndex(); - if (curPointInd != -1){ + if (curPointInd != -1) { pointsIndex.add(curPointInd); listToSort.add(plugin.getCurrentPoint()); } @@ -197,11 +202,11 @@ public class RoutePointsActivity extends OsmandListActivity { } List timeOfVisits = new ArrayList(); - for(int i=0; i valuesList, List indexList, int piviotPos, int endIndex){ + private void swap(List valuesList, List indexList, int piviotPos, int endIndex) { long value = valuesList.get(piviotPos); valuesList.set(piviotPos, valuesList.get(endIndex)); - valuesList.set(endIndex,value); + valuesList.set(endIndex, value); int index = indexList.get(piviotPos); - indexList.set(piviotPos,indexList.get(endIndex)); - indexList.set(endIndex,index); + indexList.set(piviotPos, indexList.get(endIndex)); + indexList.set(endIndex, index); } diff --git a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java index eb66262947..3252f6c162 100644 --- a/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/routepointsnavigation/RoutePointsPlugin.java @@ -44,13 +44,17 @@ public class RoutePointsPlugin extends OsmandPlugin { } public void setCurrentPoint(GPXUtilities.WptPt point) { - currentPoint = point; - currentPointIndex = findPointPosition(point); + TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper(); + LatLon latLon = new LatLon(point.lat, point.lon); + targetPointsHelper.navigateToPoint(latLon, true, -1,":" + point.name); + getCurrentPoint(); } public void setCurrentPoint(int number) { - currentPoint = pointsList.get(number); - currentPointIndex = number; + GPXUtilities.WptPt point = pointsList.get(number); + TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper(); + LatLon latLon = new LatLon(point.lat, point.lon); + targetPointsHelper.navigateToPoint(latLon, true, -1, point.name); } public List getPoints() { @@ -79,12 +83,11 @@ public class RoutePointsPlugin extends OsmandPlugin { public GPXUtilities.WptPt getCurrentPoint() { TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper(); - LatLon latLon = targetPointsHelper.getPointToNavigate(); - - for(int i=0; i