diff --git a/core/src/main/java/org/openedx/core/extension/ViewExt.kt b/core/src/main/java/org/openedx/core/extension/ViewExt.kt index ebd007d3d..8d4fda03b 100644 --- a/core/src/main/java/org/openedx/core/extension/ViewExt.kt +++ b/core/src/main/java/org/openedx/core/extension/ViewExt.kt @@ -3,7 +3,6 @@ package org.openedx.core.extension import android.content.Context import android.content.res.Resources import android.graphics.Rect -import android.os.Build import android.util.DisplayMetrics import android.view.View import android.view.ViewGroup @@ -66,23 +65,11 @@ fun WebView.loadUrl(url: String, scope: CoroutineScope, cookieManager: AppCookie } fun WebView.applyDarkModeIfEnabled(isDarkTheme: Boolean) { - if (isDarkTheme && WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - settings.setAlgorithmicDarkeningAllowed(true) - } else { - // Switch WebView to dark mode; uses default dark theme - if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) { - WebSettingsCompat.setForceDark( - settings, - WebSettingsCompat.FORCE_DARK_ON - ) - } - if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) { - WebSettingsCompat.setForceDarkStrategy( - settings, - WebSettingsCompat.DARK_STRATEGY_PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING - ) - } + if (isDarkTheme && WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) { + try { + WebSettingsCompat.setAlgorithmicDarkeningAllowed(settings, true) + } catch (e: Exception) { + e.printStackTrace() } } }