Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
android:label="@string/app_name"
android:theme="@style/Theme.Emptything"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:configChanges="uiMode|orientation|screenSize|screenLayout|keyboardHidden">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 Logic Error: Adding android:configChanges="uiMode|orientation|screenSize|screenLayout|keyboardHidden" prevents Activity recreation, but MainActivity.kt does not implement the required onConfigurationChanged() callback. Without this callback, the app cannot respond to theme changes, causing the WebView UI to remain in the old theme after switching between dark/light mode. The WebView dark mode logic (lines 841-854 in MainActivity.kt) only executes during WebView factory creation in onCreate(), which no longer runs on theme changes with this configuration.

Add this callback to MainActivity.kt to handle configuration changes:

override fun onConfigurationChanged(newConfig: Configuration) {
    super.onConfigurationChanged(newConfig)
    
    // Update WebView dark mode settings
    webViewInstance?.let { webView ->
        if (WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) {
            WebSettingsCompat.setAlgorithmicDarkeningAllowed(webView.settings, true)
        } else if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
            val isNightMode = (newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES
            @Suppress("DEPRECATION")
            WebSettingsCompat.setForceDark(
                webView.settings,
                if (isNightMode) WebSettingsCompat.FORCE_DARK_ON else WebSettingsCompat.FORCE_DARK_OFF
            )
        }
    }
}

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Loading