Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2014-06-19 11:34:05 +02:00
commit 0f9333a967
11 changed files with 819 additions and 49 deletions

View file

@ -114,6 +114,7 @@
<activity android:name="net.osmand.plus.activities.SettingsNavigationActivity" android:configChanges="keyboardHidden|orientation"></activity> <activity android:name="net.osmand.plus.activities.SettingsNavigationActivity" android:configChanges="keyboardHidden|orientation"></activity>
<activity android:name="net.osmand.plus.monitoring.SettingsMonitoringActivity" android:configChanges="keyboardHidden|orientation"></activity> <activity android:name="net.osmand.plus.monitoring.SettingsMonitoringActivity" android:configChanges="keyboardHidden|orientation"></activity>
<activity android:name="net.osmand.plus.rastermaps.SettingsRasterMapsActivity" android:configChanges="keyboardHidden|orientation"></activity> <activity android:name="net.osmand.plus.rastermaps.SettingsRasterMapsActivity" android:configChanges="keyboardHidden|orientation"></activity>
<activity android:name="net.osmand.plus.routepointsnavigation.RoutePointsActivity"/>
<activity android:name="net.osmand.plus.osmedit.SettingsOsmEditingActivity" android:configChanges="keyboardHidden|orientation"></activity> <activity android:name="net.osmand.plus.osmedit.SettingsOsmEditingActivity" android:configChanges="keyboardHidden|orientation"></activity>
<activity android:name="net.osmand.plus.development.SettingsDevelopmentActivity" android:configChanges="keyboardHidden|orientation"></activity> <activity android:name="net.osmand.plus.development.SettingsDevelopmentActivity" android:configChanges="keyboardHidden|orientation"></activity>

View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:background="?android:attr/activatedBackgroundIndicator">
<ImageView android:id="@+id/point_icon"
android:layout_width="32dp"
android:padding="3dp"
android:layout_marginLeft="5dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"/>
<TextView
android:id="@+id/name"
android:layout_marginLeft="6dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="10dp"
android:layout_weight="1"/>
<TextView
android:id="@+id/date_or_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_gravity="center_vertical"/>
</LinearLayout>

View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content">
<TextView android:id="@+id/gpx_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textSize="20sp"/>
<TextView android:id="@+id/points_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="20sp"/>
</LinearLayout>
<ListView android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
style="@style/OsmandListView"/>
</LinearLayout>

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="map_widget_route_points">Route steps</string>
<string name="route_points_no_gpx">No gpx</string>
<string name="mark_as_current">Mark as current</string>
<string name="marking_as_visited">Marking as visited…</string>
<string name="current_route">Current route:</string>
<string name="done">Done</string>
<string name="marking_as_unvisited">Marking as unvisited…</string>
<string name="map_widget_route_steps">Route steps</string>
<string name="context_menu_item_show_route_points">Show route points</string>
<string name="route_step_menu_mark_as_next">Mark as next</string>
<string name="mark_as_visited">Mark as visited</string>
<string name="select_gpx">Select gpx</string>
<string name="save_gpx">Save gpx</string>
<string name="all_route_points">All route points</string>
<string name="start_route">Start route</string>
</resources>

View file

