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

Commit 214015eb authored by Edgar Wang's avatar Edgar Wang Committed by Android (Google) Code Review
Browse files

Merge "[Expressive design] Apply expressive design to Settings" into main

parents f0e88a2b b2ada5df
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2024 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->

<!-- This file only contains custom attribute and style definition for preferences -->
<!-- Things unrelated to preference framework UI customization should go to other styles files -->
<resources>

    <style name="SettingsPreferenceTheme.Expressive" parent="@style/PreferenceTheme.SettingsLib.Expressive">
        <item name="apnPreferenceStyle">@style/ApnPreference</item>
        <item name="cardPreferenceStyle">@style/CardPreference</item>
        <item name="slicePreferenceStyle">@style/SlicePreference</item>
        <item name="seekBarPreferenceStyle">@style/SettingsSeekBarPreference</item>
        <item name="twoStateButtonPreferenceStyle">@style/TwoStateButtonPreference</item>
        <item name="preferenceFragmentCompatStyle">@style/SettingsPreferenceFragmentStyle</item>
    </style>
</resources>
+88 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2024 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<resources
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android">
    <style name="Theme.Settings.Expressive" parent="Theme.SettingsBase.Expressive">
        <item name="android:clipToPadding">false</item>
        <item name="android:clipChildren">false</item>
        <item name="preferenceTheme">@style/SettingsPreferenceTheme.Expressive</item>
        <item name="android:listPreferredItemHeight">72dip</item>
        <item name="android:homeAsUpIndicator">@drawable/ic_arrow_back</item>
        <item name="android:navigationBarColor">@android:color/transparent</item>
        <item name="android:datePickerDialogTheme">@style/PickerDialogTheme.Settings</item>

        <item name="fingerprint_layout_theme">@style/FingerprintLayoutTheme</item>
        <item name="face_layout_theme">@style/FaceLayoutTheme</item>
        <item name="ic_menu_moreoverflow">@*android:drawable/ic_menu_moreoverflow_holo_dark</item>

        <!-- For edge-to-edge -->
        <item name="android:navigationBarColor">@android:color/transparent</item>
        <item name="android:statusBarColor">@android:color/transparent</item>

        <!-- For wifi icon -->
        <item name="wifi_signal">@drawable/wifi_signal</item>
        <item name="wifi_signal_color">?android:attr/colorAccent</item>
        <item name="wifi_friction">@drawable/wifi_friction</item>

        <item name="side_margin">0dp</item>
        <item name="sudListItemIconColor">?android:attr/colorAccent</item>

        <!-- Redefine the ActionBar style for contentInsetStart -->
        <item name="android:actionBarStyle">@style/Widget.ActionBar</item>

        <item name="preferenceBackgroundColor">@drawable/preference_background</item>

        <!-- For AndroidX AlertDialog -->
        <item name="alertDialogTheme">@style/Theme.AlertDialog</item>

        <item name="*android:lockPatternStyle">@style/LockPatternStyle</item>

        <!-- For AppBarLayout -->
        <item name="colorPrimary">@*android:color/primary_device_default_settings_light</item>
        <item name="colorPrimaryVariant">@android:color/white</item>

        <!-- For slice view in settings -->
        <item name="sliceViewStyle">@style/Widget.SliceView.Settings</item>

        <item name="notification_importance_button_background_color_unselected">@android:color/transparent</item>
        <item name="notification_importance_button_border_color_unselected">?androidprv:attr/materialColorOutlineVariant</item>
        <item name="notification_importance_button_foreground_color_unselected">?androidprv:attr/materialColorOnSurfaceVariant</item>

        <item name="notification_importance_button_background_color_selected">?androidprv:attr/materialColorSecondaryContainer</item>
        <item name="notification_importance_button_border_color_selected">?androidprv:attr/materialColorOnSecondaryContainer</item>
        <item name="notification_importance_button_foreground_color_selected">?androidprv:attr/materialColorOnSecondaryContainer</item>

        <!-- For AppCompat widgets, e.g. TextInputLayout -->
        <item name="colorAccent">?android:attr/colorAccent</item>
    </style>

    <style name="Theme.Settings.Expressive.NoActionBar">
        <item name="android:windowActionBar">false</item>
        <item name="android:windowNoTitle">true</item>
        <item name="colorSurface">@color/settingslib_colorSurface</item>
    </style>

    <style name="Theme.SubSettings.Expressive.Base" parent="Theme.Settings.Expressive.NoActionBar">
        <!-- Redefine the ActionBar style for contentInsetStart -->
        <item name="android:actionBarStyle">@style/Widget.ActionBar.SubSettings</item>

        <item name="android:navigationBarColor">@android:color/transparent</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
    </style>

    <style name="Theme.SubSettings.Expressive" parent="Theme.SubSettings.Expressive.Base"/>
