[android] Add Configuration hook for local ideograph font family and demo activity
This commit is contained in:
committed by
Chris Loer
parent
56aa7dad4f
commit
bee60130d3
@@ -293,7 +293,7 @@ public class MapView extends FrameLayout {
|
||||
private void initialiseDrawingSurface(MapboxMapOptions options) {
|
||||
if (options.getTextureMode()) {
|
||||
TextureView textureView = new TextureView(getContext());
|
||||
mapRenderer = new TextureViewMapRenderer(getContext(), textureView) {
|
||||
mapRenderer = new TextureViewMapRenderer(getContext(), textureView, options.getLocalIdeographFontFamily()) {
|
||||
@Override
|
||||
protected void onSurfaceCreated(GL10 gl, EGLConfig config) {
|
||||
MapView.this.post(new Runnable() {
|
||||
@@ -315,7 +315,7 @@ public class MapView extends FrameLayout {
|
||||
GLSurfaceView glSurfaceView = (GLSurfaceView) findViewById(R.id.surfaceView);
|
||||
glSurfaceView.setZOrderMediaOverlay(mapboxMapOptions.getRenderSurfaceOnTop());
|
||||
|
||||
mapRenderer = new GLSurfaceViewMapRenderer(getContext(), glSurfaceView) {
|
||||
mapRenderer = new GLSurfaceViewMapRenderer(getContext(), glSurfaceView, options.getLocalIdeographFontFamily()) {
|
||||
@Override
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
|
||||
MapView.this.post(new Runnable() {
|
||||
|
||||
@@ -82,6 +82,7 @@ public class MapboxMapOptions implements Parcelable {
|
||||
private float myLocationAccuracyThreshold;
|
||||
private boolean prefetchesTiles = true;
|
||||
private boolean zMediaOverlay = false;
|
||||
private String localIdeographFontFamily;
|
||||
|
||||
private String apiBaseUrl;
|
||||
|
||||
@@ -157,6 +158,7 @@ public class MapboxMapOptions implements Parcelable {
|
||||
textureMode = in.readByte() != 0;
|
||||
prefetchesTiles = in.readByte() != 0;
|
||||
zMediaOverlay = in.readByte() != 0;
|
||||
localIdeographFontFamily = in.readString();
|
||||
}
|
||||
|
||||
static Bitmap getBitmapFromDrawable(Drawable drawable) {
|
||||
@@ -304,6 +306,7 @@ public class MapboxMapOptions implements Parcelable {
|
||||
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));
|
||||
} finally {
|
||||
typedArray.recycle();
|
||||
}
|
||||
@@ -733,6 +736,18 @@ public class MapboxMapOptions implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the font-family for generating glyphs locally for ideographs in the ‘CJK Unified Ideographs’
|
||||
* and ‘Hangul Syllables’ ranges.
|
||||
*
|
||||
* @param fontFamily font family for local ideograph generation.
|
||||
* @return
|
||||
*/
|
||||
public MapboxMapOptions localIdeographFontFamily(String fontFamily) {
|
||||
this.localIdeographFontFamily = fontFamily;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether tile pre-fetching is enabled.
|
||||
*
|
||||
@@ -1079,6 +1094,14 @@ public class MapboxMapOptions implements Parcelable {
|
||||
return textureMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the font-family for locally overriding generation of glyphs in the
|
||||
* ‘CJK Unified Ideographs’ and ‘Hangul Syllables’ ranges.
|
||||
*
|
||||
* @return Local ideograph font family name.
|
||||
*/
|
||||
public String getLocalIdeographFontFamily() { return localIdeographFontFamily; }
|
||||
|
||||
public static final Parcelable.Creator<MapboxMapOptions> CREATOR = new Parcelable.Creator<MapboxMapOptions>() {
|
||||
public MapboxMapOptions createFromParcel(Parcel in) {
|
||||
return new MapboxMapOptions(in);
|
||||
@@ -1145,6 +1168,7 @@ public class MapboxMapOptions implements Parcelable {
|
||||
dest.writeByte((byte) (textureMode ? 1 : 0));
|
||||
dest.writeByte((byte) (prefetchesTiles ? 1 : 0));
|
||||
dest.writeByte((byte) (zMediaOverlay ? 1 : 0));
|
||||
dest.writeString(localIdeographFontFamily);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1274,6 +1298,9 @@ public class MapboxMapOptions implements Parcelable {
|
||||
if (zMediaOverlay != options.zMediaOverlay) {
|
||||
return false;
|
||||
}
|
||||
if (localIdeographFontFamily != options.localIdeographFontFamily) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1323,6 +1350,7 @@ public class MapboxMapOptions implements Parcelable {
|
||||
result = 31 * result + (style != null ? style.hashCode() : 0);
|
||||
result = 31 * result + (prefetchesTiles ? 1 : 0);
|
||||
result = 31 * result + (zMediaOverlay ? 1 : 0);
|
||||
result = 31 * result + (localIdeographFontFamily != null ? localIdeographFontFamily.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,14 +23,13 @@ public abstract class MapRenderer implements MapRendererScheduler {
|
||||
|
||||
private MapboxMap.OnFpsChangedListener onFpsChangedListener;
|
||||
|
||||
public MapRenderer(Context context) {
|
||||
public MapRenderer(Context context, String localIdeographFontFamily) {
|
||||
|
||||
FileSource fileSource = FileSource.getInstance(context);
|
||||
float pixelRatio = context.getResources().getDisplayMetrics().density;
|
||||
String programCacheDir = context.getCacheDir().getAbsolutePath();
|
||||
|
||||
// Initialise native peer
|
||||
nativeInitialize(this, fileSource, pixelRatio, programCacheDir);
|
||||
nativeInitialize(this, fileSource, pixelRatio, programCacheDir, localIdeographFontFamily);
|
||||
}
|
||||
|
||||
public void onStart() {
|
||||
@@ -112,7 +111,8 @@ public abstract class MapRenderer implements MapRendererScheduler {
|
||||
private native void nativeInitialize(MapRenderer self,
|
||||
FileSource fileSource,
|
||||
float pixelRatio,
|
||||
String programCacheDir);
|
||||
String programCacheDir,
|
||||
String localIdeographFontFamily);
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
|
||||
@@ -21,8 +21,8 @@ public class GLSurfaceViewMapRenderer extends MapRenderer implements GLSurfaceVi
|
||||
|
||||
private final GLSurfaceView glSurfaceView;
|
||||
|
||||
public GLSurfaceViewMapRenderer(Context context, GLSurfaceView glSurfaceView) {
|
||||
super(context);
|
||||
public GLSurfaceViewMapRenderer(Context context, GLSurfaceView glSurfaceView, String localIdeographFontFamily) {
|
||||
super(context, localIdeographFontFamily);
|
||||
this.glSurfaceView = glSurfaceView;
|
||||
glSurfaceView.setEGLContextClientVersion(2);
|
||||
glSurfaceView.setEGLConfigChooser(new EGLConfigChooser());
|
||||
|
||||
@@ -24,8 +24,8 @@ public class TextureViewMapRenderer extends MapRenderer {
|
||||
* @param context the current Context
|
||||
* @param textureView the TextureView
|
||||
*/
|
||||
public TextureViewMapRenderer(@NonNull Context context, @NonNull TextureView textureView) {
|
||||
super(context);
|
||||
public TextureViewMapRenderer(@NonNull Context context, @NonNull TextureView textureView, String localIdeographFontFamily) {
|
||||
super(context, localIdeographFontFamily);
|
||||
renderThread = new TextureViewRenderThread(textureView, this);
|
||||
renderThread.start();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user