@ -22,6 +22,7 @@ import net.osmand.plus.osmo.OsMoPlugin;
import net.osmand.plus.osmodroid.OsMoDroidPlugin; import net.osmand.plus.osmodroid.OsMoDroidPlugin;
import net.osmand.plus.parkingpoint.ParkingPositionPlugin; import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.routepointsnavigation.RoutePointsPlugin;
import net.osmand.plus.srtmplugin.SRTMPlugin; import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -44,7 +45,6 @@ public abstract class OsmandPlugin {
private static final String OSMODROID_PLUGIN_COMPONENT = "com.OsMoDroid"; //$NON-NLS-1$ private static final String OSMODROID_PLUGIN_COMPONENT = "com.OsMoDroid"; //$NON-NLS-1$
public abstract String getId(); public abstract String getId();
public abstract String getDescription(); public abstract String getDescription();
@ -82,6 +82,11 @@ public abstract class OsmandPlugin {
if(!f && Version.isParkingPluginInlined(app)) { if(!f && Version.isParkingPluginInlined(app)) {
installedPlugins.add(parking); installedPlugins.add(parking);
} }
//routePointsPlugin routePointsPlugin = new RoutePointsPlugin(app);
//installedPlugins.add(routePointsPlugin);
//enablePlugin(app,routePointsPlugin,true);
installPlugin(OSMODROID_PLUGIN_COMPONENT, OsMoDroidPlugin.ID, app, new OsMoDroidPlugin(app)); installPlugin(OSMODROID_PLUGIN_COMPONENT, OsMoDroidPlugin.ID, app, new OsMoDroidPlugin(app));
installedPlugins.add(new OsmEditingPlugin(app)); installedPlugins.add(new OsmEditingPlugin(app));
installedPlugins.add(new OsmandDevelopmentPlugin(app)); installedPlugins.add(new OsmandDevelopmentPlugin(app));

View file

@ -0,0 +1,488 @@
package net.osmand.plus.routepointsnavigation;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.format.DateFormat;
import android.util.Log;
import android.view.*;
import android.view.ActionMode;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.*;
import net.osmand.CallbackWithObject;
import net.osmand.plus.*;
import net.osmand.plus.activities.OsmandListActivity;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.util.MapUtils;
import java.io.File;
import java.util.*;
/**
* Created by Bars on 13.06.2014.
*
*/
public class RoutePointsActivity extends OsmandListActivity {
private static final String CURRENT_ROUTE_KEY = "CurrentRoute";
private GPXUtilities.GPXFile gpx;
private RoutePointsPlugin plugin;
private OsmandApplication app;
private List<GPXUtilities.WptPt> sortedPointsList;
//saves indexed of sorted list
private List<Integer> pointsIndex;
private int selectedItemIndex;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.setContentView(R.layout.route_steps_main);
this.app = (OsmandApplication) getApplication();
getPlugin();
getGpx(false);
if (gpx != null) {
prepareView();
}
super.onCreate(savedInstanceState);
}
private void getPlugin() {
List<OsmandPlugin> plugins = OsmandPlugin.getEnabledPlugins();
for (OsmandPlugin plugin : plugins) {
if (plugin instanceof RoutePointsPlugin) {
this.plugin = (RoutePointsPlugin) plugin;
}
}
}
private void getGpx(boolean forced) {
if (plugin.getGpx() != null && !forced) {
this.gpx = plugin.getGpx();
return;
}
GpxUiHelper.selectGPXFile(this, false, false, new CallbackWithObject<GPXUtilities.GPXFile[]>() {
@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) {
getActivity().startActionMode(mGpxActionModeCallback);
}
});
TextView visited = (TextView) findViewById(R.id.points_count);
visited.setText("(" + plugin.getVisitedAllString() + ")");
loadCurrentRoute();
sortPoints();
displayListView();
}
private void displayListView() {
ArrayList<PointItem> pointItemsList = new ArrayList<PointItem>();
for (int i = 0; i < sortedPointsList.size(); i++) {
String pointName = sortedPointsList.get(i).name;
long time = plugin.getPointStatus(pointsIndex.get(i));
if (time != 0) {
String dateString;
Date date = new Date(time);
if (DateFormat.is24HourFormat(app)) {
dateString = DateFormat.format("MM/dd k:mm", date).toString();
} else {
dateString = DateFormat.format("MM/dd h:mm", date).toString() + DateFormat.format("aa", date).toString();
}
pointItemsList.add(new PointItem(true, pointName, dateString));
} else {
if (i == 0) {
pointItemsList.add(new PointItem(false, pointName, ""));
continue;
}
GPXUtilities.WptPt first = sortedPointsList.get(i - 1);
GPXUtilities.WptPt second = sortedPointsList.get(i);
double d = MapUtils.getDistance(first.lat, first.lon, second.lat, second.lon);
String distance = OsmAndFormatter.getFormattedDistance((float) d, app);
pointItemsList.add(new PointItem(false, pointName, distance));
}
}
PointItemAdapter adapter = new PointItemAdapter(this, R.layout.route_point_info, pointItemsList);
ListView listView = getListView();
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
selectedItemIndex = i;
view.setSelected(true);
getActivity().startActionMode(mPointActionModeCallback);
}
});
}
private void loadCurrentRoute() {
if (gpx.routes.size() < 1) {
return;
}
Map<String, String> map = gpx.getExtensionsToRead();
if (map.containsKey(CURRENT_ROUTE_KEY)) {
String routeName = map.get(CURRENT_ROUTE_KEY);
for (GPXUtilities.Route route : gpx.routes) {
if (route.name.equals(routeName)) {
return;
}
}
}
}
private void sortPoints() {
sortedPointsList = plugin.getPoints();
List<GPXUtilities.WptPt> listToSort = new ArrayList<GPXUtilities.WptPt>();
List<Integer> indexItemsAtTheEnd = new ArrayList<Integer>();
pointsIndex = new ArrayList<Integer>();
int curPointInd = plugin.getCurrentPointIndex();
//current item should be first if it's exists
if (curPointInd != -1) {
pointsIndex.add(curPointInd);
listToSort.add(plugin.getCurrentPoint());
}
//all not visited points should be at the top
for (int i = 0; i < sortedPointsList.size(); i++) {
if (i == curPointInd) {
continue;
}
long status = plugin.getPointStatus(i);
if (status == 0L) {
listToSort.add(sortedPointsList.get(i));
pointsIndex.add(i);
} else {
indexItemsAtTheEnd.add(i);
}
}
List<Long> timeOfVisits = new ArrayList<Long>();
for (Integer anIndexItemsAtTheEnd : indexItemsAtTheEnd) {
timeOfVisits.add(plugin.getPointStatus(anIndexItemsAtTheEnd));
}
//sorting visited point from earliest to latest
quickSort(timeOfVisits, indexItemsAtTheEnd, 0, indexItemsAtTheEnd.size());
//reverting items so they will be from latest to earliest
Collections.reverse(indexItemsAtTheEnd);
for (int i : indexItemsAtTheEnd) {
listToSort.add(sortedPointsList.get(i));
pointsIndex.add(i);
}
sortedPointsList = listToSort;
}
private class PointItemAdapter extends ArrayAdapter<PointItem> {
private ArrayList<PointItem> pointsList;
public PointItemAdapter(Context context, int textViewResourceId, ArrayList<PointItem> pointsList) {
super(context, textViewResourceId, pointsList);
this.pointsList = new ArrayList<PointItem>();
this.pointsList.addAll(pointsList);
}
private class ViewHolder {
ImageView image;
TextView name;
TextView dateOrDistance;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
Log.v("ConvertView", String.valueOf(position));
if (convertView == null) {
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = vi.inflate(R.layout.route_point_info, null);
holder = new ViewHolder();
holder.dateOrDistance = (TextView) convertView.findViewById(R.id.date_or_distance);
holder.name = (TextView) convertView.findViewById(R.id.name);
holder.image = (ImageView) convertView.findViewById(R.id.point_icon);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
PointItem point = pointsList.get(position);
holder.name.setText(point.getName());
holder.dateOrDistance.setText(String.valueOf(point.getTime()));
if (point.isSelected()) {
holder.image.setImageResource(R.drawable.ic_action_ok_dark);
holder.name.setTextColor(getResources().getColor(R.color.osmbug_closed));
holder.dateOrDistance.setTextColor(getResources().getColor(R.color.color_unknown));
} else {
if (sortedPointsList.get(position).equals(plugin.getCurrentPoint())) {
holder.image.setImageResource(R.drawable.ic_action_signpost_dark);
} else {
holder.image.setImageResource(R.drawable.ic_action_marker_dark);
}
holder.name.setTextColor(getResources().getColor(R.color.color_update));
holder.dateOrDistance.setTextColor(getResources().getColor(R.color.osmbug_not_submitted));
}
return convertView;
}
}
//this class needed to represent route point in UI
private class PointItem {
private boolean visited;
private String name;
private String time;
public PointItem(boolean visited, String name, String time) {
this.visited = visited;
this.name = name;
this.time = time;
}
public String getName() {
return name;
}
public String getTime() {
return time;
}
public boolean isSelected() {
return visited;
}
public void setSelected(boolean selected) {
this.visited = selected;
}
}
private void revertPointStatusAsync(final GPXUtilities.WptPt point) {
new AsyncTask<GPXUtilities.WptPt, Void, Void>() {
private ProgressDialog dlg;
protected void onPreExecute() {
dlg = new ProgressDialog(getActivity());
if (plugin.getPointStatus(point) == 0) {
dlg.setTitle(R.string.marking_as_visited);
} else {
dlg.setTitle(getString(R.string.marking_as_unvisited));
}
dlg.setMessage(point.name);
dlg.show();
}
@Override
protected Void doInBackground(GPXUtilities.WptPt... params) {
long status = plugin.getPointStatus(point);
if (status == 0) {
plugin.setPointStatus(point, true);
} else {
plugin.setPointStatus(point, false);
}
GPXUtilities.writeGpxFile(new File(gpx.path), gpx, app);
return null;
}
protected void onPostExecute(Void result) {
//to avoid illegal argument exception when rotating phone during loading
try {
dlg.dismiss();
} catch (Exception ex) {
ex.printStackTrace();
}
sortPoints();
displayListView();
}
}.execute(point);
}
private ActionMode.Callback mGpxActionModeCallback = new ActionMode.Callback() {
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
MenuItem item = menu.add(getString(R.string.select_gpx));
item.setIcon(R.drawable.ic_action_layers_dark);
item = menu.add(getString(R.string.start_route));
item.setIcon(R.drawable.ic_action_map_marker_dark);
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
return false;
}
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
if (menuItem.getTitle().equals(getResources().getString(R.string.select_gpx))) {
getGpx(true);
} else if (menuItem.getTitle().equals(getResources().getString(R.string.start_route))) {
GPXUtilities.WptPt point = plugin.getCurrentPoint();
if (point == null) {
if (plugin.getPointStatus(pointsIndex.get(0)) == 0) {
plugin.setCurrentPoint(sortedPointsList.get(0));
}
}
actionMode.finish();
finish();
}
actionMode.finish();
return true;
}
@Override
public void onDestroyActionMode(ActionMode actionMode) {
}
};
private ActionMode.Callback mPointActionModeCallback = new ActionMode.Callback() {
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
MenuItem item = menu.add(getString(R.string.mark_as_current));
item.setIcon(R.drawable.ic_action_signpost_dark);
item = menu.add(getString(R.string.mark_as_visited));
item.setIcon(R.drawable.ic_action_ok_dark);
item = menu.add(getString(R.string.show_poi_on_map));
item.setIcon(R.drawable.ic_action_map_marker_dark);
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
return false;
}
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
if (menuItem.getTitle().equals(getResources().getString(R.string.mark_as_current))) {
plugin.setCurrentPoint(sortedPointsList.get(selectedItemIndex));
sortPoints();
displayListView();
} else if (menuItem.getTitle().equals(getResources().getString(R.string.show_poi_on_map))) {
GPXUtilities.WptPt point = sortedPointsList.get(selectedItemIndex);
app.getSettings().setMapLocationToShow(point.lat, point.lon, app.getSettings().getMapZoomToShow());
finish();
} else {
//inverts selection state of item
revertPointStatusAsync(sortedPointsList.get(selectedItemIndex));
sortPoints();
displayListView();
}
actionMode.finish();
return true;
}
@Override
public void onDestroyActionMode(ActionMode actionMode) {
}
};
@Override
public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
com.actionbarsherlock.view.MenuItem doneItem = menu.add(getString(R.string.done));
doneItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
doneItem.setIcon(R.drawable.ic_action_map_marker_dark);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
if (item.getTitle().equals(getString(R.string.done))) {
GPXUtilities.WptPt point = plugin.getCurrentPoint();
app.getSettings().setMapLocationToShow(point.lat, point.lon, app.getSettings().getMapZoomToShow());
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
private void quickSort(List<Long> valuesList, List<Integer> indexList, int beginIdx, int len) {
if (len <= 1) {
return;
}
final int endIdx = beginIdx + len - 1;
// Pivot selection
final int pivotPos = beginIdx + len / 2;
final long pivot = valuesList.get(pivotPos);
swap(valuesList, indexList, pivotPos, endIdx);
// partitioning
int p = beginIdx;
for (int i = beginIdx; i != endIdx; ++i) {
if (valuesList.get(i) <= pivot) {
swap(valuesList, indexList, i, p++);
}
}
swap(valuesList, indexList, p, endIdx);
// recursive call
quickSort(valuesList, indexList, beginIdx, p - beginIdx);
quickSort(valuesList, indexList, p + 1, endIdx - p);
}
private void swap(List<Long> valuesList, List<Integer> indexList, int piviotPos, int endIndex) {
long value = valuesList.get(piviotPos);
valuesList.set(piviotPos, valuesList.get(endIndex));
valuesList.set(endIndex, value);
int index = indexList.get(piviotPos);
indexList.set(piviotPos, indexList.get(endIndex));
indexList.set(endIndex, index);
}
private Activity getActivity() {
return this;
}
}

