diff options
author | Tobrun <tobrun@mapbox.com> | 2016-02-01 16:00:30 +0100 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2016-02-01 16:22:54 +0100 |
commit | 0e66d4dcc53fad046673346f3db83346ad54e3e8 (patch) | |
tree | 3cb89ffc623a8eefd461a17a3c6e587feefbe68b /platform/android/MapboxGLAndroidSDK/src/main/java/com | |
parent | 6ebb3e88d869ee85530df4b101752a390ca3ebb3 (diff) | |
download | qtlocation-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
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com')
5 files changed, 93 insertions, 158 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); } /** |