Skip to content

Commit

Permalink
second attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
Okuro3499 committed Dec 5, 2024
1 parent 07bd526 commit fe4fddc
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import android.util.Log
import android.view.View
import android.webkit.CookieManager
import android.webkit.WebChromeClient
import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.appcompat.app.AppCompatActivity
import org.ole.planet.myplanet.databinding.ActivityWebViewBinding
import org.ole.planet.myplanet.utilities.Utilities

class WebViewActivity : AppCompatActivity() {
private lateinit var activityWebViewBinding: ActivityWebViewBinding
Expand All @@ -34,13 +36,25 @@ class WebViewActivity : AppCompatActivity() {
activityWebViewBinding.contentWebView.pBar.max = 100
activityWebViewBinding.contentWebView.pBar.progress = 0
setListeners()
activityWebViewBinding.contentWebView.wv.settings.javaScriptEnabled = true
activityWebViewBinding.contentWebView.wv.settings.javaScriptCanOpenWindowsAutomatically = true
activityWebViewBinding.contentWebView.wv.loadUrl(link)
activityWebViewBinding.contentWebView.wv.settings.apply {
javaScriptEnabled = true
domStorageEnabled = true
javaScriptCanOpenWindowsAutomatically = true
mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
setSupportZoom(true)
builtInZoomControls = true
}

val headers = mapOf("Authorization" to Utilities.header)

// activityWebViewBinding.contentWebView.wv.settings.javaScriptEnabled = true
// activityWebViewBinding.contentWebView.wv.settings.javaScriptCanOpenWindowsAutomatically = true
activityWebViewBinding.contentWebView.wv.loadUrl(link, headers)
activityWebViewBinding.contentWebView.finish.setOnClickListener { finish() }
setWebClient()
}


private fun setWebClient() {
activityWebViewBinding.contentWebView.wv.webViewClient = object : WebViewClient() {
override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
Expand All @@ -64,7 +78,6 @@ class WebViewActivity : AppCompatActivity() {
cookieManager.flush()
}


private fun setListeners() {
activityWebViewBinding.contentWebView.wv.webChromeClient = object : WebChromeClient() {
override fun onProgressChanged(view: WebView, newProgress: Int) {
Expand All @@ -84,4 +97,5 @@ class WebViewActivity : AppCompatActivity() {
}
}
}

}

0 comments on commit fe4fddc

Please sign in to comment.