capawesome-team / capacitor-android-dark-mode-support Goto Github PK
View Code? Open in Web Editor NEW⚡️ Capacitor plugin to support dark mode on Android.
License: MIT License
⚡️ Capacitor plugin to support dark mode on Android.
License: MIT License
Is your feature request related to a problem? Please describe:
As stated in readme, Capacitor v4 supports dark mode on Android - however it doesn't work for WebView versions lower than ~ v100.
At the same time, Capacitor v4 supports Android WebView 60+
Describe the solution you'd like:
src/main/java/dev/robingenz/capacitor/androiddarkmodesupport.java
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) {
- WebSettingsCompat.setForceDarkStrategy(settings, WebSettingsCompat.WEB_THEME_DARKENING_ONLY);
+ WebSettingsCompat.setForceDarkStrategy(settings, WebSettingsCompat.DARK_STRATEGY_WEB_THEME_DARKENING_ONLY);
}
Describe alternatives you've considered:
I've tried @aparajita/capacitor-dark-mode however it's not a straight forward drop-in solution as this plugin is
Additional context:
Some of related issues:
Plugin version:
1.0.1
Platform(s):
Android
Current behavior:
Gradle build fails because a constant is not recognized
Expected behavior:
It should build
Steps to reproduce:
Try to build the app
Related code:
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) {
WebSettingsCompat.setForceDarkStrategy(settings, WebSettingsCompat.WEB_THEME_DARKENING_ONLY);
}
Other information:
Error log:
WebSettingsCompat.setForceDarkStrategy(settings, WebSettingsCompat.WEB_THEME_DARKENING_ONLY);
^
symbol: variable WEB_THEME_DARKENING_ONLY
location: class WebSettingsCompat
I think it might be replaced with
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) {
WebSettingsCompat.setForceDarkStrategy(settings, WebSettingsCompat.DARK_STRATEGY_WEB_THEME_DARKENING_ONLY);
}
Capacitor doctor:
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 4.3.0
@capacitor/core: 4.3.0
@capacitor/android: 4.3.0
@capacitor/ios: 4.3.0
Installed Dependencies:
@capacitor/cli: 4.0.1
@capacitor/android: 4.0.0
@capacitor/core: 4.0.0
@capacitor/ios: 4.0.1
[success] iOS looking great! 👌
[success] Android looking great! 👌
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.