Fix dark theme for screen lock settings
Test: atest [...]/SetupWizardUtilsTest.java Bug: 36529801 Change-Id: I81581b4f73754ba6b0754c80a8f962e8f7ed6949
This commit is contained in:
@@ -30,7 +30,10 @@ public class SetupWizardUtils {
|
|||||||
if (theme == null) {
|
if (theme == null) {
|
||||||
theme = SetupWizardProperties.theme().orElse("");
|
theme = SetupWizardProperties.theme().orElse("");
|
||||||
}
|
}
|
||||||
|
// TODO(yukl): Move to ThemeResolver and add any additional required attributes in
|
||||||
|
// onApplyThemeResource using Theme overlays
|
||||||
if (theme != null) {
|
if (theme != null) {
|
||||||
|
if (WizardManagerHelper.isAnySetupWizard(intent)) {
|
||||||
switch (theme) {
|
switch (theme) {
|
||||||
case ThemeHelper.THEME_GLIF_V3_LIGHT:
|
case ThemeHelper.THEME_GLIF_V3_LIGHT:
|
||||||
return R.style.GlifV3Theme_Light;
|
return R.style.GlifV3Theme_Light;
|
||||||
@@ -45,25 +48,38 @@ public class SetupWizardUtils {
|
|||||||
case ThemeHelper.THEME_GLIF:
|
case ThemeHelper.THEME_GLIF:
|
||||||
return R.style.GlifTheme;
|
return R.style.GlifTheme;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
switch (theme) {
|
||||||
|
case ThemeHelper.THEME_GLIF_V3_LIGHT:
|
||||||
|
case ThemeHelper.THEME_GLIF_V3:
|
||||||
|
return R.style.GlifV3Theme;
|
||||||
|
case ThemeHelper.THEME_GLIF_V2_LIGHT:
|
||||||
|
case ThemeHelper.THEME_GLIF_V2:
|
||||||
|
return R.style.GlifV2Theme;
|
||||||
|
case ThemeHelper.THEME_GLIF_LIGHT:
|
||||||
|
case ThemeHelper.THEME_GLIF:
|
||||||
|
return R.style.GlifTheme;
|
||||||
}
|
}
|
||||||
return R.style.GlifTheme_Light;
|
}
|
||||||
|
}
|
||||||
|
return R.style.GlifTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getTransparentTheme(Intent intent) {
|
public static int getTransparentTheme(Intent intent) {
|
||||||
final int suwTheme = getTheme(intent);
|
final int suwTheme = getTheme(intent);
|
||||||
int wifiDialogTheme = R.style.GlifV2Theme_Light_Transparent;
|
int transparentTheme = R.style.GlifV2Theme_Light_Transparent;
|
||||||
if (suwTheme == R.style.GlifV3Theme) {
|
if (suwTheme == R.style.GlifV3Theme) {
|
||||||
wifiDialogTheme = R.style.GlifV3Theme_Transparent;
|
transparentTheme = R.style.GlifV3Theme_Transparent;
|
||||||
} else if (suwTheme == R.style.GlifV3Theme_Light) {
|
} else if (suwTheme == R.style.GlifV3Theme_Light) {
|
||||||
wifiDialogTheme = R.style.GlifV3Theme_Light_Transparent;
|
transparentTheme = R.style.GlifV3Theme_Light_Transparent;
|
||||||
} else if (suwTheme == R.style.GlifV2Theme) {
|
} else if (suwTheme == R.style.GlifV2Theme) {
|
||||||
wifiDialogTheme = R.style.GlifV2Theme_Transparent;
|
transparentTheme = R.style.GlifV2Theme_Transparent;
|
||||||
} else if (suwTheme == R.style.GlifTheme_Light) {
|
} else if (suwTheme == R.style.GlifTheme_Light) {
|
||||||
wifiDialogTheme = R.style.SetupWizardTheme_Light_Transparent;
|
transparentTheme = R.style.SetupWizardTheme_Light_Transparent;
|
||||||
} else if (suwTheme == R.style.GlifTheme) {
|
} else if (suwTheme == R.style.GlifTheme) {
|
||||||
wifiDialogTheme = R.style.SetupWizardTheme_Transparent;
|
transparentTheme = R.style.SetupWizardTheme_Transparent;
|
||||||
}
|
}
|
||||||
return wifiDialogTheme;
|
return transparentTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void copySetupExtras(Intent fromIntent, Intent toIntent) {
|
public static void copySetupExtras(Intent fromIntent, Intent toIntent) {
|
||||||
|
@@ -31,6 +31,9 @@ import org.robolectric.RobolectricTestRunner;
|
|||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class SetupWizardUtilsTest {
|
public class SetupWizardUtilsTest {
|
||||||
|
|
||||||
|
private static final String EXTRA_IS_SETUP_FLOW = "isSetupFlow";
|
||||||
|
private static final String EXTRA_IS_FIRST_RUN = "firstRun";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCopySetupExtras() {
|
public void testCopySetupExtras() {
|
||||||
Intent fromIntent = new Intent();
|
Intent fromIntent = new Intent();
|
||||||
@@ -48,7 +51,7 @@ public class SetupWizardUtilsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetTheme_withIntentExtra_shouldReturnExtraTheme() {
|
public void testGetTheme_withIntentExtra_shouldReturnExtraTheme() {
|
||||||
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF);
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF);
|
||||||
Intent intent = new Intent();
|
Intent intent = createSetupWizardIntent();
|
||||||
intent.putExtra(WizardManagerHelper.EXTRA_THEME, ThemeHelper.THEME_GLIF_V2);
|
intent.putExtra(WizardManagerHelper.EXTRA_THEME, ThemeHelper.THEME_GLIF_V2);
|
||||||
|
|
||||||
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV2Theme);
|
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV2Theme);
|
||||||
@@ -57,7 +60,7 @@ public class SetupWizardUtilsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetTheme_withEmptyIntent_shouldReturnSystemProperty() {
|
public void testGetTheme_withEmptyIntent_shouldReturnSystemProperty() {
|
||||||
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V2_LIGHT);
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V2_LIGHT);
|
||||||
Intent intent = new Intent();
|
Intent intent = createSetupWizardIntent();
|
||||||
|
|
||||||
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV2Theme_Light);
|
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV2Theme_Light);
|
||||||
}
|
}
|
||||||
@@ -65,10 +68,26 @@ public class SetupWizardUtilsTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testGetTheme_glifV3Light_shouldReturnThemeResource() {
|
public void testGetTheme_glifV3Light_shouldReturnThemeResource() {
|
||||||
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V3_LIGHT);
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V3_LIGHT);
|
||||||
Intent intent = new Intent();
|
Intent intent = createSetupWizardIntent();
|
||||||
|
|
||||||
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV3Theme_Light);
|
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV3Theme_Light);
|
||||||
assertThat(SetupWizardUtils.getTransparentTheme(intent))
|
assertThat(SetupWizardUtils.getTransparentTheme(intent))
|
||||||
.isEqualTo(R.style.GlifV3Theme_Light_Transparent);
|
.isEqualTo(R.style.GlifV3Theme_Light_Transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetTheme_nonSuw_shouldReturnDayNightTheme() {
|
||||||
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V3_LIGHT);
|
||||||
|
Intent intent = new Intent();
|
||||||
|
|
||||||
|
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV3Theme);
|
||||||
|
assertThat(SetupWizardUtils.getTransparentTheme(intent))
|
||||||
|
.isEqualTo(R.style.GlifV3Theme_Transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Intent createSetupWizardIntent() {
|
||||||
|
return new Intent()
|
||||||
|
.putExtra(EXTRA_IS_SETUP_FLOW, true)
|
||||||
|
.putExtra(EXTRA_IS_FIRST_RUN, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user