diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com')
2 files changed, 106 insertions, 8 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 25ff819470..c3451845dd 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 @@ -2843,7 +2843,8 @@ public class Expression { * CircleLayer circleLayer = new CircleLayer("layer-id", "source-id"); * circleLayer.setProperties( * circleColor(switchCase( - * eq(literal("it"), resolvedLocale(collator(true, true, Locale.ITALY))), literal(ColorUtils.colorToRgbaString(Color.GREEN)), + * eq(literal("it"), resolvedLocale(collator(true, true, Locale.ITALY))), literal(ColorUtils.colorToRgbaString + * (Color.GREEN)), * literal(ColorUtils.colorToRgbaString(Color.RED)))) * ); * } @@ -3626,7 +3627,8 @@ public class Expression { * @return expression * @see <a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-step">Style specification</a> */ - public static Expression step(@NonNull Expression input, @NonNull Expression defaultOutput, @NonNull Expression... stops) { + public static Expression step(@NonNull Expression input, @NonNull Expression defaultOutput, + @NonNull Expression... stops) { return new Expression("step", join(new Expression[] {input, defaultOutput}, stops)); } @@ -4411,7 +4413,7 @@ public class Expression { /** * If set, the text-font argument overrides the font specified by the root layout properties. * <p> - * "text-font" is required to a literal array. + * "text-font" is required to be a literal array. * <p> * The requested font stack has to be a part of the used style. * For more information see <a href="https://www.mapbox.com/help/define-font-stack/">the documentation</a>. @@ -4427,7 +4429,7 @@ public class Expression { /** * If set, the text-font argument overrides the font specified by the root layout properties. * <p> - * "text-font" is required to a literal array. + * "text-font" is required to be a literal array. * <p> * The requested font stack has to be a part of the used style. * For more information see <a href="https://www.mapbox.com/help/define-font-stack/">the documentation</a>. @@ -4439,6 +4441,28 @@ public class Expression { public static FormatOption formatTextFont(@NonNull String[] fontStack) { return new FormatOption("text-font", literal(fontStack)); } + + /** + * If set, the text-color argument overrides the color specified by the root paint properties. + * + * @param expression expression + * @return format option + */ + @NonNull + public static FormatOption formatTextColor(@NonNull Expression expression) { + return new FormatOption("text-color", expression); + } + + /** + * If set, the text-color argument overrides the color specified by the root paint properties. + * + * @param color value + * @return format option + */ + @NonNull + public static FormatOption formatTextColor(@ColorInt int color) { + return new FormatOption("text-color", color(color)); + } } /** diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/types/FormattedSection.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/types/FormattedSection.java index c96a104afd..df70a511c1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/types/FormattedSection.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/types/FormattedSection.java @@ -13,9 +13,10 @@ import java.util.Map; */ @Keep public class FormattedSection { - private final String text; - private final Number fontScale; - private final String[] fontStack; + private String text; + private Number fontScale; + private String[] fontStack; + private String textColor; /** * Creates a formatted section. @@ -24,7 +25,9 @@ public class FormattedSection { * @param fontScale scale of the font, setting to null will fall back to style's default settings * @param fontStack main and fallback fonts that are a part of the style, * setting null will fall back to style's default settings + * @deprecated use setters instead */ + @Deprecated public FormattedSection(@NonNull String text, @Nullable Number fontScale, @Nullable String[] fontStack) { this.text = text; this.fontScale = fontScale; @@ -36,7 +39,27 @@ public class FormattedSection { * * @param text displayed string * @param fontScale scale of the font, setting to null will fall back to style's default settings + * @param fontStack main and fallback fonts that are a part of the style, + * setting null will fall back to style's default settings + * @deprecated use setters instead + */ + @Deprecated + public FormattedSection(@NonNull String text, @Nullable Number fontScale, @Nullable String[] fontStack, + @Nullable String textColor) { + this.text = text; + this.fontScale = fontScale; + this.fontStack = fontStack; + this.textColor = textColor; + } + + /** + * Creates a formatted section. + * + * @param text displayed string + * @param fontScale scale of the font, setting to null will fall back to style's default settings + * @deprecated use setters instead */ + @Deprecated public FormattedSection(@NonNull String text, @Nullable Number fontScale) { this(text, fontScale, null); } @@ -45,6 +68,7 @@ public class FormattedSection { * Creates a formatted section. * * @param text displayed string + * @deprecated use setters instead */ public FormattedSection(@NonNull String text) { this(text, null, null); @@ -56,7 +80,9 @@ public class FormattedSection { * @param text displayed string * @param fontStack main and fallback fonts that are a part of the style, * setting null will fall back to style's default settings + * @deprecated use setters instead */ + @Deprecated public FormattedSection(@NonNull String text, @Nullable String[] fontStack) { this(text, null, fontStack); } @@ -91,6 +117,49 @@ public class FormattedSection { return fontStack; } + /** + * Returns the text color. + * + * @return text color + */ + public String getTextColor() { + return textColor; + } + + /** + * Set font scale. + * + * @param fontScale fontScale + */ + public void setFontScale(@Nullable Number fontScale) { + // called from JNI + this.fontScale = fontScale; + } + + /** + * Set font stack. + * + * @param fontStack fontStack + */ + public void setFontStack(@Nullable String[] fontStack) { + // called from JNI + this.fontStack = fontStack; + } + + /** + * Set text color. + * + * @param textColor text color + */ + public void setTextColor(@Nullable String textColor) { + this.textColor = textColor; + } + + void setTextColor(@Nullable Object textColor) { + // called from JNI + setTextColor((String) textColor); + } + @Override public boolean equals(Object o) { if (this == o) { @@ -109,7 +178,10 @@ public class FormattedSection { return false; } // Probably incorrect - comparing Object[] arrays with Arrays.equals - return Arrays.equals(fontStack, that.fontStack); + if (!Arrays.equals(fontStack, that.fontStack)) { + return false; + } + return textColor != null ? textColor.equals(that.textColor) : that.textColor == null; } @Override @@ -117,6 +189,7 @@ public class FormattedSection { int result = text != null ? text.hashCode() : 0; result = 31 * result + (fontScale != null ? fontScale.hashCode() : 0); result = 31 * result + Arrays.hashCode(fontStack); + result = 31 * result + (textColor != null ? textColor.hashCode() : 0); return result; } @@ -124,6 +197,7 @@ public class FormattedSection { Map<String, Object> params = new HashMap<>(); params.put("font-scale", fontScale); params.put("text-font", fontStack); + params.put("text-color", textColor); return new Object[] {text, params}; } } |