Skip to content

Commit

Permalink
[Catalog] Update Catalog preferences demo to use MaterialSwitch
Browse files Browse the repository at this point in the history
Related to #2828

PiperOrigin-RevId: 464830220
  • Loading branch information
dsn5ft authored and drchen committed Aug 4, 2022
1 parent 5c6f0c8 commit 229eb9d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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.
-->

<!-- Layout used by SwitchPreference for the switch widget style. This is inflated
inside android.R.layout.preference. -->
<com.google.android.material.materialswitch.MaterialSwitch
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/switchWidget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:clickable="false"
android:background="@null"/>
Expand Up @@ -17,6 +17,7 @@
<resources xmlns:tools="http://schemas.android.com/tools">

<style name="Theme.Catalog" parent="Theme.Material3.DayNight.NoActionBar">
<item name="preferenceTheme">@style/CatalogPreferenceThemeOverlay</item>
<item name="catalogToolbarStyle">@style/Widget.Catalog.Toolbar</item>
<item name="catalogToolbarWithCloseButtonStyle">@style/Widget.Catalog.Toolbar.WithCloseButton</item>
<item name="textInputSignInStyle">@style/Widget.Material3.TextInputLayout.OutlinedBox</item>
Expand All @@ -28,4 +29,12 @@
<item name="android:statusBarColor" tools:targetApi="21">@android:color/transparent</item>
</style>

<style name="CatalogPreferenceThemeOverlay" parent="PreferenceThemeOverlay">
<item name="switchPreferenceCompatStyle">@style/Preference.SwitchPreferenceCompat.Catalog</item>
</style>

<style name="Preference.SwitchPreferenceCompat.Catalog" parent="Preference.SwitchPreferenceCompat.Material">
<item name="android:widgetLayout">@layout/preference_widget_material_switch</item>
</style>

</resources>

0 comments on commit 229eb9d

Please sign in to comment.