Status Update
Comments
jb...@google.com <jb...@google.com>
ap...@google.com <ap...@google.com> #2
Are there many use cases for this? The current logic works fine with dark mode of platform, appcompat, and Compose.
pr...@google.com <pr...@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.
ty...@gmail.com <ty...@gmail.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.
dr...@gmail.com <dr...@gmail.com>
lb...@gmail.com <lb...@gmail.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
Description
Version used: 1.7.0
Devices/Android versions reproduced on: API 33
If this is a bug in the library, we would appreciate if you could attach:
Example project attached
Description:
It appears that ComponentActivity$ReportFullyDrawnExecutorApi16Impl.this$0 leaks memory when used in an ActivityScenario if the ActivityScenario is used to recreate the Activity soon after the Activity has been launched.
Reproduction steps:
1. Create an Activity that extends ComponentActivity
2. Set a content view for the Activity in the onCreate using either setContentView(View) or setContent { <Composable> }
3. Create an instrumented test that uses LeakCanary's DetectLeaksAfterTestSuccess Test Rule
4. In the test: Launch the Activity using ActivityScenario, and then call "recreate" on the ActivityScenario
5a. Expected result: The test launches the Activity, recreates it, and the test passes.
5b. Actual result: The test launches the Activity, recreates it, and then LeakCanary detects a memory leak from ComponentActivity$ReportFullyDrawnExecutorApi16Impl.this$0 leaking an instance of the Activity.
This issue does not occur for ComponentActivity instance that do not set a content view in onCreate, and does not occur for regular android.app.Activity instances.
I have attached an example project with eight instrumented tests that show case this issue. In the ExampleInstrumentedTest.kt tests `launchExampleViewActivityAndRecreate` and `launchExampleComposeActivityAndRecreate` both fail, and all other tests succeed. The expected behaviour is that all tests should pass.