Class ColorUtils

java.lang.Object
com.trimblemaps.mapsdk.utils.ColorUtils

public class ColorUtils extends Object
Color utility class.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static float[]
    colorToGlRgbaArray(int color)
    Converts Android color int to GL rgba float array.
    static float[]
    colorToRgbaArray(int color)
    Converts Android color int to rgba float array.
    static String
    colorToRgbaString(int color)
    Converts Android color int to "rbga(r, g, b, a)" String equivalent.
    static int
    getAccentColor(android.content.Context context)
    Returns a color integer associated as accent color from a theme based on a Context.
    static int
    getPrimaryColor(android.content.Context context)
    Returns a color integer associated as primary color from a theme based on a Context.
    static int
    getPrimaryDarkColor(android.content.Context context)
    Returns a color integer associated as primary dark color from a theme based on a Context.
    static android.content.res.ColorStateList
    getSelector(int color)
    Returns a color state list associated with a theme based on a Context.
    static int
    Convert an rgba string to a Color int.
    static void
    setTintList(android.widget.ImageView imageView, int tintColor)
    Set a color tint list to the Drawable of an ImageView.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ColorUtils

      public ColorUtils()
  • Method Details

    • getPrimaryColor

      @ColorInt public static int getPrimaryColor(@NonNull android.content.Context context)
      Returns a color integer associated as primary color from a theme based on a Context.
      Parameters:
      context - The context used to style the color attributes.
      Returns:
      The primary color value of current theme in the form 0xAARRGGBB.
    • getPrimaryDarkColor

      @ColorInt public static int getPrimaryDarkColor(@NonNull android.content.Context context)
      Returns a color integer associated as primary dark color from a theme based on a Context.
      Parameters:
      context - The context used to style the color attributes.
      Returns:
      The primary dark color value of current theme in the form 0xAARRGGBB.
    • getAccentColor

      @ColorInt public static int getAccentColor(@NonNull android.content.Context context)
      Returns a color integer associated as accent color from a theme based on a Context.
      Parameters:
      context - The context used to style the color attributes.
      Returns:
      The accent color value of current theme in the form 0xAARRGGBB.
    • getSelector

      @NonNull public static android.content.res.ColorStateList getSelector(@ColorInt int color)
      Returns a color state list associated with a theme based on a Context.
      Parameters:
      color - The color used for tinting.
      Returns:
      A ColorStateList object containing the primary color of a theme
    • setTintList

      public static void setTintList(@NonNull android.widget.ImageView imageView, @ColorInt int tintColor)
      Set a color tint list to the Drawable of an ImageView.
      Parameters:
      imageView - The view to set the default tint list.
      tintColor - The color to tint.
    • rgbaToColor

      @ColorInt public static int rgbaToColor(@NonNull String value)
      Convert an rgba string to a Color int.

      R, G, B color components have to be in the [0-255] range, while alpha has to be in the [0.0-1.0] range. For example: "rgba(255, 128, 0, 0.7)".

      Parameters:
      value - the String representation of rgba
      Returns:
      the int representation of rgba
      Throws:
      ConversionException - on illegal input
    • colorToRgbaString

      public static String colorToRgbaString(@ColorInt int color)
      Converts Android color int to "rbga(r, g, b, a)" String equivalent.

      Alpha value will be converted from 0-255 range to 0-1.

      Parameters:
      color - Android color int
      Returns:
      String rgba color
    • colorToRgbaArray

      public static float[] colorToRgbaArray(@ColorInt int color)
      Converts Android color int to rgba float array.

      Returned RGB values range from 0 to 255. Alpha value ranges from 0-1.

      Parameters:
      color - Android color int
      Returns:
      float rgba array, rgb values range from 0-255, alpha from 0-1
    • colorToGlRgbaArray

      public static float[] colorToGlRgbaArray(@ColorInt int color)
      Converts Android color int to GL rgba float array.

      Returned values range from 0-1.

      Parameters:
      color - Android color int
      Returns:
      float rgba array, values range from 0 to 1