diff options
author | Brad Leege <brad@mapbox.com> | 2016-01-20 16:53:58 -0500 |
---|---|---|
committer | Brad Leege <brad@mapbox.com> | 2016-01-20 16:53:58 -0500 |
commit | baae67cafd5bb3cb6f6bb08748edbf05ec9d5fcb (patch) | |
tree | 302742007debf06667b44ed73700c4b700c80096 | |
parent | 0bde7a6fd6c06b29b5e46714723cd28846cd0d01 (diff) | |
parent | 3797bbf75c783900b6fa9af1942953c624c2e588 (diff) | |
download | qtlocation-mapboxgl-baae67cafd5bb3cb6f6bb08748edbf05ec9d5fcb.tar.gz |
Merge pull request #3639 from mapbox/release-android-v3.1.0
Android 3.1.0 --> master
42 files changed, 887 insertions, 345 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle index 55beb8dea8..c194a8c34c 100644 --- a/platform/android/MapboxGLAndroidSDK/build.gradle +++ b/platform/android/MapboxGLAndroidSDK/build.gradle @@ -25,7 +25,7 @@ dependencies { compile "com.android.support:support-annotations:${supportLibVersion}" compile "com.android.support:support-v4:${supportLibVersion}" compile "com.android.support:design:${supportLibVersion}" - compile 'com.squareup.okhttp3:okhttp:3.0.0' + compile 'com.squareup.okhttp3:okhttp:3.0.1' compile 'com.mapzen.android:lost:1.0.1' } diff --git a/platform/android/MapboxGLAndroidSDK/gradle.properties b/platform/android/MapboxGLAndroidSDK/gradle.properties index 8b50b5b17a..bd2d4f3859 100644 --- a/platform/android/MapboxGLAndroidSDK/gradle.properties +++ b/platform/android/MapboxGLAndroidSDK/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.mapbox.mapboxsdk -VERSION_NAME=3.1.0-SNAPSHOT +VERSION_NAME=3.1.0 POM_DESCRIPTION=Mapbox GL Android SDK POM_URL=https://github.com/mapbox/mapbox-gl-native diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapFragment.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapFragment.java index 98d0f79656..5725989964 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapFragment.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapFragment.java @@ -10,6 +10,20 @@ import android.view.ViewGroup; import com.mapbox.mapboxsdk.utils.ApiAccess; import com.mapbox.mapboxsdk.views.MapView; +/** + * Fragment wrapper around a {@link MapView}. + * <p> + * A Map component in an app. This fragment is the simplest way to place a map in an application. + * It's a wrapper around a view of a map to automatically handle the necessary life cycle needs. + * Being a fragment, this component can be added to an activity's layout or can dynamically be added + * using a FragmentManager. + * </p> + * <p> + * To get a reference to the MapView, use {@link #getMap()} + * </p> + * + * @see #getMap() + */ public class MapFragment extends Fragment { // diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java index bf89998788..813e489e94 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java @@ -5,10 +5,12 @@ import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.views.MapView; /** - * Annotation is the most general kind of overlay on top of a map, - * from which {@link InfoWindow} and {@link Marker} are derived: it manages - * attachment to a map and identification, but does not require + * Annotation is a overlay on top of a {@link MapView}, + * from which {@link Polygon}, {@link Polyline} and {@link Marker} are derived. + * <p> + * it manages attachment to a map and identification, but does not require * content to be placed at a geographical point. + * </p> */ public abstract class Annotation implements Comparable<Annotation> { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java index d7e28dde73..b9691914e2 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java @@ -2,6 +2,10 @@ package com.mapbox.mapboxsdk.annotations; import android.graphics.Bitmap; +/** + * Icon is the visual representation of a {@link Marker} on a {@link com.mapbox.mapboxsdk.views.MapView}. + * @see Marker + */ public final class Icon { private Bitmap mBitmap; private String mId; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java index 8d58866acd..bee4ec47c5 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java @@ -22,6 +22,10 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +/** + * Factory for creating {@link Icon} objects. + * @see Icon + */ public final class IconFactory { private static final String ICON_ID_PREFIX = "com.mapbox.icons.icon_"; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java index c74cf478d1..696301cf54 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java @@ -1,8 +1,8 @@ package com.mapbox.mapboxsdk.annotations; -import android.content.Context; import android.content.res.Resources; import android.graphics.PointF; +import android.support.annotation.LayoutRes; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -17,32 +17,29 @@ import java.lang.ref.WeakReference; /** * <p> - * A tooltip view. This is a UI element placed over a map at a specific geographic - * location. + * InfoWindow is a tooltip shown when a {@link Marker} is tapped. + * </p> + * <p> + * This is a UI element placed over a map at a specific geographic location. * </p> */ public class InfoWindow { private WeakReference<Marker> mBoundMarker; private WeakReference<MapView> mMapView; + protected WeakReference<View> mView; + private float mMarkerHeightOffset; private float mViewWidthOffset; private PointF mCoordinates; private boolean mIsVisible; - protected WeakReference<View> mView; - static int mTitleId = 0; - static int mDescriptionId = 0; - static int mSubDescriptionId = 0; - static int mImageId = 0; + @LayoutRes + private int mLayoutRes; InfoWindow(int layoutResId, MapView mapView) { + mLayoutRes = layoutResId; View view = LayoutInflater.from(mapView.getContext()).inflate(layoutResId, mapView, false); - - if (mTitleId == 0) { - setResIds(mapView.getContext()); - } - initialize(view, mapView); } @@ -86,7 +83,7 @@ public class InfoWindow { * This allows to offset the view from the object position. * @return this infowindow */ - InfoWindow open(Marker boundMarker, LatLng position, int offsetX, int offsetY) { + InfoWindow open(MapView mapView, Marker boundMarker, LatLng position, int offsetX, int offsetY) { setBoundMarker(boundMarker); MapView.LayoutParams lp = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT); @@ -99,21 +96,21 @@ public class InfoWindow { mMarkerHeightOffset = -view.getMeasuredHeight() + offsetY; // Calculate default Android x,y coordinate - mCoordinates = mMapView.get().toScreenLocation(position); + mCoordinates = mapView.toScreenLocation(position); float x = mCoordinates.x - (view.getMeasuredWidth() / 2) + offsetX; float y = mCoordinates.y - view.getMeasuredHeight() + offsetY; if (view instanceof InfoWindowView) { // only apply repositioning/margin for InfoWindowView - Resources resources = mMapView.get().getContext().getResources(); + Resources resources = mapView.getContext().getResources(); // get right/left popup window float rightSideInfowWindow = x + view.getMeasuredWidth(); float leftSideInfoWindow = x; // get right/left map view - final float mapRight = mMapView.get().getRight(); - final float mapLeft = mMapView.get().getLeft(); + final float mapRight = mapView.getRight(); + final float mapLeft = mapView.getLeft(); float marginHorizontal = resources.getDimension(R.dimen.infowindow_margin); float tipViewOffset = resources.getDimension(R.dimen.infowindow_tipview_width) / 2; @@ -164,7 +161,7 @@ public class InfoWindow { mViewWidthOffset = x - mCoordinates.x - offsetX; close(); //if it was already opened - mMapView.get().addView(view, lp); + mapView.addView(view, lp); mIsVisible = true; } return this; @@ -194,25 +191,17 @@ public class InfoWindow { * * @param overlayItem the tapped overlay item */ - void adaptDefaultMarker(Marker overlayItem) { + void adaptDefaultMarker(Marker overlayItem, MapView mapView) { View view = mView.get(); - if (view != null) { - String title = overlayItem.getTitle(); - ((TextView) view.findViewById(mTitleId /*R.id.title*/)).setText(title); - String snippet = overlayItem.getSnippet(); - ((TextView) view.findViewById(mDescriptionId /*R.id.description*/)).setText(snippet); - } -/* - //handle sub-description, hiding or showing the text view: - TextView subDescText = (TextView) mView.findViewById(mSubDescriptionId); - String subDesc = overlayItem.getSubDescription(); - if ("".equals(subDesc)) { - subDescText.setVisibility(View.GONE); - } else { - subDescText.setText(subDesc); - subDescText.setVisibility(View.VISIBLE); + if (view == null) { + view = LayoutInflater.from(mapView.getContext()).inflate(mLayoutRes, mapView, false); + initialize(view, mapView); } -*/ + mMapView = new WeakReference<>(mapView); + String title = overlayItem.getTitle(); + ((TextView) view.findViewById(R.id.infowindow_title)).setText(title); + String snippet = overlayItem.getSnippet(); + ((TextView) view.findViewById(R.id.infowindow_description)).setText(snippet); } private void onClose() { @@ -231,22 +220,6 @@ public class InfoWindow { return mBoundMarker.get(); } - /** - * Given a context, set the resource ids for the layout - * of the InfoWindow. - * - * @param context the apps Context - */ - private static void setResIds(Context context) { - String packageName = context.getPackageName(); //get application package name - mTitleId = context.getResources().getIdentifier("id/infowindow_title", null, packageName); - mDescriptionId = - context.getResources().getIdentifier("id/infowindow_description", null, packageName); - mSubDescriptionId = context.getResources() - .getIdentifier("id/infowindow_subdescription", null, packageName); - mImageId = context.getResources().getIdentifier("id/infowindow_image", null, packageName); - } - public void update() { MapView mapView = mMapView.get(); Marker marker = mBoundMarker.get(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java index 8978d4be48..3463801448 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java @@ -1,5 +1,6 @@ package com.mapbox.mapboxsdk.annotations; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.view.View; @@ -8,9 +9,10 @@ import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.views.MapView; /** - * A marker is a map overlay that shows an icon image at a specific - * geographical location and can be associated with a {@link InfoWindow} - * that is shown when the marker is tapped. + * Marker is an annotation that shows an icon image at a geographical location. + * </p> + * An {@link InfoWindow} can be shown when a Marker is pressed + * <p> */ public final class Marker extends Annotation { @@ -53,6 +55,8 @@ public final class Marker extends Annotation { /** * Do not use this method. Used internally by the SDK. + * + * @return boolean State of a InfoWindow */ public boolean isInfoWindowShown() { return infoWindowShown; @@ -68,6 +72,8 @@ public final class Marker extends Annotation { /** * Do not use this method. Used internally by the SDK. + * + * @param icon The icon to be used as Marker image */ public void setIcon(@Nullable Icon icon) { this.icon = icon; @@ -83,29 +89,29 @@ public final class Marker extends Annotation { /** * Do not use this method. Used internally by the SDK. + * + * @param mapView The MapView to show the InfoWindow on. + * @return infoWindow The infoWindow to show */ - public InfoWindow showInfoWindow() { - if (getMapView() == null) { - return null; - } - + public InfoWindow showInfoWindow(@NonNull MapView mapView) { + setMapView(mapView); MapView.InfoWindowAdapter infoWindowAdapter = getMapView().getInfoWindowAdapter(); if (infoWindowAdapter != null) { // end developer is using a custom InfoWindowAdapter View content = infoWindowAdapter.getInfoWindow(this); if (content != null) { infoWindow = new InfoWindow(content, getMapView()); - showInfoWindow(infoWindow); + showInfoWindow(infoWindow, mapView); return infoWindow; } } - getInfoWindow().adaptDefaultMarker(this); - return showInfoWindow(getInfoWindow()); + getInfoWindow().adaptDefaultMarker(this, mapView); + return showInfoWindow(getInfoWindow(), mapView); } - private InfoWindow showInfoWindow(InfoWindow iw) { - iw.open(this, getPosition(), 0, topOffsetPixels); + private InfoWindow showInfoWindow(InfoWindow iw, MapView mapView) { + iw.open(mapView, this, getPosition(), 0, topOffsetPixels); infoWindowShown = true; return iw; } @@ -129,6 +135,8 @@ public final class Marker extends Annotation { /** * Do not use this method. Used internally by the SDK. + * + * @param topOffsetPixels the pixels to have as offset */ public void setTopOffsetPixels(int topOffsetPixels) { this.topOffsetPixels = topOffsetPixels; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java index 69e8b03bda..a83a6991b2 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java @@ -10,9 +10,7 @@ import com.mapbox.mapboxsdk.geometry.LatLng; /** * <p> - * A builder object for the options configuration {@link com.mapbox.mapboxsdk.annotations.Marker} and - * {@link com.mapbox.mapboxsdk.annotations.InfoWindow} - * instances on maps. + * Builder for composing {@link com.mapbox.mapboxsdk.annotations.Marker} objects. * </p> * * <h3>Example</h3> @@ -70,6 +68,8 @@ public final class MarkerOptions implements Parcelable { /** * Do not use this method. Used internally by the SDK. + * + * @return Marker The build marker */ public Marker getMarker() { return marker; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MultiPoint.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MultiPoint.java index 5c1dfb119f..d2aaea1d17 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MultiPoint.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MultiPoint.java @@ -5,6 +5,9 @@ import com.mapbox.mapboxsdk.geometry.LatLng; import java.util.ArrayList; import java.util.List; +/** + * Multipoint is an abstract annotation for combining geographical locations. + */ public abstract class MultiPoint extends Annotation { private List<LatLng> points; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolygonOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolygonOptions.java index c716d10edf..30847807b9 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolygonOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolygonOptions.java @@ -9,6 +9,9 @@ import com.mapbox.mapboxsdk.geometry.LatLng; import java.util.ArrayList; import java.util.List; +/** + * Builder for composing {@link Polygon} objects. + */ public final class PolygonOptions implements Parcelable { public static final Parcelable.Creator<PolygonOptions> CREATOR @@ -96,6 +99,8 @@ public final class PolygonOptions implements Parcelable { /** * Do not use this method. Used internally by the SDK. + * + * @return Polygon the Polygon to return */ public Polygon getPolygon() { return polygon; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolylineOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolylineOptions.java index d48858c7d9..1e625c10fc 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolylineOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolylineOptions.java @@ -8,6 +8,9 @@ import com.mapbox.mapboxsdk.geometry.LatLng; import java.util.ArrayList; import java.util.List; +/** + * Builder for composing {@link Polyline} objects. + */ public final class PolylineOptions implements Parcelable { @@ -83,6 +86,7 @@ public final class PolylineOptions implements Parcelable { * Sets the color of the polyline. * * @param color - the color in ARGB format + * @return PolyLineOptions The builder used to build a Polyline */ public PolylineOptions color(int color) { polyline.setColor(color); @@ -95,6 +99,7 @@ public final class PolylineOptions implements Parcelable { /** * Do not use this method. Used internally by the SDK. + * @return PolyLine The polyline build by this class. */ public Polyline getPolyline() { return polyline; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/BoundingBox.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/BoundingBox.java index ca805b38e9..72a851e1af 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/BoundingBox.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/BoundingBox.java @@ -9,7 +9,7 @@ import java.util.List; /** * A rectangular geographical area defined in latitude and longitude units. */ -public final class BoundingBox implements Parcelable, Serializable { +public final class BoundingBox implements Parcelable { private final double mLatNorth; private final double mLatSouth; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateBounds.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateBounds.java index 1ad584f8c8..fefc2502d3 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateBounds.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateBounds.java @@ -1,41 +1,52 @@ package com.mapbox.mapboxsdk.geometry; +import android.os.Parcel; +import android.os.Parcelable; +import android.support.annotation.NonNull; + /** - * Implementation of iOS MGLCoordinateBounds + * A rectangular geograpical region defined by a south west {@link LatLng} and a north east {@link LatLng}. */ -public class CoordinateBounds { +public class CoordinateBounds implements Parcelable { + + private LatLng mSouthWest; + private LatLng mNorthEast; - private LatLng southWest; - private LatLng northEast; + public CoordinateBounds(@NonNull Parcel in) { + mSouthWest = in.readParcelable(LatLng.class.getClassLoader()); + mNorthEast = in.readParcelable(LatLng.class.getClassLoader()); + } - public CoordinateBounds(LatLng southWest, LatLng northEast) { - this.southWest = southWest; - this.northEast = northEast; + public CoordinateBounds(@NonNull LatLng southWest, @NonNull LatLng northEast) { + mSouthWest = southWest; + mNorthEast = northEast; } + @NonNull public LatLng getSouthWest() { - return southWest; + return mSouthWest; } - public void setSouthWest(LatLng southWest) { - this.southWest = southWest; + public void setSouthWest(@NonNull LatLng mSouthWest) { + this.mSouthWest = mSouthWest; } + @NonNull public LatLng getNorthEast() { - return northEast; + return mNorthEast; } - public void setNorthEast(LatLng northEast) { - this.northEast = northEast; + public void setNorthEast(@NonNull LatLng mNorthEast) { + this.mNorthEast = mNorthEast; } @Override public int hashCode() { int result; long temp; - temp = southWest.hashCode(); + temp = mSouthWest.hashCode(); result = (int) (temp ^ (temp >>> 32)); - temp = northEast.hashCode(); + temp = mNorthEast.hashCode(); result = 31 * result + (int) (temp ^ (temp >>> 32)); return result; } @@ -53,6 +64,30 @@ public class CoordinateBounds { @Override public String toString() { - return "CoordinateBounds [northEast[" + getNorthEast() + "], southWest[]" + getSouthWest() + "]"; + return "CoordinateBounds [mNorthEast[" + getNorthEast() + "], mSouthWest[]" + getSouthWest() + "]"; + } + + public static final Parcelable.Creator<CoordinateBounds> CREATOR = + new Parcelable.Creator<CoordinateBounds>() { + @Override + public CoordinateBounds createFromParcel(Parcel in) { + return new CoordinateBounds(in); + } + + @Override + public CoordinateBounds[] newArray(int size) { + return new CoordinateBounds[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel out, int arg1) { + out.writeParcelable(mSouthWest, arg1); + out.writeParcelable(mNorthEast, arg1); } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateRegion.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateRegion.java index a70bb05a41..c7c0aa1c49 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateRegion.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateRegion.java @@ -1,30 +1,64 @@ package com.mapbox.mapboxsdk.geometry; +import android.os.Parcel; +import android.os.Parcelable; +import android.support.annotation.NonNull; + /** - * Implementation of iOS MKCoordinateRegion + * A geographical region defined by a {@link LatLng} and a {@link CoordinateSpan}. */ -public class CoordinateRegion { - private LatLng center; - private CoordinateSpan span; +public class CoordinateRegion implements Parcelable{ + + private LatLng mCenter; + private CoordinateSpan mSpan; - public CoordinateRegion(final LatLng center, final CoordinateSpan span) { - this.center = center; - this.span = span; + public CoordinateRegion(@NonNull Parcel in){ + mCenter = in.readParcelable(LatLng.class.getClassLoader()); + mSpan = in.readParcelable(CoordinateSpan.class.getClassLoader()); + } + + public CoordinateRegion(@NonNull LatLng center, @NonNull CoordinateSpan span) { + mCenter = center; + mSpan = span; } public LatLng getCenter() { - return center; + return mCenter; } - public void setCenter(final LatLng center) { - this.center = center; + public void setCenter(@NonNull LatLng center) { + mCenter = center; } public CoordinateSpan getSpan() { - return span; + return mSpan; + } + + public void setSpan(@NonNull CoordinateSpan span) { + this.mSpan = span; + } + + public static final Parcelable.Creator<CoordinateRegion> CREATOR = + new Parcelable.Creator<CoordinateRegion>() { + @Override + public CoordinateRegion createFromParcel(Parcel in) { + return new CoordinateRegion(in); + } + + @Override + public CoordinateRegion[] newArray(int size) { + return new CoordinateRegion[size]; + } + }; + + @Override + public int describeContents() { + return 0; } - public void setSpan(final CoordinateSpan span) { - this.span = span; + @Override + public void writeToParcel(Parcel out, int arg1) { + out.writeParcelable(mCenter, arg1); + out.writeParcelable(mSpan, arg1); } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateSpan.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateSpan.java index 79361f725a..a43757713d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateSpan.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateSpan.java @@ -1,32 +1,41 @@ package com.mapbox.mapboxsdk.geometry; +import android.os.Parcel; +import android.os.Parcelable; +import android.support.annotation.NonNull; + /** - * Implementation of iOS MKCoordinateSpan + * A geographical span defined by its latitude and longitude span. */ -public class CoordinateSpan { +public class CoordinateSpan implements Parcelable { + + private double mLatitudeSpan; + private double mLongitudeSpan; - private double latitudeSpan; - private double longitudeSpan; + public CoordinateSpan(@NonNull Parcel in){ + mLatitudeSpan = in.readDouble(); + mLongitudeSpan = in.readDouble(); + } - public CoordinateSpan(final double latitudeSpan, final double longitudeSpan) { - this.latitudeSpan = latitudeSpan; - this.longitudeSpan = longitudeSpan; + public CoordinateSpan(double latitudeSpan, double longitudeSpan) { + mLatitudeSpan = latitudeSpan; + mLongitudeSpan = longitudeSpan; } public double getLatitudeSpan() { - return latitudeSpan; + return mLatitudeSpan; } - public void setLatitudeSpan(final double latitudeSpan) { - this.latitudeSpan = latitudeSpan; + public void setLatitudeSpan(double latitudeSpan) { + mLatitudeSpan = latitudeSpan; } public double getLongitudeSpan() { - return longitudeSpan; + return mLongitudeSpan; } - public void setLongitudeSpan(final double longitudeSpan) { - this.longitudeSpan = longitudeSpan; + public void setLongitudeSpan(double longitudeSpan) { + mLongitudeSpan = longitudeSpan; } @Override @@ -34,10 +43,33 @@ public class CoordinateSpan { if (this == o) return true; if (o instanceof CoordinateSpan) { CoordinateSpan other = (CoordinateSpan) o; - return longitudeSpan == other.getLongitudeSpan() - && latitudeSpan == other.getLatitudeSpan(); + return mLongitudeSpan == other.getLongitudeSpan() + && mLatitudeSpan == other.getLatitudeSpan(); } return false; } -} + public static final Parcelable.Creator<CoordinateSpan> CREATOR = + new Parcelable.Creator<CoordinateSpan>() { + @Override + public CoordinateSpan createFromParcel(Parcel in) { + return new CoordinateSpan(in); + } + + @Override + public CoordinateSpan[] newArray(int size) { + return new CoordinateSpan[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel out, int arg1) { + out.writeDouble(mLatitudeSpan); + out.writeDouble(mLongitudeSpan); + } +}
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java index 892d0ad4ae..afd22e5ddb 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java @@ -1,7 +1,7 @@ package com.mapbox.mapboxsdk.geometry; /** - * A Latitude, Longitude point. + * Describes a latitude, longitude point. */ public interface ILatLng { double getLatitude(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java index 5aa5f607eb..43fe25f8e5 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java @@ -1,5 +1,8 @@ package com.mapbox.mapboxsdk.geometry; +/** + * Describes a projection in Mercator meters. + */ public interface IProjectedMeters { double getNorthing(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java index c340b09e05..f24c2ed431 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java @@ -10,9 +10,10 @@ import com.mapbox.mapboxsdk.constants.MathConstants; import java.io.Serializable; /** + * A geographical location which contains a single latitude, longitude pair, with + * optional altitude. * <p> - * This class is container for a single latitude, longitude pair, with - * optional altitude. Latitude and longitude are expressed as decimal degrees + * Latitude and longitude are expressed as decimal degrees * in the WGS84 datum. By default, altitude is 0.0, or sea level. * </p> * <p> @@ -20,7 +21,7 @@ import java.io.Serializable; * data automatically, so all data enters in the WGS84 datum. * </p> */ -public class LatLng implements ILatLng, Parcelable, Serializable { +public class LatLng implements ILatLng, Parcelable { public static final Parcelable.Creator<LatLng> CREATOR = new Parcelable.Creator<LatLng>() { public LatLng createFromParcel(Parcel in) { @@ -129,7 +130,6 @@ public class LatLng implements ILatLng, Parcelable, Serializable { LatLng latLng = (LatLng) o; return Double.compare(latLng.altitude, altitude) == 0 && Double.compare(latLng.latitude, latitude) == 0 && Double.compare(latLng.longitude, longitude) == 0; - } @Override @@ -168,6 +168,10 @@ public class LatLng implements ILatLng, Parcelable, Serializable { * @return distance in meters */ public double distanceTo(LatLng other) { + if(latitude == other.latitude && longitude == other.longitude){ + // return 0.0 to avoid a NaN + return 0.0; + } final double a1 = MathConstants.DEG2RAD * this.latitude; final double a2 = MathConstants.DEG2RAD * this.longitude; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngZoom.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngZoom.java index 9e453a391c..6e24faaa9d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngZoom.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngZoom.java @@ -5,7 +5,10 @@ import android.os.Parcelable; import java.io.Serializable; -public class LatLngZoom extends LatLng implements Parcelable, Serializable { +/** + * A geographical location which contains a {@link LatLng}, zoom pair. + */ +public class LatLngZoom extends LatLng implements Parcelable { public static final Parcelable.Creator<LatLngZoom> CREATOR = new Parcelable.Creator<LatLngZoom>() { public LatLngZoom createFromParcel(Parcel in) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java index fc821e887c..06a58fe8ad 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java @@ -6,12 +6,14 @@ import android.os.Parcelable; import java.io.Serializable; /** - * ProjectedMeters is an internal representation of longitude, latitude points that - * have been projected into Mapbox GL's Mercator projection. Instead of decimal + * ProjectedMeters is a projection of longitude, latitude points in Mercator meters. + * <p> + * these have been projected into Mapbox GL's Mercator projection. Instead of decimal * degrees, it uses Mercator meters (which are notably not equivalent to SI meters) * except at the equator. + * </p> */ -public class ProjectedMeters implements IProjectedMeters, Parcelable, Serializable { +public class ProjectedMeters implements IProjectedMeters, Parcelable { public static final Creator<ProjectedMeters> CREATOR = new Creator<ProjectedMeters>() { public ProjectedMeters createFromParcel(Parcel in) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java index 9f6a675715..7ffe338d87 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java @@ -139,6 +139,7 @@ public final class MapView extends FrameLayout { private static final String STATE_DEFAULT_TRANSITION_DURATION = "defaultTransitionDuration"; private static final String STATE_MY_LOCATION_ENABLED = "myLocationEnabled"; private static final String STATE_MY_LOCATION_TRACKING_MODE = "myLocationTracking"; + private static final String STATE_MY_BEARING_TRACKING_MODE = "myBearingTracking"; private static final String STATE_COMPASS_ENABLED = "compassEnabled"; private static final String STATE_COMPASS_GRAVITY = "compassGravity"; private static final String STATE_COMPASS_MARGIN_LEFT = "compassMarginLeft"; @@ -804,7 +805,7 @@ public final class MapView extends FrameLayout { mZoomButtonsController.setOnZoomListener(new OnZoomListener()); // Check current connection status - ConnectivityManager connectivityManager = (ConnectivityManager) context + ConnectivityManager connectivityManager = (ConnectivityManager) context.getApplicationContext() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo(); boolean isConnected = (activeNetwork != null) && activeNetwork.isConnectedOrConnecting(); @@ -973,6 +974,8 @@ public final class MapView extends FrameLayout { //noinspection ResourceType setMyLocationTrackingMode(savedInstanceState.getInt(STATE_MY_LOCATION_TRACKING_MODE, MyLocationTracking.TRACKING_NONE)); + //noinspection ResourceType + setMyBearingTrackingMode(savedInstanceState.getInt(STATE_MY_BEARING_TRACKING_MODE, MyBearingTracking.NONE)); } // Force a check for an access token @@ -1025,6 +1028,7 @@ public final class MapView extends FrameLayout { outState.putLong(STATE_DEFAULT_TRANSITION_DURATION, mNativeMapView.getDefaultTransitionDuration()); outState.putBoolean(STATE_MY_LOCATION_ENABLED, isMyLocationEnabled()); outState.putInt(STATE_MY_LOCATION_TRACKING_MODE, mUserLocationView.getMyLocationTrackingMode()); + outState.putInt(STATE_MY_BEARING_TRACKING_MODE, mUserLocationView.getMyBearingTrackingMode()); // Compass LayoutParams compassParams = (LayoutParams) mCompassView.getLayoutParams(); @@ -2694,8 +2698,9 @@ public final class MapView extends FrameLayout { } if (!handledDefaultClick) { - // default behaviour show InfoWindow - mInfoWindows.add(marker.showInfoWindow()); + if (isInfoWindowValidForMarker(marker)) { + mInfoWindows.add(marker.showInfoWindow(this)); + } } mSelectedMarkers.add(marker); @@ -2736,6 +2741,10 @@ public final class MapView extends FrameLayout { mSelectedMarkers.remove(marker); } + private boolean isInfoWindowValidForMarker(@NonNull Marker marker) { + return !TextUtils.isEmpty(marker.getTitle()) || !TextUtils.isEmpty(marker.getSnippet()); + } + // // Mapbox Core GL Camera // @@ -2873,10 +2882,8 @@ public final class MapView extends FrameLayout { for (Marker marker : mSelectedMarkers) { if (marker.isInfoWindowShown()) { - Marker temp = marker; - temp.hideInfoWindow(); - temp.showInfoWindow(); - marker = temp; + marker.hideInfoWindow(); + marker.showInfoWindow(this); } } } @@ -3173,9 +3180,9 @@ public final class MapView extends FrameLayout { // Open / Close InfoWindow PointF tapPoint = new PointF(e.getX(), e.getY()); - final float toleranceSides = 30 * mScreenDensity; - final float toleranceTop = 40 * mScreenDensity; - final float toleranceBottom = 10 * mScreenDensity; + final float toleranceSides = 15 * mScreenDensity; + final float toleranceTop = 20 * mScreenDensity; + final float toleranceBottom = 5 * mScreenDensity; RectF tapRect = new RectF(tapPoint.x - toleranceSides, tapPoint.y + toleranceTop, tapPoint.x + toleranceSides, tapPoint.y - toleranceBottom); @@ -3188,52 +3195,27 @@ public final class MapView extends FrameLayout { ); BoundingBox tapBounds = BoundingBox.fromLatLngs(corners); - List<Marker> nearbyMarkers = getMarkersInBounds(tapBounds); + long newSelectedMarkerId = -1; - long newSelectedMarkerId; - - if (nearbyMarkers.size() > 0) { - - // there is at least one nearby marker; select one - // - // first, sort for comparison and iteration + if (nearbyMarkers!=null && nearbyMarkers.size() > 0) { Collections.sort(nearbyMarkers); - - if (nearbyMarkers == mMarkersNearLastTap) { - - // TODO: We still need to adapt this logic to the new mSelectedMarkers list, - // though the basic functionality is there. - - // the selection candidates haven't changed; cycle through them -// if (mSelectedMarker != null -// && (mSelectedMarker.getId() == mMarkersNearLastTap.get(mMarkersNearLastTap.size() - 1).getId())) { -// // the selected marker is the last in the set; cycle back to the first -// // note: this could be the selected marker if only one in set -// newSelectedMarkerId = mMarkersNearLastTap.get(0).getId(); -// } else if (mSelectedMarker != null) { -// // otherwise increment the selection through the candidates -// long result = mMarkersNearLastTap.indexOf(mSelectedMarker); -// newSelectedMarkerId = mMarkersNearLastTap.get((int) result + 1).getId(); -// } else { - // no current selection; select the first one - newSelectedMarkerId = mMarkersNearLastTap.get(0).getId(); -// } - } else { - // start tracking a new set of nearby markers - mMarkersNearLastTap = nearbyMarkers; - - // select the first one - newSelectedMarkerId = mMarkersNearLastTap.get(0).getId(); + for (Marker nearbyMarker : nearbyMarkers) { + boolean found = false; + for (Marker selectedMarker : mSelectedMarkers) { + if(selectedMarker.equals(nearbyMarker)){ + found = true; + } + } + if(!found){ + newSelectedMarkerId = nearbyMarker.getId(); + break; + } } - - } else { - // there are no nearby markers; deselect if necessary - newSelectedMarkerId = -1; + mMarkersNearLastTap = nearbyMarkers; } if (newSelectedMarkerId >= 0) { - int count = mAnnotations.size(); for (int i = 0; i < count; i++) { Annotation annotation = mAnnotations.get(i); @@ -3246,7 +3228,6 @@ public final class MapView extends FrameLayout { } } } - } else { // deselect any selected marker deselectMarkers(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/UserLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/UserLocationView.java index 67dc9a3499..d0f278a521 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/UserLocationView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/UserLocationView.java @@ -34,11 +34,13 @@ import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.location.LocationListener; import com.mapbox.mapboxsdk.location.LocationServices; +import java.lang.ref.WeakReference; + /** * This view shows the user's location, as determined from GPS, on the map * as a dot annotation. */ -final class UserLocationView extends View implements LocationListener { +final class UserLocationView extends View { private MapView mMapView; @@ -85,6 +87,7 @@ final class UserLocationView extends View implements LocationListener { private boolean mPaused = false; private Location mUserLocation; + private UserLocationListener mUserLocationListener; MapView.OnMyLocationChangeListener mOnMyLocationChangeListener; @@ -377,14 +380,18 @@ final class UserLocationView extends View implements LocationListener { setLocation(lastLocation); } + if(mUserLocationListener==null){ + mUserLocationListener = new UserLocationListener(this); + } + // Register for Location Updates - locationServices.addLocationListener(this); + locationServices.addLocationListener(mUserLocationListener); } else { // Disable location and user dot setLocation(null); // Deregister for Location Updates - locationServices.removeLocationListener(this); + locationServices.removeLocationListener(mUserLocationListener); } locationServices.toggleGPS(enableGps); @@ -498,17 +505,27 @@ final class UserLocationView extends View implements LocationListener { } } - /** - * Callback method for receiving location updates from LocationServices. - * - * @param location The new Location data - */ - @Override - public void onLocationChanged(Location location) { - if (mPaused) { - return; + private static class UserLocationListener implements LocationListener{ + + private WeakReference<UserLocationView> mUserLocationView; + + public UserLocationListener(UserLocationView userLocationView) { + mUserLocationView = new WeakReference<>(userLocationView); + } + + + /** + * Callback method for receiving location updates from LocationServices. + * + * @param location The new Location data + */ + @Override + public void onLocationChanged(Location location) { + UserLocationView locationView = mUserLocationView.get(); + if(locationView!=null && !locationView.isPaused()){ + locationView.setLocation(location); + } } - setLocation(location); } private boolean isStale(Location location) { @@ -751,4 +768,8 @@ final class UserLocationView extends View implements LocationListener { } } + public boolean isPaused(){ + return mPaused; + } + } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties b/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties index 030ebae5ce..e09bb0110d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties +++ b/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties @@ -1,3 +1,3 @@ fabric-identifier=com.mapbox.mapboxsdk.mapbox-android-sdk -fabric-version=3.0.0 +fabric-version=3.1.0 fabric-build-type=binary diff --git a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle index 815fe8d00e..41d75cc0b0 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle +++ b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle @@ -86,6 +86,11 @@ dependencies { transitive=true } + // Geocoder SDK + compile ('com.mapbox.mapboxsdk:mapbox-android-geocoder:1.0.0@aar'){ + transitive=true + } + // Testing dependencies testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.10.19' diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml index af74d52c2c..d5a6df9566 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml @@ -66,6 +66,12 @@ <activity android:name=".DirectionsActivity" android:label="@string/activity_directions" /> + <activity + android:name=".GeocoderActivity" + android:label="@string/activity_geocoder" /> + <activity + android:name=".DoubleMapActivity" + android:label="@string/activity_double_map" /> <meta-data android:name="com.mapbox.AccessToken" diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/DoubleMapActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/DoubleMapActivity.java new file mode 100644 index 0000000000..ae22622a19 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/DoubleMapActivity.java @@ -0,0 +1,147 @@ +package com.mapbox.mapboxsdk.testapp; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentTransaction; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.LayoutInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; + +import com.mapbox.mapboxsdk.constants.MyLocationTracking; +import com.mapbox.mapboxsdk.constants.Style; +import com.mapbox.mapboxsdk.views.MapView; + +public class DoubleMapActivity extends AppCompatActivity { + + private static final String TAG_FRAGMENT = "map"; + private DoubleMapFragment mMapFragment; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_map_fragment); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowHomeEnabled(true); + } + + if (savedInstanceState == null) { + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + transaction.add(R.id.fragment_container, mMapFragment = new DoubleMapFragment(), TAG_FRAGMENT); + transaction.commit(); + } else { + mMapFragment = (DoubleMapFragment) getSupportFragmentManager().findFragmentByTag(TAG_FRAGMENT); + } + } + + public static class DoubleMapFragment extends Fragment { + + private MapView mMapView; + private MapView mMapViewMini; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + return inflater.inflate(R.layout.fragment_double_map, container, false); + } + + @Override + public void onViewCreated(View view, Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + + // MapView large + mMapView = (MapView) view.findViewById(R.id.mapview); + mMapView.onCreate(savedInstanceState); + mMapView.setStyle(Style.DARK); + mMapView.setZoom(18); + + // MapView mini + mMapViewMini = (MapView) view.findViewById(R.id.mini_map); + mMapViewMini.onCreate(savedInstanceState); + mMapViewMini.setStyle(Style.LIGHT); + mMapViewMini.setAttributionVisibility(View.GONE); + mMapViewMini.setLogoVisibility(View.GONE); + mMapViewMini.setCompassEnabled(false); + mMapViewMini.setZoom(4); + mMapViewMini.setAllGesturesEnabled(false); + + try { + mMapView.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); + mMapViewMini.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); + }catch (SecurityException e){ + // permission is handled in MainActivity + getActivity().finish(); + } + } + + @Override + public void onStart() { + super.onStart(); + mMapView.onStart(); + mMapViewMini.onStart(); + } + + @Override + public void onResume() { + super.onResume(); + mMapView.onResume(); + mMapViewMini.onResume(); + } + + @Override + public void onPause() { + super.onPause(); + mMapView.onPause(); + mMapViewMini.onPause(); + } + + @Override + public void onStop() { + super.onStop(); + mMapView.onStop(); + mMapViewMini.onStop(); + } + + @Override + public void onDestroy() { + super.onDestroy(); + mMapView.onDestroy(); + mMapViewMini.onDestroy(); + } + + @Override + public void onLowMemory() { + super.onLowMemory(); + mMapView.onLowMemory(); + mMapViewMini.onLowMemory(); + } + + @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mMapView.onSaveInstanceState(outState); + mMapViewMini.onSaveInstanceState(outState); + } + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + onBackPressed(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } + + +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/GeocoderActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/GeocoderActivity.java new file mode 100644 index 0000000000..200ca8ac0e --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/GeocoderActivity.java @@ -0,0 +1,158 @@ +package com.mapbox.mapboxsdk.testapp; + +import android.os.Bundle; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.util.Log; +import android.widget.TextView; + +import com.mapbox.geocoder.GeocoderCriteria; +import com.mapbox.geocoder.MapboxGeocoder; +import com.mapbox.geocoder.service.models.GeocoderFeature; +import com.mapbox.geocoder.service.models.GeocoderResponse; +import com.mapbox.mapboxsdk.annotations.MarkerOptions; +import com.mapbox.mapboxsdk.constants.Style; +import com.mapbox.mapboxsdk.geometry.LatLng; +import com.mapbox.mapboxsdk.utils.ApiAccess; +import com.mapbox.mapboxsdk.views.MapView; + +import java.util.List; + +import retrofit.Callback; +import retrofit.Response; +import retrofit.Retrofit; + +public class GeocoderActivity extends AppCompatActivity { + + private static final String LOG_TAG = "GeocoderActivity"; + + private MapView mapView; + private TextView textView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_geocoder); + + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + ActionBar actionBar = getSupportActionBar(); + if (actionBar != null) { + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setDisplayShowHomeEnabled(true); + } + + textView = (TextView) findViewById(R.id.message); + setMessage("Tap the map to trigger the geocoder."); + + LatLng dupontCircle = new LatLng(38.90962, -77.04341); + + mapView = (MapView) findViewById(R.id.mapView); + mapView.setAccessToken(ApiAccess.getToken(this)); + mapView.setStyleUrl(Style.MAPBOX_STREETS); + mapView.setCenterCoordinate(dupontCircle); + mapView.setZoomLevel(15); + mapView.onCreate(savedInstanceState); + + mapView.setOnMapClickListener(new MapView.OnMapClickListener() { + @Override + public void onMapClick(LatLng point) { + setMessage("Geocoding..."); + mapView.removeAllAnnotations(); + mapView.addMarker(new MarkerOptions() + .position(point) + .title("Your finger is here")); + geocode(point); + } + }); + } + + @Override + protected void onStart() { + super.onStart(); + mapView.onStart(); + } + + @Override + protected void onStop() { + super.onStop(); + mapView.onStop(); + } + + @Override + public void onPause() { + super.onPause(); + mapView.onPause(); + } + + @Override + public void onResume() { + super.onResume(); + mapView.onResume(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + mapView.onDestroy(); + } + + @Override + protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + mapView.onSaveInstanceState(outState); + } + + /* + * Forward geocoding + */ + + private void geocode(LatLng point) { + MapboxGeocoder client = new MapboxGeocoder.Builder() + .setAccessToken(ApiAccess.getToken(this)) + .setCoordinates(point.getLongitude(), point.getLatitude()) + .setType(GeocoderCriteria.TYPE_POI) + .build(); + + client.enqueue(new Callback<GeocoderResponse>() { + @Override + public void onResponse(Response<GeocoderResponse> response, Retrofit retrofit) { + List<GeocoderFeature> results = response.body().getFeatures(); + if (results.size() > 0) { + String placeName = results.get(0).getPlaceName(); + setSuccess(placeName); + } else { + setMessage("No results."); + } + } + + @Override + public void onFailure(Throwable t) { + setError(t.getMessage()); + } + }); + + } + + /* + * Update text view + */ + + private void setMessage(String message) { + Log.d(LOG_TAG, "Message: " + message); + textView.setText(message); + } + + private void setSuccess(String placeName) { + Log.d(LOG_TAG, "Place name: " + placeName); + textView.setText(placeName); + } + + private void setError(String message) { + Log.e(LOG_TAG, "Error: " + message); + textView.setText("Error: " + message); + } + +} diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java index 63fa396af0..6451046448 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java @@ -389,8 +389,6 @@ public class MainActivity extends AppCompatActivity { } else { startActivity(new Intent(getApplicationContext(), MyLocationTrackingModeActivity.class)); } - - return true; case R.id.action_polyline: @@ -409,6 +407,23 @@ public class MainActivity extends AppCompatActivity { startActivity(new Intent(getApplicationContext(), DirectionsActivity.class)); return true; + case R.id.action_double_mapview: + if ((ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION) + != PackageManager.PERMISSION_GRANTED) || + (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) + != PackageManager.PERMISSION_GRANTED)) { + ActivityCompat.requestPermissions(MainActivity.this, + new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, + PERMISSIONS_TRACKING_MODE_ACTIVITY); + } else { + startActivity(new Intent(getApplicationContext(), DoubleMapActivity.class)); + } + return true; + + case R.id.action_geocoder: + startActivity(new Intent(getApplicationContext(), GeocoderActivity.class)); + return true; + default: return changeMapStyle(menuItem.getItemId()); } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/PolylineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/PolylineActivity.java index e000cf079d..d2d266a31b 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/PolylineActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/PolylineActivity.java @@ -22,6 +22,12 @@ import java.util.List; public class PolylineActivity extends AppCompatActivity { private static final String STATE_POLYLINE_OPTIONS = "polylineOptions"; + private static final LatLng ANDORRA = new LatLng(42.505777, 1.52529); + private static final LatLng LUXEMBOURG = new LatLng(49.815273, 6.129583); + private static final LatLng MONACO = new LatLng(43.738418, 7.424616); + private static final LatLng VATICAN_CITY = new LatLng(41.902916, 12.453389); + private static final LatLng SAN_MARINO = new LatLng(43.942360, 12.457777); + private static final LatLng LIECHTENSTEIN = new LatLng(47.166000, 9.555373); private List<Polyline> mPolylines; private ArrayList<PolylineOptions> mPolylineOptions = new ArrayList<>(); @@ -48,8 +54,9 @@ public class PolylineActivity extends AppCompatActivity { if (savedInstanceState != null) { mPolylineOptions = savedInstanceState.getParcelableArrayList(STATE_POLYLINE_OPTIONS); } else { - mPolylineOptions.addAll(PolylineProvider.getAll()); + mPolylineOptions.addAll(getAllPolylines()); } + mPolylines = mMapView.addPolylines(mPolylineOptions); findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() { @@ -65,12 +72,38 @@ public class PolylineActivity extends AppCompatActivity { } } mPolylineOptions.clear(); - mPolylineOptions.addAll(PolylineProvider.getRandomLine()); + mPolylineOptions.addAll(getRandomLine()); mPolylines = mMapView.addPolylines(mPolylineOptions); } }); } + private List<PolylineOptions> getAllPolylines() { + List<PolylineOptions> options = new ArrayList<>(); + options.add(generatePolyline(ANDORRA, LUXEMBOURG, "#F44336")); + options.add(generatePolyline(ANDORRA, MONACO, "#FF5722")); + options.add(generatePolyline(MONACO, VATICAN_CITY, "#673AB7")); + options.add(generatePolyline(VATICAN_CITY, SAN_MARINO, "#009688")); + options.add(generatePolyline(SAN_MARINO, LIECHTENSTEIN, "#795548")); + options.add(generatePolyline(LIECHTENSTEIN, LUXEMBOURG, "#3F51B5")); + return options; + } + + private PolylineOptions generatePolyline(LatLng start, LatLng end, String color) { + PolylineOptions line = new PolylineOptions(); + line.add(start); + line.add(end); + line.color(Color.parseColor(color)); + return line; + } + + public List<PolylineOptions> getRandomLine() { + final List<PolylineOptions> randomLines = getAllPolylines(); + Collections.shuffle(randomLines); + return new ArrayList<PolylineOptions>(){{ + add(randomLines.get(0)); + }}; + } @Override protected void onStart() { @@ -139,42 +172,4 @@ public class PolylineActivity extends AppCompatActivity { } } - private static class PolylineProvider { - private static final LatLng ANDORRA = new LatLng(42.505777, 1.52529); - private static final LatLng LUXEMBOURG = new LatLng(49.815273, 6.129583); - private static final LatLng MONACO = new LatLng(43.738418, 7.424616); - private static final LatLng VATICAN_CITY = new LatLng(41.902916, 12.453389); - private static final LatLng SAN_MARINO = new LatLng(43.942360, 12.457777); - private static final LatLng LIECHTENSTEIN = new LatLng(47.166000, 9.555373); - - private static final List<PolylineOptions> POLYLINES = new ArrayList<PolylineOptions>() {{ - add(generatePolyline(ANDORRA, LUXEMBOURG, "#F44336")); - add(generatePolyline(ANDORRA, MONACO, "#FF5722")); - add(generatePolyline(MONACO, VATICAN_CITY, "#673AB7")); - add(generatePolyline(VATICAN_CITY, SAN_MARINO, "#009688")); - add(generatePolyline(SAN_MARINO, LIECHTENSTEIN, "#795548")); - add(generatePolyline(LIECHTENSTEIN, LUXEMBOURG, "#3F51B5")); - }}; - - private static PolylineOptions generatePolyline(LatLng start, LatLng end, String color) { - PolylineOptions line = new PolylineOptions(); - line.add(start); - line.add(end); - line.color(Color.parseColor(color)); - return line; - } - - public static List<PolylineOptions> getAll() { - return POLYLINES; - } - - public static List<PolylineOptions> getRandomLine() { - List<PolylineOptions> randomLines = new ArrayList<>(); - Collections.shuffle(POLYLINES); - randomLines.add(POLYLINES.get(0)); - return randomLines; - } - - } - } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_dns_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_dns_24dp.xml new file mode 100644 index 0000000000..5b7b1bce6a --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_dns_24dp.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0"> + <path + android:fillColor="#FFFFFF" + android:pathData="M20,13H4c-0.55,0 -1,0.45 -1,1v6c0,0.55 0.45,1 1,1h16c0.55,0 1,-0.45 1,-1v-6c0,-0.55 -0.45,-1 -1,-1zM7,19c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM20,3H4c-0.55,0 -1,0.45 -1,1v6c0,0.55 0.45,1 1,1h16c0.55,0 1,-0.45 1,-1V4c0,-0.55 -0.45,-1 -1,-1zM7,9c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/> +</vector> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geocoder.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geocoder.xml new file mode 100644 index 0000000000..ce0802385a --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geocoder.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <android.support.v7.widget.Toolbar + android:id="@+id/toolbar" + android:layout_width="match_parent" + android:layout_height="?attr/actionBarSize" + android:background="@color/primary" + android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" /> + + <com.mapbox.mapboxsdk.views.MapView + android:id="@+id/mapView" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="5" /> + + <TextView + android:id="@+id/message" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1" + android:gravity="center" /> + +</LinearLayout> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_double_map.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_double_map.xml new file mode 100644 index 0000000000..0695fafd12 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_double_map.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:mapbox="http://schemas.android.com/apk/res-auto" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + + <com.mapbox.mapboxsdk.views.MapView + android:id="@+id/mapview" + android:layout_width="match_parent" + android:layout_height="match_parent" + mapbox:access_token="@string/access_token" /> + + <FrameLayout + android:id="@+id/map_card" + android:layout_width="100dp" + android:layout_height="100dp" + android:layout_marginLeft="5dp" + android:layout_marginRight="5dp" + android:layout_marginTop="5dp"> + + <com.mapbox.mapboxsdk.views.MapView + android:id="@+id/mini_map" + android:layout_width="100dp" + android:layout_height="100dp" + mapbox:access_token="@string/access_token" /> + </FrameLayout> +</RelativeLayout>
\ No newline at end of file diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml index ad9deba187..2fd9e6c757 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml @@ -155,6 +155,18 @@ android:icon="@drawable/ic_directions" android:title="@string/activity_directions" /> + <item + android:id="@+id/action_double_mapview" + android:checkable="false" + android:icon="@drawable/ic_dns_24dp" + android:title="@string/action_double_mapview" /> + + <item + android:id="@+id/action_geocoder" + android:checkable="false" + android:icon="@drawable/ic_directions" + android:title="@string/activity_geocoder" /> + </menu> </item> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml index c096284fd8..6caf0f7df7 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml @@ -20,6 +20,8 @@ <string name="activity_animate_coordinate_change">Animate Coordinate Change</string> <string name="activity_custom_layer">Custom Layer</string> <string name="activity_directions">Directions Activity</string> + <string name="activity_geocoder">Geocoder Activity</string> + <string name="activity_double_map">Double Map Activity</string> <string name="navdrawer_menu_title_mainactivity_controls">Main Activity Controls</string> <string name="navdrawer_menu_title_mainactivity_styles">Main Activity Styles</string> @@ -43,6 +45,7 @@ <string name="action_visible_bounds">Set Visible Bounds</string> <string name="action_visible_bounds_explanation">Center map around 2 markers</string> <string name="action_remove_polylines">Remove polylines</string> + <string name="action_double_mapview">Double MapView</string> <string name="button_camera_move">Move</string> <string name="button_camera_ease">Ease</string> diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateBoundsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateBoundsTest.java index a5d3891305..1dc4be723f 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateBoundsTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateBoundsTest.java @@ -44,7 +44,7 @@ public class CoordinateBoundsTest { CoordinateBounds coordinateBounds = new CoordinateBounds(northEast, southWest); assertEquals("string should match", coordinateBounds.toString(), - "CoordinateBounds [northEast[" + coordinateBounds.getNorthEast() + "], southWest[]" + coordinateBounds.getSouthWest() + "]"); + "CoordinateBounds [mNorthEast[" + coordinateBounds.getNorthEast() + "], mSouthWest[]" + coordinateBounds.getSouthWest() + "]"); } @Test diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java index dd075f327f..5b24f32b6c 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java @@ -6,6 +6,7 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -43,6 +44,23 @@ public class LatLngTest { assertEquals("altitude default value", latLng2.getAltitude(), altitude, DELTA); } + @Test + public void testDistanceTo() { + LatLng latLng1 = new LatLng(0.0, 0.0); + LatLng latLng2 = new LatLng(1.0, 1.0); + assertEquals("distances should match", + latLng1.distanceTo(latLng2), + 157425.53710839353, DELTA); + } + + @Test + public void testDistanceToSamePoint() { + LatLng latLng1 = new LatLng(40.71199035644531, -74.0081); + LatLng latLng2 = new LatLng(40.71199035644531, -74.0081); + double distance = latLng1.distanceTo(latLng2); + assertEquals("distance should match", 0.0, distance, DELTA); + } + /* * A sample test where Mockito is necessary */ @@ -86,13 +104,4 @@ public class LatLngTest { "LatLng [longitude=3.4, latitude=1.2, altitude=5.6]"); } - @Test - public void testDistanceTo() { - LatLng latLng1 = new LatLng(0.0, 0.0); - LatLng latLng2 = new LatLng(1.0, 1.0); - assertEquals("distances should match", - latLng1.distanceTo(latLng2), - 157425.53710839353, DELTA); - } - } diff --git a/platform/android/build.gradle b/platform/android/build.gradle index 2f5700c87b..f3a1cc06ba 100644 --- a/platform/android/build.gradle +++ b/platform/android/build.gradle @@ -22,5 +22,5 @@ allprojects { } task wrapper(type: Wrapper) { - gradleVersion = '2.8' + gradleVersion = '2.10' } diff --git a/platform/android/gradle/wrapper/gradle-wrapper.jar b/platform/android/gradle/wrapper/gradle-wrapper.jar Binary files differindex 085a1cdc27..13372aef5e 100644 --- a/platform/android/gradle/wrapper/gradle-wrapper.jar +++ b/platform/android/gradle/wrapper/gradle-wrapper.jar diff --git a/platform/android/gradle/wrapper/gradle-wrapper.properties b/platform/android/gradle/wrapper/gradle-wrapper.properties index 4267591703..b4ada9d74b 100644 --- a/platform/android/gradle/wrapper/gradle-wrapper.properties +++ b/platform/android/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ -#Thu Nov 05 15:43:10 CST 2015 +#Fri Jan 15 17:23:43 CET 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-bin.zip -distributionSha256Sum=a88db9c2f104defdaa8011c58cf6cda6c114298ae3695ecfb8beb30da3a903cb +distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip +distributionSha256Sum=66406247f745fc6f05ab382d3f8d3e120c339f34ef54b86f6dc5f6efc18fbb13 diff --git a/platform/android/gradlew b/platform/android/gradlew index 91a7e269e1..9d82f78915 100755 --- a/platform/android/gradlew +++ b/platform/android/gradlew @@ -42,11 +42,6 @@ case "`uname`" in ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" @@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do fi done SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- +cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" -cd "$SAVED" >&- +cd "$SAVED" >/dev/null CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar @@ -114,6 +109,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` diff --git a/platform/android/gradlew.bat b/platform/android/gradlew.bat index 8a0b282aa6..aec99730b4 100644 --- a/platform/android/gradlew.bat +++ b/platform/android/gradlew.bat @@ -1,90 +1,90 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
|