1
0
Fork 0

the Settings screen now follows the Dynamic Color theme on Android 12 and higher

This commit is contained in:
sspanak 2025-01-09 14:31:11 +02:00
parent 28801ba95b
commit ada5261773
19 changed files with 286 additions and 63 deletions

View file

@ -9,7 +9,7 @@
<TextView
android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:labelFor="@id/input_text_input_field"
android:text="?android:title" />

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="@dimen/preference_search_height">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.search.SearchBar
android:id="@+id/search_bar"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.search.SearchView
android:id="@+id/search_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_anchor="@id/search_bar" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Derived from https://github.com/androidx/androidx/blob/8cb282cc/preference/preference/res/layout/preference_widget_switch_compat.xml -->
<!-- Thanks to https://stackoverflow.com/a/73782598 -->
<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" />

View file

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="TTheme" parent="Theme.Material3.DynamicColors.Dark">
<item name="preferenceTheme">@style/PreferenceOverlay</item>
<!-- title bar -->
<item name="tint">@color/material_dynamic_neutral90</item> <!-- back button color -->
<item name="colorOnSurface">@color/material_dynamic_neutral90</item> <!-- title text color -->
<item name="colorSurfaceContainer">@color/material_dynamic_neutral_variant30</item> <!-- title background -->
<!-- page -->
<item name="android:windowBackground">@color/material_dynamic_neutral10</item> <!-- page background -->
<item name="colorSecondary">@color/material_dynamic_primary70</item> <!-- category title -->
<item name="android:textAppearanceListItem">@style/TextAppearance.Material3.TitleLarge</item> <!-- preference title -->
<!-- <item name="android:popupMenuStyle">@style/AppDropDownStyle</item> &lt;!&ndash; dropdown background &ndash;&gt;-->
</style>
<style name="PreferenceOverlay" parent="@style/PreferenceThemeOverlay">
<item name="switchPreferenceCompatStyle">@style/AppSwitchStyle</item>
</style>
<!-- <style name="AppDropDownStyle" parent="Widget.AppCompat.ListPopupWindow">-->
<!-- <item name="android:background">@color/material_dynamic_neutral_variant30</item>-->
<!-- <item name="popupMenuBackground">@color/material_dynamic_neutral_variant30</item>-->
<!-- </style>-->
<style name="AppSwitchStyle" parent="@style/Preference.SwitchPreferenceCompat.Material">
<item name="widgetLayout">@layout/pref_switch_v31</item>
</style>
<style name="TTheme.AddWord" parent="Theme.Material3.Dark.Dialog.Alert">
<item name="windowNoTitle">true</item> <!-- hide some weird floating rectangle above the dialog -->
<item name="android:textColor">@color/material_dynamic_neutral99</item> <!-- headline (title) text color -->
<item name="android:textColorPrimary">@color/material_dynamic_neutral_variant95</item> <!-- supporting text (body text) color -->
<item name="android:background">@color/material_dynamic_neutral20</item> <!-- container background -->
<item name="colorPrimary">@color/material_dynamic_primary90</item> <!-- label text (button text) color -->
<item name="textAppearanceBodyMedium">@style/TextAppearance.AppCompat.Widget.PopupMenu.Large</item> <!-- body text size -->
<item name="textAppearanceLabelLarge">@style/TextAppearance.MaterialComponents.Button</item> <!-- button text size -->
</style>
</resources>

View file

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="TTheme" parent="Theme.Material3.DynamicColors.Light">
<item name="preferenceTheme">@style/PreferenceOverlay</item>
<!-- title bar -->
<item name="tint">@color/material_dynamic_neutral20</item> <!-- back button color -->
<item name="colorSurfaceContainer">@color/material_dynamic_neutral_variant90</item> <!-- title bar background -->
<!-- page -->
<item name="android:windowBackground">@color/material_dynamic_neutral95</item> <!-- page background -->
<item name="colorSecondary">@color/material_dynamic_primary40</item> <!-- category title -->
<item name="android:textAppearanceListItem">@style/TextAppearance.Material3.TitleLarge</item> <!-- preference title -->
<!-- <item name="android:popupWindowStyle">@style/AppDropDownStyle</item> &lt;!&ndash; dropdown background &ndash;&gt;-->
<!--
// ANY PREFERENCE
android:textColor = preference text color
android:textColorSecondary = preference summary color
// SWITCH
colorOutline = switch outline
colorSurfaceContainerHighest = switch background when off
colorPrimary = switch background when on
colorOnPrimary = switch handle color
colorPrimaryContainer = switch handle color when moving
-->
</style>
<style name="PreferenceOverlay" parent="@style/PreferenceThemeOverlay">
<item name="switchPreferenceCompatStyle">@style/AppSwitchStyle</item>
</style>
<style name="AppSwitchStyle" parent="@style/Preference.SwitchPreferenceCompat.Material">
<item name="widgetLayout">@layout/pref_switch_v31</item>
</style>
<!-- <style name="AppDropDownStyle" parent="Widget.Material3.PopupMenu.ListPopupWindow">-->
<!-- <item name="android:background">@color/material_dynamic_neutral_variant90</item>-->
<!-- <item name="popupMenuBackground">@color/material_dynamic_neutral_variant90</item>-->
<!-- </style>-->
<style name="TTheme.AddWord" parent="Theme.Material3.Light.Dialog.Alert">
<item name="windowNoTitle">true</item> <!-- hide some weird floating rectangle above the dialog -->
<item name="android:textColor">@color/material_dynamic_neutral10</item> <!-- headline (title) text color -->
<item name="android:textColorPrimary">@color/material_dynamic_neutral_variant10</item> <!-- supporting text (body text) color -->
<item name="android:background">@color/material_dynamic_neutral95</item> <!-- container background -->
<item name="colorPrimary">@color/material_dynamic_primary20</item> <!-- label text (button text) color -->
<item name="textAppearanceBodyMedium">@style/TextAppearance.AppCompat.Widget.PopupMenu.Large</item> <!-- body text size -->
<item name="textAppearanceLabelLarge">@style/TextAppearance.MaterialComponents.Button</item> <!-- button text size -->
</style>
</resources>

View file

@ -5,6 +5,7 @@
<dimen name="candidate_padding_horizontal">6sp</dimen>
<dimen name="preferences_text_min_height">48dp</dimen>
<dimen name="preference_search_height">72dp</dimen>
<dimen name="soft_key_height">44dp</dimen>
<dimen name="soft_key_icon_size">24sp</dimen>

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="TT9Theme" parent="Theme.AppCompat.DayNight" />
<style name="TTheme" parent="Theme.AppCompat.DayNight" />
<style name="hSeparator">
<item name="android:layout_height">match_parent</item>
@ -22,7 +22,7 @@
<item name="android:layout_width">match_parent</item>
</style>
<style name="alertDialog" parent="Theme.AppCompat.DayNight.Dialog.Alert">
<item name="android:windowBackground">@android:color/transparent</item>
<style name="TTheme.AddWord" parent="Theme.AppCompat.DayNight.Dialog.Alert">
<item name="windowNoTitle">true</item> <!-- hide some weird floating rectangle above the dialog -->
</style>
</resources>