Merge "Monochromatic Theme" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
3e2ed2a87b
@@ -205,6 +205,13 @@ enum class Style(internal val coreSpec: CoreSpec) {
|
||||
n1 = TonalSpec(HueSource(), ChromaMultiple(0.0833)),
|
||||
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(
|
||||
@@ -219,7 +226,7 @@ class ColorScheme(
|
||||
val neutral1: List<Int>
|
||||
val neutral2: List<Int>
|
||||
|
||||
constructor(@ColorInt seed: Int, darkTheme: Boolean):
|
||||
constructor(@ColorInt seed: Int, darkTheme: Boolean) :
|
||||
this(seed, darkTheme, Style.TONAL_SPOT)
|
||||
|
||||
@JvmOverloads
|
||||
@@ -227,7 +234,7 @@ class ColorScheme(
|
||||
wallpaperColors: WallpaperColors,
|
||||
darkTheme: Boolean,
|
||||
style: Style = Style.TONAL_SPOT
|
||||
):
|
||||
) :
|
||||
this(getSeedColor(wallpaperColors, style != Style.CONTENT), darkTheme, style)
|
||||
|
||||
val allAccentColors: List<Int>
|
||||
@@ -472,4 +479,4 @@ class ColorScheme(
|
||||
return huePopulation
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,6 +212,9 @@ public class Flags {
|
||||
// 803 - screen contents translation
|
||||
public static final UnreleasedFlag SCREEN_CONTENTS_TRANSLATION = new UnreleasedFlag(803);
|
||||
|
||||
// 804 - monochromatic themes
|
||||
public static final UnreleasedFlag MONOCHROMATIC_THEMES = new UnreleasedFlag(804);
|
||||
|
||||
/***************************************/
|
||||
// 900 - media
|
||||
public static final ReleasedFlag MEDIA_TAP_TO_TRANSFER = new ReleasedFlag(900);
|
||||
|
||||
@@ -79,6 +79,7 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@@ -114,6 +115,7 @@ public class ThemeOverlayController implements CoreStartable, Dumpable {
|
||||
private final SecureSettings mSecureSettings;
|
||||
private final Executor mMainExecutor;
|
||||
private final Handler mBgHandler;
|
||||
private final boolean mIsMonochromaticEnabled;
|
||||
private final Context mContext;
|
||||
private final boolean mIsMonetEnabled;
|
||||
private final UserTracker mUserTracker;
|
||||
@@ -363,6 +365,7 @@ public class ThemeOverlayController implements CoreStartable, Dumpable {
|
||||
UserTracker userTracker, DumpManager dumpManager, FeatureFlags featureFlags,
|
||||
@Main Resources resources, WakefulnessLifecycle wakefulnessLifecycle) {
|
||||
mContext = context;
|
||||
mIsMonochromaticEnabled = featureFlags.isEnabled(Flags.MONOCHROMATIC_THEMES);
|
||||
mIsMonetEnabled = featureFlags.isEnabled(Flags.MONET);
|
||||
mDeviceProvisionedController = deviceProvisionedController;
|
||||
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
|
||||
// used as a system-wide theme.
|
||||
// - Content intentionally excluded, intended for media player, not system-wide
|
||||
List<Style> validStyles = Arrays.asList(Style.EXPRESSIVE, Style.SPRITZ, Style.TONAL_SPOT,
|
||||
Style.FRUIT_SALAD, Style.RAINBOW, Style.VIBRANT);
|
||||
List<Style> validStyles = new ArrayList<>(Arrays.asList(Style.EXPRESSIVE, Style.SPRITZ,
|
||||
Style.TONAL_SPOT, Style.FRUIT_SALAD, Style.RAINBOW, Style.VIBRANT));
|
||||
|
||||
if (mIsMonochromaticEnabled) {
|
||||
validStyles.add(Style.MONOCHROMATIC);
|
||||
}
|
||||
|
||||
Style style = mThemeStyle;
|
||||
final String overlayPackageJson = mSecureSettings.getStringForUser(
|
||||
Settings.Secure.THEME_CUSTOMIZATION_OVERLAY_PACKAGES,
|
||||
|
||||
@@ -146,6 +146,18 @@ public class ColorSchemeTest extends SysuiTestCase {
|
||||
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
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
public void testToString() {
|
||||
|
||||
Reference in New Issue
Block a user