diff options
4 files changed, 77 insertions, 68 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt index f3339c06ce8f..b04d9705f857 100644 --- a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt +++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt @@ -382,6 +382,9 @@ object Flags { // 804 - monochromatic themes @JvmField val MONOCHROMATIC_THEME = releasedFlag(804, "monochromatic") + // TODO(b/293380347): Tracking Bug + @JvmField val COLOR_FIDELITY = unreleasedFlag(805, "color_fidelity") + // 900 - media // TODO(b/254512697): Tracking Bug val MEDIA_TAP_TO_TRANSFER = releasedFlag(900, "media_tap_to_transfer") diff --git a/packages/SystemUI/src/com/android/systemui/theme/DynamicColors.kt b/packages/SystemUI/src/com/android/systemui/theme/DynamicColors.kt index eef66b6bd4af..a983d2f9b78e 100644 --- a/packages/SystemUI/src/com/android/systemui/theme/DynamicColors.kt +++ b/packages/SystemUI/src/com/android/systemui/theme/DynamicColors.kt @@ -22,83 +22,86 @@ import com.google.ux.material.libmonet.dynamiccolor.MaterialDynamicColors class DynamicColors { companion object { - private val MDC = MaterialDynamicColors() - @JvmField - val ALL_DYNAMIC_COLORS_MAPPED: List<Pair<String, DynamicColor>> = - arrayListOf( - Pair.create("primary_container", MDC.primaryContainer()), - Pair.create("on_primary_container", MDC.onPrimaryContainer()), - Pair.create("primary", MDC.primary()), - Pair.create("on_primary", MDC.onPrimary()), - Pair.create("secondary_container", MDC.secondaryContainer()), - Pair.create("on_secondary_container", MDC.onSecondaryContainer()), - Pair.create("secondary", MDC.secondary()), - Pair.create("on_secondary", MDC.onSecondary()), - Pair.create("tertiary_container", MDC.tertiaryContainer()), - Pair.create("on_tertiary_container", MDC.onTertiaryContainer()), - Pair.create("tertiary", MDC.tertiary()), - Pair.create("on_tertiary", MDC.onTertiary()), - Pair.create("background", MDC.background()), - Pair.create("on_background", MDC.onBackground()), - Pair.create("surface", MDC.surface()), - Pair.create("on_surface", MDC.onSurface()), - Pair.create("surface_container_low", MDC.surfaceContainerLow()), - Pair.create("surface_container_lowest", MDC.surfaceContainerLowest()), - Pair.create("surface_container", MDC.surfaceContainer()), - Pair.create("surface_container_high", MDC.surfaceContainerHigh()), - Pair.create("surface_container_highest", MDC.surfaceContainerHighest()), - Pair.create("surface_bright", MDC.surfaceBright()), - Pair.create("surface_dim", MDC.surfaceDim()), - Pair.create("surface_variant", MDC.surfaceVariant()), - Pair.create("on_surface_variant", MDC.onSurfaceVariant()), - Pair.create("outline", MDC.outline()), - Pair.create("outline_variant", MDC.outlineVariant()), - Pair.create("error", MDC.error()), - Pair.create("on_error", MDC.onError()), - Pair.create("error_container", MDC.errorContainer()), - Pair.create("on_error_container", MDC.onErrorContainer()), - Pair.create("control_activated", MDC.controlActivated()), - Pair.create("control_normal", MDC.controlNormal()), - Pair.create("control_highlight", MDC.controlHighlight()), - Pair.create("text_primary_inverse", MDC.textPrimaryInverse()), + @JvmStatic + fun allDynamicColorsMapped(isExtendedFidelity: Boolean): List<Pair<String, DynamicColor>> { + val mdc = MaterialDynamicColors(isExtendedFidelity) + return arrayListOf( + Pair.create("primary_container", mdc.primaryContainer()), + Pair.create("on_primary_container", mdc.onPrimaryContainer()), + Pair.create("primary", mdc.primary()), + Pair.create("on_primary", mdc.onPrimary()), + Pair.create("secondary_container", mdc.secondaryContainer()), + Pair.create("on_secondary_container", mdc.onSecondaryContainer()), + Pair.create("secondary", mdc.secondary()), + Pair.create("on_secondary", mdc.onSecondary()), + Pair.create("tertiary_container", mdc.tertiaryContainer()), + Pair.create("on_tertiary_container", mdc.onTertiaryContainer()), + Pair.create("tertiary", mdc.tertiary()), + Pair.create("on_tertiary", mdc.onTertiary()), + Pair.create("background", mdc.background()), + Pair.create("on_background", mdc.onBackground()), + Pair.create("surface", mdc.surface()), + Pair.create("on_surface", mdc.onSurface()), + Pair.create("surface_container_low", mdc.surfaceContainerLow()), + Pair.create("surface_container_lowest", mdc.surfaceContainerLowest()), + Pair.create("surface_container", mdc.surfaceContainer()), + Pair.create("surface_container_high", mdc.surfaceContainerHigh()), + Pair.create("surface_container_highest", mdc.surfaceContainerHighest()), + Pair.create("surface_bright", mdc.surfaceBright()), + Pair.create("surface_dim", mdc.surfaceDim()), + Pair.create("surface_variant", mdc.surfaceVariant()), + Pair.create("on_surface_variant", mdc.onSurfaceVariant()), + Pair.create("outline", mdc.outline()), + Pair.create("outline_variant", mdc.outlineVariant()), + Pair.create("error", mdc.error()), + Pair.create("on_error", mdc.onError()), + Pair.create("error_container", mdc.errorContainer()), + Pair.create("on_error_container", mdc.onErrorContainer()), + Pair.create("control_activated", mdc.controlActivated()), + Pair.create("control_normal", mdc.controlNormal()), + Pair.create("control_highlight", mdc.controlHighlight()), + Pair.create("text_primary_inverse", mdc.textPrimaryInverse()), Pair.create( "text_secondary_and_tertiary_inverse", - MDC.textSecondaryAndTertiaryInverse() + mdc.textSecondaryAndTertiaryInverse() ), Pair.create( "text_primary_inverse_disable_only", - MDC.textPrimaryInverseDisableOnly() + mdc.textPrimaryInverseDisableOnly() ), Pair.create( "text_secondary_and_tertiary_inverse_disabled", - MDC.textSecondaryAndTertiaryInverseDisabled() + mdc.textSecondaryAndTertiaryInverseDisabled() ), - Pair.create("text_hint_inverse", MDC.textHintInverse()), - Pair.create("palette_key_color_primary", MDC.primaryPaletteKeyColor()), - Pair.create("palette_key_color_secondary", MDC.secondaryPaletteKeyColor()), - Pair.create("palette_key_color_tertiary", MDC.tertiaryPaletteKeyColor()), - Pair.create("palette_key_color_neutral", MDC.neutralPaletteKeyColor()), + Pair.create("text_hint_inverse", mdc.textHintInverse()), + Pair.create("palette_key_color_primary", mdc.primaryPaletteKeyColor()), + Pair.create("palette_key_color_secondary", mdc.secondaryPaletteKeyColor()), + Pair.create("palette_key_color_tertiary", mdc.tertiaryPaletteKeyColor()), + Pair.create("palette_key_color_neutral", mdc.neutralPaletteKeyColor()), Pair.create( "palette_key_color_neutral_variant", - MDC.neutralVariantPaletteKeyColor() + mdc.neutralVariantPaletteKeyColor() ), ) + } - @JvmField - val FIXED_COLORS_MAPPED: List<Pair<String, DynamicColor>> = - arrayListOf( - Pair.create("primary_fixed", MDC.primaryFixed()), - Pair.create("primary_fixed_dim", MDC.primaryFixedDim()), - Pair.create("on_primary_fixed", MDC.onPrimaryFixed()), - Pair.create("on_primary_fixed_variant", MDC.onPrimaryFixedVariant()), - Pair.create("secondary_fixed", MDC.secondaryFixed()), - Pair.create("secondary_fixed_dim", MDC.secondaryFixedDim()), - Pair.create("on_secondary_fixed", MDC.onSecondaryFixed()), - Pair.create("on_secondary_fixed_variant", MDC.onSecondaryFixedVariant()), - Pair.create("tertiary_fixed", MDC.tertiaryFixed()), - Pair.create("tertiary_fixed_dim", MDC.tertiaryFixedDim()), - Pair.create("on_tertiary_fixed", MDC.onTertiaryFixed()), - Pair.create("on_tertiary_fixed_variant", MDC.onTertiaryFixedVariant()), + @JvmStatic + fun getFixedColorsMapped(isExtendedFidelity: Boolean): List<Pair<String, DynamicColor>> { + val mdc = MaterialDynamicColors(isExtendedFidelity) + return arrayListOf( + Pair.create("primary_fixed", mdc.primaryFixed()), + Pair.create("primary_fixed_dim", mdc.primaryFixedDim()), + Pair.create("on_primary_fixed", mdc.onPrimaryFixed()), + Pair.create("on_primary_fixed_variant", mdc.onPrimaryFixedVariant()), + Pair.create("secondary_fixed", mdc.secondaryFixed()), + Pair.create("secondary_fixed_dim", mdc.secondaryFixedDim()), + Pair.create("on_secondary_fixed", mdc.onSecondaryFixed()), + Pair.create("on_secondary_fixed_variant", mdc.onSecondaryFixedVariant()), + Pair.create("tertiary_fixed", mdc.tertiaryFixed()), + Pair.create("tertiary_fixed_dim", mdc.tertiaryFixedDim()), + Pair.create("on_tertiary_fixed", mdc.onTertiaryFixed()), + Pair.create("on_tertiary_fixed_variant", mdc.onTertiaryFixedVariant()), ) + } } } diff --git a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java index 06f68c6ee103..5a9f5d5a72d2 100644 --- a/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java +++ b/packages/SystemUI/src/com/android/systemui/theme/ThemeOverlayController.java @@ -130,6 +130,7 @@ public class ThemeOverlayController implements CoreStartable, Dumpable { private final boolean mIsMonochromaticEnabled; private final Context mContext; private final boolean mIsMonetEnabled; + private final boolean mIsFidelityEnabled; private final UserTracker mUserTracker; private final DeviceProvisionedController mDeviceProvisionedController; private final Resources mResources; @@ -398,6 +399,7 @@ public class ThemeOverlayController implements CoreStartable, Dumpable { mContext = context; mIsMonochromaticEnabled = featureFlags.isEnabled(Flags.MONOCHROMATIC_THEME); mIsMonetEnabled = featureFlags.isEnabled(Flags.MONET); + mIsFidelityEnabled = featureFlags.isEnabled(Flags.COLOR_FIDELITY); mDeviceProvisionedController = deviceProvisionedController; mBroadcastDispatcher = broadcastDispatcher; mUserManager = userManager; @@ -632,7 +634,7 @@ public class ThemeOverlayController implements CoreStartable, Dumpable { private void assignDynamicPaletteToOverlay(FabricatedOverlay overlay, boolean isDark) { String suffix = isDark ? "dark" : "light"; DynamicScheme scheme = isDark ? mDynamicSchemeDark : mDynamicSchemeLight; - DynamicColors.ALL_DYNAMIC_COLORS_MAPPED.forEach(p -> { + DynamicColors.allDynamicColorsMapped(mIsFidelityEnabled).forEach(p -> { String resourceName = "android:color/system_" + p.first + "_" + suffix; int colorValue = p.second.getArgb(scheme); overlay.setResourceValue(resourceName, TYPE_INT_COLOR_ARGB8, colorValue, @@ -641,7 +643,7 @@ public class ThemeOverlayController implements CoreStartable, Dumpable { } private void assignFixedColorsToOverlay(FabricatedOverlay overlay) { - DynamicColors.FIXED_COLORS_MAPPED.forEach(p -> { + DynamicColors.getFixedColorsMapped(mIsFidelityEnabled).forEach(p -> { String resourceName = "android:color/system_" + p.first; int colorValue = p.second.getArgb(mDynamicSchemeLight); overlay.setResourceValue(resourceName, TYPE_INT_COLOR_ARGB8, colorValue, @@ -660,7 +662,7 @@ public class ThemeOverlayController implements CoreStartable, Dumpable { Resources res = userHandle.isSystem() ? mResources : mContext.createContextAsUser(userHandle, 0).getResources(); Resources.Theme theme = mContext.getTheme(); - MaterialDynamicColors dynamicColors = new MaterialDynamicColors(); + MaterialDynamicColors dynamicColors = new MaterialDynamicColors(mIsFidelityEnabled); if (!(res.getColor(android.R.color.system_accent1_500, theme) == mColorScheme.getAccent1().getS500() && res.getColor(android.R.color.system_accent2_500, theme) @@ -819,6 +821,7 @@ public class ThemeOverlayController implements CoreStartable, Dumpable { pw.println("mNeutralOverlay=" + mNeutralOverlay); pw.println("mDynamicOverlay=" + mDynamicOverlay); pw.println("mIsMonetEnabled=" + mIsMonetEnabled); + pw.println("mIsFidelityEnabled=" + mIsFidelityEnabled); pw.println("mColorScheme=" + mColorScheme); pw.println("mNeedsOverlayCreation=" + mNeedsOverlayCreation); pw.println("mAcceptColorEvents=" + mAcceptColorEvents); diff --git a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java index 09ac0e312e21..c454b45a7312 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/theme/ThemeOverlayControllerTest.java @@ -959,8 +959,8 @@ public class ThemeOverlayControllerTest extends SysuiTestCase { // All dynamic colors were added twice: light and dark them // All fixed colors were added once verify(dynamic, times( - DynamicColors.ALL_DYNAMIC_COLORS_MAPPED.size() * 2 - + DynamicColors.FIXED_COLORS_MAPPED.size()) + DynamicColors.allDynamicColorsMapped(false).size() * 2 + + DynamicColors.getFixedColorsMapped(false).size()) ).setResourceValue(any(String.class), eq(TYPE_INT_COLOR_ARGB8), anyInt(), eq(null)); } } |