Skip to content

Commit

Permalink
fix dialog background colors (#4864)
Browse files Browse the repository at this point in the history
In #4851 I changed the theme of
`AccountsInListFragment`, which accidentally turned its background white
for the dark theme.

Additionally this fixes the color for the preference dialogs, which I
think have been incorrect since the Material3 redesign.

I also wondered if we should make dialogs darker for the black theme,
but looks like there is not much interest in that
https://chaos.social/deck/@ConnyDuck/113802937491059461
(Currently they are just the same as the dark theme)
  • Loading branch information
connyduck committed Jan 16, 2025
1 parent 5aaf885 commit a24c471
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class AccountsInListFragment : DialogFragment() {
viewModel.load(listId)
}

override fun getTheme() = R.style.TuskyDialogOverlay
override fun getTheme() = R.style.TuskyDialogFragment

override fun onStart() {
super.onStart()
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/dialog_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetLeft="16dp"
android:insetTop="16dp"
android:insetRight="16dp"
android:insetBottom="16dp">
<shape android:shape="rectangle">
<corners android:radius="?attr/dialogCornerRadius" />
<solid android:color="@color/colorBackground" />
</shape>
</inset>
20 changes: 15 additions & 5 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@
<item name="snackbarButtonStyle">@style/TuskyButton.TextButton</item>

<!-- for dialogs created with MaterialALertDialogBuilder -->
<item name="materialAlertDialogTheme">@style/TuskyDialogOverlay</item>
<item name="materialAlertDialogTheme">@style/TuskyMaterialDialogOverlay</item>
<!-- for dialogs opened from preferences -->
<item name="alertDialogTheme">@style/TuskyDialogOverlay</item>
<item name="alertDialogTheme">@style/TuskyAlertDialog</item>
<item name="dialogCornerRadius">16dp</item>

<item name="materialTimePickerTheme">@style/TuskyTimePickerOverlay</item>
Expand Down Expand Up @@ -146,12 +146,22 @@
<item name="android:colorControlNormal">@color/white</item>
</style>

<style name="TuskyDialogOverlay" parent="@style/ThemeOverlay.Material3.MaterialAlertDialog">
<item name="alertDialogStyle">@style/TuskyDialog</item>
<style name="TuskyDialogFragment" parent="@style/ThemeOverlay.Material3.Dialog">
<item name="android:windowBackground">@drawable/dialog_background</item>
<item name="android:backgroundDimAmount">0.5</item>
</style>

<style name="TuskyDialog" parent="@style/MaterialAlertDialog.Material3">
<style name="TuskyAlertDialog" parent="@style/ThemeOverlay.Material3.Dialog.Alert">
<item name="android:windowBackground">@drawable/dialog_background</item>
<item name="android:backgroundDimAmount">0.5</item>
</style>

<style name="TuskyMaterialDialogOverlay" parent="@style/ThemeOverlay.Material3.MaterialAlertDialog">
<item name="alertDialogStyle">@style/TuskyMaterialDialog</item>
<item name="android:backgroundDimAmount">0.5</item>
</style>

<style name="TuskyMaterialDialog" parent="@style/MaterialAlertDialog.Material3">
<item name="shapeAppearance">@style/ShapeAppearance.Material3.Corner.Large</item>
<item name="backgroundTint">@color/colorBackground</item>
</style>
Expand Down

0 comments on commit a24c471

Please sign in to comment.