From 7aa0302521a7ae093cbb289aeb1add3073eec5ff Mon Sep 17 00:00:00 2001 From: MKer Date: Sat, 17 Sep 2016 15:14:55 +0200 Subject: [PATCH] Minor code improvements. --- .../clustering/GridMarkerClusterer.java | 3 +- .../org/osmdroid/bonuspack/kml/HotSpot.java | 4 +- .../osmdroid/bonuspack/kml/KmlDocument.java | 100 +++++++++--------- .../osmdroid/bonuspack/kml/KmlLineString.java | 6 +- .../org/osmdroid/bonuspack/kml/KmlPoint.java | 6 +- .../org/osmdroid/bonuspack/kml/KmlTrack.java | 23 ++-- .../bonuspack/location/GeocoderGisgraphy.java | 9 +- .../bonuspack/location/GeocoderNominatim.java | 11 +- .../bonuspack/utils/PolylineEncoder.java | 4 +- .../java/com/osmnavigator/KmlListAdapter.java | 18 ++-- .../java/com/osmnavigator/MapActivity.java | 4 +- .../res/drawable-mdpi/kml_icon_gxtrack.png | Bin 0 -> 224 bytes .../src/main/res/values-fr/strings.xml | 4 +- OSMNavigator/src/main/res/values/strings.xml | 4 +- 14 files changed, 98 insertions(+), 98 deletions(-) create mode 100644 OSMNavigator/src/main/res/drawable-mdpi/kml_icon_gxtrack.png diff --git a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/clustering/GridMarkerClusterer.java b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/clustering/GridMarkerClusterer.java index 3c844ae6..932f31e9 100644 --- a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/clustering/GridMarkerClusterer.java +++ b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/clustering/GridMarkerClusterer.java @@ -1,6 +1,5 @@ package org.osmdroid.bonuspack.clustering; -import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Color; @@ -40,7 +39,7 @@ /** anchor point to draw the number of markers inside the cluster icon */ public float mTextAnchorU = Marker.ANCHOR_CENTER, mTextAnchorV = Marker.ANCHOR_CENTER; - public GridMarkerClusterer(Context ctx) { + public GridMarkerClusterer() { super(); mTextPaint = new Paint(); mTextPaint.setColor(Color.WHITE); diff --git a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/HotSpot.java b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/HotSpot.java index 1df3b18d..eb97faea 100644 --- a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/HotSpot.java +++ b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/HotSpot.java @@ -12,11 +12,11 @@ */ public class HotSpot implements Parcelable { - public static enum Units { + public enum Units { fraction, pixels, insetPixels; private static Units[] allValues = values(); public static Units fromOrdinal(int n) {return allValues[n];} - }; + } public float mx, my; public Units mXUnits, mYUnits; diff --git a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlDocument.java b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlDocument.java index cbdb8656..b25ebb07 100644 --- a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlDocument.java +++ b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlDocument.java @@ -378,60 +378,60 @@ else if (kmzContainer == null){ public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { - if (localName.equals("Document")){ + if (name.equals("Document")) { mKmlCurrentFeature = mKmlRoot; //If there is a Document, it will be the root. mKmlCurrentFeature.mId = attributes.getValue("id"); - } else if (localName.equals("Folder")){ + } else if (name.equals("Folder")) { mKmlCurrentFeature = new KmlFolder(); mKmlCurrentFeature.mId = attributes.getValue("id"); mKmlFeatureStack.add(mKmlCurrentFeature); //push on stack - } else if (localName.equals("NetworkLink")){ + } else if (name.equals("NetworkLink")) { mKmlCurrentFeature = new KmlFolder(); mKmlCurrentFeature.mId = attributes.getValue("id"); mKmlFeatureStack.add(mKmlCurrentFeature); //push on stack mIsNetworkLink = true; - } else if (localName.equals("GroundOverlay")){ + } else if (name.equals("GroundOverlay")) { mKmlCurrentGroundOverlay = new KmlGroundOverlay(); mKmlCurrentFeature = mKmlCurrentGroundOverlay; mKmlCurrentFeature.mId = attributes.getValue("id"); mKmlFeatureStack.add(mKmlCurrentFeature); //push on stack - } else if (localName.equals("Placemark")) { + } else if (name.equals("Placemark")) { mKmlCurrentFeature = new KmlPlacemark(); mKmlCurrentFeature.mId = attributes.getValue("id"); mKmlFeatureStack.add(mKmlCurrentFeature); //push on Feature stack - } else if (localName.equals("Point")){ + } else if (name.equals("Point")) { mKmlCurrentGeometry = new KmlPoint(); mKmlGeometryStack.add(mKmlCurrentGeometry); //push on Geometry stack - } else if (localName.equals("LineString")){ + } else if (name.equals("LineString")) { mKmlCurrentGeometry = new KmlLineString(); mKmlGeometryStack.add(mKmlCurrentGeometry); } else if (name.equals("gx:Track")) { mKmlCurrentGeometry = new KmlTrack(); mKmlGeometryStack.add(mKmlCurrentGeometry); - } else if (localName.equals("Polygon")){ + } else if (name.equals("Polygon")) { mKmlCurrentGeometry = new KmlPolygon(); mKmlGeometryStack.add(mKmlCurrentGeometry); - } else if (localName.equals("innerBoundaryIs")) { + } else if (name.equals("innerBoundaryIs")) { mIsInnerBoundary = true; - } else if (localName.equals("MultiGeometry")){ + } else if (name.equals("MultiGeometry")) { mKmlCurrentGeometry = new KmlMultiGeometry(); mKmlGeometryStack.add(mKmlCurrentGeometry); - } else if (localName.equals("Style")) { + } else if (name.equals("Style")) { mCurrentStyle = new Style(); mCurrentStyleId = attributes.getValue("id"); - } else if (localName.equals("StyleMap")) { + } else if (name.equals("StyleMap")) { mCurrentStyleMap = new StyleMap(); mCurrentStyleId = attributes.getValue("id"); - } else if (localName.equals("LineStyle")) { + } else if (name.equals("LineStyle")) { mCurrentStyle.mLineStyle = new LineStyle(); mColorStyle = mCurrentStyle.mLineStyle; - } else if (localName.equals("PolyStyle")) { + } else if (name.equals("PolyStyle")) { mCurrentStyle.mPolyStyle = new ColorStyle(); mColorStyle = mCurrentStyle.mPolyStyle; - } else if (localName.equals("IconStyle")) { + } else if (name.equals("IconStyle")) { mCurrentStyle.mIconStyle = new IconStyle(); mColorStyle = mCurrentStyle.mIconStyle; - } else if (localName.equals("hotSpot")){ + } else if (name.equals("hotSpot")) { if (mCurrentStyle != null && mColorStyle != null && mColorStyle instanceof IconStyle){ mCurrentStyle.mIconStyle.mHotSpot = new HotSpot( Float.parseFloat(attributes.getValue("x")), @@ -446,7 +446,7 @@ public void startElement(String uri, String localName, String name, mCurrentStyle.mIconStyle.mHotSpotY = Float.parseFloat(attributes.getValue("y")); */ } - } else if (localName.equals("Data") || localName.equals("SimpleData")) { + } else if (name.equals("Data") || name.equals("SimpleData")) { mDataName = attributes.getValue("name"); } mStringBuilder.setLength(0); @@ -459,20 +459,20 @@ public void startElement(String uri, String localName, String name, public void endElement(String uri, String localName, String name) throws SAXException { - if (localName.equals("Document")){ + if (name.equals("Document")) { //Document is the root, nothing to do. - } else if (localName.equals("Folder") || localName.equals("Placemark") - || localName.equals("NetworkLink") || localName.equals("GroundOverlay")) { + } else if (name.equals("Folder") || name.equals("Placemark") + || name.equals("NetworkLink") || name.equals("GroundOverlay")) { //this was a Feature: KmlFolder parent = (KmlFolder)mKmlFeatureStack.get(mKmlFeatureStack.size()-2); //get parent parent.add(mKmlCurrentFeature); //add current in its parent mKmlFeatureStack.remove(mKmlFeatureStack.size()-1); //pop current from stack mKmlCurrentFeature = mKmlFeatureStack.get(mKmlFeatureStack.size()-1); //set current to top of stack - if (localName.equals("NetworkLink")) + if (name.equals("NetworkLink")) mIsNetworkLink = false; - else if (localName.equals("GroundOverlay")) + else if (name.equals("GroundOverlay")) mKmlCurrentGroundOverlay = null; - } else if (localName.equals("innerBoundaryIs")){ + } else if (name.equals("innerBoundaryIs")) { mIsInnerBoundary = false; } else if (name.equals("Point") || name.equals("LineString") || name.equals("Polygon") || name.equals("MultiGeometry") || name.equals("gx:Track")) { @@ -488,15 +488,15 @@ else if (localName.equals("GroundOverlay")) mKmlGeometryStack.remove(mKmlGeometryStack.size()-1); //pop current from stack mKmlCurrentGeometry = mKmlGeometryStack.get(mKmlGeometryStack.size()-1); //set current to top of stack } - } else if (localName.equals("name")){ + } else if (name.equals("name")) { mKmlCurrentFeature.mName = mStringBuilder.toString(); - } else if (localName.equals("description")){ + } else if (name.equals("description")) { mKmlCurrentFeature.mDescription = mStringBuilder.toString(); - } else if (localName.equals("visibility")){ + } else if (name.equals("visibility")) { mKmlCurrentFeature.mVisibility = ("1".equals(mStringBuilder.toString())); - } else if (localName.equals("open")){ + } else if (name.equals("open")) { mKmlCurrentFeature.mOpen = ("1".equals(mStringBuilder.toString())); - } else if (localName.equals("coordinates")) { + } else if (name.equals("coordinates")) { if (mKmlCurrentFeature instanceof KmlPlacemark) { if (!mIsInnerBoundary) { mKmlCurrentGeometry.mCoordinates = parseKmlCoordinates(mStringBuilder.toString()); @@ -511,10 +511,10 @@ else if (localName.equals("GroundOverlay")) } else if (name.equals("gx:coord")) { if (mKmlCurrentGeometry != null && mKmlCurrentGeometry instanceof KmlTrack) ((KmlTrack) mKmlCurrentGeometry).addGxCoord(mStringBuilder.toString()); - } else if (localName.equals("when")){ + } else if (name.equals("when")) { if (mKmlCurrentGeometry != null && mKmlCurrentGeometry instanceof KmlTrack) ((KmlTrack) mKmlCurrentGeometry).addWhen(mStringBuilder.toString()); - } else if (localName.equals("styleUrl")){ + } else if (name.equals("styleUrl")) { String styleUrl; if (mStringBuilder.charAt(0) == '#') styleUrl = mStringBuilder.substring(1); //remove the # @@ -526,30 +526,30 @@ else if (localName.equals("GroundOverlay")) } else if (mKmlCurrentFeature != null){ mKmlCurrentFeature.mStyle = styleUrl; } - } else if (localName.equals("key")){ + } else if (name.equals("key")) { mCurrentStyleKey = mStringBuilder.toString(); - } else if (localName.equals("color")){ + } else if (name.equals("color")) { if (mCurrentStyle != null) { if (mColorStyle != null) mColorStyle.mColor = ColorStyle.parseKMLColor(mStringBuilder.toString()); } else if (mKmlCurrentGroundOverlay != null){ mKmlCurrentGroundOverlay.mColor = ColorStyle.parseKMLColor(mStringBuilder.toString()); } - } else if (localName.equals("colorMode")){ + } else if (name.equals("colorMode")) { if (mCurrentStyle != null && mColorStyle != null) mColorStyle.mColorMode = (mStringBuilder.toString().equals("random")?ColorStyle.MODE_RANDOM:ColorStyle.MODE_NORMAL); - } else if (localName.equals("width")){ + } else if (name.equals("width")) { if (mCurrentStyle != null && mColorStyle != null && mColorStyle instanceof LineStyle) mCurrentStyle.mLineStyle.mWidth = Float.parseFloat(mStringBuilder.toString()); - } else if (localName.equals("scale")){ + } else if (name.equals("scale")) { if (mCurrentStyle != null && mColorStyle != null && mColorStyle instanceof IconStyle){ mCurrentStyle.mIconStyle.mScale = Float.parseFloat(mStringBuilder.toString()); } - } else if (localName.equals("heading")){ + } else if (name.equals("heading")) { if (mCurrentStyle != null && mColorStyle != null && mColorStyle instanceof IconStyle){ mCurrentStyle.mIconStyle.mHeading = Float.parseFloat(mStringBuilder.toString()); } - } else if (localName.equals("href")) { + } else if (name.equals("href")) { if (mCurrentStyle != null && mColorStyle != null && mColorStyle instanceof IconStyle) { //href of an Icon in an IconStyle: String href = mStringBuilder.toString(); @@ -562,13 +562,13 @@ else if (localName.equals("GroundOverlay")) //href of a GroundOverlay Icon: mKmlCurrentGroundOverlay.setIcon(mStringBuilder.toString(), mFile, mKMZFile); } - } else if (localName.equals("LineStyle")){ + } else if (name.equals("LineStyle")) { mColorStyle = null; - } else if (localName.equals("PolyStyle")){ + } else if (name.equals("PolyStyle")) { mColorStyle = null; - } else if (localName.equals("IconStyle")){ + } else if (name.equals("IconStyle")) { mColorStyle = null; - } else if (localName.equals("Style")){ + } else if (name.equals("Style")) { if (mCurrentStyleId != null) putStyle(mCurrentStyleId, mCurrentStyle); else { @@ -580,32 +580,32 @@ else if (localName.equals("GroundOverlay")) } mCurrentStyle = null; mCurrentStyleId = null; - } else if (localName.equals("StyleMap")){ + } else if (name.equals("StyleMap")) { if (mCurrentStyleId != null) putStyle(mCurrentStyleId, mCurrentStyleMap); //TODO: inline StyleMap ??? mCurrentStyleMap = null; mCurrentStyleId = null; mCurrentStyleKey = null; - } else if (localName.equals("north")){ + } else if (name.equals("north")) { mNorth = Double.parseDouble(mStringBuilder.toString()); - } else if (localName.equals("south")){ + } else if (name.equals("south")) { mSouth = Double.parseDouble(mStringBuilder.toString()); - } else if (localName.equals("east")){ + } else if (name.equals("east")) { mEast = Double.parseDouble(mStringBuilder.toString()); - } else if (localName.equals("west")){ + } else if (name.equals("west")) { mWest = Double.parseDouble(mStringBuilder.toString()); - } else if (localName.equals("rotation")){ + } else if (name.equals("rotation")) { mKmlCurrentGroundOverlay.mRotation = Float.parseFloat(mStringBuilder.toString()); - } else if (localName.equals("LatLonBox")){ + } else if (name.equals("LatLonBox")) { if (mKmlCurrentGroundOverlay != null){ mKmlCurrentGroundOverlay.setLatLonBox(mNorth, mSouth, mEast, mWest); } - } else if (localName.equals("SimpleData")){ + } else if (name.equals("SimpleData")) { //We don't check the schema from SchemaData. We just pick the name and the value from SimpleData: mKmlCurrentFeature.setExtendedData(mDataName, mStringBuilder.toString()); mDataName = null; - } else if (localName.equals("value")){ + } else if (name.equals("value")) { mKmlCurrentFeature.setExtendedData(mDataName, mStringBuilder.toString()); mDataName = null; } diff --git a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlLineString.java b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlLineString.java index e0366cde..d25089c9 100644 --- a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlLineString.java +++ b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlLineString.java @@ -111,9 +111,9 @@ public void applyDefaultStyling(Polyline lineStringOverlay, Style defaultStyle, return 0; } - @Override public void writeToParcel(Parcel out, int flags) { - super.writeToParcel(out, flags); - } + //@Override public void writeToParcel(Parcel out, int flags) { + // super.writeToParcel(out, flags); + //} public static final Creator CREATOR = new Creator() { @Override public KmlLineString createFromParcel(Parcel source) { diff --git a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlPoint.java b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlPoint.java index 34582796..333e4467 100644 --- a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlPoint.java +++ b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlPoint.java @@ -133,9 +133,9 @@ public void applyDefaultStyling(Marker marker, Style defaultStyle, KmlPlacemark return 0; } - @Override public void writeToParcel(Parcel out, int flags) { - super.writeToParcel(out, flags); - } + //@Override public void writeToParcel(Parcel out, int flags) { + // super.writeToParcel(out, flags); + //} public static final Creator CREATOR = new Creator() { @Override public KmlPoint createFromParcel(Parcel source) { diff --git a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlTrack.java b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlTrack.java index ecf9703e..37b114fc 100644 --- a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlTrack.java +++ b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/kml/KmlTrack.java @@ -3,7 +3,6 @@ import android.content.Context; import android.os.Parcel; -import com.google.gson.JsonArray; import com.google.gson.JsonObject; import org.osmdroid.bonuspack.kml.KmlFeature.Styler; @@ -63,7 +62,7 @@ public void addGxCoord(String sGxCoord){ } /** - * @param sWhen "when" string, in one of the KML dateTime formats. Local time not supported yet. + * @param sWhen "when" string, in one of the KML dateTime formats. Local time format not supported yet. * @return java Date if success, or null */ public Date parseKmlWhen(String sWhen){ @@ -79,6 +78,9 @@ public Date parseKmlWhen(String sWhen){ case 19: ft = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); break; + case 20: + ft = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); + break; default: return null; } @@ -97,12 +99,6 @@ public void addWhen(String sWhen){ mWhen.add(parseKmlWhen(sWhen)); } - public KmlTrack(JsonObject json){ - this(); - JsonArray coordinates = json.get("coordinates").getAsJsonArray(); - mCoordinates = KmlGeometry.parseGeoJSONPositions(coordinates); - } - public void applyDefaultStyling(Polyline lineStringOverlay, Style defaultStyle, KmlPlacemark kmlPlacemark, KmlDocument kmlDocument, MapView map){ Context context = map.getContext(); @@ -187,8 +183,11 @@ public void applyDefaultStyling(Polyline lineStringOverlay, Style defaultStyle, //Cloneable implementation ------------------------------------ @Override public KmlTrack clone(){ - return (KmlTrack)super.clone(); - //TODO aWhen + KmlTrack cloned = (KmlTrack) super.clone(); + cloned.mWhen = new ArrayList<>(mWhen.size()); + for (Date d : mWhen) + cloned.mWhen.add((Date) d.clone()); + return cloned; } //Parcelable implementation ------------ @@ -199,7 +198,7 @@ public void applyDefaultStyling(Polyline lineStringOverlay, Style defaultStyle, @Override public void writeToParcel(Parcel out, int flags) { super.writeToParcel(out, flags); - //TODO aWhen + out.writeList(mWhen); } public static final Creator CREATOR = new Creator() { @@ -213,6 +212,6 @@ public void applyDefaultStyling(Polyline lineStringOverlay, Style defaultStyle, public KmlTrack(Parcel in){ super(in); - //TODO aWhen + mWhen = in.readArrayList(Date.class.getClassLoader()); } } diff --git a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/location/GeocoderGisgraphy.java b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/location/GeocoderGisgraphy.java index 08b7b07a..b6718a6b 100644 --- a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/location/GeocoderGisgraphy.java +++ b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/location/GeocoderGisgraphy.java @@ -1,6 +1,5 @@ package org.osmdroid.bonuspack.location; -import android.content.Context; import android.location.Address; import android.util.Log; @@ -41,13 +40,13 @@ public class GeocoderGisgraphy { protected Locale mLocale; protected String mServiceUrl; - public GeocoderGisgraphy(Context context, Locale locale){ + public GeocoderGisgraphy(Locale locale) { mLocale = locale; setService(GISGRAPHY_SERVICE_URL); //default service } - - public GeocoderGisgraphy(Context context){ - this(context, Locale.getDefault()); + + public GeocoderGisgraphy() { + this(Locale.getDefault()); } static public boolean isPresent(){ diff --git a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/location/GeocoderNominatim.java b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/location/GeocoderNominatim.java index dedc757c..bb1913b6 100644 --- a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/location/GeocoderNominatim.java +++ b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/location/GeocoderNominatim.java @@ -1,6 +1,5 @@ package org.osmdroid.bonuspack.location; -import android.content.Context; import android.location.Address; import android.os.Bundle; import android.util.Log; @@ -39,16 +38,16 @@ public class GeocoderNominatim { protected String mServiceUrl, mKey; protected String mUserAgent; protected boolean mPolygon; - - public GeocoderNominatim(Context context, Locale locale, String userAgent){ + + public GeocoderNominatim(Locale locale, String userAgent) { mLocale = locale; setOptions(false); setService(NOMINATIM_SERVICE_URL); //default service mUserAgent = userAgent; } - - public GeocoderNominatim(Context context, String userAgent){ - this(context, Locale.getDefault(), userAgent); + + public GeocoderNominatim(String userAgent) { + this(Locale.getDefault(), userAgent); } static public boolean isPresent(){ diff --git a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/utils/PolylineEncoder.java b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/utils/PolylineEncoder.java index 59d13121..30441fa8 100644 --- a/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/utils/PolylineEncoder.java +++ b/OSMBonusPack/src/main/java/org/osmdroid/bonuspack/utils/PolylineEncoder.java @@ -37,8 +37,8 @@ private static StringBuffer encodeNumber(int num) { * @return the encoded polyline, as a String */ public static String encode(ArrayList polyline, int precision) { - StringBuffer encodedPoints = new StringBuffer(); - int prev_lat = 0, prev_lng = 0; + StringBuilder encodedPoints = new StringBuilder(); + int prev_lat = 0, prev_lng = 0; for (GeoPoint trackpoint:polyline) { int lat = trackpoint.getLatitudeE6() / precision; int lng = trackpoint.getLongitudeE6() / precision; diff --git a/OSMNavigator/src/main/java/com/osmnavigator/KmlListAdapter.java b/OSMNavigator/src/main/java/com/osmnavigator/KmlListAdapter.java index d43a51d1..a50a7949 100644 --- a/OSMNavigator/src/main/java/com/osmnavigator/KmlListAdapter.java +++ b/OSMNavigator/src/main/java/com/osmnavigator/KmlListAdapter.java @@ -1,5 +1,13 @@ package com.osmnavigator; +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.TextView; + import org.osmdroid.bonuspack.kml.KmlFeature; import org.osmdroid.bonuspack.kml.KmlFolder; import org.osmdroid.bonuspack.kml.KmlGeometry; @@ -9,13 +17,7 @@ import org.osmdroid.bonuspack.kml.KmlPlacemark; import org.osmdroid.bonuspack.kml.KmlPoint; import org.osmdroid.bonuspack.kml.KmlPolygon; -import android.content.Context; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.ImageView; -import android.widget.TextView; +import org.osmdroid.bonuspack.kml.KmlTrack; public class KmlListAdapter extends BaseAdapter { @@ -78,6 +80,8 @@ else if (geometry instanceof KmlPolygon) img.setImageResource(R.drawable.kml_icon_polygon); else if (geometry instanceof KmlMultiGeometry) img.setImageResource(R.drawable.kml_icon_multigeometry); + else if (geometry instanceof KmlTrack) + img.setImageResource(R.drawable.kml_icon_gxtrack); else img.setImageDrawable(null); } else if (item instanceof KmlGroundOverlay){ diff --git a/OSMNavigator/src/main/java/com/osmnavigator/MapActivity.java b/OSMNavigator/src/main/java/com/osmnavigator/MapActivity.java index e1b6e075..164f1c0f 100644 --- a/OSMNavigator/src/main/java/com/osmnavigator/MapActivity.java +++ b/OSMNavigator/src/main/java/com/osmnavigator/MapActivity.java @@ -591,7 +591,7 @@ void updateUIWithTrackingMode(){ * Reverse Geocoding */ public String getAddress(GeoPoint p){ - GeocoderNominatim geocoder = new GeocoderNominatim(this, userAgent); + GeocoderNominatim geocoder = new GeocoderNominatim(userAgent); String theAddress; try { double dLatitude = p.getLatitude(); @@ -625,7 +625,7 @@ private class GeocodingTask extends AsyncTask> { protected List
doInBackground(Object... params) { String locationAddress = (String)params[0]; mIndex = (Integer)params[1]; - GeocoderNominatim geocoder = new GeocoderNominatim(getApplicationContext(), userAgent); + GeocoderNominatim geocoder = new GeocoderNominatim(userAgent); geocoder.setOptions(true); //ask for enclosing polygon (if any) try { BoundingBox viewbox = map.getBoundingBox(); diff --git a/OSMNavigator/src/main/res/drawable-mdpi/kml_icon_gxtrack.png b/OSMNavigator/src/main/res/drawable-mdpi/kml_icon_gxtrack.png new file mode 100644 index 0000000000000000000000000000000000000000..90e6dbdc3b093465bf49589f256012865d3e874f GIT binary patch literal 224 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`Gj%ROBjLn>}1rzi+!Ec^SPKRJH> z(GwmXwvMa@AMSVY=WLjE&b=+$xUs~lQ!Jra@=U;nL&@_cG(RzVD4$8azV5?fiLSHe zJDzxaV%+yY=_XUqffcNa#dw6cKRo4L71^-*jN~6Xg%k!?F@Z}xXVZVwcyGGCaq6xg zuQ=R-PM1%rZP4F3fonr6!$~`Zn@l-e8XHAY*fjh$L^Z5ouvPM8Jn?JeuD(kN&e!-E YTod*kaKAKz1L$N1Pgg&ebxsLQ04ShXMgRZ+ literal 0 HcmV?d00001 diff --git a/OSMNavigator/src/main/res/values-fr/strings.xml b/OSMNavigator/src/main/res/values-fr/strings.xml index 5cb7f256..5f09b7ef 100644 --- a/OSMNavigator/src/main/res/values-fr/strings.xml +++ b/OSMNavigator/src/main/res/values-fr/strings.xml @@ -44,7 +44,7 @@ Départ Destination Ajouter Etape - Ajouter Point KML + Poser un Marqueur Annuler @@ -63,7 +63,7 @@ GraphHopper - Vélo GraphHopper - Piéton Google - Voiture - Boîte à outils KML + Ma Carte Ouvrir url... Ouvrir fichier... OverpassAPI Wizard... diff --git a/OSMNavigator/src/main/res/values/strings.xml b/OSMNavigator/src/main/res/values/strings.xml index c2c5f884..761e4e84 100644 --- a/OSMNavigator/src/main/res/values/strings.xml +++ b/OSMNavigator/src/main/res/values/strings.xml @@ -45,7 +45,7 @@ Set Departure Set Destination Add Via-Point - Add KML Point + Drop a Marker Cancel @@ -64,7 +64,7 @@ GraphHopper - Bicycle GraphHopper - Pedestrian Google - Car - KML Toolbox + My Map Open url... Open file... OverpassAPI Wizard...