summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
authorŁukasz Paczos <lukas.paczos@gmail.com>2018-10-23 19:37:32 +0200
committerŁukasz Paczos <lukasz.paczos@mapbox.com>2018-10-24 13:35:36 +0200
commitd5b66e56e9bc3c01252cd4b3948dea6cf11307f2 (patch)
tree714407ceb8cf7a6c3e6770b2af8ca3543624de9a /platform/android
parent3d67c7813bf0fc7fee953e4aa177472d84f9b6a2 (diff)
downloadqtlocation-mapboxgl-d5b66e56e9bc3c01252cd4b3948dea6cf11307f2.tar.gz
[android] renamed format expression options, added format expression example
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java17
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java2
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs2
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/style/expressions/ExpressionTest.java14
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java45
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java17
6 files changed, 63 insertions, 34 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java
index 1184baba65..9ec8d8bc2a 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java
@@ -3246,10 +3246,13 @@ public class Expression {
* format(
* formatEntry(
* get("header_property"),
- * fontScale(2.0),
- * textFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
+ * formatFontScale(2.0),
+ * formatTextFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
* ),
- * formatEntry(concat(literal("\n"), get("description_property")), fontScale(1.5)),
+ * formatEntry(concat(literal("\n"), get("description_property")), formatFontScale(1.5))
+ * )
+ * )
+ * );
* }
* </pre>
*
@@ -4375,7 +4378,7 @@ public class Expression {
* @return format option
*/
@NonNull
- public static FormatOption fontScale(@NonNull Expression expression) {
+ public static FormatOption formatFontScale(@NonNull Expression expression) {
return new FormatOption("font-scale", expression);
}
@@ -4389,7 +4392,7 @@ public class Expression {
* @return format option
*/
@NonNull
- public static FormatOption fontScale(double scale) {
+ public static FormatOption formatFontScale(double scale) {
return new FormatOption("font-scale", literal(scale));
}
@@ -4405,7 +4408,7 @@ public class Expression {
* @return format option
*/
@NonNull
- public static FormatOption textFont(@NonNull Expression expression) {
+ public static FormatOption formatTextFont(@NonNull Expression expression) {
return new FormatOption("text-font", expression);
}
@@ -4421,7 +4424,7 @@ public class Expression {
* @return format option
*/
@NonNull
- public static FormatOption textFont(@NonNull String[] fontStack) {
+ public static FormatOption formatTextFont(@NonNull String[] fontStack) {
return new FormatOption("text-font", literal(fontStack));
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java
index 7b9128343c..079292c512 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java
@@ -386,7 +386,7 @@ public class SymbolLayer extends Layer {
* Get the TextField property as {@link Formatted} object
*
* @return property wrapper value around String
- * @see Expression#format(Expression...)
+ * @see Expression#format(Expression.FormatEntry...)
*/
@SuppressWarnings("unchecked")
public PropertyValue<Formatted> getFormattedTextField() {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs
index 961991c7a1..0e6cad78f6 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs
@@ -199,7 +199,7 @@ public class <%- camelize(type) %>Layer extends Layer {
* Get the <%- camelize(property.name) %> property as {@link Formatted} object
*
* @return property wrapper value around <%- propertyType(property) %>
- * @see Expression#format(Expression...)
+ * @see Expression#format(Expression.FormatEntry...)
*/
@SuppressWarnings("unchecked")
public PropertyValue<Formatted> getFormatted<%- camelize(property.name) %>() {
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/style/expressions/ExpressionTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/style/expressions/ExpressionTest.java
index 3d1bbf5214..13cdadbc97 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/style/expressions/ExpressionTest.java
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/style/expressions/ExpressionTest.java
@@ -14,8 +14,8 @@ import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.fontScale;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.textFont;
+import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatFontScale;
+import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatTextFont;
import static com.mapbox.mapboxsdk.style.expressions.Expression.abs;
import static com.mapbox.mapboxsdk.style.expressions.Expression.acos;
import static com.mapbox.mapboxsdk.style.expressions.Expression.all;
@@ -1420,7 +1420,8 @@ public class ExpressionTest {
}
};
Object[] actual = format(
- formatEntry(literal("test"), fontScale(literal(1.5)), textFont(literal(new String[] {"awesome"})))
+ formatEntry(
+ literal("test"), formatFontScale(literal(1.5)), formatTextFont(literal(new String[] {"awesome"})))
).toArray();
assertTrue("expression should match", Arrays.deepEquals(expected, actual));
}
@@ -1455,10 +1456,11 @@ public class ExpressionTest {
}
};
Object[] actual = format(
- formatEntry(literal("test"), textFont(new String[] {"awesome"})),
- formatEntry("test2", fontScale(1.5)),
+ formatEntry(literal("test"), formatTextFont(new String[] {"awesome"})),
+ formatEntry("test2", formatFontScale(1.5)),
formatEntry(literal("test3")),
- formatEntry(literal("test4"), fontScale(literal(1.5)), textFont(new String[] {"awesome"}))
+ formatEntry(
+ literal("test4"), formatFontScale(literal(1.5)), formatTextFont(new String[] {"awesome"}))
).toArray();
assertTrue("expression should match", Arrays.deepEquals(expected, actual));
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
index 773baf17eb..0574f3e8e4 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
@@ -30,8 +30,8 @@ import java.io.IOException;
import timber.log.Timber;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.fontScale;
-import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.textFont;
+import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatFontScale;
+import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatTextFont;
import static com.mapbox.mapboxsdk.style.expressions.Expression.collator;
import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
import static com.mapbox.mapboxsdk.style.expressions.Expression.exponential;
@@ -315,7 +315,7 @@ public class ExpressionTest extends BaseActivityTest {
mapboxMap.addLayer(layer);
Expression expression = format(
- formatEntry("test", fontScale(1.75))
+ formatEntry("test", formatFontScale(1.75))
);
layer.setProperties(textField(expression));
waitForLayer(uiController, mapboxMap, latLng);
@@ -344,13 +344,16 @@ public class ExpressionTest extends BaseActivityTest {
Expression expression = format(
formatEntry(
- literal("test"), fontScale(1.0), textFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
+ literal("test"),
+ formatFontScale(1.0),
+ formatTextFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
)
);
layer.setProperties(textField(expression));
waitForLayer(uiController, mapboxMap, latLng);
- assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
- .isEmpty());
+ assertFalse(
+ mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
+ );
assertNull(layer.getTextField().getExpression());
assertEquals("test", layer.getTextField().getValue());
@@ -375,13 +378,16 @@ public class ExpressionTest extends BaseActivityTest {
Expression expression = format(
formatEntry(
- "test", fontScale(0.5), textFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
+ "test",
+ formatFontScale(0.5),
+ formatTextFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
)
);
layer.setProperties(textField(expression));
waitForLayer(uiController, mapboxMap, latLng);
- assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
- .isEmpty());
+ assertFalse(
+ mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
+ );
assertNull(layer.getTextField().getExpression());
assertEquals("test", layer.getTextField().getValue());
@@ -404,14 +410,17 @@ public class ExpressionTest extends BaseActivityTest {
Expression expression = format(
formatEntry(
- "test", fontScale(1.5), textFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
+ "test",
+ formatFontScale(1.5),
+ formatTextFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"})
),
- formatEntry("\ntest2", fontScale(2))
+ formatEntry("\ntest2", formatFontScale(2))
);
layer.setProperties(textField(expression));
waitForLayer(uiController, mapboxMap, latLng);
- assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
- .isEmpty());
+ assertFalse(
+ mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer").isEmpty()
+ );
assertNull(layer.getTextField().getExpression());
assertEquals("test\ntest2", layer.getTextField().getValue());
@@ -440,8 +449,8 @@ public class ExpressionTest extends BaseActivityTest {
Expression expression = format(
formatEntry(
get("test_property"),
- fontScale(number(get("test_property_number"))),
- textFont(new String[] {"Arial Unicode MS Regular", "DIN Offc Pro Regular"})
+ Expression.FormatOption.formatFontScale(number(get("test_property_number"))),
+ formatTextFont(new String[] {"Arial Unicode MS Regular", "DIN Offc Pro Regular"})
)
);
layer.setProperties(textField(expression));
@@ -472,10 +481,10 @@ public class ExpressionTest extends BaseActivityTest {
Expression expression = format(
formatEntry(
get("test_property"),
- fontScale(1.25),
- textFont(new String[] {"Arial Unicode MS Regular", "DIN Offc Pro Regular"})
+ formatFontScale(1.25),
+ formatTextFont(new String[] {"Arial Unicode MS Regular", "DIN Offc Pro Regular"})
),
- formatEntry("\ntest2", fontScale(2))
+ formatEntry("\ntest2", formatFontScale(2))
);
layer.setProperties(textField(expression));
waitForLayer(uiController, mapboxMap, latLng);
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java
index acdb1d216d..cb95176126 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java
@@ -10,6 +10,7 @@ import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewGroup;
+
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.mapbox.geojson.Feature;
@@ -29,6 +30,11 @@ import com.mapbox.mapboxsdk.utils.BitmapUtils;
import java.util.List;
+import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatFontScale;
+import static com.mapbox.mapboxsdk.style.expressions.Expression.FormatOption.formatTextFont;
+import static com.mapbox.mapboxsdk.style.expressions.Expression.concat;
+import static com.mapbox.mapboxsdk.style.expressions.Expression.format;
+import static com.mapbox.mapboxsdk.style.expressions.Expression.formatEntry;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.switchCase;
@@ -118,7 +124,16 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap.
iconSize(switchCase(toBool(get(SELECTED_FEATURE_PROPERTY)), literal(3.0f), literal(1.0f))),
iconAnchor(Property.ICON_ANCHOR_BOTTOM),
iconColor(Color.RED),
- textField(get(TITLE_FEATURE_PROPERTY)),
+ textField(
+ format(
+ formatEntry("this is", formatFontScale(0.75)),
+ formatEntry(
+ concat(literal("\n"), get(TITLE_FEATURE_PROPERTY)),
+ formatFontScale(1.25),
+ formatTextFont(new String[] {"DIN Offc Pro Bold", "Arial Unicode MS Regular"})
+ )
+ )
+ ),
textFont(new String[] {"DIN Offc Pro Regular", "Arial Unicode MS Regular"}),
textColor(Color.RED),
textAllowOverlap(true),