Refactor labels
This commit is contained in:
parent
aba4a57d27
commit
c3d3f509c1
15 changed files with 308 additions and 121 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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$
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
51
OsmAnd/res/layout/gpx_item_list_item.xml
Normal file
51
OsmAnd/res/layout/gpx_item_list_item.xml
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?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="vertical"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingTop="4dp" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="fill_parent"
|
||||
android:paddingRight="2dp"
|
||||
android:paddingTop="2dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name"
|
||||
style="@style/ListText.Small"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical" >
|
||||
</TextView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/additional"
|
||||
style="@style/ListText.Small"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="3dp"
|
||||
android:gravity="right" >
|
||||
</TextView>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
style="@style/ListText.Small"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="25" >
|
||||
</TextView>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,5 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="gpx_speed">#CCAA0088</color>
|
||||
<color name="gpx_altitude_desc">#32CD32</color>
|
||||
<color name="gpx_altitude_asc">#EE3232</color>
|
||||
<color name="gpx_distance_color">#FD9822</color>
|
||||
<color name="gpx_time_span_color">#0080FF</color>
|
||||
|
||||
<color name="color_transparent">#00000000</color>
|
||||
|
||||
<!-- style colors -->
|
||||
|
|
|
@ -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
|
||||
-->
|
||||
<string name="local_index_gpx_info_show">\n\nPress and hold for options</string>
|
||||
<string name="gpx_info_subtracks">Subtracks: %1$s </string>
|
||||
<string name="gpx_info_waypoints">Waypoints: %1$s </string>
|
||||
<string name="gpx_info_distance">Distance: %1$s (%2$s points) </string>
|
||||
<string name="gpx_info_start_time">Start time: %1$tF, %1$tR </string>
|
||||
<string name="gpx_info_end_time">End time: %1$tF, %1$tR </string>
|
||||
<string name="gpx_info_average_speed">Average speed: %1$s </string>
|
||||
<string name="gpx_info_maximum_speed">Maximum speed: %1$s </string>
|
||||
<string name="gpx_info_avg_altitude">Average altitude: %1$s</string>
|
||||
<string name="gpx_info_difference_altitude">Altitude diff.: %1$s</string>
|
||||
<string name="gpx_timespan">Time span: %1$s</string>
|
||||
<string name="gpx_timemoving">Time moving: %1$s</string>
|
||||
<string name="gpx_selection_segment_title">Segment</string>
|
||||
<string name="gpx_selection_number_of_points"> %1$s points</string>
|
||||
<string name="gpx_selection_point">Point %1$s</string>
|
||||
<string name="gpx_selection_current_track">recording</string>
|
||||
<string name="gpx_selection_route_points">Gpx %1$s - Route points %2$s</string>
|
||||
<string name="gpx_selection_points">Gpx %1$s - Points</string>
|
||||
|
@ -321,8 +335,7 @@
|
|||
<string name="route_to">To:</string>
|
||||
<string name="route_via">Via:</string>
|
||||
<string name="route_from">From:</string>
|
||||
<string name="local_index_gpx_timespan">\nTime span: %1$d:%2$02d:%3$02d</string>
|
||||
<string name="local_index_gpx_timemoving">\nTime moving: %1$d:%2$02d:%3$02d</string>
|
||||
|
||||
<string name="app_mode_default">Browse map</string>
|
||||
<string name="settings_preset">Default profile</string>
|
||||
<string name="settings_preset_descr">Map view and navigation settings are remembered per use profile. Set your default profile here.</string>
|
||||
|
@ -1279,10 +1292,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
|
|||
<string name="vector_map_not_needed">No, thanks</string>
|
||||
<string name="basemap_missing">Base world map (covering the whole world at small zooms) is missing. Please consider downloading World_basemap_x.obf for a complete environment.</string>
|
||||
<string name="vector_data_missing">On board (\'offline\') data is missing on SD card. Please consider to download it in order to use maps offline.</string>
|
||||
<string name="local_index_gpx_info_show">\n\nPress and hold for options</string>
|
||||
<string name="local_index_gpx_info_speed">\nAverage speed: %1$s \nMaximum speed: %2$s</string>
|
||||
<string name="local_index_gpx_info_elevation">\nAverage altitude: %1$s\nMinimum altitude: %2$s\nMaximum altitude: %3$s\nAscents: %4$s\nDescents: %5$s</string>
|
||||
<string name="local_index_gpx_info">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</string>
|
||||
<string name="local_index_installed">Edition</string>
|
||||
<string name="local_index_items_backuped">%1$d of %2$d item(s) successfully deactivated.</string>
|
||||
<string name="local_index_items_deleted">%1$d of %2$d item(s) successfully deleted.</string>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<SelectedGpxFile> selectedGPXFiles = new java.util.concurrent.CopyOnWriteArrayList<SelectedGpxFile>();
|
||||
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<GpxDisplayItem> 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<GpxDisplayItem> 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<GpxDisplayItem> 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 = " <font color=\"" + distanceClr + "\">"
|
||||
+ OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app) + "</font>";
|
||||
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 += " <font color=\"" + timeSpanClr + "\">"
|
||||
+ Algorithms.formatDuration((int) (tm / 1000)) + "</font>";
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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<GpxInfo> doInBackground(Activity... params) {
|
||||
List<GpxInfo> result = new ArrayList<GpxInfo>();
|
||||
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<GpxInfo> 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", "<br/>"));
|
||||
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) {
|
||||
|
|
|
@ -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<LocalIndexInfo> getLocalIndexData(LoadLocalIndexTask loadTask){
|
||||
Map<String, String> loadedMaps = app.getResourceManager().getIndexFileNames();
|
||||
List<LocalIndexInfo> result = new ArrayList<LocalIndexInfo>();
|
||||
|
@ -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;
|
||||
|
|
|
@ -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<GpxDisplayGroup> 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", "<br/>")));
|
||||
if(child.expanded) {
|
||||
description.setText(Html.fromHtml(child.description.replace("\n", "<br/>")));
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 "<font color=\"" + clr + "\">" + value + "</font>";
|
||||
}
|
||||
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("<br/>").append(app.getString(R.string.gpx_info_subtracks, getColorValue(speedClr, analysis.totalTracks+"")));
|
||||
}
|
||||
if(analysis.wptPoints > 0) {
|
||||
description.append("<br/>").append(app.getString(R.string.gpx_info_waypoints, getColorValue(speedClr, analysis.wptPoints+"")));
|
||||
}
|
||||
if(analysis.isTimeSpecified()) {
|
||||
description.append("<br/>").append(app.getString(R.string.gpx_info_start_time, analysis.startTime));
|
||||
description.append("<br/>").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("<br/>").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("<br/>").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("<br/>");
|
||||
description.append(app.getString(R.string.gpx_info_avg_altitude,
|
||||
getColorValue(speedClr, OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app))));
|
||||
description.append("<br/>");
|
||||
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("<br/>").append(app.getString(R.string.gpx_info_average_speed,avg));
|
||||
description.append("<br/>").append(app.getString(R.string.gpx_info_maximum_speed,max));
|
||||
}
|
||||
return description.toString();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue