Status Update
Comments
ze...@google.com <ze...@google.com> #2
Are there many use cases for this? The current logic works fine with dark mode of platform, appcompat, and Compose.
ke...@gmail.com <ke...@gmail.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.
ze...@google.com <ze...@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.
ke...@gmail.com <ke...@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
ze...@google.com <ze...@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.
ke...@gmail.com <ke...@gmail.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
ze...@google.com <ze...@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
ke...@gmail.com <ke...@gmail.com> #9
Here is the jar file
ze...@google.com <ze...@google.com> #10
Specifically this comes from code of the form:
class A {
public void m(int i) {
if (i > 0)
invoke-special A.m(i - 1);
}
}
It is not possible to write the above method in Java source code and the DEX file format has no equivalent instruction that would preserve the same semantics as on the JVM.
I verified that this issue is also in the non-jetified je-18.3.12 jar as obtained from:
It appears that the library is doing some code generation/transformation and generating these invokes-special instructions as part of that. It may be that the library provider would be willing to change the generation if you filed an issue in their project. If you file an issue do link to this bug and post the issue you filed so we are sure to track their resolution.
Changing the issue to a feature request.
(Internal only link to bug/feature request for full invoke-special support:
ap...@google.com <ap...@google.com> #11
Branch: master
commit e096047f0a211e3cd6fef02135e8f723b4db0ac6
Author: Ian Zerny <zerny@google.com>
Date: Thu Jun 11 19:53:38 2020
Update unsupported invoke-special test.
Bug: 157969878
Bug: 110175213
Change-Id: I008a6cb98685ba9b9121e5f325aaeda6a41cc0bf
M src/main/java/com/android/tools/r8/cf/code/CfInvoke.java
D src/test/java/com/android/tools/r8/graph/invokespecial/InvokeSpecialTest.java
A src/test/java/com/android/tools/r8/graph/invokespecial/InvokeSpecialToVirtualMethodTest.java
D src/test/java/com/android/tools/r8/graph/invokespecial/Main.java
D src/test/java/com/android/tools/r8/graph/invokespecial/TestClass.java
D src/test/java/com/android/tools/r8/graph/invokespecial/TestClassDump.java
ze...@google.com <ze...@google.com>
mk...@google.com <mk...@google.com>
ap...@google.com <ap...@google.com> #13
Branch: master
commit b9c2b836ed9057749737ac4bb81c09ac64079d22
Author: Clément Béra <clementbera@google.com>
Date: Fri Dec 11 08:23:47 2020
Introduce invoke-special bridges in D8
Bug: 110175213
Bug: 157969878
Change-Id: Id4b540a7232e6769d1be016b93934d26e3295cec
M src/main/java/com/android/tools/r8/cf/code/CfInvoke.java
M src/main/java/com/android/tools/r8/graph/AppView.java
M src/main/java/com/android/tools/r8/graph/DexEncodedMethod.java
M src/main/java/com/android/tools/r8/graph/DexProgramClass.java
M src/main/java/com/android/tools/r8/ir/conversion/IRBuilder.java
M src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java
A src/main/java/com/android/tools/r8/ir/desugar/InvokeSpecialBridgeSynthesizer.java
M src/main/java/com/android/tools/r8/utils/InternalOptions.java
M src/test/java/com/android/tools/r8/graph/invokespecial/InvokeSpecialOnSameClassTest.java
M src/test/java/com/android/tools/r8/graph/invokespecial/InvokeSpecialSuperVirtualTest.java
M src/test/java/com/android/tools/r8/graph/invokespecial/InvokeSpecialToVirtualMethodTest.java
M src/test/java/com/android/tools/r8/jasmin/InvokeSpecialTests.java
ap...@google.com <ap...@google.com> #14
Branch: master
commit 7bb0bd161422b03d47bf5706c1c3213cc78e908d
Author: Clément Béra <clementbera@google.com>
Date: Fri Dec 11 12:58:57 2020
R8 support for invoke-special to same class
Bug: 110175213
Bug: 157969878
Change-Id: Idd60882abff91f767e08bb3b58cc20ea130f9804
M src/main/java/com/android/tools/r8/cf/code/CfInvoke.java
M src/main/java/com/android/tools/r8/graph/AppView.java
M src/main/java/com/android/tools/r8/graph/DexEncodedMethod.java
M src/main/java/com/android/tools/r8/ir/conversion/IRConverter.java
M src/main/java/com/android/tools/r8/ir/desugar/InvokeSpecialBridgeSynthesizer.java
M src/main/java/com/android/tools/r8/shaking/Enqueuer.java
M src/test/java/com/android/tools/r8/graph/invokespecial/InvokeSpecialOnSameClassTest.java
M src/test/java/com/android/tools/r8/graph/invokespecial/InvokeSpecialSuperVirtualTest.java
M src/test/java/com/android/tools/r8/graph/invokespecial/InvokeSpecialToVirtualMethodTest.java
Description
Tried to upgrade the gradle plugin of my proect from 3.6 to 4.0, now I get this issuecom.android.tools.r8.errors.a: Failed to compile unsupported use of invokespecial
I wonder what might be the cause.
Edit: Digging further, I found the failure occurs when it tries to transform this artefact, com.sleepycat:je:4.1.10