diff --git a/lib/java/com/google/android/material/color/MaterialColorUtilitiesHelper.java b/lib/java/com/google/android/material/color/MaterialColorUtilitiesHelper.java index 923c7de6c56..6441c8ad177 100644 --- a/lib/java/com/google/android/material/color/MaterialColorUtilitiesHelper.java +++ b/lib/java/com/google/android/material/color/MaterialColorUtilitiesHelper.java @@ -33,13 +33,11 @@ private MaterialColorUtilitiesHelper() {} private static final Map colorResourceIdToColorValue; static { - // TODO(b/261178654): Add the missing primaryInverse, surfaceInverse, onSurfaceInverse and - // outlineVariant in MCU. Map map = new HashMap<>(); map.put(R.color.material_personalized_color_primary, MaterialDynamicColors.primary); map.put(R.color.material_personalized_color_on_primary, MaterialDynamicColors.onPrimary); - // map.put(R.color.material_personalized_color_primary_inverse, - // MaterialDynamicColors.primaryInverse); + map.put( + R.color.material_personalized_color_primary_inverse, MaterialDynamicColors.primaryInverse); map.put( R.color.material_personalized_color_primary_container, MaterialDynamicColors.primaryContainer); @@ -71,10 +69,11 @@ private MaterialColorUtilitiesHelper() {} map.put( R.color.material_personalized_color_on_surface_variant, MaterialDynamicColors.onSurfaceVariant); - // map.put(R.color.material_personalized_color_surface_inverse, - // MaterialDynamicColors.surfaceInverse); - // map.put(R.color.material_personalized_color_on_surface_inverse, - // MaterialDynamicColors.onSurfaceInverse); + map.put( + R.color.material_personalized_color_surface_inverse, MaterialDynamicColors.surfaceInverse); + map.put( + R.color.material_personalized_color_on_surface_inverse, + MaterialDynamicColors.onSurfaceInverse); map.put( R.color.material_personalized_color_surface_bright, MaterialDynamicColors.surfaceBright); map.put(R.color.material_personalized_color_surface_dim, MaterialDynamicColors.surfaceDim); @@ -94,8 +93,8 @@ private MaterialColorUtilitiesHelper() {} R.color.material_personalized_color_surface_container_highest, MaterialDynamicColors.surfaceAdd2); map.put(R.color.material_personalized_color_outline, MaterialDynamicColors.outline); - // map.put(R.color.material_personalized_color_outline_variant, - // MaterialDynamicColors.outlineVariant); + map.put( + R.color.material_personalized_color_outline_variant, MaterialDynamicColors.outlineVariant); map.put(R.color.material_personalized_color_error, MaterialDynamicColors.error); map.put(R.color.material_personalized_color_on_error, MaterialDynamicColors.onError); map.put( diff --git a/lib/java/com/google/android/material/color/utilities/MaterialDynamicColors.java b/lib/java/com/google/android/material/color/utilities/MaterialDynamicColors.java index e17ddd63865..92d3e883561 100644 --- a/lib/java/com/google/android/material/color/utilities/MaterialDynamicColors.java +++ b/lib/java/com/google/android/material/color/utilities/MaterialDynamicColors.java @@ -45,6 +45,9 @@ public static DynamicColor highestSurface(DynamicScheme s) { public static final DynamicColor surface = DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 6.0 : 98.0); + public static final DynamicColor surfaceInverse = + DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 90.0 : 20.0); + public static final DynamicColor surfaceBright = DynamicColor.fromPalette((s) -> s.neutralPalette, (s) -> s.isDark ? 24.0 : 98.0); @@ -70,6 +73,10 @@ public static DynamicColor highestSurface(DynamicScheme s) { DynamicColor.fromPalette( (s) -> s.neutralPalette, (s) -> s.isDark ? 90.0 : 10.0, (s) -> highestSurface(s)); + public static final DynamicColor onSurfaceInverse = + DynamicColor.fromPalette( + (s) -> s.neutralPalette, (s) -> s.isDark ? 20.0 : 95.0, (s) -> surfaceInverse); + public static final DynamicColor surfaceVariant = DynamicColor.fromPalette((s) -> s.neutralVariantPalette, (s) -> s.isDark ? 30.0 : 90.0); @@ -81,6 +88,10 @@ public static DynamicColor highestSurface(DynamicScheme s) { DynamicColor.fromPalette( (s) -> s.neutralVariantPalette, (s) -> 50.0, (s) -> highestSurface(s)); + public static final DynamicColor outlineVariant = + DynamicColor.fromPalette( + (s) -> s.neutralVariantPalette, (s) -> 80.0, (s) -> highestSurface(s)); + public static final DynamicColor primaryContainer = DynamicColor.fromPalette( (s) -> s.primaryPalette, (s) -> s.isDark ? 30.0 : 90.0, (s) -> highestSurface(s)); @@ -100,6 +111,10 @@ public static DynamicColor highestSurface(DynamicScheme s) { primaryContainer, s.isDark ? TonePolarity.DARKER : TonePolarity.LIGHTER)); + public static final DynamicColor primaryInverse = + DynamicColor.fromPalette( + (s) -> s.primaryPalette, (s) -> s.isDark ? 40.0 : 80.0, (s) -> surfaceInverse); + public static final DynamicColor onPrimary = DynamicColor.fromPalette( (s) -> s.primaryPalette, (s) -> s.isDark ? 20.0 : 100.0, (s) -> primary);