</resources>
+10 −1
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import com.android.settings.widget.SettingsMainSwitchBar;
import com.android.settingslib.core.instrumentation.Instrumentable;
import com.android.settingslib.core.instrumentation.SharedPreferencesLogger;
import com.android.settingslib.drawer.DashboardCategory;
import com.android.settingslib.widget.SettingsThemeHelper;

import com.google.android.setupcompat.util.WizardManagerHelper;

@@ -169,6 +170,9 @@ public class SettingsActivity extends SettingsBaseActivity

    private static final String EXTRA_UI_OPTIONS = "settings:ui_options";

    private static final int EXPRESSIVE_BACK_ICON =
            com.android.settingslib.collapsingtoolbar.R.drawable.settingslib_expressive_icon_back;

    private String mFragmentClass;
    private String mHighlightMenuKey;

@@ -301,7 +305,9 @@ public class SettingsActivity extends SettingsBaseActivity
        // If this is in setup flow, don't apply theme. Because light theme needs to be applied
        // in SettingsBaseActivity#onCreate().
        if (isSubSettings(intent) && !WizardManagerHelper.isAnySetupWizard(getIntent())) {
            setTheme(R.style.Theme_SubSettings);
            int themeId = SettingsThemeHelper.isExpressiveTheme(this)
                    ? R.style.Theme_SubSettings_Expressive : R.style.Theme_SubSettings;
            setTheme(themeId);
        }

        setContentView(R.layout.settings_main_prefs);
@@ -388,6 +394,9 @@ public class SettingsActivity extends SettingsBaseActivity
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(isActionBarButtonEnabled);
            actionBar.setHomeButtonEnabled(isActionBarButtonEnabled);
            if (SettingsThemeHelper.isExpressiveTheme(this)) {
                actionBar.setHomeAsUpIndicator(EXPRESSIVE_BACK_ICON);
            }
            actionBar.setDisplayShowTitleEnabled(true);
        }
    }
+10 −2
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.settings.Utils;
import com.android.settings.core.CategoryMixin.CategoryHandler;
import com.android.settingslib.core.lifecycle.HideNonSystemOverlayMixin;
import com.android.settingslib.transition.SettingsTransitionHelper.TransitionType;
import com.android.settingslib.widget.SettingsThemeHelper;
import com.android.window.flags.Flags;

import com.google.android.material.appbar.AppBarLayout;
@@ -68,6 +69,12 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
    private static final int DEFAULT_REQUEST = -1;
    private static final float TOOLBAR_LINE_SPACING_MULTIPLIER = 1.1f;

    private static final int EXPRESSIVE_LAYOUT_ID =
            com.android.settingslib.collapsingtoolbar.R.layout.settingslib_expressive_collapsing_toolbar_base_layout;
    private static final int COLLAPSING_LAYOUT_ID =
            com.android.settingslib.collapsingtoolbar.R.layout.collapsing_toolbar_base_layout;


    protected CategoryMixin mCategoryMixin;
    protected CollapsingToolbarLayout mCollapsingToolbarLayout;
    protected AppBarLayout mAppBarLayout;
@@ -116,8 +123,9 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
        }

        if (isToolbarEnabled() && !isAnySetupWizard) {
            super.setContentView(
                    com.android.settingslib.collapsingtoolbar.R.layout.collapsing_toolbar_base_layout);
            int resId = SettingsThemeHelper.isExpressiveTheme(getApplicationContext())
                    ? EXPRESSIVE_LAYOUT_ID : COLLAPSING_LAYOUT_ID;
            super.setContentView(resId);
            mCollapsingToolbarLayout =
                    findViewById(com.android.settingslib.collapsingtoolbar.R.id.collapsing_toolbar);
            mAppBarLayout = findViewById(R.id.app_bar);