[android] Add "localIdeographs" option to OfflineRegionDefinition.

This commit is contained in:
Chris Loer
2018-12-18 17:26:31 -08:00
committed by Chris Loer
parent 387fa1800f
commit a889ff6523
4 changed files with 82 additions and 9 deletions

View File

@@ -21,6 +21,8 @@ import com.mapbox.turf.TurfMeasurement;
* tiles from minZoom up to the maximum zoom level provided by that source.
* <p>
* pixelRatio must be ≥ 0 and should typically be 1.0 or 2.0.
* <p>
* if includeIdeographs is false, offline region will not include CJK glyphs
*/
public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition, Parcelable {
@@ -35,6 +37,8 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition,
private double maxZoom;
@Keep
private float pixelRatio;
@Keep
private boolean includeIdeographs;
/**
* Constructor to create an OfflineGeometryRegionDefinition from parameters.
@@ -47,13 +51,31 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition,
*/
@Keep
public OfflineGeometryRegionDefinition(
String styleURL, Geometry geometry, double minZoom, double maxZoom, float pixelRatio) {
String styleURL, Geometry geometry, double minZoom, double maxZoom, float pixelRatio) {
this(styleURL, geometry, minZoom, maxZoom, pixelRatio, true);
}
/**
* Constructor to create an OfflineGeometryRegionDefinition from parameters.
*
* @param styleURL the style
* @param geometry the geometry
* @param minZoom min zoom
* @param maxZoom max zoom
* @param pixelRatio pixel ratio of the device
* @param includeIdeographs include glyphs for CJK languages
*/
@Keep
public OfflineGeometryRegionDefinition(
String styleURL, Geometry geometry, double minZoom, double maxZoom, float pixelRatio,
boolean includeIdeographs) {
// Note: Also used in JNI
this.styleURL = styleURL;
this.geometry = geometry;
this.minZoom = minZoom;
this.maxZoom = maxZoom;
this.pixelRatio = pixelRatio;
this.includeIdeographs = includeIdeographs;
}
/**
@@ -110,6 +132,11 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition,
return pixelRatio;
}
@Override
public boolean getIncludeIdeographs() {
return includeIdeographs;
}
@NonNull
@Override
public String getType() {

View File

@@ -48,7 +48,20 @@ public interface OfflineRegionDefinition {
float getPixelRatio();
/**
* Gest the type of the OfflineRegionDefinition for telemetry ("tileregion", "shaperegion").
* Specifies whether to include ideographic glyphs in downloaded font data.
* Ideographic glyphs make up the majority of downloaded font data, but
* it is possible to configure the renderer to use locally installed fonts
* instead of relying on fonts downloaded as part of the offline pack.
*
* Defaults to `true`
*
* @return true if offline region will include ideographic glyphs
* @see MapboxMapOptions localIdeographFontFamily
*/
boolean getIncludeIdeographs();
/**
* Gets the type of the OfflineRegionDefinition for telemetry ("tileregion", "shaperegion").
*
* @return The type of the OfflineRegionDefinition.
*/

View File

@@ -18,6 +18,8 @@ import com.mapbox.mapboxsdk.geometry.LatLngBounds;
* tiles from minZoom up to the maximum zoom level provided by that source.
* <p>
* pixelRatio must be &#x2265; 0 and should typically be 1.0 or 2.0.
* <p>
* if includeIdeographs is false, offline region will not include CJK glyphs
*/
public class OfflineTilePyramidRegionDefinition implements OfflineRegionDefinition, Parcelable {
@@ -31,6 +33,8 @@ public class OfflineTilePyramidRegionDefinition implements OfflineRegionDefiniti
private double maxZoom;
@Keep
private float pixelRatio;
@Keep
private boolean includeIdeographs;
/**
* Constructor to create an OfflineTilePyramidDefinition from parameters.
@@ -43,13 +47,31 @@ public class OfflineTilePyramidRegionDefinition implements OfflineRegionDefiniti
*/
@Keep
public OfflineTilePyramidRegionDefinition(
String styleURL, LatLngBounds bounds, double minZoom, double maxZoom, float pixelRatio) {
String styleURL, LatLngBounds bounds, double minZoom, double maxZoom, float pixelRatio) {
this(styleURL, bounds, minZoom, maxZoom, pixelRatio, true);
}
/**
* Constructor to create an OfflineTilePyramidDefinition from parameters.
*
* @param styleURL the style
* @param bounds the bounds
* @param minZoom min zoom
* @param maxZoom max zoom
* @param pixelRatio pixel ratio of the device
* @param includeIdeographs include glyphs for CJK languages
*/
@Keep
public OfflineTilePyramidRegionDefinition(
String styleURL, LatLngBounds bounds, double minZoom, double maxZoom, float pixelRatio,
boolean includeIdeographs) {
// Note: Also used in JNI
this.styleURL = styleURL;
this.bounds = bounds;
this.minZoom = minZoom;
this.maxZoom = maxZoom;
this.pixelRatio = pixelRatio;
this.includeIdeographs = includeIdeographs;
}
/**
@@ -94,6 +116,11 @@ public class OfflineTilePyramidRegionDefinition implements OfflineRegionDefiniti
return pixelRatio;
}
@Override
public boolean getIncludeIdeographs() {
return includeIdeographs;
}
@NonNull
@Override
public String getType() {