Merge "Monochromatic Theme" into tm-qpr-dev am: 3e2ed2a87b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20170464

Change-Id: Ic8403e80b233cca2aee833b2a50330d592fb1732
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Marcelo Arteiro
2022-10-20 16:26:23 +00:00
committed by Automerger Merge Worker
4 changed files with 35 additions and 5 deletions

View File

@@ -205,6 +205,13 @@ enum class Style(internal val coreSpec: CoreSpec) {
n1 = TonalSpec(HueSource(), ChromaMultiple(0.0833)), n1 = TonalSpec(HueSource(), ChromaMultiple(0.0833)),
n2 = TonalSpec(HueSource(), ChromaMultiple(0.1666)) n2 = TonalSpec(HueSource(), ChromaMultiple(0.1666))
)), )),
MONOCHROMATIC(CoreSpec(
a1 = TonalSpec(HueSource(), ChromaConstant(.0)),
a2 = TonalSpec(HueSource(), ChromaConstant(.0)),
a3 = TonalSpec(HueSource(), ChromaConstant(.0)),
n1 = TonalSpec(HueSource(), ChromaConstant(.0)),
n2 = TonalSpec(HueSource(), ChromaConstant(.0))
)),
} }
class ColorScheme( class ColorScheme(

View File

@@ -212,6 +212,9 @@ public class Flags {
// 803 - screen contents translation // 803 - screen contents translation
public static final UnreleasedFlag SCREEN_CONTENTS_TRANSLATION = new UnreleasedFlag(803); public static final UnreleasedFlag SCREEN_CONTENTS_TRANSLATION = new UnreleasedFlag(803);
// 804 - monochromatic themes
public static final UnreleasedFlag MONOCHROMATIC_THEMES = new UnreleasedFlag(804);
/***************************************/ /***************************************/
// 900 - media // 900 - media
public static final ReleasedFlag MEDIA_TAP_TO_TRANSFER = new ReleasedFlag(900); public static final ReleasedFlag MEDIA_TAP_TO_TRANSFER = new ReleasedFlag(900);

View File

@@ -79,6 +79,7 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
@@ -114,6 +115,7 @@ public class ThemeOverlayController implements CoreStartable, Dumpable {
private final SecureSettings mSecureSettings; private final SecureSettings mSecureSettings;
private final Executor mMainExecutor; private final Executor mMainExecutor;
private final Handler mBgHandler; private final Handler mBgHandler;
private final boolean mIsMonochromaticEnabled;
private final Context mContext; private final Context mContext;
private final boolean mIsMonetEnabled; private final boolean mIsMonetEnabled;
private final UserTracker mUserTracker; private final UserTracker mUserTracker;
@@ -363,6 +365,7 @@ public class ThemeOverlayController implements CoreStartable, Dumpable {
UserTracker userTracker, DumpManager dumpManager, FeatureFlags featureFlags, UserTracker userTracker, DumpManager dumpManager, FeatureFlags featureFlags,
@Main Resources resources, WakefulnessLifecycle wakefulnessLifecycle) { @Main Resources resources, WakefulnessLifecycle wakefulnessLifecycle) {
mContext = context; mContext = context;
mIsMonochromaticEnabled = featureFlags.isEnabled(Flags.MONOCHROMATIC_THEMES);
mIsMonetEnabled = featureFlags.isEnabled(Flags.MONET); mIsMonetEnabled = featureFlags.isEnabled(Flags.MONET);
mDeviceProvisionedController = deviceProvisionedController; mDeviceProvisionedController = deviceProvisionedController;
mBroadcastDispatcher = broadcastDispatcher; mBroadcastDispatcher = broadcastDispatcher;
@@ -665,8 +668,13 @@ public class ThemeOverlayController implements CoreStartable, Dumpable {
// Allow-list of Style objects that can be created from a setting string, i.e. can be // Allow-list of Style objects that can be created from a setting string, i.e. can be
// used as a system-wide theme. // used as a system-wide theme.
// - Content intentionally excluded, intended for media player, not system-wide // - Content intentionally excluded, intended for media player, not system-wide
List<Style> validStyles = Arrays.asList(Style.EXPRESSIVE, Style.SPRITZ, Style.TONAL_SPOT, List<Style> validStyles = new ArrayList<>(Arrays.asList(Style.EXPRESSIVE, Style.SPRITZ,
Style.FRUIT_SALAD, Style.RAINBOW, Style.VIBRANT); Style.TONAL_SPOT, Style.FRUIT_SALAD, Style.RAINBOW, Style.VIBRANT));
if (mIsMonochromaticEnabled) {
validStyles.add(Style.MONOCHROMATIC);
}
Style style = mThemeStyle; Style style = mThemeStyle;
final String overlayPackageJson = mSecureSettings.getStringForUser( final String overlayPackageJson = mSecureSettings.getStringForUser(
Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES, Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES,

View File

@@ -146,6 +146,18 @@ public class ColorSchemeTest extends SysuiTestCase {
Assert.assertTrue(cam.getChroma() <= 8.0); Assert.assertTrue(cam.getChroma() <= 8.0);
} }
@Test
public void testMonochromatic() {
int colorInt = 0xffB3588A; // H350 C50 T50
ColorScheme colorScheme = new ColorScheme(colorInt, false /* darkTheme */,
Style.MONOCHROMATIC /* style */);
int neutralMid = colorScheme.getNeutral1().get(colorScheme.getNeutral1().size() / 2);
Assert.assertTrue(
Color.red(neutralMid) == Color.green(neutralMid)
&& Color.green(neutralMid) == Color.blue(neutralMid)
);
}
@Test @Test
@SuppressWarnings("ResultOfMethodCallIgnored") @SuppressWarnings("ResultOfMethodCallIgnored")
public void testToString() { public void testToString() {