diff --git a/OsmAnd-java/src/net/osmand/render/RenderingRule.java b/OsmAnd-java/src/net/osmand/render/RenderingRule.java
index b5c3f39c92..90bb7b2165 100644
--- a/OsmAnd-java/src/net/osmand/render/RenderingRule.java
+++ b/OsmAnd-java/src/net/osmand/render/RenderingRule.java
@@ -7,6 +7,8 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import net.osmand.util.Algorithms;
+
public class RenderingRule {
private RenderingRuleProperty[] properties;
@@ -81,7 +83,7 @@ public class RenderingRule {
public String getColorPropertyValue(String property) {
int i = getPropertyIndex(property);
if(i >= 0){
- return RenderingRuleProperty.colorToString(intProperties[i]);
+ return Algorithms.colorToString(intProperties[i]);
}
return null;
}
diff --git a/OsmAnd-java/src/net/osmand/render/RenderingRuleProperty.java b/OsmAnd-java/src/net/osmand/render/RenderingRuleProperty.java
index e18b4c03d0..3eaf51cf5d 100644
--- a/OsmAnd-java/src/net/osmand/render/RenderingRuleProperty.java
+++ b/OsmAnd-java/src/net/osmand/render/RenderingRuleProperty.java
@@ -308,12 +308,6 @@ public class RenderingRuleProperty {
throw new IllegalArgumentException("Unknown color " + colorString); //$NON-NLS-1$
}
- public static String colorToString(int color) {
- if ((0xFF000000 & color) == 0xFF000000) {
- return "#" + Integer.toHexString(color & 0x00FFFFFF); //$NON-NLS-1$
- } else {
- return "#" + Integer.toHexString(color); //$NON-NLS-1$
- }
- }
+
}
diff --git a/OsmAnd-java/src/net/osmand/render/RenderingRuleSearchRequest.java b/OsmAnd-java/src/net/osmand/render/RenderingRuleSearchRequest.java
index 3024ef6aff..d3fc97edf1 100644
--- a/OsmAnd-java/src/net/osmand/render/RenderingRuleSearchRequest.java
+++ b/OsmAnd-java/src/net/osmand/render/RenderingRuleSearchRequest.java
@@ -1,6 +1,7 @@
package net.osmand.render;
import net.osmand.binary.BinaryMapDataObject;
+import net.osmand.util.Algorithms;
public class RenderingRuleSearchRequest {
@@ -239,7 +240,7 @@ public class RenderingRuleSearchRequest {
}
public String getColorStringPropertyValue(RenderingRuleProperty property) {
- return RenderingRuleProperty.colorToString(values[property.getId()]);
+ return Algorithms.colorToString(values[property.getId()]);
}
public int getIntPropertyValue(RenderingRuleProperty property) {
diff --git a/OsmAnd-java/src/net/osmand/util/Algorithms.java b/OsmAnd-java/src/net/osmand/util/Algorithms.java
index 2c94bf125d..5cc68b39d6 100644
--- a/OsmAnd-java/src/net/osmand/util/Algorithms.java
+++ b/OsmAnd-java/src/net/osmand/util/Algorithms.java
@@ -345,5 +345,12 @@ public class Algorithms {
}
return defaultValue;
}
-
+
+ public static String colorToString(int color) {
+ if ((0xFF000000 & color) == 0xFF000000) {
+ return "#" + Integer.toHexString(color & 0x00FFFFFF); //$NON-NLS-1$
+ } else {
+ return "#" + Integer.toHexString(color); //$NON-NLS-1$
+ }
+ }
}
diff --git a/OsmAnd/res/layout/gpx_item_list_item.xml b/OsmAnd/res/layout/gpx_item_list_item.xml
new file mode 100644
index 0000000000..f2f7562ab3
--- /dev/null
+++ b/OsmAnd/res/layout/gpx_item_list_item.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml
index ac040fe905..d6ec0f68e1 100644
--- a/OsmAnd/res/values/colors.xml
+++ b/OsmAnd/res/values/colors.xml
@@ -1,5 +1,11 @@
+ #CCAA0088
+ #32CD32
+ #EE3232
+ #FD9822
+ #0080FF
+
#00000000
diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 988059dcf5..e9bed7b7c5 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,7 +9,21 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
+ \n\nPress and hold for options
+ Subtracks: %1$s
+ Waypoints: %1$s
+ Distance: %1$s (%2$s points)
+ Start time: %1$tF, %1$tR
+ End time: %1$tF, %1$tR
+ Average speed: %1$s
+ Maximum speed: %1$s
+ Average altitude: %1$s
+ Altitude diff.: %1$s
+ Time span: %1$s
+ Time moving: %1$s
+ Segment
%1$s points
+ Point %1$s
recording
Gpx %1$s - Route points %2$s
Gpx %1$s - Points
@@ -321,8 +335,7 @@
To:
Via:
From:
- \nTime span: %1$d:%2$02d:%3$02d
- \nTime moving: %1$d:%2$02d:%3$02d
+
Browse map
Default profile
Map view and navigation settings are remembered per use profile. Set your default profile here.
@@ -1279,10 +1292,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
No, thanks
Base world map (covering the whole world at small zooms) is missing. Please consider downloading World_basemap_x.obf for a complete environment.
On board (\'offline\') data is missing on SD card. Please consider to download it in order to use maps offline.
- \n\nPress and hold for options
- \nAverage speed: %1$s \nMaximum speed: %2$s
- \nAverage altitude: %1$s\nMinimum altitude: %2$s\nMaximum altitude: %3$s\nAscents: %4$s\nDescents: %5$s
- Subtracks: %1$d\nTotal points: %2$d\nWaypoints: %3$d\nTotal distance: %4$s\nStart time: %5$tF, %5$tR\nEnd time: %6$tF, %6$tR
Edition
%1$d of %2$d item(s) successfully deactivated.
%1$d of %2$d item(s) successfully deleted.
diff --git a/OsmAnd/src/net/osmand/plus/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/ApplicationMode.java
index 30f151d6f1..4b34cae932 100644
--- a/OsmAnd/src/net/osmand/plus/ApplicationMode.java
+++ b/OsmAnd/src/net/osmand/plus/ApplicationMode.java
@@ -73,7 +73,7 @@ public class ApplicationMode {
// top
regWidget("compass", all);
- regWidget("config", all);
+ regWidget("config", none);
regWidget("street_name", exceptAirBoat);
regWidget("back_to_location", all);
regWidget("monitoring_services", none);
diff --git a/OsmAnd/src/net/osmand/plus/GPXUtilities.java b/OsmAnd/src/net/osmand/plus/GPXUtilities.java
index b7865aa358..ab75e74592 100644
--- a/OsmAnd/src/net/osmand/plus/GPXUtilities.java
+++ b/OsmAnd/src/net/osmand/plus/GPXUtilities.java
@@ -29,6 +29,7 @@ import java.util.TimeZone;
import net.osmand.Location;
import net.osmand.PlatformUtil;
+import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log;
import org.xmlpull.v1.XmlPullParser;
@@ -133,7 +134,7 @@ public class GPXUtilities {
public int metricEnd;
public boolean isTimeSpecified() {
- return startTime != Long.MAX_VALUE;
+ return startTime != Long.MAX_VALUE && startTime != 0;
}
public boolean isTimeMoving() {
@@ -148,6 +149,7 @@ public class GPXUtilities {
return (int) ((time / 1000) / 3600);
}
+
public int getTimeSeconds(long time) {
return (int) ((time / 1000) % 60);
}
@@ -161,8 +163,11 @@ public class GPXUtilities {
}
+ public static GPXTrackAnalysis segment(long filetimestamp, TrkSegment segment) {
+ return new GPXTrackAnalysis().prepareInformation(filetimestamp, new SplitSegment(segment));
+ }
- public void prepareInformation(long filestamp, SplitSegment... splitSegments) {
+ public GPXTrackAnalysis prepareInformation(long filestamp, SplitSegment... splitSegments) {
float[] calculations = new float[1];
float totalElevation = 0;
@@ -250,7 +255,9 @@ public class GPXUtilities {
} else {
avgSpeed = -1;
}
+ return this;
}
+
}
private static class SplitSegment {
@@ -354,6 +361,7 @@ public class GPXUtilities {
return "cloudmade".equalsIgnoreCase(author);
}
+
public GPXTrackAnalysis getAnalysis(long fileTimestamp) {
GPXTrackAnalysis g = new GPXTrackAnalysis();
g.wptPoints = points.size();
@@ -390,8 +398,6 @@ public class GPXUtilities {
return split(new SplitMetric() {
- private float[] calculations = new float[1];
-
@Override
public int metric(WptPt p1, WptPt p2) {
if(p1.time != 0 && p2.time != 0) {
diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
index 446eb9cc22..1c9e58dfe6 100644
--- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
+++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
@@ -4,11 +4,16 @@ import java.util.ArrayList;
import java.util.List;
import net.osmand.plus.GPXUtilities.GPXFile;
+import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
import net.osmand.plus.GPXUtilities.Route;
import net.osmand.plus.GPXUtilities.Track;
+import net.osmand.plus.GPXUtilities.TrkSegment;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.activities.SavingTrackHelper;
+import net.osmand.plus.helpers.GpxUiHelper;
+import net.osmand.util.Algorithms;
import android.graphics.Bitmap;
+import android.graphics.Color;
public class GpxSelectionHelper {
@@ -18,6 +23,7 @@ public class GpxSelectionHelper {
// new BooleanPreference("show_current_gpx_track", false).makeGlobal().cache();
private List selectedGPXFiles = new java.util.concurrent.CopyOnWriteArrayList();
private SavingTrackHelper savingTrackHelper;
+ private Runnable uiListener;
public GpxSelectionHelper(OsmandApplication osmandApplication) {
this.app = osmandApplication;
@@ -55,13 +61,18 @@ public class GpxSelectionHelper {
if(g.showCurrentTrack){
name = getString(R.string.gpx_selection_current_track);
} else {
- int i = name.indexOf('/');
+ int i = name.lastIndexOf('/');
+ if(i >= 0) {
+ name = name.substring(i + 1);
+ }
+ i = name.lastIndexOf('\\');
if(i >= 0) {
name = name.substring(i + 1);
}
if(name.endsWith(".gpx")) {
name = name.substring(0, name.length() - 4);
}
+ name = name.replace('_', ' ');
}
if (g.tracks.size() > 0) {
int k = 0;
@@ -77,21 +88,40 @@ public class GpxSelectionHelper {
}
group.setDescription(d);
dg.add(group);
+ processGroupTrack(group);
}
}
if (g.routes.size() > 0) {
int k = 0;
- for (Route r : g.routes) {
+ for (Route route : g.routes) {
GpxDisplayGroup group = new GpxDisplayGroup(g);
group.setType(GpxDisplayItemType.TRACK_ROUTE_POINTS);
- String d = getString(R.string.gpx_selection_number_of_points, name, r.points.size());
- if(r.name != null && r.name.length() > 0) {
- d = r.name + " " + d;
+ String d = getString(R.string.gpx_selection_number_of_points, name, route.points.size());
+ if(route.name != null && route.name.length() > 0) {
+ d = route.name + " " + d;
}
group.setDescription(d);
String ks = (k++) + "";
group.setName(getString(R.string.gpx_selection_route_points, name, g.routes.size() == 1 ? "" : ks));
dg.add(group);
+ List list = group.getModifiableList();
+ int t = 0;
+ for (WptPt r : route.points) {
+ GpxDisplayItem item = new GpxDisplayItem();
+ item.group = group;
+ item.description = r.desc;
+ item.name = r.name;
+ t++;
+ if (Algorithms.isEmpty(item.name)) {
+ item.name = getString(R.string.gpx_selection_point, t + "");
+ }
+ if(Algorithms.isEmpty(item.description)) {
+ item.description = item.name;
+ }
+ item.locationStart = r;
+ item.locationEnd = r;
+ list.add(item);
+ }
}
}
@@ -102,10 +132,19 @@ public class GpxSelectionHelper {
group.setName(getString(R.string.gpx_selection_points, name));
dg.add(group);
List list = group.getModifiableList();
+ int k = 0;
for (WptPt r : g.points) {
GpxDisplayItem item = new GpxDisplayItem();
+ item.group = group;
item.description = r.desc;
item.name = r.name;
+ k++;
+ if (Algorithms.isEmpty(item.name)) {
+ item.name = getString(R.string.gpx_selection_point, k + "");
+ }
+ if(Algorithms.isEmpty(item.description)) {
+ item.description = item.name;
+ }
item.locationStart = r;
item.locationEnd = r;
list.add(item);
@@ -113,6 +152,36 @@ public class GpxSelectionHelper {
}
}
+ private void processGroupTrack(GpxDisplayGroup group) {
+ List list = group.getModifiableList();
+ String timeSpanClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_time_span_color));
+ String distanceClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_distance_color));
+ for (TrkSegment r : group.track.segments) {
+ if (r.points.size() > 0) {
+ GpxDisplayItem item = new GpxDisplayItem();
+ item.group = group;
+ GPXTrackAnalysis analysis = GPXTrackAnalysis.segment(0, r);
+ item.description = GpxUiHelper.getDescription(app, analysis);
+ String dist = " "
+ + OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app) + "";
+ item.name = app.getString(R.string.gpx_selection_segment_title) + dist;
+
+ if (analysis.timeSpan > 0 || analysis.timeMoving > 0) {
+ long tm = analysis.timeMoving;
+ if (tm == 0) {
+ tm = analysis.timeSpan;
+ }
+ item.name += " "
+ + Algorithms.formatDuration((int) (tm / 1000)) + "";
+ }
+
+ item.locationStart = r.points.get(0);
+ item.locationEnd = r.points.get(r.points.size() - 1);
+ list.add(item);
+ }
+ }
+ }
+
public SelectedGpxFile getSelectedFileByPath(String path) {
for(SelectedGpxFile s : selectedGPXFiles) {
if(s.getGpxFile().path.equals(path)) {
@@ -181,6 +250,15 @@ public class GpxSelectionHelper {
saveCurrentSelections();
}
+ public void setUiListener(Runnable r) {
+ this.uiListener = r;
+ }
+
+ public Runnable getUiListener() {
+ return uiListener;
+ }
+
+
public static class SelectedGpxFile {
private boolean showCurrentTrack;
private GPXFile gpxFile;
@@ -290,15 +368,18 @@ public class GpxSelectionHelper {
public static class GpxDisplayItem {
+ public GpxDisplayGroup group;
public WptPt locationStart;
public WptPt locationEnd;
public String name;
public String description;
public String url;
public Bitmap image;
+ public boolean expanded;
}
+
}
diff --git a/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java
index 9e89ef1719..2bfc8586fd 100644
--- a/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java
+++ b/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java
@@ -14,7 +14,6 @@ import java.util.Set;
import net.osmand.IndexConstants;
import net.osmand.access.AccessibleToast;
-import net.osmand.data.LatLon;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.GPXUtilities;
@@ -38,6 +37,8 @@ import android.graphics.Typeface;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
+import android.text.Html;
+import android.text.Spanned;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
@@ -257,6 +258,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
return true;
}
runSelection(true);
+ actionMode.finish();
return true;
}
@@ -457,7 +459,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
protected List doInBackground(Activity... params) {
List result = new ArrayList();
- if(savingTrackHelper.getCurrentGpx().isEmpty()) {
+ if(!savingTrackHelper.getCurrentGpx().isEmpty()) {
loadFile(new GpxInfo(savingTrackHelper.getCurrentGpx(),
getMyApplication().getString(R.string.gpx_available_current_track)));
}
@@ -600,7 +602,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
if(info.gpx != null && info.gpx.showCurrentTrack) {
catName = info.name;
} else {
- catName = info.subfolder;
+ catName = getString(R.string.local_indexes_cat_gpx) + " " + info.subfolder;
}
int found = -1;
// search from end
@@ -647,7 +649,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
if (child.isCorrupted()) {
viewName.setTextColor(corruptedColor);
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
- } else if(selectedGpxHelper.getSelectedFileByPath(child.getFileName()) != null){
+ } else if(selectedGpxHelper.getSelectedFileByName(child.getFileName()) != null){
viewName.setTextColor(okColor);
viewName.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
} else {
@@ -668,7 +670,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
TextView descr = ((TextView) v.findViewById(R.id.local_index_descr));
if (child.isExpanded()) {
descr.setVisibility(View.VISIBLE);
- descr.setText(child.getDescription());
+ descr.setText(child.getHtmlDescription());
} else {
descr.setVisibility(View.GONE);
}
@@ -702,7 +704,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
LayoutInflater inflater = getActivity().getLayoutInflater();
v = inflater.inflate(net.osmand.plus.R.layout.expandable_list_item_category, parent, false);
}
- StringBuilder t = new StringBuilder(getString(R.string.local_indexes_cat_gpx) + " " + group);
+ StringBuilder t = new StringBuilder(group);
adjustIndicator(groupPosition, isExpanded, v);
TextView nameView = ((TextView) v.findViewById(R.id.category_name));
List list = data.get(group);
@@ -891,6 +893,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
protected void onPostExecute(String result) {
+ Runnable r = selectedGpxHelper.getUiListener();
+ if(r != null) {
+ r.run();
+ }
getSherlockActivity().setProgressBarIndeterminateVisibility(false);
if(showOnMap && toShow != null) {
getMyApplication().getSettings().setMapLocationToShow(toShow.lat, toShow.lon,
@@ -957,12 +963,14 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
GpxInfo item = listAdapter.getChild(groupPosition, childPosition);
+ if(!selectionMode){
item.setExpanded(!item.isExpanded());
+
if (item.isExpanded()) {
descriptionLoader = new LoadLocalIndexDescriptionTask();
descriptionLoader.execute(item);
}
- if(selectionMode){
+ } else {
selectedItems.add(item);
}
listAdapter.notifyDataSetInvalidated();
@@ -981,6 +989,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
private String description;
private boolean corrupted;
private boolean expanded;
+ private Spanned htmlDescription;
public GpxInfo(){
}
@@ -1034,6 +1043,16 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
return description;
}
+ public Spanned getHtmlDescription() {
+ if(htmlDescription != null) {
+ return htmlDescription;
+ }
+ htmlDescription = Html.fromHtml(getDescription().toString().replace("\n", "
"));
+ return htmlDescription;
+ }
+
+
+
public void setGpx(GPXFile gpx) {
this.gpx = gpx;
}
@@ -1050,6 +1069,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
description = GpxUiHelper.getDescription(app, gpx, file) +
app.getString(R.string.local_index_gpx_info_show);
}
+ htmlDescription = null;
+ getHtmlDescription();
}
public String getFileName() {
if(fileName != null) {
diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java
index 0fb9130cd6..fdf2812a25 100644
--- a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java
+++ b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java
@@ -27,14 +27,11 @@ import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
import net.osmand.binary.BinaryMapTransportReaderAdapter.TransportIndex;
import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager;
-import net.osmand.plus.GPXUtilities;
-import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.SQLiteTileSource;
import net.osmand.plus.activities.LocalIndexesActivity.LoadLocalIndexTask;
-import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.voice.MediaCommandPlayerImpl;
import net.osmand.plus.voice.TTSCommandPlayerImpl;
import net.osmand.util.MapUtils;
@@ -69,8 +66,6 @@ public class LocalIndexHelper {
File f = new File(info.getPathToData());
if(info.getType() == LocalIndexType.MAP_DATA){
updateObfFileInformation(info, f);
- } else if(info.getType() == LocalIndexType.GPX_DATA){
- updateGpxInfo(info, f);
} else if(info.getType() == LocalIndexType.VOICE_DATA){
info.setDescription(getInstalledDate(f));
} else if(info.getType() == LocalIndexType.TTS_VOICE_DATA){
@@ -107,21 +102,6 @@ public class LocalIndexHelper {
}
- private void updateGpxInfo(LocalIndexInfo info, File f) {
- if(info.getGpxFile() == null){
- info.setGpxFile(GPXUtilities.loadGPXFile(app, f));
- }
- GPXFile result = info.getGpxFile();
- if(result.warning != null){
- info.setCorrupted(true);
- info.setDescription(result.warning);
- } else {
- // 'Long-press for options' message
- info.setDescription(GpxUiHelper.getDescription(app, result, f) +
- app.getString(R.string.local_index_gpx_info_show));
- }
- }
-
public List getLocalIndexData(LoadLocalIndexTask loadTask){
Map loadedMaps = app.getResourceManager().getIndexFileNames();
List result = new ArrayList();
@@ -297,7 +277,6 @@ public class LocalIndexHelper {
SRTM_DATA(R.string.local_indexes_cat_srtm),
VOICE_DATA(R.string.local_indexes_cat_voice),
TTS_VOICE_DATA(R.string.local_indexes_cat_tts),
- GPX_DATA(R.string.local_indexes_cat_gpx),
AV_DATA(R.string.local_indexes_cat_av);;
private final int resId;
diff --git a/OsmAnd/src/net/osmand/plus/activities/SelectedGPXFragment.java b/OsmAnd/src/net/osmand/plus/activities/SelectedGPXFragment.java
index 7f7f8210dc..50d502907d 100644
--- a/OsmAnd/src/net/osmand/plus/activities/SelectedGPXFragment.java
+++ b/OsmAnd/src/net/osmand/plus/activities/SelectedGPXFragment.java
@@ -10,11 +10,13 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import android.app.Activity;
+import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.Filter;
+import android.widget.ImageView;
import android.widget.TextView;
import com.actionbarsherlock.view.ActionMode;
@@ -53,6 +55,19 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
public void onResume() {
super.onResume();
adapter.setDisplayGroups(selectedGpxHelper.getDisplayGroups());
+ selectedGpxHelper.setUiListener(new Runnable() {
+
+ @Override
+ public void run() {
+ adapter.setDisplayGroups(selectedGpxHelper.getDisplayGroups());
+ }
+ });
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ selectedGpxHelper.setUiListener(null);
}
@@ -104,6 +119,7 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
public void setDisplayGroups(List displayGroups) {
this.displayGroups = displayGroups;
+ notifyDataSetChanged();
}
@@ -192,50 +208,24 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
View row = convertView;
if (row == null) {
LayoutInflater inflater = getActivity().getLayoutInflater();
- row = inflater.inflate(R.layout.favourites_list_item, parent, false);
+ row = inflater.inflate(R.layout.gpx_item_list_item, parent, false);
+ }
+
+ TextView label = (TextView) row.findViewById(R.id.name);
+ TextView additional = (TextView) row.findViewById(R.id.additional);
+ TextView description = (TextView) row.findViewById(R.id.description);
+ ImageView icon = (ImageView) row.findViewById(R.id.icon);
+ GpxDisplayItem child = getChild(groupPosition, childPosition);
+ row.setTag(child);
+ icon.setImageResource(R.drawable.list_favorite);
+ label.setText(Html.fromHtml(child.name.replace("\n", "
")));
+ if(child.expanded) {
+ description.setText(Html.fromHtml(child.description.replace("\n", "
")));
+ description.setVisibility(View.VISIBLE);
+ } else {
+ description.setVisibility(View.GONE);
}
-// TextView label = (TextView) row.findViewById(R.id.favourite_label);
-// ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon);
-// final FavouritePoint model = (FavouritePoint) getChild(groupPosition, childPosition);
-// row.setTag(model);
-// if (model.isStored()) {
-// icon.setImageResource(R.drawable.list_favorite);
-// } else {
-// icon.setImageResource(R.drawable.opened_poi);
-// }
-// LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
-// int dist = (int) (MapUtils.getDistance(model.getLatitude(), model.getLongitude(),
-// lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude()));
-// String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication()) + " ";
-// label.setText(distance + model.getName(), TextView.BufferType.SPANNABLE);
-// ((Spannable) label.getText()).setSpan(
-// new ForegroundColorSpan(getResources().getColor(R.color.color_distance)), 0, distance.length() - 1,
-// 0);
-// final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
-// if (selectionMode && model.isStored()) {
-// ch.setVisibility(View.VISIBLE);
-// ch.setChecked(favoritesToDelete.contains(model));
-// row.findViewById(R.id.favourite_icon).setVisibility(View.GONE);
-// ch.setOnClickListener(new View.OnClickListener() {
-//
-// @Override
-// public void onClick(View v) {
-// if (ch.isChecked()) {
-// favoritesToDelete.add(model);
-// } else {
-// favoritesToDelete.remove(model);
-// if (groupsToDelete.contains(model.getCategory())) {
-// groupsToDelete.remove(model.getCategory());
-// favouritesAdapter.notifyDataSetInvalidated();
-// }
-// }
-// }
-// });
-// } else {
-// row.findViewById(R.id.favourite_icon).setVisibility(View.VISIBLE);
-// ch.setVisibility(View.GONE);
-// }
return row;
}
@@ -244,7 +234,10 @@ public class SelectedGPXFragment extends OsmandExpandableListFragment {
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
- return false;
+ GpxDisplayItem child = adapter.getChild(groupPosition, childPosition);
+ child.expanded = !child.expanded;
+ adapter.notifyDataSetInvalidated();
+ return true;
}
diff --git a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java
index a4cf7ddf41..49549b986a 100644
--- a/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java
+++ b/OsmAnd/src/net/osmand/plus/helpers/GpxUiHelper.java
@@ -13,9 +13,11 @@ import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
+import net.osmand.plus.GPXUtilities.TrkSegment;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
+import net.osmand.util.Algorithms;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
@@ -44,42 +46,75 @@ public class GpxUiHelper {
return getDescription(app, analysis);
}
+ public static String getDescription(OsmandApplication app, TrkSegment t) {
+ return getDescription(app, GPXTrackAnalysis.segment(0, t));
+ }
+
+
+
+ private static String getColorValue(String clr, String value) {
+ return "" + value + "";
+ }
public static String getDescription(OsmandApplication app, GPXTrackAnalysis analysis) {
StringBuilder description = new StringBuilder();
+ String timeSpanClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_time_span_color));
+ String distanceClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_distance_color));
+ String speedClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_speed));
+ String ascClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_altitude_asc));
+ String descClr = Algorithms.colorToString(app.getResources().getColor(R.color.gpx_altitude_desc));
// OUTPUT:
// 1. Total distance, Start time, End time
- description.append(app.getString(R.string.local_index_gpx_info, analysis.totalTracks, analysis.points,
- analysis.wptPoints, OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app),
- analysis.startTime, analysis.endTime));
+ // TODO distance
+ description.append(app.getString(R.string.gpx_info_distance, getColorValue(distanceClr,
+ OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app)),
+ getColorValue(distanceClr, analysis.points+"") ));
+ if(analysis.totalTracks > 1) {
+ description.append("
").append(app.getString(R.string.gpx_info_subtracks, getColorValue(speedClr, analysis.totalTracks+"")));
+ }
+ if(analysis.wptPoints > 0) {
+ description.append("
").append(app.getString(R.string.gpx_info_waypoints, getColorValue(speedClr, analysis.wptPoints+"")));
+ }
+ if(analysis.isTimeSpecified()) {
+ description.append("
").append(app.getString(R.string.gpx_info_start_time, analysis.startTime));
+ description.append("
").append(app.getString(R.string.gpx_info_end_time, analysis.endTime));
+ }
// 2. Time span
- description.append(app.getString(R.string.local_index_gpx_timespan, analysis.getTimeHours(analysis.timeSpan),
- analysis.getTimeMinutes(analysis.timeSpan), analysis.getTimeSeconds(analysis.timeSpan)));
+ if(analysis.timeSpan > 0 && analysis.timeSpan / 1000 != analysis.timeMoving / 1000) {
+ final String formatDuration = Algorithms.formatDuration((int) (analysis.timeSpan/1000)
+ );
+ description.append("
").append(app.getString(R.string.gpx_timespan,
+ getColorValue(timeSpanClr, formatDuration)));
+ }
// 3. Time moving, if any
if(analysis.isTimeMoving()){
- description.append(
- app.getString(R.string.local_index_gpx_timemoving, analysis.getTimeHours(analysis.timeMoving),
- analysis.getTimeMinutes(analysis.timeMoving), analysis.getTimeSeconds(analysis.timeMoving)));
+ final String formatDuration = Algorithms.formatDuration((int) (analysis.timeMoving/1000)
+ );
+ description.append("
").append(app.getString(R.string.gpx_timemoving,
+ getColorValue(timeSpanClr, formatDuration)));
}
// 4. Elevation, eleUp, eleDown, if recorded
- if(analysis.isElevationSpecified()){
- description.append(
- app.getString(R.string.local_index_gpx_info_elevation,
- OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app),
- OsmAndFormatter.getFormattedAlt(analysis.minElevation, app),
- OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app),
- OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app),
- OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app)));
+ if (analysis.isElevationSpecified()) {
+ description.append("
");
+ description.append(app.getString(R.string.gpx_info_avg_altitude,
+ getColorValue(speedClr, OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app))));
+ description.append("
");
+ String min = getColorValue(descClr, OsmAndFormatter.getFormattedAlt(analysis.minElevation, app));
+ String max = getColorValue(ascClr, OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app));
+ String asc = getColorValue(ascClr, OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app));
+ String desc = getColorValue(descClr, OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app));
+ String format = min +" - " + max + " ( \u2193 " + desc + ", \u2191 " + asc + " ) ";
+ description.append(app.getString(R.string.gpx_info_difference_altitude,format));
}
if(analysis.isSpeedSpecified()){
- description.append(
- app.getString(R.string.local_index_gpx_info_speed,
- OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app),
- OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app)));
+ String avg = getColorValue(speedClr, OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app));
+ String max = getColorValue(ascClr, OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app));
+ description.append("
").append(app.getString(R.string.gpx_info_average_speed,avg));
+ description.append("
").append(app.getString(R.string.gpx_info_maximum_speed,max));
}
return description.toString();
}
diff --git a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java
index 90a42b2f20..826e73f2d0 100644
--- a/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java
+++ b/OsmAnd/src/net/osmand/plus/views/MapInfoLayer.java
@@ -668,14 +668,16 @@ public class MapInfoLayer extends OsmandMapLayer {
private UpdateFrameLayout createBackToLocation(MapInfoWidgetsFactory mic){
progressBar = new View(view.getContext());
+ progressBar.setPadding((int) (5 * scaleCoefficient), 0, (int) (5 * scaleCoefficient), 0);
final ImageViewWidget widget = mic.createBackToLocation(map);
- Drawable backToLoc = map.getResources().getDrawable(R.drawable.back_to_loc);
+ Drawable backToLoc = map.getResources().getDrawable(R.drawable.la_backtoloc_disabled);
UpdateFrameLayout layout = new UpdateFrameLayout(view.getContext(), widget) ;
FrameLayout.LayoutParams fparams;
- //= new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
- fparams = new FrameLayout.LayoutParams(backToLoc.getMinimumWidth(), backToLoc.getMinimumHeight());
+ fparams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
layout.addView(widget, fparams);
- fparams = new FrameLayout.LayoutParams(backToLoc.getMinimumWidth(), backToLoc.getMinimumHeight());
+ fparams = new FrameLayout.LayoutParams((int) (backToLoc.getMinimumWidth() ),
+ backToLoc.getMinimumHeight());
+ fparams.setMargins((int) (5 * scaleCoefficient), 0, 0, 0);
layout.addView(progressBar, fparams);
layout.setOnClickListener(new View.OnClickListener() {
@Override