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

Commit 3aff4b15 authored by cnchen's avatar cnchen
Browse files

Add dynamic color support

(before)https://hsv.googleplex.com/6220707954425856
(after)https://hsv.googleplex.com/6270261408038912

Bug: 209889556
Test: see the hsv above
Change-Id: Ifee0392c189dbe7210ba2561355e2c275e7cb7fe
parent f74e1195
Loading
Loading
Loading
Loading
+17 −3
Original line number Original line Diff line number Diff line
@@ -26,6 +26,8 @@ import com.android.settings.R;
import com.android.settings.SetupWizardUtils;
import com.android.settings.SetupWizardUtils;
import com.android.settings.core.InstrumentedActivity;
import com.android.settings.core.InstrumentedActivity;


import com.google.android.setupdesign.util.ThemeHelper;

public abstract class WifiDppBaseActivity extends InstrumentedActivity {
public abstract class WifiDppBaseActivity extends InstrumentedActivity {
    protected FragmentManager mFragmentManager;
    protected FragmentManager mFragmentManager;


@@ -35,6 +37,8 @@ public abstract class WifiDppBaseActivity extends InstrumentedActivity {
    protected void onCreate(Bundle savedInstanceState) {
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.onCreate(savedInstanceState);


        applyTheme();

        setContentView(R.layout.wifi_dpp_activity);
        setContentView(R.layout.wifi_dpp_activity);
        mFragmentManager = getSupportFragmentManager();
        mFragmentManager = getSupportFragmentManager();


@@ -45,8 +49,18 @@ public abstract class WifiDppBaseActivity extends InstrumentedActivity {


    @Override
    @Override
    protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
    protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
        final int new_resid = SetupWizardUtils.getTheme(this, getIntent());
        theme.applyStyle(R.style.SetupWizardPartnerResource, true);
        theme.applyStyle(R.style.SetupWizardPartnerResource, /* force */ true);
        super.onApplyThemeResource(theme, resid, first);
        super.onApplyThemeResource(theme, new_resid, first);
    }

    private void applyTheme() {
        if (ThemeHelper.trySetDynamicColor(this)) {
            final int appliedTheme = ThemeHelper.isSetupWizardDayNightEnabled(this)
                    ? R.style.SudDynamicColorThemeSettings_SetupWizard_DayNight
                    : R.style.SudDynamicColorThemeSettings_SetupWizard;
            setTheme(appliedTheme);
        } else {
            setTheme(SetupWizardUtils.getTheme(this, getIntent()));
        }
    }
    }
}
}