Skip to content

Commit

Permalink
Use Material3 switch for settings.
Browse files Browse the repository at this point in the history
Part of #1586.
  • Loading branch information
dennisguse committed Dec 28, 2023
1 parent db8f1ef commit 7ac75aa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/res/layout/view_preference_switch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<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" />
6 changes: 6 additions & 0 deletions src/main/res/values-night/themes_custom.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
<resources xmlns:android="http://schemas.android.com/apk/res/android">

<style name="ThemeCustom" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Material3 tech documentation; https://github.com/material-components/material-components-android/blob/master/docs/components/ -->

<item name="colorPrimary">@color/opentracks</item>
<item name="colorSecondary">@color/opentracks</item>

<!-- Material3 https://github.com/material-components/material-components-android/issues/2828#issuecomment-1187563903 -->
<item name="switchPreferenceCompatStyle">@style/MaterialSwitchPreferenceCompat</item>

<item name="android:statusBarColor">@color/oled_friendly</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:navigationBarColor">@color/oled_friendly</item>


<item name="bottomAppBarStyle">@style/Widget.OpenTracks.BottomAppBar</item>
<item name="floatingActionButtonStyle">@style/Widget.OpenTracks.FloatingActionButton</item>

Expand Down
6 changes: 6 additions & 0 deletions src/main/res/values/themes_custom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ limitations under the License.
<item name="colorPrimary">@color/opentracks</item>
<item name="colorSecondary">@color/opentracks</item>

<!-- Material3 https://github.com/material-components/material-components-android/issues/2828#issuecomment-1187563903 -->
<item name="switchPreferenceCompatStyle">@style/MaterialSwitchPreferenceCompat</item>

<item name="android:statusBarColor">?attr/colorSurfaceBright</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:navigationBarColor">?attr/colorSurfaceContainer</item>
Expand Down Expand Up @@ -49,4 +52,7 @@ limitations under the License.
<item name="fabCustomSize">64dp</item>
</style>

<style name="MaterialSwitchPreferenceCompat" parent="@style/Preference.SwitchPreferenceCompat.Material">
<item name="widgetLayout">@layout/view_preference_switch</item>
</style>
</resources>

0 comments on commit 7ac75aa

Please sign in to comment.