Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] Android bindings for new 'text-placement-mode' layout property
Browse files Browse the repository at this point in the history
  • Loading branch information
alexshalamov committed Jun 18, 2019
1 parent 79fac75 commit 59983ee
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2375,6 +2375,26 @@ public static PropertyValue<Expression> textMaxAngle(Expression value) {
return new LayoutPropertyValue<>("text-max-angle", value);
}

/**
* Hint for an orientation of a symbol with point placement. Symbols whose language does not support provided hint, will be laid out in their natural orientation. The order of elements in an array define priority order for the placement.
*
* @param value a String[] value
* @return property wrapper around String[]
*/
public static PropertyValue<String[]> textPlacementMode(String[] value) {
return new LayoutPropertyValue<>("text-placement-mode", value);
}

/**
* Hint for an orientation of a symbol with point placement. Symbols whose language does not support provided hint, will be laid out in their natural orientation. The order of elements in an array define priority order for the placement.
*
* @param value a String[] value
* @return property wrapper around String[]
*/
public static PropertyValue<Expression> textPlacementMode(Expression value) {
return new LayoutPropertyValue<>("text-placement-mode", value);
}

/**
* Rotates the text clockwise.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,18 @@ public PropertyValue<Float> getTextMaxAngle() {
return (PropertyValue<Float>) new PropertyValue("text-max-angle", nativeGetTextMaxAngle());
}

/**
* Get the TextPlacementMode property
*
* @return property wrapper value around String[]
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<String[]> getTextPlacementMode() {
checkThread();
return (PropertyValue<String[]>) new PropertyValue("text-placement-mode", nativeGetTextPlacementMode());
}

/**
* Get the TextRotate property
*
Expand Down Expand Up @@ -1241,6 +1253,10 @@ public PropertyValue<String> getTextTranslateAnchor() {
@Keep
private native Object nativeGetTextMaxAngle();

@NonNull
@Keep
private native Object nativeGetTextPlacementMode();

@NonNull
@Keep
private native Object nativeGetTextRotate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,19 @@ public void testTextMaxAngleAsConstant() {
assertEquals(layer.getTextMaxAngle().getValue(), propertyValue);
}

@Test
@UiThreadTest
public void testTextPlacementModeAsConstant() {
Timber.i("text-placement-mode");
assertNotNull(layer);
assertNull(layer.getTextPlacementMode().getValue());

// Set and Get
String[] propertyValue = new String[0];
layer.setProperties(textPlacementMode(propertyValue));
assertEquals(layer.getTextPlacementMode().getValue(), propertyValue);
}

@Test
@UiThreadTest
public void testTextRotateAsConstant() {
Expand Down
6 changes: 6 additions & 0 deletions platform/android/src/style/layers/symbol_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ namespace android {
return std::move(*convert<jni::Local<jni::Object<>>>(env, toSymbolLayer(layer).getTextMaxAngle()));
}

jni::Local<jni::Object<>> SymbolLayer::getTextPlacementMode(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return std::move(*convert<jni::Local<jni::Object<>>>(env, toSymbolLayer(layer).getTextPlacementMode()));
}

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()));
Expand Down Expand Up @@ -534,6 +539,7 @@ namespace android {
METHOD(&SymbolLayer::getTextVariableAnchor, "nativeGetTextVariableAnchor"),
METHOD(&SymbolLayer::getTextAnchor, "nativeGetTextAnchor"),
METHOD(&SymbolLayer::getTextMaxAngle, "nativeGetTextMaxAngle"),
METHOD(&SymbolLayer::getTextPlacementMode, "nativeGetTextPlacementMode"),
METHOD(&SymbolLayer::getTextRotate, "nativeGetTextRotate"),
METHOD(&SymbolLayer::getTextPadding, "nativeGetTextPadding"),
METHOD(&SymbolLayer::getTextKeepUpright, "nativeGetTextKeepUpright"),
Expand Down
2 changes: 2 additions & 0 deletions platform/android/src/style/layers/symbol_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class SymbolLayer : public Layer {

jni::Local<jni::Object<jni::ObjectTag>> getTextMaxAngle(jni::JNIEnv&);

jni::Local<jni::Object<jni::ObjectTag>> getTextPlacementMode(jni::JNIEnv&);

jni::Local<jni::Object<jni::ObjectTag>> getTextRotate(jni::JNIEnv&);

jni::Local<jni::Object<jni::ObjectTag>> getTextPadding(jni::JNIEnv&);
Expand Down

0 comments on commit 59983ee

Please sign in to comment.