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

Commit 4e062dd1 authored by Chun-Ku Lin's avatar Chun-Ku Lin
Browse files

feat(expressive): Apply expressive theme correctly in SUW

- Expressive style persists after configuration change

Bug: 400479388
Bug: 411579174
Test: visually view the UI
Flag: com.android.settingslib.widget.theme.flags.is_expressive_design_enabled
Change-Id: I5d56f14988b151855e3d93b36ae191838560d126
parent d419986d
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -263,6 +263,14 @@
        <item name="preferenceFragmentCompatStyle">@style/SetupWizardPreferenceFragmentStyle</item>
    </style>

    <!-- This theme was applied to Settings pages which are running under SUW. -->
    <style name="SettingsPreferenceTheme.SetupWizard.Expressive" parent="PreferenceTheme.SettingsLib.Expressive">
        <item name="android:clipToPadding">true</item>
        <item name="android:clipChildren">true</item>
        <item name="preferenceTheme">@style/PreferenceTheme.SettingsLib.Expressive</item>
        <item name="preferenceFragmentCompatStyle">@style/SetupWizardPreferenceFragmentStyle</item>
    </style>

    <!-- DayNight themes -->
    <style name="GlifTheme.DayNight" parent="GlifTheme.Light" />
    <style name="GlifV2Theme.DayNight" parent="GlifV2Theme.Light" />
+9 −2
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.settings.core.SubSettingLauncher;
import com.android.settings.search.actionbar.SearchMenuController;
import com.android.settings.support.actionbar.HelpResourceProvider;
import com.android.settingslib.core.instrumentation.Instrumentable;
import com.android.settingslib.widget.SettingsThemeHelper;

import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.util.ThemeHelper;
@@ -89,15 +90,21 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit

    @Override
    protected void onCreate(Bundle savedState) {
        super.onCreate(savedState);
        // Custom theme needs to be set before any view is inflated, so that the theme would
        // apply correctly including when the configuration changes.
        applyTheme();
        super.onCreate(savedState);
        findViewById(R.id.content_parent).setFitsSystemWindows(false);
    }

    private void applyTheme() {
        final boolean isAnySetupWizard = WizardManagerHelper.isAnySetupWizard(getIntent());
        if (isAnySetupWizard) {
            if (SettingsThemeHelper.isExpressiveTheme(this)) {
                setTheme(R.style.SettingsPreferenceTheme_SetupWizard_Expressive);
            } else {
                setTheme(R.style.SettingsPreferenceTheme_SetupWizard);
            }
            ThemeHelper.trySetSuwTheme(this);
        }
    }
+12 −5
Original line number Diff line number Diff line
@@ -99,6 +99,18 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
        if (isAnySetupWizard) {
            TransitionHelper.applyForwardTransition(this);
            TransitionHelper.applyBackwardTransition(this);

            // Apply SetupWizard light theme during setup flow. This is for SubSettings pages.
            if (this instanceof SubSettings) {
                // setTheme needs to be called before inflating any views (e.g. before calling
                // super.onCreate)
                if (SettingsThemeHelper.isExpressiveTheme(this)) {
                    setTheme(R.style.SettingsPreferenceTheme_SetupWizard_Expressive);
                } else {
                    setTheme(R.style.SettingsPreferenceTheme_SetupWizard);
                }
                ThemeHelper.trySetSuwTheme(this);
            }
        }
        super.onCreate(savedInstanceState);
        if (isFinishing()) {
@@ -123,11 +135,6 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
        if (!theme.getBoolean(android.R.styleable.Theme_windowNoTitle, false)) {
            requestWindowFeature(Window.FEATURE_NO_TITLE);
        }
        // Apply SetupWizard light theme during setup flow. This is for SubSettings pages.
        if (isAnySetupWizard && this instanceof SubSettings) {
            setTheme(R.style.SettingsPreferenceTheme_SetupWizard);
            ThemeHelper.trySetSuwTheme(this);
        }

        if (isToolbarEnabled() && !isAnySetupWizard) {
            int resId = SettingsThemeHelper.isExpressiveTheme(getApplicationContext())