/*
- * Copyright © 2021-2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2021-2022 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Cell <https://www.stoutner.com/privacy-cell>.
*
import android.app.Dialog
import android.content.Intent
-import android.content.res.Configuration
import android.os.Bundle
import android.webkit.WebResourceRequest
import android.webkit.WebResourceResponse
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
-import androidx.webkit.WebSettingsCompat
import androidx.webkit.WebViewAssetLoader
-import androidx.webkit.WebViewFeature
import com.stoutner.privacycell.R
// Get a handle for the WebView.
webView = alertDialog.findViewById(R.id.webview)!!
- // Get the current theme status.
- val currentThemeStatus = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
-
- // Check to see if the app is in night mode.
- if (currentThemeStatus == Configuration.UI_MODE_NIGHT_YES && WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) { // The app is in night mode.
- // Apply the dark WebView theme.
- WebSettingsCompat.setForceDark(webView.settings, WebSettingsCompat.FORCE_DARK_ON)
- }
-
// Create a WebView asset loader.
val webViewAssetLoader = WebViewAssetLoader.Builder().addPathHandler("/assets/", WebViewAssetLoader.AssetsPathHandler(requireContext())).build()
// Save the scroll position.
savedInstanceState.putInt(SCROLL_Y, webView.scrollY)
}
-}
\ No newline at end of file
+}