Status Update
Comments
jb...@google.com <jb...@google.com>
ya...@google.com <ya...@google.com> #2
Are there many use cases for this? The current logic works fine with dark mode of platform, appcompat, and Compose.
va...@google.com <va...@google.com> #3
When I was trying out integrating this with Now in Android, I ran into this issue since Now in Android currently doesn't inherit from AppCompatActivity
and doesn't call AppCompatDelegate.setDefaultNightMode
, so maybe the solution is instead to inherit from AppCompatActivity
instead of just ComponentActivity
to update the underlying configuration.
ya...@google.com <ya...@google.com> #4
I just tested it with ComponentActivity. It's working fine for me. The scrim for 3-button nav and the icons are properly changed on light/dark mode switch. The extension function detect light/dark mode from resources.configuration.uiMode
which is commonly used by the platform, AppCompat, and Compose, so I don't know why it doesn't work. Can I take a look at what you tried in Now in Android.
va...@google.com <va...@google.com> #5
The theme switcher based on the user's preference within the app is handled separately from Configuration.uiMode
and isn't updating the configuration directly, so I was attempting to call enableEdgeToEdge
and manually specifying the dark and light themes.
The two options I see:
- Allow a different way of specifying for
enableEdgeToEdge
whether the app is effectively in dark mode or light mode instead of that being based just onConfiguration.uiMode
(this issue) - Switch Now in Android to use
AppCompatActivity
andAppCompatDelegate.setDefaultNightMode
so that theConfiguration.uiMode
is updated based on the user's preference
ya...@google.com <ya...@google.com> #6
I see, so it has in-app light/dark setting.
On API 31+, apps with custom in-app light/dark settings should call UiModeManager.setApplicationNightMode
enableEdgeToEdge
as well.
On API <31, it's easy if you can use AppCompatDelegate.setDefaultNightMode(int)
So, custom mode is useful for apps that:
- Provide in-app light/dark mode settings on API <31.
- Don't want to depend on appcompat
I'm not sure if it's super common, but I guess the feature is worth implementing. I'll put it during the next alpha phase.
For Now in Android, I recommend you still call setApplicationNightMode
on API 31+ regardless of enableEdgeToEdge
. On API <31, just for the time being, you can either use the current e2e implementation, hide the setting, depend on appcompat, or just bear with the minor UI glitch. None of these are great, but I don't have a good solution now.
ap...@google.com <ap...@google.com> #7
Branch: androidx-main
commit 27e7d52e8604a080133e8b842db10c89b4482598
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Apr 19 12:56:59 2023
Add SystemBarStyle.custom
Relnote: "Add an optional parameter `detectDarkMode` to SystemBarStyle.auto for detecting night mode by custom logic"
Test: androidx.activity.EdgeToEdgeTest.enableCustom
Bug: 278263793
Change-Id: I78322867ba3940939e137479383eca08efc9a2b6
M activity/activity/api/current.txt
M activity/activity/api/restricted_current.txt
M activity/activity/src/androidTest/java/androidx/activity/EdgeToEdgeTest.kt
M activity/activity/src/main/java/androidx/activity/EdgeToEdge.kt
M activity/integration-tests/testapp/src/main/java/androidx/activity/integration/testapp/EdgeToEdgeActivity.kt
M activity/integration-tests/testapp/src/main/res/layout/edge_to_edge_activity.xml
va...@google.com <va...@google.com>
ya...@google.com <ya...@google.com>
pr...@google.com <pr...@google.com> #8
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.activity:activity:1.8.0-alpha06
Description
Version used: 1.8.0-alpha03
When trying out the new `enableEdgeToEdge` method, I ran into one slightly annoying aspect.
When apps have their own theme picker for choosing dark mode and light mode, the resulting UI them (light vs dark) that the app uses may differ from the system theme, as passed down via the `Configuration`.
`enableEdgeToEdge` always looks at the system theme via the `Configuration`, so there isn't a good way to have a different source of truth for choosing whether to show a dark or light theme.
It also doesn't directly work to have an `if` statement and call `SystemBarStyle.light` or `SystemBarStyle.dark`, because those don't have the transparent behavior that `SystemBarStyle.auto` does on API 29 and above.
Maybe `enableEdgeToEdge` could take an optional lambda for `isShowingDarkTheme`, with a default implementation that uses the `Configuration`.