HarmonizedColorAttributes

public final class HarmonizedColorAttributes


A class for specifying color attributes for harmonization, which contains an array of color attributes, with the option to specify a custom theme overlay.

Summary

Public fields

final int[]
final int

Public methods

static HarmonizedColorAttributes
create(int[] attributes)

Create HarmonizedColorAttributes with an array of color attributes.

static HarmonizedColorAttributes
create(int[] attributes, int themeOverlay)

Create HarmonizedColorAttributes with a theme overlay, along with an array of attributes in the theme overlay.

static HarmonizedColorAttributes

Create HarmonizedColorAttributes with Material default, with Error colors being harmonized.

int[]

Returns the array of color attributes for harmonization.

int

Returns the custom theme overlay for harmonization, default is 0 if not specified.

Public fields

attributes

public final int[] attributes

themeOverlay

public final int themeOverlay

Public methods

create

public static HarmonizedColorAttributes create(int[] attributes)

Create HarmonizedColorAttributes with an array of color attributes. If this is called, the resources pointed by the attributes will be resolved at runtime and harmonized. If you're concerned about accidentally overwriting color resources, see create.

create

public static HarmonizedColorAttributes create(int[] attributes, int themeOverlay)

Create HarmonizedColorAttributes with a theme overlay, along with an array of attributes in the theme overlay.

In this method, instead of the color resource that the color attribute is pointing to in the main theme/context being harmonized directly, the color resource in the theme overlay context will be replaced with the harmonized color attribute instead.

createMaterialDefaults

public static HarmonizedColorAttributes createMaterialDefaults()

Create HarmonizedColorAttributes with Material default, with Error colors being harmonized.

Instead of directly overwriting the resources that `colorError`, `colorOnError`, `colorErrorContainer` and `colorOnErrorContainer` points to in the main theme/context, we would:

1. look up the resources values in the theme overlay `Context`. 2. retrieve the harmonized resources with Primary. 3. replace `@color/material_harmonized_color_error`, `@color/material_harmonized_color_on_error`, etc. with the harmonized resources.

That way the Error roles in the theme overlay would point to harmonized resources.

getAttributes

public int[] getAttributes()

Returns the array of color attributes for harmonization.

getThemeOverlay

public int getThemeOverlay()

Returns the custom theme overlay for harmonization, default is 0 if not specified.