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

Commit

Permalink
[android] Removed previously deprecated colorToRgbaString and colorTo…
Browse files Browse the repository at this point in the history
…RgbaArray (#13337)

from PropertyFactory
  • Loading branch information
osana authored Nov 14, 2018
1 parent 1ceea72 commit 0f6f73f
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
import static com.mapbox.mapboxsdk.style.expressions.Expression.zoom;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.colorToRgbaString;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
import static com.mapbox.mapboxsdk.utils.ColorUtils.colorToRgbaString;

final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsValuesChangeListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.Locale;
import java.util.Map;

import static com.mapbox.mapboxsdk.utils.ColorUtils.colorToRgbaArray;

/**
* The value for any layout property, paint property, or filter may be specified as an expression.
* An expression defines a formula for computing the value of the property using the operators described below.
Expand Down Expand Up @@ -220,7 +222,7 @@ public static Expression literal(@NonNull Object[] array) {
* @return the color expression
*/
public static Expression color(@ColorInt int color) {
float[] rgba = PropertyFactory.colorToRgbaArray(color);
float[] rgba = colorToRgbaArray(color);
return rgba(rgba[0], rgba[1], rgba[2], rgba[3]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import android.support.annotation.ColorInt;

import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.utils.ColorUtils;
import static com.mapbox.mapboxsdk.utils.ColorUtils.colorToRgbaString;

/**
* Constructs paint/layout properties for Layers
Expand Down Expand Up @@ -2444,33 +2444,4 @@ public static PropertyValue<Expression> textOptional(Expression value) {
return new LayoutPropertyValue<>("text-optional", value);
}

/**
* Converts Android color int to "rbga(r, g, b, a)" String equivalent.
* <p>
* Alpha value will be converted from 0-255 range to 0-1.
* </p>
*
* @param color Android color int
* @return String rgba color
* @deprecated use {@link com.mapbox.mapboxsdk.utils.ColorUtils#colorToRgbaString(int)} instead
*/
@Deprecated
public static String colorToRgbaString(@ColorInt int color) {
return ColorUtils.colorToRgbaString(color);
}

/**
* Converts Android color int to rgba float array.
* <p>
* Alpha value will be converted from 0-255 range to 0-1.
* </p>
*
* @param color Android color int
* @return int rgba array
* @deprecated use {@link com.mapbox.mapboxsdk.utils.ColorUtils#colorToRgbaArray(int)} instead
*/
@Deprecated
public static float[] colorToRgbaArray(@ColorInt int color) {
return ColorUtils.colorToRgbaArray(color);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ package com.mapbox.mapboxsdk.style.layers;
import android.support.annotation.ColorInt;

import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.utils.ColorUtils;
import static com.mapbox.mapboxsdk.utils.ColorUtils.colorToRgbaString;

/**
* Constructs paint/layout properties for Layers
Expand Down Expand Up @@ -84,33 +84,4 @@ public class PropertyFactory {
}
<% } -%>
/**
* Converts Android color int to "rbga(r, g, b, a)" String equivalent.
* <p>
* Alpha value will be converted from 0-255 range to 0-1.
* </p>
*
* @param color Android color int
* @return String rgba color
* @deprecated use {@link com.mapbox.mapboxsdk.utils.ColorUtils#colorToRgbaString(int)} instead
*/
@Deprecated
public static String colorToRgbaString(@ColorInt int color) {
return ColorUtils.colorToRgbaString(color);
}

/**
* Converts Android color int to rgba float array.
* <p>
* Alpha value will be converted from 0-255 range to 0-1.
* </p>
*
* @param color Android color int
* @return int rgba array
* @deprecated use {@link com.mapbox.mapboxsdk.utils.ColorUtils#colorToRgbaArray(int)} instead
*/
@Deprecated
public static float[] colorToRgbaArray(@ColorInt int color) {
return ColorUtils.colorToRgbaArray(color);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import android.support.annotation.UiThread;

import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.utils.ColorUtils;
import com.mapbox.mapboxsdk.utils.ThreadUtils;

/**
Expand Down Expand Up @@ -104,7 +104,7 @@ public void setPositionTransition(@NonNull TransitionOptions options) {
*/
public void setColor(@ColorInt int color) {
checkThread();
nativeSetColor(PropertyFactory.colorToRgbaString(color));
nativeSetColor(ColorUtils.colorToRgbaString(color));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import android.support.annotation.NonNull;
import android.support.annotation.UiThread;

import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.utils.ColorUtils;
import com.mapbox.mapboxsdk.utils.ThreadUtils;

/**
Expand Down Expand Up @@ -70,7 +70,7 @@ public class Light {
*/
public void set<%- camelize(property.name) %>(@ColorInt int <%- property.name %>) {
checkThread();
nativeSet<%- camelize(property.name) %>(PropertyFactory.colorToRgbaString(<%- property.name %>));
nativeSet<%- camelize(property.name) %>(ColorUtils.colorToRgbaString(<%- property.name %>));
}
<% } -%>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import android.graphics.Color;

import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.layers.PropertyValue;
import com.mapbox.mapboxsdk.utils.ColorUtils;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -147,7 +147,7 @@ public void testRgbaLiteral() throws Exception {
@Test
public void testToRgba() throws Exception {
Object[] expected = new Object[] {"to-rgba", new Object[] {"to-color", "rgba(255, 0, 0, 1)"}};
Object[] actual = toRgba(toColor(literal(PropertyFactory.colorToRgbaString(Color.RED)))).toArray();
Object[] actual = toRgba(toColor(literal(ColorUtils.colorToRgbaString(Color.RED)))).toArray();
assertTrue("expression should match", Arrays.deepEquals(expected, actual));
}

Expand Down Expand Up @@ -1282,7 +1282,7 @@ public void testRawRgbaColor() {
literal(5f), literal("rgba(0, 0, 0, 1)"),
literal(10.5f), literal("rgb(255, 0, 0)"),
literal(15), color(Color.GREEN),
literal(20), literal(PropertyFactory.colorToRgbaString(Color.BLUE)));
literal(20), literal(ColorUtils.colorToRgbaString(Color.BLUE)));
assertEquals("expressions should match", expected, raw(expected.toString()));
}

Expand Down Expand Up @@ -1312,7 +1312,7 @@ public void testAlphaValueInColorConversion() {

@Test
public void testAlphaValueInStringConversion() {
String color = PropertyFactory.colorToRgbaString(Color.parseColor("#41FF0000")).split(" ")[3];
String color = ColorUtils.colorToRgbaString(Color.parseColor("#41FF0000")).split(" ")[3];
String alpha = color.substring(0, color.length() - 1);
assertEquals("alpha value should match", 0.254f, Float.valueOf(alpha), 0.001f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.light.Light;
import com.mapbox.mapboxsdk.style.light.Position;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.utils.ColorUtils;

import static com.mapbox.mapboxsdk.style.expressions.Expression.eq;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
Expand Down Expand Up @@ -79,7 +79,7 @@ private void setupLight() {

findViewById(R.id.fabLightColor).setOnClickListener(v -> {
isRedColor = !isRedColor;
light.setColor(PropertyFactory.colorToRgbaString(isRedColor ? Color.RED : Color.BLUE));
light.setColor(ColorUtils.colorToRgbaString(isRedColor ? Color.RED : Color.BLUE));
});
}

Expand Down

0 comments on commit 0f6f73f

Please sign in to comment.