From f86f0226dd7f87fef97378cff225754ae5d69c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Tue, 30 Jul 2019 14:07:58 +0300 Subject: [PATCH] [android] ensure default local ideographs font family is not overwrote --- .../com/mapbox/mapboxsdk/maps/MapboxMapOptions.java | 12 +++++++++--- .../mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java | 10 ++++++++++ 2 files changed, 19 insertions(+), 3 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 09bb5012d11..a394b971242 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 @@ -69,7 +69,7 @@ public class MapboxMapOptions implements Parcelable { private boolean prefetchesTiles = true; private boolean zMediaOverlay = false; - private String localIdeographFontFamily = "sans-serif"; + private String localIdeographFontFamily; private String apiBaseUri; @@ -246,8 +246,14 @@ public static MapboxMapOptions createFromAttributes(@NonNull Context context, @N typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_enableTilePrefetch, true)); mapboxMapOptions.renderSurfaceOnTop( typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_enableZMediaOverlay, false)); - mapboxMapOptions.localIdeographFontFamily( - typedArray.getString(R.styleable.mapbox_MapView_mapbox_localIdeographFontFamily)); + + String localIdeographFontFamily = + typedArray.getString(R.styleable.mapbox_MapView_mapbox_localIdeographFontFamily); + if (localIdeographFontFamily == null) { + localIdeographFontFamily = "sans-serif"; + } + mapboxMapOptions.localIdeographFontFamily(localIdeographFontFamily); + mapboxMapOptions.pixelRatio( typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_pixelRatio, 0)); mapboxMapOptions.foregroundLoadColor( 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 f03d1fb15f4..11035c050f5 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 @@ -8,6 +8,9 @@ import com.mapbox.mapboxsdk.geometry.LatLng; import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; import java.util.Arrays; @@ -18,6 +21,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +@RunWith(RobolectricTestRunner.class) public class MapboxMapOptionsTest { private static final double DELTA = 1e-15; @@ -172,5 +176,11 @@ public void testCrossSourceCollisions() { assertTrue(new MapboxMapOptions().crossSourceCollisions(true).getCrossSourceCollisions()); assertFalse(new MapboxMapOptions().crossSourceCollisions(false).getCrossSourceCollisions()); } + + @Test + public void testLocalIdeographFontFamily_enabledByDefault() { + MapboxMapOptions options = MapboxMapOptions.createFromAttributes(RuntimeEnvironment.application, null); + assertEquals("sans-serif", options.getLocalIdeographFontFamily()); + } }