summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/types/FormattedSection.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/types/FormattedSection.java')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/types/FormattedSection.java82
1 files changed, 78 insertions, 4 deletions
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};
}
}