Skip to content

Commit

Permalink
Tweak palette based container color token APIs
Browse files Browse the repository at this point in the history
For #400
  • Loading branch information
kirill-grouchnikov committed Jan 6, 2025
1 parent 0fb1a28 commit 0caa773
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -900,8 +900,8 @@ public static RadianceColorScheme2 getDarkPrimaryFidelityColorScheme(
return result;
}

public static ContainerColorTokens getLightContainerTokens(Hct sourceColorHct,
boolean isFidelity, TonalPalette palette, ActiveStatesContainerType activeStatesContainerType) {
public static ContainerColorTokens getLightTonalContainerTokens(Hct sourceColorHct,
boolean isFidelity, TonalPalette palette) {

DynamicPalette dynamicPalette = new DynamicPalette(
/* sourceColorHct */ sourceColorHct,
Expand All @@ -911,25 +911,23 @@ public static ContainerColorTokens getLightContainerTokens(Hct sourceColorHct,
/* palette */ palette);

PaletteContainerColorsResolver paletteColorResolver =
PaletteResolverUtils.getPaletteColorResolver();
PaletteResolverUtils.getPaletteTonalColorResolver();

return getContainerTokens(dynamicPalette, paletteColorResolver);
}

public static ContainerColorTokens getLightTonalFidelityContainerTokens(Hct seed) {
return ColorSchemeUtils.getLightContainerTokens(
return ColorSchemeUtils.getLightTonalContainerTokens(
/* sourceColorHct */ seed,
/* isFidelity */ true,
/* palette */ TonalPalette.fromHct(seed),
/* activeStatesContainerType */ ColorSchemeUtils.ActiveStatesContainerType.TONAL);
/* palette */ TonalPalette.fromHct(seed));
}

public static ContainerColorTokens getLightTonalBalancedContainerTokens(Hct seed) {
return ColorSchemeUtils.getLightContainerTokens(
public static ContainerColorTokens getLightBalancedContainerTokens(Hct seed) {
return ColorSchemeUtils.getLightTonalContainerTokens(
/* sourceColorHct */ seed,
/* isFidelity */ false,
/* palette */ TonalPalette.fromHct(seed),
/* activeStatesContainerType */ ColorSchemeUtils.ActiveStatesContainerType.TONAL);
/* palette */ TonalPalette.fromHct(seed));
}

public static ContainerColorTokens tint(ContainerColorTokens original, float tintFactor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,52 +34,52 @@
import java.awt.*;

public class PaletteResolverUtils {
public static PaletteContainerColorsResolver getPaletteColorResolver() {
public static PaletteContainerColorsResolver getPaletteTonalColorResolver() {
PaletteContainerColorsResolver result =
new PaletteContainerColorsResolver() {
@Override
public Color getContainerSurfaceLowest(DynamicPalette dynamicPalette) {
return new Color(dynamicPalette.getContainerSurfaceLowest());
return new Color(dynamicPalette.getTonalContainerSurfaceLowest());
}

@Override
public Color getContainerSurfaceLow(DynamicPalette dynamicPalette) {
return new Color(dynamicPalette.getContainerSurfaceLow());
return new Color(dynamicPalette.getTonalContainerSurfaceLow());
}

@Override
public Color getContainerSurface(DynamicPalette dynamicPalette) {
return new Color(dynamicPalette.getContainerSurface());
return new Color(dynamicPalette.getTonalContainerSurface());
}

@Override
public Color getContainerSurfaceHigh(DynamicPalette dynamicPalette) {
return new Color(dynamicPalette.getContainerSurfaceHigh());
return new Color(dynamicPalette.getTonalContainerSurfaceHigh());
}

@Override
public Color getContainerSurfaceHighest(DynamicPalette dynamicPalette) {
return new Color(dynamicPalette.getContainerSurfaceHighest());
return new Color(dynamicPalette.getTonalContainerSurfaceHighest());
}

@Override
public Color getOnContainer(DynamicPalette dynamicPalette) {
return new Color(dynamicPalette.getOnContainer());
return new Color(dynamicPalette.getOnTonalContainer());
}

@Override
public Color getOnContainerVariant(DynamicPalette dynamicPalette) {
return new Color(dynamicPalette.getOnContainerVariant());
return new Color(dynamicPalette.getOnTonalContainerVariant());
}

@Override
public Color getContainerOutline(DynamicPalette dynamicPalette) {
return new Color(dynamicPalette.getContainerOutline());
return new Color(dynamicPalette.getTonalContainerOutline());
}

@Override
public Color getContainerOutlineVariant(DynamicPalette dynamicPalette) {
return new Color(dynamicPalette.getContainerOutlineVariant());
return new Color(dynamicPalette.getTonalContainerOutlineVariant());
}
};
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public BusinessBlueSteelTonalSkin() {
Hct.fromInt(0xFF83AFCE)))
.withActiveControlsAccent(ColorSchemeUtils.getLightTonalFidelityColorScheme(
Hct.fromInt(0xFF98B7CC), Hct.fromInt(0xFFC4C8CC), Hct.fromInt(0xFFE4EAF0)))
.withHighlightsAccent(ColorSchemeUtils.getLightTonalBalancedContainerTokens(
.withHighlightsAccent(ColorSchemeUtils.getLightBalancedContainerTokens(
Hct.fromInt(0xFFEBD296))));

RadianceColorScheme2 controlPaneColorScheme =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ public BusinessTonalSkin() {
super(new AccentBuilder()
.withWindowChromeAccent(ColorSchemeUtils.getLightTonalFidelityColorScheme(
Hct.fromInt(0xFFBDC8D3), Hct.fromInt(0xFFDEDDDF), Hct.fromInt(0xFFE4EAF0)))
.withWindowChromeHighlightsAccent(ColorSchemeUtils.getLightTonalBalancedContainerTokens(
.withWindowChromeHighlightsAccent(ColorSchemeUtils.getLightBalancedContainerTokens(
Hct.fromInt(0xFFEBD296)))
.withActiveControlsAccent(ColorSchemeUtils.getLightTonalFidelityColorScheme(
Hct.fromInt(0xFFEAEDF3), Hct.fromInt(0xFFC4C8CC), Hct.fromInt(0xFFE5EAEF)))
.withHighlightsAccent(ColorSchemeUtils.getLightTonalBalancedContainerTokens(
.withHighlightsAccent(ColorSchemeUtils.getLightBalancedContainerTokens(
Hct.fromInt(0xFFEBD296))));
}

Expand Down

0 comments on commit 0caa773

Please sign in to comment.