diff options
author | Tobrun <tobrun.van.nuland@gmail.com> | 2018-01-04 13:40:34 +0100 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2018-01-10 13:14:04 +0100 |
commit | 8b1303a183d3b154048f4f8eb7a1190277b88ad8 (patch) | |
tree | 1cddedfd9270f82134d2013254b05473fa323a4e /platform/android | |
parent | 1985bb83f40b1f4ef3433137fb5434956cd265ac (diff) | |
download | qtlocation-mapboxgl-8b1303a183d3b154048f4f8eb7a1190277b88ad8.tar.gz |
[android] - RTL support
Diffstat (limited to 'platform/android')
3 files changed, 12 insertions, 4 deletions
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 34be958329..46dba28b98 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 @@ -55,7 +55,7 @@ public class MapboxMapOptions implements Parcelable { @ColorInt private int attributionTintColor = UNDEFINED_COLOR; private boolean attributionEnabled = true; - private int attributionGravity = Gravity.BOTTOM; + private int attributionGravity = Gravity.BOTTOM | Gravity.START; private int[] attributionMargins; private double minZoom = MapboxConstants.MINIMUM_ZOOM; @@ -234,7 +234,7 @@ public class MapboxMapOptions implements Parcelable { mapboxMapOptions.attributionEnabled(typedArray.getBoolean( R.styleable.mapbox_MapView_mapbox_uiAttribution, true)); mapboxMapOptions.attributionGravity(typedArray.getInt( - R.styleable.mapbox_MapView_mapbox_uiAttributionGravity, Gravity.BOTTOM)); + R.styleable.mapbox_MapView_mapbox_uiAttributionGravity, Gravity.BOTTOM | Gravity.START)); mapboxMapOptions.attributionMargins(new int[] { (int) (typedArray.getDimension(R.styleable.mapbox_MapView_mapbox_uiAttributionMarginLeft, NINETY_TWO_DP * pxlRatio)), 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 0843828554..4f37dd6f36 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 @@ -6,6 +6,7 @@ import android.content.res.Resources; import android.graphics.Color; import android.graphics.PointF; import android.graphics.drawable.Drawable; +import android.os.Build; import android.os.Bundle; import android.support.annotation.ColorInt; import android.support.annotation.NonNull; @@ -925,7 +926,7 @@ public final class UiSettings { initMargins[2] = right; initMargins[3] = bottom; - // convert inital margins with padding + // convert initial margins with padding int[] contentPadding = projection.getContentPadding(); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams(); left += contentPadding[0]; @@ -933,6 +934,13 @@ public final class UiSettings { right += contentPadding[2]; bottom += contentPadding[3]; layoutParams.setMargins(left, top, right, bottom); + + // support RTL + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + layoutParams.setMarginStart(left); + layoutParams.setMarginEnd(right); + } + view.setLayoutParams(layoutParams); } } diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java index 4f929641f3..65bdff41ab 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java @@ -91,7 +91,7 @@ public class MapboxMapOptionsTest { @Test public void testAttributionGravity() { - assertEquals(Gravity.BOTTOM, new MapboxMapOptions().getAttributionGravity()); + assertEquals(Gravity.BOTTOM | Gravity.START, new MapboxMapOptions().getAttributionGravity()); assertEquals(Gravity.BOTTOM, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity()); assertNotEquals(Gravity.START, new MapboxMapOptions().attributionGravity(Gravity.BOTTOM).getAttributionGravity()); } |