mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
api33: prefer color-scheme over setForceDark()
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
html {
|
||||
color-scheme: dark light;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ public class ConnectivityActivity extends WebViewActivity implements DcEventCent
|
||||
}
|
||||
|
||||
private void refresh() {
|
||||
String connectivityHtml = DcHelper.getContext(this).getConnectivityHtml();
|
||||
final String connectivityHtml = DcHelper.getContext(this).getConnectivityHtml()
|
||||
.replace("</style>", " html { color-scheme: dark light; }</style>");
|
||||
webView.loadDataWithBaseURL(null, connectivityHtml, "text/html", "utf-8", null);
|
||||
}
|
||||
|
||||
|
||||
@@ -133,9 +133,10 @@ public class WebViewActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
|
||||
protected void setForceDark() {
|
||||
if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
|
||||
if (Build.VERSION.SDK_INT <= 32 && WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
|
||||
// needed for older API (tested on android7) that do not set `color-scheme` without the following hint
|
||||
WebSettingsCompat.setForceDark(webView.getSettings(),
|
||||
DynamicTheme.isDarkTheme(this) ? WebSettingsCompat.FORCE_DARK_ON : WebSettingsCompat.FORCE_DARK_OFF);
|
||||
DynamicTheme.isDarkTheme(this) ? WebSettingsCompat.FORCE_DARK_ON : WebSettingsCompat.FORCE_DARK_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user