[android] Android bindings for new 'text-writing-mode' layout property
This commit is contained in:
@@ -669,6 +669,27 @@ public final class Property {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface ANCHOR {}
|
||||
|
||||
// TEXT_WRITING_MODE: The property allows control over a symbol's orientation. Note that the property values act as a hint, so that a symbol whose language doesn’t support the provided orientation will be laid out in its natural orientation. Example: English point symbol will be rendered horizontally even if array value contains single 'vertical' enum value. The order of elements in an array define priority order for the placement of an orientation variant.
|
||||
|
||||
/**
|
||||
* If a text's language supports horizontal writing mode, symbols with point placement would be laid out horizontally.
|
||||
*/
|
||||
public static final String TEXT_WRITING_MODE_HORIZONTAL = "horizontal";
|
||||
/**
|
||||
* If a text's language supports vertical writing mode, symbols with point placement would be laid out vertically.
|
||||
*/
|
||||
public static final String TEXT_WRITING_MODE_VERTICAL = "vertical";
|
||||
|
||||
/**
|
||||
* The property allows control over a symbol's orientation. Note that the property values act as a hint, so that a symbol whose language doesn’t support the provided orientation will be laid out in its natural orientation. Example: English point symbol will be rendered horizontally even if array value contains single 'vertical' enum value. The order of elements in an array define priority order for the placement of an orientation variant.
|
||||
*/
|
||||
@StringDef({
|
||||
TEXT_WRITING_MODE_HORIZONTAL,
|
||||
TEXT_WRITING_MODE_VERTICAL,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface TEXT_WRITING_MODE {}
|
||||
|
||||
|
||||
private Property() {
|
||||
}
|
||||
|
||||
@@ -2375,6 +2375,26 @@ public class PropertyFactory {
|
||||
return new LayoutPropertyValue<>("text-max-angle", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The property allows control over a symbol's orientation. Note that the property values act as a hint, so that a symbol whose language doesn’t support the provided orientation will be laid out in its natural orientation. Example: English point symbol will be rendered horizontally even if array value contains single 'vertical' enum value. The order of elements in an array define priority order for the placement of an orientation variant.
|
||||
*
|
||||
* @param value a String[] value
|
||||
* @return property wrapper around String[]
|
||||
*/
|
||||
public static PropertyValue<String[]> textWritingMode(String[] value) {
|
||||
return new LayoutPropertyValue<>("text-writing-mode", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The property allows control over a symbol's orientation. Note that the property values act as a hint, so that a symbol whose language doesn’t support the provided orientation will be laid out in its natural orientation. Example: English point symbol will be rendered horizontally even if array value contains single 'vertical' enum value. The order of elements in an array define priority order for the placement of an orientation variant.
|
||||
*
|
||||
* @param value a String[] value
|
||||
* @return property wrapper around String[]
|
||||
*/
|
||||
public static PropertyValue<Expression> textWritingMode(Expression value) {
|
||||
return new LayoutPropertyValue<>("text-writing-mode", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotates the text clockwise.
|
||||
*
|
||||
|
||||
@@ -529,6 +529,18 @@ public class SymbolLayer extends Layer {
|
||||
return (PropertyValue<Float>) new PropertyValue("text-max-angle", nativeGetTextMaxAngle());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the TextWritingMode property
|
||||
*
|
||||
* @return property wrapper value around String[]
|
||||
*/
|
||||
@NonNull
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String[]> getTextWritingMode() {
|
||||
checkThread();
|
||||
return (PropertyValue<String[]>) new PropertyValue("text-writing-mode", nativeGetTextWritingMode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the TextRotate property
|
||||
*
|
||||
@@ -1241,6 +1253,10 @@ public class SymbolLayer extends Layer {
|
||||
@Keep
|
||||
private native Object nativeGetTextMaxAngle();
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
private native Object nativeGetTextWritingMode();
|
||||
|
||||
@NonNull
|
||||
@Keep
|
||||
private native Object nativeGetTextRotate();
|
||||
|
||||
@@ -668,6 +668,19 @@ public class SymbolLayerTest extends BaseLayerTest {
|
||||
assertEquals(layer.getTextMaxAngle().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testTextWritingModeAsConstant() {
|
||||
Timber.i("text-writing-mode");
|
||||
assertNotNull(layer);
|
||||
assertNull(layer.getTextWritingMode().getValue());
|
||||
|
||||
// Set and Get
|
||||
String[] propertyValue = new String[0];
|
||||
layer.setProperties(textWritingMode(propertyValue));
|
||||
assertEquals(layer.getTextWritingMode().getValue(), propertyValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@UiThreadTest
|
||||
public void testTextRotateAsConstant() {
|
||||
|
||||
@@ -49,10 +49,19 @@ var layers = Object.keys(spec.layer.type.values).map((type) => {
|
||||
});
|
||||
|
||||
// Process all layer properties
|
||||
const uniqueArrayEnum = (prop, enums) => {
|
||||
if (prop.value !== 'enum') return false;
|
||||
const enumsEqual = (val1, val2) => val1.length === val1.length && val1.every((val, i) => val === val2[i]);
|
||||
return enums.filter(e => enumsEqual(Object.keys(prop.values).sort(), Object.keys(e.values).sort())).length == 0;
|
||||
};
|
||||
|
||||
const layoutProperties = _(layers).map('layoutProperties').flatten().value();
|
||||
const paintProperties = _(layers).map('paintProperties').flatten().value();
|
||||
const allProperties = _(layoutProperties).union(paintProperties).union(lightProperties).value();
|
||||
const enumProperties = _(allProperties).filter({'type': 'enum'}).value();
|
||||
let allEnumProperties = _(allProperties).filter({'type': 'enum'}).value();
|
||||
const uniqueArrayEnumProperties = _(allProperties).filter({'type': 'array'}).filter(prop => uniqueArrayEnum(prop, allEnumProperties)).value();
|
||||
const enumProperties = _(allEnumProperties).union(uniqueArrayEnumProperties).value();
|
||||
|
||||
|
||||
global.propertyType = function propertyType(property) {
|
||||
switch (property.type) {
|
||||
|
||||
@@ -201,6 +201,11 @@ namespace android {
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toSymbolLayer(layer).getTextMaxAngle()));
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<>> SymbolLayer::getTextWritingMode(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toSymbolLayer(layer).getTextWritingMode()));
|
||||
}
|
||||
|
||||
jni::Local<jni::Object<>> SymbolLayer::getTextRotate(jni::JNIEnv& env) {
|
||||
using namespace mbgl::android::conversion;
|
||||
return std::move(*convert<jni::Local<jni::Object<>>>(env, toSymbolLayer(layer).getTextRotate()));
|
||||
@@ -534,6 +539,7 @@ namespace android {
|
||||
METHOD(&SymbolLayer::getTextVariableAnchor, "nativeGetTextVariableAnchor"),
|
||||
METHOD(&SymbolLayer::getTextAnchor, "nativeGetTextAnchor"),
|
||||
METHOD(&SymbolLayer::getTextMaxAngle, "nativeGetTextMaxAngle"),
|
||||
METHOD(&SymbolLayer::getTextWritingMode, "nativeGetTextWritingMode"),
|
||||
METHOD(&SymbolLayer::getTextRotate, "nativeGetTextRotate"),
|
||||
METHOD(&SymbolLayer::getTextPadding, "nativeGetTextPadding"),
|
||||
METHOD(&SymbolLayer::getTextKeepUpright, "nativeGetTextKeepUpright"),
|
||||
|
||||
@@ -90,6 +90,8 @@ public:
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getTextMaxAngle(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getTextWritingMode(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getTextRotate(jni::JNIEnv&);
|
||||
|
||||
jni::Local<jni::Object<jni::ObjectTag>> getTextPadding(jni::JNIEnv&);
|
||||
|
||||
Reference in New Issue
Block a user