Skip to content

Commit

Permalink
Merge pull request #14 from FinTecSystems/fix-webview-loading
Browse files Browse the repository at this point in the history
Fix webview loading
  • Loading branch information
maik-mursall authored Jun 14, 2023
2 parents ae98335 + 7fead2b commit 307d7b0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
GROUP=com.fintecsystems
VERSION_NAME=5.1.0
VERSION_NAME=5.1.1
POM_URL=https://github.com/FinTecSystems/xs2a-android
POM_SCM_URL=[email protected]:FinTecSystems/xs2a-android.git
POM_SCM_CONNECTION=scm:git:[email protected]:FinTecSystems/xs2a-android.git
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@ class XS2AWizardViewModel(
* Returns true if a back button is present on the current form.
*/
@Suppress("MemberVisibilityCanBePrivate")
fun backButtonIsPresent() =
form.value?.any { it is SubmitLineData && !it.backLabel.isNullOrEmpty() } ?: false
fun backButtonIsPresent() = form.value?.any {
(it is SubmitLineData && !it.backLabel.isNullOrEmpty())
|| (it is RedirectLineData && !it.backLabel.isNullOrEmpty())
} ?: false

/**
* Returns true, if network requests should abort.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package com.fintecsystems.xs2awizard.components.webview

import android.annotation.SuppressLint
import android.graphics.Bitmap
import android.view.ViewGroup
import android.webkit.CookieManager
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.webkit.WebViewClient
Expand All @@ -22,6 +23,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.compose.ui.zIndex
import androidx.core.net.toUri
import com.fintecsystems.xs2awizard.R
import com.fintecsystems.xs2awizard.components.XS2AWizardViewModel
Expand Down Expand Up @@ -61,6 +63,7 @@ fun URLBarWebView(viewModel: XS2AWizardViewModel) {
}

DisposableEffect(targetUrl, webView) {
currentUrl = targetUrl
webView?.loadUrl(targetUrl ?: "about:blank")

onDispose { /* no-op */ }
Expand All @@ -78,6 +81,8 @@ fun URLBarWebView(viewModel: XS2AWizardViewModel) {
Modifier
.fillMaxWidth()
.height(48.dp)
.zIndex(1f)
.background(XS2ATheme.CURRENT.webViewBackgroundColor.value)
) {
Row(
modifier = Modifier.fillMaxWidth(),
Expand Down Expand Up @@ -129,34 +134,38 @@ fun URLBarWebView(viewModel: XS2AWizardViewModel) {
.fillMaxWidth()
.height(2.dp),
progress = loadingIndicatorProgress / 100f,
color = XS2ATheme.CURRENT.tintColor.value
color = XS2ATheme.CURRENT.tintColor.value,
backgroundColor = XS2ATheme.CURRENT.webViewBorderColor.value
)
}

// WebView
AndroidView(
modifier = Modifier.fillMaxWidth(),
modifier = Modifier
.fillMaxWidth()
.background(XS2ATheme.CURRENT.webViewBackgroundColor.value),
factory = {
WebView(it).apply {
webView = this

settings.javaScriptEnabled = true
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)

CookieManager.getInstance().setAcceptThirdPartyCookies(this, true)
settings.domStorageEnabled = true
settings.javaScriptEnabled = true
addJavascriptInterface(XS2AJavascriptInterface(callbackHandler), "App")

webViewClient = object : WebViewClient() {
@Deprecated("Deprecated in Java")
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
currentUrl = url
view.loadUrl(url)
return true
}

override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)

currentUrl = url
}

override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)

Expand Down

0 comments on commit 307d7b0

Please sign in to comment.