View file

@ -0,0 +1,223 @@
package net.osmand.plus.routepointsnavigation;
import android.content.Intent;
import android.graphics.Paint;
import android.view.View;
import net.osmand.data.LatLon;
import net.osmand.plus.*;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.views.MapInfoLayer;
import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
/**
* Created by Barsik on 10.06.2014.
*/
public class RoutePointsPlugin extends OsmandPlugin {
public static final String ID = "osmand.route.stepsPlugin";
private static final String VISITED_KEY = "IsVisited";
private static final String POINT_KEY = "Point";
private OsmandApplication app;
private GPXUtilities.GPXFile gpx;
private GPXUtilities.Route currentRoute;
private GPXUtilities.WptPt currentPoint;
private List<GPXUtilities.WptPt> pointsList;
private TextInfoWidget routeStepsControl;
private int visitedCount;
private int currentPointIndex = -1;
public RoutePointsPlugin(OsmandApplication app) {
ApplicationMode.regWidget("route_steps", (ApplicationMode[]) null);
this.app = app;
}
public void setCurrentPoint(GPXUtilities.WptPt 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) {
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<GPXUtilities.WptPt> getPoints() {
return currentRoute.points;
}
@Override
public String getId() {
return ID;
}
@Override
public String getDescription() {
return "This plugin allows you to view key positions of your route...";
}
@Override
public String getName() {
return "Tour Point Plugin";
}
@Override
public boolean init(OsmandApplication app) {
return true;
}
public GPXUtilities.WptPt getCurrentPoint() {
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
String locName = targetPointsHelper.getPointNavigateDescription();
for (int i = 0; i < pointsList.size(); i++) {
String pointName = ":" + pointsList.get(i).name;
if (pointName.equals(locName)) {
currentPoint = pointsList.get(i);
currentPointIndex = i;
break;
}
}
return currentPoint;
}
public GPXUtilities.GPXFile getGpx() {
return gpx;
}
public void setGpx(GPXUtilities.GPXFile gpx) {
this.gpx = gpx;
currentRoute = gpx.routes.get(0);
pointsList = currentRoute.points;
refreshPointsStatus();
getCurrentPoint();
}
private void registerWidget(MapActivity activity) {
MapInfoLayer mapInfoLayer = activity.getMapLayers().getMapInfoLayer();
if (mapInfoLayer != null) {
routeStepsControl = createRouteStepsInfoControl(activity, mapInfoLayer.getPaintSubText(), mapInfoLayer.getPaintSubText());
mapInfoLayer.getMapInfoControls().registerSideWidget(routeStepsControl,
R.drawable.widget_target, R.string.map_widget_route_points, "route_steps", false, 8);
mapInfoLayer.recreateControls();
}
}
public GPXUtilities.WptPt getNextPoint() {
if (pointsList.size() > currentPointIndex + 1) {
return pointsList.get(currentPointIndex + 1);
} else {
return null;
}
}
public int findPointPosition(GPXUtilities.WptPt point) {
int i = 0;
for (GPXUtilities.WptPt item : pointsList) {
if (item.equals(point)) {
return i;
}
i++;
}
return -1;
}
@Override
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
if (routeStepsControl == null) {
registerWidget(activity);
}
}
public String getVisitedAllString() {
return String.valueOf(visitedCount) + "/" + String.valueOf(pointsList.size());
}
private TextInfoWidget createRouteStepsInfoControl(final MapActivity map, Paint paintText, Paint paintSubText) {
TextInfoWidget routeStepsControl = new TextInfoWidget(map, 0, paintText, paintSubText) {
@Override()
public boolean updateInfo(OsmandMapLayer.DrawSettings drawSettings) {
if (gpx != null) {
setText(String.valueOf(visitedCount) + "/", String.valueOf(pointsList.size()));
} else {
setText(app.getString(R.string.route_points_no_gpx), "");
}
return true;
}
};
routeStepsControl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(app, RoutePointsActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
app.startActivity(intent);
}
});
routeStepsControl.setText(null, null);
routeStepsControl.setImageDrawable(map.getResources().getDrawable(R.drawable.widget_parking));
return routeStepsControl;
}
public void refreshPointsStatus() {
visitedCount = 0;
for (int i = 0; i < pointsList.size(); i++) {
if (getPointStatus(i) != 0) {
visitedCount++;
}
}
}
public long getPointStatus(GPXUtilities.WptPt point) {
return getPointStatus(findPointPosition(point));
}
public long getPointStatus(int numberOfPoint) {
Map<String, String> map = currentRoute.getExtensionsToRead();
String mapKey = POINT_KEY + numberOfPoint + VISITED_KEY;
if (map.containsKey(mapKey)) {
String value = map.get(mapKey);
return (Long.valueOf(value));
}
return 0L;
}
//saves point status value to gpx extention file
public void setPointStatus(GPXUtilities.WptPt point, boolean status) {
Map<String, String> map = currentRoute.getExtensionsToWrite();
int pos = findPointPosition(point);
String mapKey = POINT_KEY + pos + VISITED_KEY;
if (status) {
//value is current time
Calendar c = Calendar.getInstance();
long number = c.getTimeInMillis();
map.put(mapKey, String.valueOf(number));
} else if (map.containsKey(mapKey)) {
map.remove(mapKey);
}
refreshPointsStatus();
}
public Integer getCurrentPointIndex() {
return currentPointIndex;
}
}

View file

@ -2,3 +2,4 @@ bin
gen gen
raw raw
obj obj
*.iml

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager" forced_jdk="true">
<conelement value="com.android.ide.eclipse.adt.DEPENDENCIES" />
<src_description expected_position="1">
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
<src_folder value="file://$MODULE_DIR$/gen" expected_position="1" />
<src_folder value="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK" expected_position="2" />
<src_folder value="com.android.ide.eclipse.adt.LIBRARIES" expected_position="3" />
</src_description>
</component>
<component name="FacetManager">
<facet type="android" name="Android">
<configuration />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/bin/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="Android 4.1.2 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>