diff options
author | Tobrun <tobrun@mapbox.com> | 2017-06-20 15:48:24 +0200 |
---|---|---|
committer | Antonio Zugaldia <antonio@mapbox.com> | 2017-06-20 09:48:24 -0400 |
commit | a9f52e24e63af6d322b3f4744a38aab395344b1d (patch) | |
tree | 015072cdd1d3fe07894be73c3761f4ed5685e48f /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps | |
parent | 899d2b0de931ca1a7295cce35dc7cfb177a5d14b (diff) | |
download | qtlocation-mapboxgl-a9f52e24e63af6d322b3f4744a38aab395344b1d.tar.gz |
Revisit Javadoc for 5.1.0 (#9266)
* [android] - revisit public API javadoc
* [android] fix javadoc minor mistakes and typos
* grammar tweak
* add missing public javadoc
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps')
6 files changed, 195 insertions, 40 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 098c701e03..c51d9327d2 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -1,7 +1,5 @@ package com.mapbox.mapboxsdk.maps; -import android.app.Activity; -import android.app.Fragment; import android.content.Context; import android.graphics.Canvas; import android.graphics.PointF; @@ -27,7 +25,6 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ZoomButtonsController; -import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.annotations.MarkerViewManager; import com.mapbox.mapboxsdk.constants.MapboxConstants; @@ -178,14 +175,14 @@ public class MapView extends FrameLayout { /** * <p> - * You must call this method from the parent's {@link android.app.Activity#onCreate(Bundle)} or - * {@link android.app.Fragment#onCreate(Bundle)}. + * You must call this method from the parent's Activity#onCreate(Bundle)} or + * Fragment#onCreate(Bundle). * </p> - * You must set a valid access token with {@link Mapbox#getInstance(Context, String)}) before you call this method - * or an exception will be thrown. + * You must set a valid access token with {@link com.mapbox.mapboxsdk.Mapbox#getInstance(Context, String)} + * before you call this method or an exception will be thrown. * * @param savedInstanceState Pass in the parent's savedInstanceState. - * @see Mapbox#getInstance(Context, String) + * @see com.mapbox.mapboxsdk.Mapbox#getInstance(Context, String) */ @UiThread public void onCreate(@Nullable Bundle savedInstanceState) { @@ -214,12 +211,11 @@ public class MapView extends FrameLayout { } /** - * You must call this method from the parent's {@link android.app.Activity#onSaveInstanceState(Bundle)} - * or {@link android.app.Fragment#onSaveInstanceState(Bundle)}. + * You must call this method from the parent's Activity#onSaveInstanceState(Bundle) + * or Fragment#onSaveInstanceState(Bundle). * * @param outState Pass in the parent's outState. */ - @UiThread public void onSaveInstanceState(@NonNull Bundle outState) { outState.putBoolean(MapboxConstants.STATE_HAS_SAVED_STATE, true); @@ -227,7 +223,7 @@ public class MapView extends FrameLayout { } /** - * You must call this method from the parent's {@link Activity#onStart()} or {@link Fragment#onStart()} + * You must call this method from the parent's Activity#onStart() or Fragment#onStart() */ @UiThread public void onStart() { @@ -236,7 +232,7 @@ public class MapView extends FrameLayout { } /** - * You must call this method from the parent's {@link Activity#onResume()} or {@link Fragment#onResume()}. + * You must call this method from the parent's Activity#onResume() or Fragment#onResume(). */ @UiThread public void onResume() { @@ -244,7 +240,7 @@ public class MapView extends FrameLayout { } /** - * You must call this method from the parent's {@link Activity#onPause()} or {@link Fragment#onPause()}. + * You must call this method from the parent's Activity#onPause() or Fragment#onPause(). */ @UiThread public void onPause() { @@ -252,7 +248,7 @@ public class MapView extends FrameLayout { } /** - * You must call this method from the parent's {@link Activity#onStop()} or {@link Fragment#onStop()}. + * You must call this method from the parent's Activity#onStop() or Fragment#onStop(). */ @UiThread public void onStop() { @@ -261,7 +257,7 @@ public class MapView extends FrameLayout { } /** - * You must call this method from the parent's {@link Activity#onDestroy()} or {@link Fragment#onDestroy()}. + * You must call this method from the parent's Activity#onDestroy() or Fragment#onDestroy(). */ @UiThread public void onDestroy() { @@ -325,7 +321,7 @@ public class MapView extends FrameLayout { } /** - * You must call this method from the parent's {@link Activity#onLowMemory()} or {@link Fragment#onLowMemory()}. + * You must call this method from the parent's Activity#onLowMemory() or Fragment#onLowMemory(). */ @UiThread public void onLowMemory() { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 8a708cb186..d672ab37c3 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -736,8 +736,8 @@ public final class MapboxMap { * will return the current location of the camera in flight. * <p> * Note that this will cancel location tracking mode if enabled. You can change this behaviour by calling - * {@link TrackingSettings#setDismissTrackingModeForCameraPositionChange(boolean)} with false before invoking this - * method and calling it with true in the {@link CancelableCallback#onFinish()}. + * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setDismissLocationTrackingOnGesture(boolean)} with false before + * invoking this method and calling it with true in the {@link CancelableCallback#onFinish()}. * </p> * * @param update The change that should be applied to the camera. @@ -763,8 +763,8 @@ public final class MapboxMap { * will return the current location of the camera in flight. * <p> * Note that this will cancel location tracking mode if enabled. You can change this behaviour by calling - * {@link TrackingSettings#setDismissTrackingModeForCameraPositionChange(boolean)} with false before invoking this - * method and calling it with true in the {@link CancelableCallback#onFinish()}. + * {@link com.mapbox.mapboxsdk.maps.TrackingSettings#setDismissLocationTrackingOnGesture(boolean)} with false before + * invoking this method and calling it with true in the {@link CancelableCallback#onFinish()}. * </p> * * @param update The change that should be applied to the camera. @@ -887,7 +887,12 @@ public final class MapboxMap { } /** - * Set focal bearing. + * Transform the map bearing given a bearing, focal point coordinates, and a duration. + * + * @param bearing The bearing of the Map to be transformed to + * @param focalX The x coordinate of the focal point + * @param focalY The y coordinate of the focal point + * @param duration The duration of the transformation */ public void setFocalBearing(double bearing, float focalX, float focalY, long duration) { transform.setBearing(bearing, focalX, focalY, duration); @@ -1059,7 +1064,7 @@ public final class MapboxMap { * An error message will be logged in the Android logcat and {@link MapView#DID_FAIL_LOADING_MAP} event will be * sent. * - * @param style The bundled style. Accepts one of the values from {@link Style}. + * @param style The bundled style. * @see Style */ @UiThread @@ -1075,7 +1080,8 @@ public final class MapboxMap { * An error message will be logged in the Android logcat and {@link MapView#DID_FAIL_LOADING_MAP} event will be * sent. * - * @param style The bundled style. Accepts one of the values from {@link Style}. + * @param style The bundled style. + * @param callback The callback to be invoked when the style has finished loading * @see Style */ @UiThread @@ -1576,9 +1582,11 @@ public final class MapboxMap { } /** - * Gets a camera position that would fit a bounds. + * Get a camera position that fits a provided bounds and padding. * * @param latLngBounds the bounds to constrain the map with + * @param padding the padding to apply to the bounds + * @return the camera position that fits the bounds and padding */ public CameraPosition getCameraForLatLngBounds(@Nullable LatLngBounds latLngBounds, int[] padding) { // calculate and set additional bounds padding @@ -2410,11 +2418,13 @@ public final class MapboxMap { } /** - * Interface definintion for a callback to be invoked when the style has finished loading. + * Interface definition for a callback to be invoked when the style has finished loading. */ public interface OnStyleLoadedListener { /** - * Invoked when the style has finished loading. + * Invoked when the style has finished loading + * + * @param style the style that has been loaded */ void onStyleLoaded(String style); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java index 98f94ddb39..2efed1b322 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java @@ -378,7 +378,7 @@ public class MapboxMapOptions implements Parcelable { /** * Specifies the gravity state of mapbox_compass_icon for a map view. * - * @param gravity see {@link android.view.Gravity} + * @param gravity Android SDK Gravity. * @return This */ public MapboxMapOptions compassGravity(int gravity) { @@ -439,7 +439,7 @@ public class MapboxMapOptions implements Parcelable { /** * Specifies the gravity state of logo for a map view. * - * @param gravity see {@link android.view.Gravity} + * @param gravity Android SDK Gravity. * @return This */ public MapboxMapOptions logoGravity(int gravity) { @@ -472,7 +472,7 @@ public class MapboxMapOptions implements Parcelable { /** * Specifies the gravity state of attribution for a map view. * - * @param gravity see {@link android.view.Gravity} + * @param gravity Android SDK Gravity. * @return This */ public MapboxMapOptions attributionGravity(int gravity) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java index accecf232b..7f8ba21e3e 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java @@ -16,7 +16,6 @@ import android.support.annotation.Nullable; import android.support.annotation.UiThread; import android.support.v4.content.ContextCompat; import android.support.v4.content.res.ResourcesCompat; -import android.view.Gravity; import android.view.View; import android.widget.FrameLayout; import android.widget.ImageView; @@ -196,7 +195,7 @@ public final class UiSettings { setLogoMargins(resources, options.getLogoMargins()); } - private void setLogoMargins(Resources resources, int[]logoMargins) { + private void setLogoMargins(Resources resources, int[] logoMargins) { if (logoMargins != null) { setLogoMargins(logoMargins[0], logoMargins[1], logoMargins[2], logoMargins[3]); } else { @@ -309,8 +308,7 @@ public final class UiSettings { * </p> * By default, the compass is in the top right corner. * - * @param gravity One of the values from {@link Gravity}. - * @see Gravity + * @param gravity Android SDK Gravity. */ @UiThread public void setCompassGravity(int gravity) { @@ -454,8 +452,7 @@ public final class UiSettings { * </p> * By default, the logo is in the bottom left corner. * - * @param gravity One of the values from {@link Gravity}. - * @see Gravity + * @param gravity Android SDK Gravity. */ public void setLogoGravity(int gravity) { setWidgetGravity(logoView, gravity); @@ -546,8 +543,7 @@ public final class UiSettings { * </p> * By default, the attribution is in the bottom left corner next to the Mapbox logo. * - * @param gravity One of the values from {@link Gravity}. - * @see Gravity + * @param gravity Android SDK Gravity. */ public void setAttributionGravity(int gravity) { setWidgetGravity(attributionsView, gravity); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java index 9740679cf5..72868a91d8 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java @@ -45,6 +45,9 @@ import timber.log.Timber; /** * UI element overlaid on a map to show the user's location. + * <p> + * Use {@link MyLocationViewSettings} to manipulate the state of this view. + * </p> */ public class MyLocationView extends View { @@ -155,6 +158,12 @@ public class MyLocationView extends View { this.locationSource = locationSource; } + /** + * Set the foreground drawable, for internal use only. + * + * @param defaultDrawable The drawable shown when showing this view + * @param bearingDrawable The drawable shown when tracking of bearing is enabled + */ public final void setForegroundDrawables(Drawable defaultDrawable, Drawable bearingDrawable) { if (defaultDrawable == null) { return; @@ -183,6 +192,11 @@ public class MyLocationView extends View { invalidateBounds(); } + /** + * Set the foreground drawable tint, for internal use only. + * + * @param color The color to tint the drawable with + */ public final void setForegroundDrawableTint(@ColorInt int color) { if (foregroundDrawable != null) { foregroundDrawable.mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN); @@ -193,10 +207,24 @@ public class MyLocationView extends View { invalidate(); } + /** + * Set the shadow drawable, for internal use only. + * + * @param drawable The drawable shown as shadow + */ public final void setShadowDrawable(Drawable drawable) { setShadowDrawable(drawable, 0, 0, 0, 0); } + /** + * Set the shadow drawable with some additional offset. + * + * @param drawable The drawable shown as shadow + * @param left The left offset margin + * @param top The top offset margin + * @param right The right offset margin + * @param bottom The bottom offset margin + */ public final void setShadowDrawable(Drawable drawable, int left, int top, int right, int bottom) { if (drawable != null) { backgroundDrawable = drawable; @@ -210,6 +238,11 @@ public class MyLocationView extends View { invalidateBounds(); } + /** + * Set the shadow drawable tint color, for internal use only. + * + * @param color The tint color to apply + */ public final void setShadowDrawableTint(@ColorInt int color) { if (backgroundDrawable == null) { return; @@ -218,6 +251,11 @@ public class MyLocationView extends View { invalidate(); } + /** + * Set the accuracy tint color, for internal use only. + * + * @param color The tint color to apply + */ public final void setAccuracyTint(@ColorInt int color) { int alpha = accuracyPaint.getAlpha(); accuracyPaint.setColor(color); @@ -225,6 +263,11 @@ public class MyLocationView extends View { invalidate(); } + /** + * Set the accuracy alpha value, for internal use only. + * + * @param alpha The alpha accuracy value to apply + */ public final void setAccuracyAlpha(@IntRange(from = 0, to = 255) int alpha) { accuracyPaint.setAlpha(alpha); invalidate(); @@ -314,6 +357,11 @@ public class MyLocationView extends View { } } + /** + * Set the tilt value, for internal use only. + * + * @param tilt The tilt to apply + */ public void setTilt(@FloatRange(from = 0, to = 60.0f) double tilt) { this.tilt = tilt; if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) { @@ -322,6 +370,11 @@ public class MyLocationView extends View { invalidate(); } + /** + * Set the bearing value, for internal use only. + * + * @param bearing The bearing to apply + */ public void setBearing(double bearing) { this.bearing = bearing; if (myLocationTrackingMode == MyLocationTracking.TRACKING_NONE) { @@ -335,6 +388,11 @@ public class MyLocationView extends View { } } + /** + * Set the bearing and tilt from a camera position, for internal use only. + * + * @param position The camera position to extract bearing and tilt from + */ public void setCameraPosition(CameraPosition position) { if (position != null) { setBearing(position.bearing); @@ -342,6 +400,9 @@ public class MyLocationView extends View { } } + /** + * Called when the hosting activity is starting, for internal use only. + */ public void onStart() { if (myBearingTrackingMode == MyBearingTracking.COMPASS && compassListener.isSensorAvailable()) { compassListener.onResume(); @@ -351,6 +412,9 @@ public class MyLocationView extends View { } } + /** + * Called when the hosting activity is stopping, for internal use only. + */ public void onStop() { compassListener.onPause(); toggleGps(false); @@ -382,6 +446,9 @@ public class MyLocationView extends View { } } + /** + * Update current locationstate. + */ public void update() { if (isEnabled()) { myLocationBehavior.invalidate(); @@ -396,17 +463,33 @@ public class MyLocationView extends View { this.projection = mapboxMap.getProjection(); } + /** + * Set the enabled state, for internal use only. + * + * @param enabled The value to set the state to + */ @Override public void setEnabled(boolean enabled) { setEnabled(enabled, false); } + /** + * Set the enabled state, for internal use only. + * + * @param enabled The value to set the state to + * @param isCustomLocationSource Flag handling for handling user provided custom location source + */ public void setEnabled(boolean enabled, boolean isCustomLocationSource) { super.setEnabled(enabled); setVisibility(enabled ? View.VISIBLE : View.INVISIBLE); toggleGps(enabled, isCustomLocationSource); } + /** + * Save the view instance state, for internal use only. + * + * @return the marshaled representation of the view state + */ @Override protected Parcelable onSaveInstanceState() { Bundle bundle = new Bundle(); @@ -415,6 +498,11 @@ public class MyLocationView extends View { return bundle; } + /** + * Restore the view instance state, for internal use only. + * + * @param state the marshalled representation of the state to restore + */ @Override public void onRestoreInstanceState(Parcelable state) { if (state instanceof Bundle) { @@ -430,7 +518,7 @@ public class MyLocationView extends View { } /** - * Enabled / Disable GPS location updates along with updating the UI + * Enabled / Disable GPS location updates along with updating the UI, for internal use only. * * @param enableGps true if GPS is to be enabled, false if GPS is to be disabled */ @@ -463,10 +551,20 @@ public class MyLocationView extends View { } } + /** + * Get the current location. + * + * @return the current location + */ public Location getLocation() { return location; } + /** + * Set the current location, for internal use only. + * + * @param location The current location + */ public void setLocation(Location location) { if (location == null) { this.location = null; @@ -482,10 +580,20 @@ public class MyLocationView extends View { } } + /** + * Set location change animation enabled, for internal use only. + * + * @param locationChangeAnimationEnabled True if location changes are animated + */ public void setLocationChangeAnimationEnabled(boolean locationChangeAnimationEnabled) { this.locationChangeAnimationEnabled = locationChangeAnimationEnabled; } + /** + * Set the bearing tracking mode, for internal use only. + * + * @param myBearingTrackingMode The bearing tracking mode + */ public void setMyBearingTrackingMode(@MyBearingTracking.Mode int myBearingTrackingMode) { this.myBearingTrackingMode = myBearingTrackingMode; if (myBearingTrackingMode == MyBearingTracking.COMPASS && compassListener.isSensorAvailable()) { @@ -502,6 +610,11 @@ public class MyLocationView extends View { invalidate(); } + /** + * Set the location tracking mode, for internla use only. + * + * @param myLocationTrackingMode The location tracking mode + */ public void setMyLocationTrackingMode(@MyLocationTracking.Mode int myLocationTrackingMode) { MyLocationBehaviorFactory factory = new MyLocationBehaviorFactory(); myLocationBehavior = factory.getBehavioralModel(myLocationTrackingMode); @@ -522,17 +635,32 @@ public class MyLocationView extends View { invalidate(); } + /** + * Get the location tracking mode, for internal use only. + * + * @return The location tracking mode + */ @MyLocationTracking.Mode public int getMyLocationTrackingMode() { return myLocationTrackingMode; } + /** + * Get the bearing tracking mode, for internal use only. + * + * @return the bearing tracking mode + */ @MyBearingTracking.Mode public int getMyBearingTrackingMode() { return myBearingTrackingMode; } + /** + * Set the compass bearing value, for internal use only. + * + * @param bearing The compas bearing value + */ private void setCompass(double bearing) { setCompass(bearing, 0 /* no animation */); } @@ -560,14 +688,29 @@ public class MyLocationView extends View { directionAnimator.start(); } + /** + * Get the center of this view in screen coordinates. + * + * @return the center of the view + */ public PointF getCenter() { return new PointF(getCenterX(), getCenterY()); } + /** + * Get the x value of the center of this view. + * + * @return the x value of the center of the view + */ private float getCenterX() { return (getX() + getMeasuredWidth()) / 2 + contentPaddingX - projectedX; } + /** + * Get the y value of the center of this view. + * + * @return the y value of the center of the view + */ private float getCenterY() { return (getY() + getMeasuredHeight()) / 2 + contentPaddingY - projectedY; } @@ -577,6 +720,11 @@ public class MyLocationView extends View { contentPaddingY = (padding[1] - padding[3]) / 2; } + /** + * Set the location source from which location updates are received, for internal use only. + * + * @param locationSource The location source to receive updates from + */ public void setLocationSource(LocationEngine locationSource) { toggleGps(false); this.locationSource = locationSource; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java index e9d823ebda..2ad1bf7ebc 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationViewSettings.java @@ -5,9 +5,9 @@ import android.support.annotation.ColorInt; import android.support.annotation.IntRange; import android.support.annotation.NonNull; +import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.constants.MyLocationTracking; import com.mapbox.mapboxsdk.maps.FocalPointChangeListener; -import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.maps.MapboxMapOptions; import com.mapbox.mapboxsdk.maps.Projection; @@ -77,6 +77,11 @@ public class MyLocationViewSettings { this.focalPointChangeListener = focalPointChangedListener; } + /** + * Initialise this with MapboxMapOptions. + * + * @param options the options to initialise this class from + */ public void initialise(@NonNull MapboxMapOptions options) { CameraPosition position = options.getCamera(); if (position != null && !position.equals(CameraPosition.DEFAULT)) { |