summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun@mapbox.com>2016-02-01 16:00:30 +0100
committerTobrun <tobrun@mapbox.com>2016-02-01 16:22:54 +0100
commit0e66d4dcc53fad046673346f3db83346ad54e3e8 (patch)
tree3cb89ffc623a8eefd461a17a3c6e587feefbe68b
parent6ebb3e88d869ee85530df4b101752a390ca3ebb3 (diff)
downloadqtlocation-mapboxgl-0e66d4dcc53fad046673346f3db83346ad54e3e8.tar.gz
[android] #3776 - UiSettings uses MapView instead of MapboxMap as dependency. Cleanup obsolete methods MapboxMap/MapView, Renaming convention Google Maps SDK, Update tests, Some minor fixes in state management
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java161
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java59
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java2
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/UiSettings.java25
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java58
6 files changed, 118 insertions, 191 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java
index ed831c6bbd..153a7d63c2 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java
@@ -77,13 +77,13 @@ public class MapboxConstants {
public static final String STATE_LOGO_MARGIN_TOP = "logoMarginTop";
public static final String STATE_LOGO_MARGIN_RIGHT = "logoMarginRight";
public static final String STATE_LOGO_MARGIN_BOTTOM = "logoMarginBottom";
- public static final String STATE_LOGO_VISIBILITY = "logoVisibility";
+ public static final String STATE_LOGO_ENABLED = "logoEnabled";
public static final String STATE_ATTRIBUTION_GRAVITY = "attrGravity";
public static final String STATE_ATTRIBUTION_MARGIN_LEFT = "attrMarginLeft";
public static final String STATE_ATTRIBUTION_MARGIN_TOP = "attrMarginTop";
public static final String STATE_ATTRIBUTION_MARGIN_RIGHT = "attrMarginRight";
public static final String STATE_ATTRIBUTION_MARGIN_BOTTOM = "atrrMarginBottom";
- public static final String STATE_ATTRIBUTION_VISIBILITY = "atrrVisibility";
+ public static final String STATE_ATTRIBUTION_ENABLED = "atrrEnabled";
public static final String TAG = "MapboxMap";
}
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 66d344312f..fc8ad0c255 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
@@ -226,7 +226,6 @@ public class MapView extends FrameLayout {
// Load the attributes
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MapView, 0, 0);
try {
-
// Debug mode
mMapboxMap.setDebugActive(typedArray.getBoolean(R.styleable.MapView_debug_active, false));
@@ -250,32 +249,31 @@ public class MapView extends FrameLayout {
uiSettings.setScrollGesturesEnabled(typedArray.getBoolean(R.styleable.MapView_scroll_enabled, true));
uiSettings.setRotateGesturesEnabled(typedArray.getBoolean(R.styleable.MapView_rotate_enabled, true));
uiSettings.setTiltGesturesEnabled(typedArray.getBoolean(R.styleable.MapView_tilt_enabled, true));
- uiSettings.setZoomControlsEnabled(typedArray.getBoolean(R.styleable.MapView_zoom_controls_enabled, false
- ));
+ uiSettings.setZoomControlsEnabled(typedArray.getBoolean(R.styleable.MapView_zoom_controls_enabled, false));
// Compass
- mMapboxMap.setCompassEnabled(typedArray.getBoolean(R.styleable.MapView_compass_enabled, true));
- mMapboxMap.setCompassGravity(typedArray.getInt(R.styleable.MapView_compass_gravity, Gravity.TOP | Gravity.END));
- setWidgetMargins(mCompassView, typedArray.getDimension(R.styleable.MapView_compass_margin_left, DIMENSION_TEN_DP)
- , typedArray.getDimension(R.styleable.MapView_compass_margin_top, DIMENSION_TEN_DP)
- , typedArray.getDimension(R.styleable.MapView_compass_margin_right, DIMENSION_TEN_DP)
- , typedArray.getDimension(R.styleable.MapView_compass_margin_bottom, DIMENSION_TEN_DP));
+ uiSettings.setCompassEnabled(typedArray.getBoolean(R.styleable.MapView_compass_enabled, true));
+ uiSettings.setCompassGravity(typedArray.getInt(R.styleable.MapView_compass_gravity, Gravity.TOP | Gravity.END));
+ uiSettings.setCompassMargins((int) (typedArray.getDimension(R.styleable.MapView_compass_margin_left, DIMENSION_TEN_DP) * mScreenDensity)
+ , ((int) typedArray.getDimension(R.styleable.MapView_compass_margin_top, DIMENSION_TEN_DP * mScreenDensity))
+ , ((int) typedArray.getDimension(R.styleable.MapView_compass_margin_right, DIMENSION_TEN_DP * mScreenDensity))
+ , ((int) typedArray.getDimension(R.styleable.MapView_compass_margin_bottom, DIMENSION_TEN_DP * mScreenDensity)));
// Logo
- mMapboxMap.setLogoVisibility(typedArray.getInt(R.styleable.MapView_logo_visibility, View.VISIBLE));
- mMapboxMap.setLogoGravity(typedArray.getInt(R.styleable.MapView_logo_gravity, Gravity.BOTTOM | Gravity.START));
- setWidgetMargins(mLogoView, typedArray.getDimension(R.styleable.MapView_logo_margin_left, DIMENSION_SIXTEEN_DP)
- , typedArray.getDimension(R.styleable.MapView_logo_margin_top, DIMENSION_SIXTEEN_DP)
- , typedArray.getDimension(R.styleable.MapView_logo_margin_right, DIMENSION_SIXTEEN_DP)
- , typedArray.getDimension(R.styleable.MapView_logo_margin_bottom, DIMENSION_SIXTEEN_DP));
+ uiSettings.setLogoEnabled(typedArray.getBoolean(R.styleable.MapView_logo_visibility, true));
+ uiSettings.setLogoGravity(typedArray.getInt(R.styleable.MapView_logo_gravity, Gravity.BOTTOM | Gravity.START));
+ uiSettings.setLogoMargins((int) (typedArray.getDimension(R.styleable.MapView_logo_margin_left, DIMENSION_SIXTEEN_DP) * mScreenDensity)
+ , (int) (typedArray.getDimension(R.styleable.MapView_logo_margin_top, DIMENSION_SIXTEEN_DP) * mScreenDensity)
+ , (int) (typedArray.getDimension(R.styleable.MapView_logo_margin_right, DIMENSION_SIXTEEN_DP) * mScreenDensity)
+ , (int) (typedArray.getDimension(R.styleable.MapView_logo_margin_bottom, DIMENSION_SIXTEEN_DP) * mScreenDensity));
// Attribution
- mMapboxMap.setAttributionVisibility(typedArray.getInt(R.styleable.MapView_attribution_visibility, View.VISIBLE));
- mMapboxMap.setAttributionGravity(typedArray.getInt(R.styleable.MapView_attribution_gravity, Gravity.BOTTOM));
- setWidgetMargins(mAttributionsView, typedArray.getDimension(R.styleable.MapView_attribution_margin_left, DIMENSION_SEVENTYSIX_DP)
- , typedArray.getDimension(R.styleable.MapView_attribution_margin_top, DIMENSION_SEVEN_DP)
- , typedArray.getDimension(R.styleable.MapView_attribution_margin_right, DIMENSION_SEVEN_DP)
- , typedArray.getDimension(R.styleable.MapView_attribution_margin_bottom, DIMENSION_SEVEN_DP));
+ uiSettings.setAttributionEnabled(typedArray.getBoolean(R.styleable.MapView_attribution_visibility, true));
+ uiSettings.setAttributionGravity(typedArray.getInt(R.styleable.MapView_attribution_gravity, Gravity.BOTTOM));
+ uiSettings.setAttributionMargins((int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_left, DIMENSION_SEVENTYSIX_DP) * mScreenDensity)
+ , (int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_top, DIMENSION_SEVEN_DP) * mScreenDensity)
+ , (int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_right, DIMENSION_SEVEN_DP) * mScreenDensity)
+ , (int) (typedArray.getDimension(R.styleable.MapView_attribution_margin_bottom, DIMENSION_SEVEN_DP) * mScreenDensity));
// User location
try {
@@ -322,44 +320,45 @@ public class MapView extends FrameLayout {
uiSettings.setTiltGesturesEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_TILT_ENABLED));
uiSettings.setZoomControlsEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_ZOOM_CONTROLS_ENABLED));
- mMapboxMap.setDebugActive(savedInstanceState.getBoolean(MapboxConstants.STATE_DEBUG_ACTIVE));
- mMapboxMap.setStyleUrl(savedInstanceState.getString(MapboxConstants.STATE_STYLE_URL));
- setAccessToken(savedInstanceState.getString(MapboxConstants.STATE_ACCESS_TOKEN));
- mNativeMapView.setDefaultTransitionDuration(
- savedInstanceState.getLong(MapboxConstants.STATE_DEFAULT_TRANSITION_DURATION));
-
- // User location
- try {
- //noinspection ResourceType
- mMapboxMap.setMyLocationEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED));
- } catch (SecurityException ignore) {
- // User did not accept location permissions
- }
-
// Compass
- mMapboxMap.setCompassEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_COMPASS_ENABLED));
- mMapboxMap.setCompassGravity(savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_GRAVITY));
- mMapboxMap.setCompassMargins(savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_LEFT)
+ uiSettings.setCompassEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_COMPASS_ENABLED));
+ uiSettings.setCompassGravity(savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_GRAVITY));
+ uiSettings.setCompassMargins(savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_LEFT)
, savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_TOP)
, savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_RIGHT)
, savedInstanceState.getInt(MapboxConstants.STATE_COMPASS_MARGIN_BOTTOM));
// Logo
- mMapboxMap.setLogoVisibility(savedInstanceState.getInt(MapboxConstants.STATE_LOGO_VISIBILITY));
- mMapboxMap.setLogoGravity(savedInstanceState.getInt(MapboxConstants.STATE_LOGO_GRAVITY));
- mMapboxMap.setLogoMargins(savedInstanceState.getInt(MapboxConstants.STATE_LOGO_MARGIN_LEFT)
+ uiSettings.setLogoEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_LOGO_ENABLED));
+ uiSettings.setLogoGravity(savedInstanceState.getInt(MapboxConstants.STATE_LOGO_GRAVITY));
+ uiSettings.setLogoMargins(savedInstanceState.getInt(MapboxConstants.STATE_LOGO_MARGIN_LEFT)
, savedInstanceState.getInt(MapboxConstants.STATE_LOGO_MARGIN_TOP)
, savedInstanceState.getInt(MapboxConstants.STATE_LOGO_MARGIN_RIGHT)
, savedInstanceState.getInt(MapboxConstants.STATE_LOGO_MARGIN_BOTTOM));
// Attribution
- mMapboxMap.setAttributionVisibility(savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_VISIBILITY));
- mMapboxMap.setAttributionGravity(savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_GRAVITY));
- mMapboxMap.setAttributionMargins(savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_LEFT)
+ uiSettings.setAttributionEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_ATTRIBUTION_ENABLED));
+ uiSettings.setAttributionGravity(savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_GRAVITY));
+ uiSettings.setAttributionMargins(savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_LEFT)
, savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_TOP)
, savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_RIGHT)
, savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_BOTTOM));
+
+ mMapboxMap.setDebugActive(savedInstanceState.getBoolean(MapboxConstants.STATE_DEBUG_ACTIVE));
+ mMapboxMap.setStyleUrl(savedInstanceState.getString(MapboxConstants.STATE_STYLE_URL));
+ setAccessToken(savedInstanceState.getString(MapboxConstants.STATE_ACCESS_TOKEN));
+ mNativeMapView.setDefaultTransitionDuration(
+ savedInstanceState.getLong(MapboxConstants.STATE_DEFAULT_TRANSITION_DURATION));
+
+ // User location
+ try {
+ //noinspection ResourceType
+ mMapboxMap.setMyLocationEnabled(savedInstanceState.getBoolean(MapboxConstants.STATE_MY_LOCATION_ENABLED));
+ } catch (SecurityException ignore) {
+ // User did not accept location permissions
+ }
+
//noinspection ResourceType
mMapboxMap.setMyLocationTrackingMode(savedInstanceState.getInt(MapboxConstants.STATE_MY_LOCATION_TRACKING_MODE, MyLocationTracking.TRACKING_NONE));
//noinspection ResourceType
@@ -395,14 +394,7 @@ public class MapView extends FrameLayout {
@UiThread
public void onSaveInstanceState(@NonNull Bundle outState) {
- UiSettings uiSettings = mMapboxMap.getUiSettings();
-
outState.putParcelable(MapboxConstants.STATE_CAMERA_POSITION, mMapboxMap.getCameraPosition());
- outState.putBoolean(MapboxConstants.STATE_ZOOM_ENABLED, uiSettings.isZoomGesturesEnabled());
- outState.putBoolean(MapboxConstants.STATE_SCROLL_ENABLED, uiSettings.isScrollGesturesEnabled());
- outState.putBoolean(MapboxConstants.STATE_ROTATE_ENABLED, uiSettings.isRotateGesturesEnabled());
- outState.putBoolean(MapboxConstants.STATE_TILT_ENABLED, uiSettings.isTiltGesturesEnabled());
- outState.putBoolean(MapboxConstants.STATE_ZOOM_CONTROLS_ENABLED, uiSettings.isZoomControlsEnabled());
outState.putBoolean(MapboxConstants.STATE_DEBUG_ACTIVE, mMapboxMap.isDebugActive());
outState.putString(MapboxConstants.STATE_STYLE_URL, mMapboxMap.getStyleUrl());
outState.putString(MapboxConstants.STATE_ACCESS_TOKEN, mMapboxMap.getAccessToken());
@@ -411,32 +403,37 @@ public class MapView extends FrameLayout {
outState.putInt(MapboxConstants.STATE_MY_LOCATION_TRACKING_MODE, mMapboxMap.getMyLocationTrackingMode());
outState.putInt(MapboxConstants.STATE_MY_BEARING_TRACKING_MODE, mMapboxMap.getMyBearingTrackingMode());
- // Compass
- LayoutParams compassParams = (LayoutParams) mCompassView.getLayoutParams();
+ // UiSettings
+ UiSettings uiSettings = mMapboxMap.getUiSettings();
+ outState.putBoolean(MapboxConstants.STATE_ZOOM_ENABLED, uiSettings.isZoomGesturesEnabled());
+ outState.putBoolean(MapboxConstants.STATE_SCROLL_ENABLED, uiSettings.isScrollGesturesEnabled());
+ outState.putBoolean(MapboxConstants.STATE_ROTATE_ENABLED, uiSettings.isRotateGesturesEnabled());
+ outState.putBoolean(MapboxConstants.STATE_TILT_ENABLED, uiSettings.isTiltGesturesEnabled());
+ outState.putBoolean(MapboxConstants.STATE_ZOOM_CONTROLS_ENABLED, uiSettings.isZoomControlsEnabled());
+
+ // UiSettings - Compass
outState.putBoolean(MapboxConstants.STATE_COMPASS_ENABLED, uiSettings.isCompassEnabled());
- outState.putInt(MapboxConstants.STATE_COMPASS_GRAVITY, compassParams.gravity);
- outState.putInt(MapboxConstants.STATE_COMPASS_MARGIN_LEFT, compassParams.leftMargin);
- outState.putInt(MapboxConstants.STATE_COMPASS_MARGIN_TOP, compassParams.topMargin);
- outState.putInt(MapboxConstants.STATE_COMPASS_MARGIN_BOTTOM, compassParams.bottomMargin);
- outState.putInt(MapboxConstants.STATE_COMPASS_MARGIN_RIGHT, compassParams.rightMargin);
-
- // Logo
- LayoutParams logoParams = (LayoutParams) mLogoView.getLayoutParams();
- outState.putInt(MapboxConstants.STATE_LOGO_GRAVITY, logoParams.gravity);
- outState.putInt(MapboxConstants.STATE_LOGO_MARGIN_LEFT, logoParams.leftMargin);
- outState.putInt(MapboxConstants.STATE_LOGO_MARGIN_TOP, logoParams.topMargin);
- outState.putInt(MapboxConstants.STATE_LOGO_MARGIN_RIGHT, logoParams.rightMargin);
- outState.putInt(MapboxConstants.STATE_LOGO_MARGIN_BOTTOM, logoParams.bottomMargin);
- outState.putInt(MapboxConstants.STATE_LOGO_VISIBILITY, mLogoView.getVisibility());
-
- // Attribution
- LayoutParams attrParams = (LayoutParams) mAttributionsView.getLayoutParams();
- outState.putInt(MapboxConstants.STATE_ATTRIBUTION_GRAVITY, attrParams.gravity);
- outState.putInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_LEFT, attrParams.leftMargin);
- outState.putInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_TOP, attrParams.topMargin);
- outState.putInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_RIGHT, attrParams.rightMargin);
- outState.putInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_BOTTOM, attrParams.bottomMargin);
- outState.putInt(MapboxConstants.STATE_ATTRIBUTION_VISIBILITY, mAttributionsView.getVisibility());
+ outState.putInt(MapboxConstants.STATE_COMPASS_GRAVITY, uiSettings.getCompassGravity());
+ outState.putInt(MapboxConstants.STATE_COMPASS_MARGIN_LEFT, uiSettings.getCompassMarginLeft());
+ outState.putInt(MapboxConstants.STATE_COMPASS_MARGIN_TOP, uiSettings.getCompassMarginTop());
+ outState.putInt(MapboxConstants.STATE_COMPASS_MARGIN_BOTTOM, uiSettings.getCompassMarginBottom());
+ outState.putInt(MapboxConstants.STATE_COMPASS_MARGIN_RIGHT, uiSettings.getCompassMarginRight());
+
+ // UiSettings - Logo
+ outState.putInt(MapboxConstants.STATE_LOGO_GRAVITY, uiSettings.getLogoGravity());
+ outState.putInt(MapboxConstants.STATE_LOGO_MARGIN_LEFT, uiSettings.getLogoMarginLeft());
+ outState.putInt(MapboxConstants.STATE_LOGO_MARGIN_TOP, uiSettings.getCompassMarginTop());
+ outState.putInt(MapboxConstants.STATE_LOGO_MARGIN_RIGHT, uiSettings.getLogoMarginRight());
+ outState.putInt(MapboxConstants.STATE_LOGO_MARGIN_BOTTOM, uiSettings.getLogoMarginBottom());
+ outState.putBoolean(MapboxConstants.STATE_LOGO_ENABLED, uiSettings.isLogoEnabled());
+
+ // UiSettings - Attribution
+ outState.putInt(MapboxConstants.STATE_ATTRIBUTION_GRAVITY, uiSettings.getAttributionGravity());
+ outState.putInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_LEFT, uiSettings.getAttributionMarginLeft());
+ outState.putInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_TOP, uiSettings.getAttributionMarginTop());
+ outState.putInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_RIGHT, uiSettings.getAttributionMarginRight());
+ outState.putInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_BOTTOM, uiSettings.getAttributionMarginBottom());
+ outState.putBoolean(MapboxConstants.STATE_ATTRIBUTION_ENABLED, uiSettings.isAttributionEnabled());
}
/**
@@ -2714,11 +2711,11 @@ public class MapView extends FrameLayout {
* </p>
* By default, the compass is enabled.
*
- * @param visibility True to enable the logo; false to disable the logo.
+ * @param visible True to enable the logo; false to disable the logo.
*/
@UiThread
- void setLogoVisibility(int visibility) {
- mLogoView.setVisibility(visibility);
+ void setLogoVisibility(boolean visible) {
+ mLogoView.setVisibility(visible ? View.VISIBLE : View.GONE);
}
//
@@ -2857,12 +2854,6 @@ public class MapView extends FrameLayout {
view.setLayoutParams(layoutParams);
}
- private void setWidgetMargins(@NonNull final View view, float leftDp, float topDp, float rightDp, float bottomDp) {
- LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
- layoutParams.setMargins((int) (leftDp * mScreenDensity), (int) (topDp * mScreenDensity), (int) (rightDp * mScreenDensity), (int) (bottomDp * mScreenDensity));
- view.setLayoutParams(layoutParams);
- }
-
private static class AttributionOnClickListener implements View.OnClickListener, DialogInterface.OnClickListener {
private static final int ATTRIBUTION_INDEX_IMPROVE_THIS_MAP = 2;
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 6076e9cd61..1a9780b92b 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
@@ -63,7 +63,7 @@ public class MapboxMap {
MapboxMap(@NonNull MapView mapView) {
mMapView = mapView;
- mUiSettings = new UiSettings(this);
+ mUiSettings = new UiSettings(mapView);
mSelectedMarkers = new ArrayList<>();
mInfoWindows = new ArrayList<>();
}
@@ -1105,63 +1105,6 @@ public class MapboxMap {
}
//
- // Compass
- //
-
- // used by UiSettings
- void setCompassEnabled(boolean compassEnabled) {
- mMapView.setCompassEnabled(compassEnabled);
- }
-
- // used by UiSettings
- void setCompassGravity(int gravity) {
- mMapView.setCompassGravity(gravity);
- }
-
- // used by UiSettings
- void setCompassMargins(int left, int top, int right, int bottom) {
- mMapView.setCompassMargins(left, top, right, bottom);
- }
-
- //
- // Logo
- //
-
- // used by UiSettings
- void setLogoGravity(int gravity) {
- mMapView.setLogoGravity(gravity);
- }
-
- // used by UiSettings
- void setLogoMargins(int left, int top, int right, int bottom) {
- mMapView.setLogoMargins(left, top, right, bottom);
- }
-
- // used by UiSettings
- void setLogoVisibility(int visibility) {
- mMapView.setLogoVisibility(visibility);
- }
-
- //
- // Attribution
- //
-
- // used by UiSettings
- void setAttributionGravity(int gravity) {
- mMapView.setAttributionGravity(gravity);
- }
-
- // used by UiSettings
- void setAttributionMargins(int left, int top, int right, int bottom) {
- mMapView.setAttributionMargins(left, top, right, bottom);
- }
-
- // used by UiSettings
- void setAttributionVisibility(int visibility) {
- mMapView.setAttributionVisibility(visibility);
- }
-
- //
// Custom layer
//
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 a0a03926a3..cb6407986e 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
@@ -37,7 +37,7 @@ public class MapboxMapOptions implements Parcelable {
}
public MapboxMapOptions compassEnabled(boolean enabled) {
- mMapboxMap.setCompassEnabled(enabled);
+ mUiSettings.setCompassEnabled(enabled);
return this;
}
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 e4ed6d52ee..d6cb106054 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
@@ -1,5 +1,6 @@
package com.mapbox.mapboxsdk.maps;
+import android.support.annotation.NonNull;
import android.support.annotation.UiThread;
import android.view.Gravity;
import android.view.View;
@@ -9,7 +10,7 @@ import android.view.View;
*/
public class UiSettings {
- private MapboxMap mapboxMap;
+ private MapView mapView;
private boolean compassEnabled;
private int compassGravity;
@@ -29,8 +30,8 @@ public class UiSettings {
private boolean zoomControlsEnabled;
private boolean scrollGesturesEnabled;
- UiSettings(MapboxMap mapboxMap) {
- this.mapboxMap = mapboxMap;
+ UiSettings(@NonNull MapView mapView) {
+ this.mapView = mapView;
this.compassMargins = new int[4];
this.attributionMargins = new int[4];
this.logoMargins = new int[4];
@@ -49,7 +50,7 @@ public class UiSettings {
*/
public void setCompassEnabled(boolean compassEnabled) {
this.compassEnabled = compassEnabled;
- this.mapboxMap.setCompassEnabled(compassEnabled);
+ this.mapView.setCompassEnabled(compassEnabled);
}
/**
@@ -74,7 +75,7 @@ public class UiSettings {
@UiThread
public void setCompassGravity(int gravity) {
this.compassGravity = gravity;
- this.mapboxMap.setCompassGravity(gravity);
+ this.mapView.setCompassGravity(gravity);
}
/**
@@ -98,7 +99,7 @@ public class UiSettings {
@UiThread
public void setCompassMargins(int left, int top, int right, int bottom) {
this.compassMargins = new int[]{left, top, right, bottom};
- this.mapboxMap.setCompassMargins(left, top, right, bottom);
+ this.mapView.setCompassMargins(left, top, right, bottom);
}
/**
@@ -147,7 +148,7 @@ public class UiSettings {
*/
public void setLogoEnabled(boolean enabled) {
this.logoEnabled = enabled;
- this.mapboxMap.setLogoVisibility(enabled ? View.VISIBLE : View.GONE);
+ this.mapView.setLogoVisibility(enabled );
}
/**
@@ -171,7 +172,7 @@ public class UiSettings {
*/
public void setLogoGravity(int gravity) {
this.logoGravity = gravity;
- this.mapboxMap.setLogoGravity(gravity);
+ this.mapView.setLogoGravity(gravity);
}
/**
@@ -194,7 +195,7 @@ public class UiSettings {
*/
public void setLogoMargins(int left, int top, int right, int bottom) {
this.logoMargins = new int[]{left, top, right, bottom};
- this.mapboxMap.setLogoMargins(left, top, right, bottom);
+ this.mapView.setLogoMargins(left, top, right, bottom);
}
/**
@@ -243,7 +244,7 @@ public class UiSettings {
*/
public void setAttributionEnabled(boolean enabled) {
this.attributionEnabled = enabled;
- this.mapboxMap.setAttributionVisibility(enabled ? View.VISIBLE : View.GONE);
+ this.mapView.setAttributionVisibility(enabled ? View.VISIBLE : View.GONE);
}
/**
@@ -267,7 +268,7 @@ public class UiSettings {
*/
public void setAttributionGravity(int gravity) {
this.attributionGravity = gravity;
- this.mapboxMap.setAttributionGravity(gravity);
+ this.mapView.setAttributionGravity(gravity);
}
/**
@@ -290,7 +291,7 @@ public class UiSettings {
*/
public void setAttributionMargins(int left, int top, int right, int bottom) {
this.attributionMargins = new int[]{left, top, right, bottom};
- this.mapboxMap.setAttributionMargins(left, top, right, bottom);
+ this.mapView.setAttributionMargins(left, top, right, bottom);
}
/**
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java
index 1494c65b05..9c867bf776 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/maps/UiSettingsTest.java
@@ -2,7 +2,6 @@ package com.mapbox.mapboxsdk.maps;
import android.view.Gravity;
-import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -13,46 +12,39 @@ import static org.mockito.Mockito.mock;
public class UiSettingsTest {
- private MapboxMap mMapboxMap;
-
@InjectMocks
MapView mMapView = mock(MapView.class);
- @Before
- public void beforeTest() {
- mMapboxMap = new MapboxMap(mMapView);
- }
-
@Test
public void testSanity() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
assertNotNull("uiSettings should not be null", uiSettings);
}
@Test
public void testCompassEnabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setCompassEnabled(true);
assertEquals("Compass should be enabled", true, uiSettings.isCompassEnabled());
}
@Test
public void testCompassDisabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setCompassEnabled(false);
assertEquals("Compass should be disabled", false, uiSettings.isCompassEnabled());
}
@Test
public void testCompassGravity() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setCompassGravity(Gravity.LEFT);
assertEquals("Compass gravity should be same", Gravity.LEFT, uiSettings.getCompassGravity());
}
@Test
public void testCompassMargins() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setCompassMargins(1, 2, 3, 4);
assertTrue("Compass margin left should be same", uiSettings.getCompassMarginLeft() == 1);
assertTrue("Compass margin top should be same", uiSettings.getCompassMarginTop() == 2);
@@ -62,28 +54,28 @@ public class UiSettingsTest {
@Test
public void testLogoEnabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setLogoEnabled(true);
assertEquals("Logo should be enabled", true, uiSettings.isLogoEnabled());
}
@Test
public void testLogoDisabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setLogoEnabled(false);
assertEquals("Logo should be disabled", false, uiSettings.isLogoEnabled());
}
@Test
public void testLogoGravity() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setLogoGravity(Gravity.RIGHT);
assertEquals("Logo gravity should be same", Gravity.RIGHT, uiSettings.getLogoGravity());
}
@Test
public void testLogoMargins() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setLogoMargins(1, 2, 3, 4);
assertTrue("Compass margin left should be same", uiSettings.getLogoMarginLeft() == 1);
assertTrue("Compass margin top should be same", uiSettings.getLogoMarginTop() == 2);
@@ -93,28 +85,28 @@ public class UiSettingsTest {
@Test
public void testAttributionEnabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setAttributionEnabled(true);
assertEquals("Attribution should be enabled", true, uiSettings.isAttributionEnabled());
}
@Test
public void testAttributionDisabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setAttributionEnabled(false);
assertEquals("Attribution should be disabled", false, uiSettings.isLogoEnabled());
}
@Test
public void testAttributionGravity() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setAttributionGravity(Gravity.RIGHT);
assertEquals("Attribution gravity should be same", Gravity.RIGHT, uiSettings.getAttributionGravity());
}
@Test
public void testAttributionMargins() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setAttributionMargins(1, 2, 3, 4);
assertTrue("Attribution margin left should be same", uiSettings.getAttributionMarginLeft() == 1);
assertTrue("Attribution margin top should be same", uiSettings.getAttributionMarginTop() == 2);
@@ -124,77 +116,77 @@ public class UiSettingsTest {
@Test
public void testRotateGesturesEnabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setRotateGesturesEnabled(true);
assertEquals("Rotate gesture should be enabled", true, uiSettings.isRotateGesturesEnabled());
}
@Test
public void testRotateGesturesDisabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setRotateGesturesEnabled(false);
assertEquals("Rotate gesture should be disabled", false, uiSettings.isRotateGesturesEnabled());
}
@Test
public void testTiltGesturesEnabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setTiltGesturesEnabled(true);
assertEquals("Tilt gesture should be enabled", true, uiSettings.isTiltGesturesEnabled());
}
@Test
public void testTiltGesturesDisabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setTiltGesturesEnabled(false);
assertEquals("Tilt gesture should be disabled", false, uiSettings.isTiltGesturesEnabled());
}
@Test
public void testZoomGesturesEnabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setZoomGesturesEnabled(true);
assertEquals("Zoom gesture should be enabled", true, uiSettings.isZoomGesturesEnabled());
}
@Test
public void testZoomGesturesDisabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setZoomGesturesEnabled(false);
assertEquals("Zoom gesture should be disabled", false, uiSettings.isZoomGesturesEnabled());
}
@Test
public void testZoomControlsEnabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setZoomControlsEnabled(true);
assertEquals("Zoom controls should be enabled", true, uiSettings.isZoomControlsEnabled());
}
@Test
public void testZoomControlsDisabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setZoomControlsEnabled(false);
assertEquals("Zoom controls should be disabled", false, uiSettings.isZoomControlsEnabled());
}
@Test
public void testScrollGesturesEnabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setScrollGesturesEnabled(true);
assertEquals("Scroll gesture should be enabled", true, uiSettings.isScrollGesturesEnabled());
}
@Test
public void testScrollGesturesDisabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setScrollGesturesEnabled(false);
assertEquals("Scroll gesture should be disabled", false, uiSettings.isScrollGesturesEnabled());
}
@Test
public void testAllGesturesEnabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setAllGesturesEnabled(true);
assertEquals("Rotate gesture should be enabled", true, uiSettings.isRotateGesturesEnabled());
assertEquals("Tilt gesture should be enabled", true, uiSettings.isTiltGesturesEnabled());
@@ -204,7 +196,7 @@ public class UiSettingsTest {
@Test
public void testAllGesturesDisabled() {
- UiSettings uiSettings = new UiSettings(mMapboxMap);
+ UiSettings uiSettings = new UiSettings(mMapView);
uiSettings.setAllGesturesEnabled(false);
assertEquals("Rotate gesture should be enabled", false, uiSettings.isRotateGesturesEnabled());
assertEquals("Tilt gesture should be disabled", false, uiSettings.isTiltGesturesEnabled());