@@ -28,17 +28,17 @@ class MainActivity : Activity() {
2828 @SuppressLint(" SetJavaScriptEnabled" )
2929 override fun onCreate (savedInstanceState : Bundle ? ) {
3030 super .onCreate(savedInstanceState)
31-
32- webView = WebView (this ).apply {
33- layoutParams = android.view.ViewGroup .LayoutParams (
34- android.view.ViewGroup .LayoutParams .MATCH_PARENT ,
35- android.view.ViewGroup .LayoutParams .MATCH_PARENT
36- )
37-
31+
32+ // Use XML layout with fitsSystemWindows
33+ setContentView(R .layout.activity_main)
34+
35+ // Find WebView from layout
36+ webView = findViewById(R .id.webview)
37+
38+ webView.apply {
3839 settings.apply {
3940 javaScriptEnabled = true
4041 domStorageEnabled = true
41- databaseEnabled = true
4242 setSupportZoom(true )
4343 builtInZoomControls = true
4444 displayZoomControls = false
@@ -147,8 +147,7 @@ class MainActivity : Activity() {
147147
148148 val urlToLoad = intent?.dataString ? : " https://chatgpt.com"
149149 webView.loadUrl(urlToLoad)
150-
151- setContentView(webView)
150+
152151 applySystemTheme()
153152 }
154153
@@ -226,6 +225,7 @@ class MainActivity : Activity() {
226225 * Dark mode: #212121 background, white icons
227226 * Light mode: #ffffff background, dark icons
228227 */
228+ @Suppress(" DEPRECATION" )
229229 private fun applySystemTheme () {
230230 val isDarkMode = (resources.configuration.uiMode and
231231 Configuration .UI_MODE_NIGHT_MASK ) == Configuration .UI_MODE_NIGHT_YES
0 commit comments