Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NSDK-245] Fix Password Reset Doesn’t Work and WebView Redirection Issue #126

Merged
merged 5 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### Next Release
* Fix: Password Reset button doesn’t work

### 2.7.4
* Fix: Inpage text is not appropriate when the size is recommended
* Fix: Inpage text for on-boarding user has 2 patterns at random
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.os.Build
import android.os.Bundle
Expand Down Expand Up @@ -148,41 +149,50 @@ class VirtusizeWebViewFragment : DialogFragment() {
resultMsg: Message,
): Boolean {
if (resultMsg.obj != null && resultMsg.obj is WebView.WebViewTransport) {
val popupWebView = WebView(view.context)
popupWebView.settings.javaScriptEnabled = true
popupWebView.settings.javaScriptCanOpenWindowsAutomatically = true
popupWebView.settings.setSupportMultipleWindows(true)
popupWebView.settings.userAgentString = System.getProperty("http.agent")
popupWebView.webViewClient =
object : WebViewClient() {
override fun shouldOverrideUrlLoading(
view: WebView,
url: String,
): Boolean {
if (VirtusizeURLCheck.isExternalLinkFromVirtusize(url)) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
try {
startActivity(intent)
} finally {
return true
val popupWebView =
WebView(view.context).apply {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I refactored it a bit using the scope function apply
For object configuration, we can use apply

setBackgroundColor(Color.TRANSPARENT)
layoutParams =
ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
)
Comment on lines +153 to +159
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Main changes

settings.javaScriptEnabled = true
settings.javaScriptCanOpenWindowsAutomatically = true
settings.setSupportMultipleWindows(true)
settings.userAgentString = System.getProperty("http.agent")
webViewClient =
object : WebViewClient() {
override fun shouldOverrideUrlLoading(
view: WebView,
url: String,
): Boolean {
if (VirtusizeURLCheck.isExternalLinkFromVirtusize(url)) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
try {
startActivity(intent)
} finally {
return true
}
}
if (showSNSButtons) {
return VirtusizeAuth.isSNSAuthUrl(
requireContext(),
virtusizeSNSAuthLauncher,
url,
)
}
return false
}
}
if (showSNSButtons) {
return VirtusizeAuth.isSNSAuthUrl(
requireContext(),
virtusizeSNSAuthLauncher,
url,
)
webChromeClient =
object : WebChromeClient() {
override fun onCloseWindow(window: WebView) {
binding.webView.removeAllViews()
}
}
return false
}
}
popupWebView.webChromeClient =
object : WebChromeClient() {
override fun onCloseWindow(window: WebView) {
binding.webView.removeAllViews()
}
}

val transport = resultMsg.obj as WebView.WebViewTransport
binding.webView.addView(popupWebView)
transport.webView = popupWebView
Expand Down
Loading