Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d426032 authored by Maurice Lam's avatar Maurice Lam Committed by Android (Google) Code Review
Browse files

Merge "Fix dark theme for screen lock settings"

parents 48fc863a 7ccbf693
Loading
Loading
Loading
Loading
+37 −21
Original line number Diff line number Diff line
@@ -30,7 +30,10 @@ public class SetupWizardUtils {
        if (theme == null) {
            theme = SetupWizardProperties.theme().orElse("");
        }
        // TODO(yukl): Move to ThemeResolver and add any additional required attributes in
        // onApplyThemeResource using Theme overlays
        if (theme != null) {
            if (WizardManagerHelper.isAnySetupWizard(intent)) {
                switch (theme) {
                    case ThemeHelper.THEME_GLIF_V3_LIGHT:
                        return R.style.GlifV3Theme_Light;
@@ -45,25 +48,38 @@ public class SetupWizardUtils {
                    case ThemeHelper.THEME_GLIF:
                        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) {
        final int suwTheme = getTheme(intent);
        int wifiDialogTheme = R.style.GlifV2Theme_Light_Transparent;
        int transparentTheme = R.style.GlifV2Theme_Light_Transparent;
        if (suwTheme == R.style.GlifV3Theme) {
            wifiDialogTheme = R.style.GlifV3Theme_Transparent;
            transparentTheme = R.style.GlifV3Theme_Transparent;
        } 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) {
            wifiDialogTheme = R.style.GlifV2Theme_Transparent;
            transparentTheme = R.style.GlifV2Theme_Transparent;
        } 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) {
            wifiDialogTheme = R.style.SetupWizardTheme_Transparent;
            transparentTheme = R.style.SetupWizardTheme_Transparent;
        }
        return wifiDialogTheme;
        return transparentTheme;
    }

    public static void copySetupExtras(Intent fromIntent, Intent toIntent) {
+22 −3
Original line number Diff line number Diff line
@@ -31,6 +31,9 @@ import org.robolectric.RobolectricTestRunner;
@RunWith(RobolectricTestRunner.class)
public class SetupWizardUtilsTest {

    private static final String EXTRA_IS_SETUP_FLOW = "isSetupFlow";
    private static final String EXTRA_IS_FIRST_RUN = "firstRun";

    @Test
    public void testCopySetupExtras() {
        Intent fromIntent = new Intent();
@@ -48,7 +51,7 @@ public class SetupWizardUtilsTest {
    @Test
    public void testGetTheme_withIntentExtra_shouldReturnExtraTheme() {
        SetupWizardProperties.theme(ThemeHelper.THEME_GLIF);
        Intent intent = new Intent();
        Intent intent = createSetupWizardIntent();
        intent.putExtra(WizardManagerHelper.EXTRA_THEME, ThemeHelper.THEME_GLIF_V2);

        assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV2Theme);
@@ -57,7 +60,7 @@ public class SetupWizardUtilsTest {
    @Test
    public void testGetTheme_withEmptyIntent_shouldReturnSystemProperty() {
        SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V2_LIGHT);
        Intent intent = new Intent();
        Intent intent = createSetupWizardIntent();

        assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV2Theme_Light);
    }
@@ -65,10 +68,26 @@ public class SetupWizardUtilsTest {
    @Test
    public void testGetTheme_glifV3Light_shouldReturnThemeResource() {
        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.getTransparentTheme(intent))
                .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);
    }
}