Skip to content

Commit c3681e1

Browse files
Material Engcopybara-github
authored andcommitted
Not a public change.
PiperOrigin-RevId: 549283686
1 parent af27fa9 commit c3681e1

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

java/dynamiccolor/MaterialDynamicColors.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,19 @@
3131
// AndroidManifest with an SDK set higher than 14.
3232
@SuppressWarnings({"AndroidJdkLibsChecker", "NewApi"})
3333
public final class MaterialDynamicColors {
34-
public MaterialDynamicColors() {}
34+
/** Optionally use fidelity on most color schemes. */
35+
private final boolean isExtendedFidelity;
36+
37+
public MaterialDynamicColors() {
38+
this.isExtendedFidelity = false;
39+
}
40+
41+
// Temporary constructor to support extended fidelity experiment.
42+
// TODO(b/291720794): Once schemes that will permanently use fidelity are identified,
43+
// remove this and default to the decided behavior.
44+
public MaterialDynamicColors(boolean isExtendedFidelity) {
45+
this.isExtendedFidelity = isExtendedFidelity;
46+
}
3547

3648
@NonNull
3749
public DynamicColor highestSurface(@NonNull DynamicScheme s) {
@@ -909,12 +921,17 @@ public DynamicColor textHintInverse() {
909921
"text_hint_inverse", (s) -> s.neutralPalette, (s) -> s.isDark ? 10.0 : 90.0);
910922
}
911923

912-
private static ViewingConditions viewingConditionsForAlbers(DynamicScheme scheme) {
913-
return ViewingConditions.defaultWithBackgroundLstar(scheme.isDark ? 30.0 : 80.0);
924+
private boolean isFidelity(DynamicScheme scheme) {
925+
if (this.isExtendedFidelity
926+
&& scheme.variant != Variant.MONOCHROME
927+
&& scheme.variant != Variant.NEUTRAL) {
928+
return true;
929+
}
930+
return scheme.variant == Variant.FIDELITY || scheme.variant == Variant.CONTENT;
914931
}
915932

916-
private static boolean isFidelity(DynamicScheme scheme) {
917-
return scheme.variant == Variant.FIDELITY || scheme.variant == Variant.CONTENT;
933+
private static ViewingConditions viewingConditionsForAlbers(DynamicScheme scheme) {
934+
return ViewingConditions.defaultWithBackgroundLstar(scheme.isDark ? 30.0 : 80.0);
918935
}
919936

920937
private static boolean isMonochrome(DynamicScheme scheme) {

0 commit comments

Comments
 (0)