Class DynamicColors

java.lang.Object
com.pranavpandey.android.dynamic.theme.DynamicColors
All Implemented Interfaces:
Parcelable

public class DynamicColors extends Object implements Parcelable
A class to handle dynamic colors generation.
  • Field Details

  • Constructor Details

    • DynamicColors

      public DynamicColors()
      Constructor to initialize an object of this class.
    • DynamicColors

      public DynamicColors(@NonNull Map<Integer,Integer> original)
      Constructor to initialize an object of this class.
      Parameters:
      original - The original colors to be handled.
    • DynamicColors

      public DynamicColors(@NonNull Parcel in)
      Read an object of this class from the parcel.
      Parameters:
      in - The parcel to read the values.
  • Method Details

    • describeContents

      public int describeContents()
      Specified by:
      describeContents in interface Parcelable
    • writeToParcel

      public void writeToParcel(Parcel dest, int flags)
      Specified by:
      writeToParcel in interface Parcelable
    • getOriginal

      @NonNull public Map<Integer,Integer> getOriginal()
      Get the map of original colors.
      Returns:
      The map of original colors.
    • getDark

      @NonNull public Map<Integer,Integer> getDark()
      Get the map of mutated (dark) colors.
      Returns:
      The map of mutated (dark) colors.
    • getLight

      @NonNull public Map<Integer,Integer> getLight()
      Get the map of mutated (light) colors.
      Returns:
      The map of mutated (light) colors.
    • get

      @ColorInt public int get(@NonNull Map<Integer,Integer> colors, int colorType, @ColorInt int fallback)
      Get the color according to its type from the supplied map.
      Parameters:
      colors - The color map to be used.
      colorType - The type of the color.
      fallback - The fallback color if the request color type is not found.
      Returns:
      The color according to its type from the supplied map.
    • getOriginal

      @ColorInt public int getOriginal(int colorType, @ColorInt int fallback)
      Get the original color according to its type.
      Parameters:
      colorType - The type of the color.
      fallback - The fallback color if the request color type is not found.
      Returns:
      The original color according to its type.
    • getMutated

      @NonNull public Map<Integer,Integer> getMutated(@NonNull DynamicColor<?> theme)
      Get the map of mutated colors according to the supplied theme.
      Parameters:
      theme - The dynamic theme to be used.
      Returns:
      The map of mutated colors according to the supplied theme.
    • getMutated

      @ColorInt public int getMutated(int colorType, @ColorInt int fallback, @NonNull DynamicColor<?> theme)
      Get the mutated color according to its type.
      Parameters:
      colorType - The type of the color.
      fallback - The fallback color if the request color type is not found.
      theme - The dynamic theme to be used.
      Returns:
      The mutated color according to its type.
    • put

      public void put(@NonNull Map<Integer,Integer> colors, int colorType, @ColorInt int color)
      Store the color according to its type in the supplied map.
      Parameters:
      colors - The map to store the color.
      colorType - The type of the color.
      color - The color to be stored.
    • putOriginal

      public void putOriginal(int colorType, @ColorInt int color)
      Store the color according to its type in the original map.
      Parameters:
      colorType - The type of the color.
      color - The color to be stored.
    • putDark

      public void putDark(int colorType, @ColorInt int color)
      Store the color according to its type in the mutated (dark) map.
      Parameters:
      colorType - The type of the color.
      color - The color to be stored.
    • putLight

      public void putLight(int colorType, @ColorInt int color)
      Store the color according to its type in the mutated (light) map.
      Parameters:
      colorType - The type of the color.
      color - The color to be stored.
    • put

      public void put(@NonNull Map<Integer,Integer> colors, @Nullable Map<Integer,Integer> newColors)
      Store the colors in the supplied map.
      Parameters:
      colors - The map to store the colors.
      newColors - The colors to be stored.
    • putOriginal

      public void putOriginal(@Nullable Map<Integer,Integer> colors)
      Store the colors in the original map.
      Parameters:
      colors - The colors to be stored.
    • putDark

      public void putDark(@Nullable Map<Integer,Integer> colors)
      Store the colors in the mutated (dark) map.
      Parameters:
      colors - The colors to be stored.
    • putLight

      public void putLight(@Nullable Map<Integer,Integer> colors)
      Store the colors in the mutated (light) map.
      Parameters:
      colors - The colors to be stored.
    • put

      public void put(@NonNull Map<Integer,Integer> colors, @Nullable WallpaperColors newColors)
      Store the wallpaper colors in the supplied map.
      Parameters:
      colors - The map to store the colors.
      newColors - The wallpaper colors to be stored.
    • putOriginal

      public void putOriginal(@Nullable WallpaperColors colors)
      Store the wallpaper colors in the original map.
      Parameters:
      colors - The wallpaper colors to be stored.
    • putDark

      public void putDark(@Nullable WallpaperColors colors)
      Store the wallpaper colors in the mutated (dark) map.
      Parameters:
      colors - The wallpaper colors to be stored.
    • putLight

      public void putLight(@Nullable WallpaperColors colors)
      Store the wallpaper colors in the mutated (light) map.
      Parameters:
      colors - The wallpaper colors to be stored.
    • mutate

      public void mutate(@NonNull Map<Integer,Integer> dark, @NonNull Map<Integer,Integer> light, @NonNull DynamicColor<?> theme)
      Mutate original colors for the supplied app theme.
      Parameters:
      dark - The map to store the mutated (dark) colors.
      light - The map to store the mutated (light) colors.
      theme - The dynamic theme to be used.
    • mutate

      public void mutate(@NonNull DynamicColor<?> theme)
      Mutate original colors for the supplied app theme.
      Parameters:
      theme - The dynamic theme to be used.
    • getAll

      @NonNull public ArrayList<Integer> getAll()
      Returns all the colors including original, light and dark.
      Returns:
      All the colors including original, dark and light.
    • clear

      public void clear()
      Clear original and mutated colors.
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • toString

      @NonNull public String toString()
      Overrides:
      toString in class Object