Skip to content

Commit 8ae2523

Browse files
Subscription webview go back action (#6752)
Task/Issue URL: https://app.asana.com/1/137249556945/project/488551667048375/task/1211073283656160?focus=true ### Description This PR changes the way navigating back works letting the FE decide in some cases when it can and cannot happen ### Steps to test this PR - [x] Apply the staging patch and VPN into US - [x] Go to https://duckduckgo.com/pro?featurePage=stripe - [x] Complete the purchase using the test cards for Stripe - [ ] On the welcome screen, the icon should be a cross rather than an arrow. - [ ] Pressing either the cross or the back button should take you back to settings (doing this on develop would take you back to Stripe) - [ ] Now that you are subscribe go to settings and click on "Need help with your subscription" - [ ] On that webview navigate to some links, see how the cross turns into an arrow and if you now press it or use the back button you navigate back rather than close the screen.
1 parent 195e6d3 commit 8ae2523

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

subscriptions/subscriptions-impl/src/main/java/com/duckduckgo/subscriptions/impl/ui/SubscriptionsWebViewActivity.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class SubscriptionsWebViewActivity : DuckDuckGoActivity(), DownloadConfirmationD
237237
newProgress: Int,
238238
) {
239239
if (newProgress == 100) {
240-
if (binding.webview.canGoBack()) {
240+
if (canGoBack()) {
241241
toolbar.setNavigationIcon(R.drawable.ic_arrow_left_24)
242242
} else {
243243
toolbar.setNavigationIcon(R.drawable.ic_close_24)
@@ -616,8 +616,20 @@ class SubscriptionsWebViewActivity : DuckDuckGoActivity(), DownloadConfirmationD
616616
return super.onOptionsItemSelected(item)
617617
}
618618

619-
override fun onBackPressed() {
619+
private fun canGoBack(): Boolean {
620620
if (binding.webview.canGoBack()) {
621+
binding.webview.url?.let { url ->
622+
val uri = url.toUri()
623+
return uri.getQueryParameter("preventBackNavigation") != "true"
624+
}
625+
return false
626+
} else {
627+
return false
628+
}
629+
}
630+
631+
override fun onBackPressed() {
632+
if (canGoBack()) {
621633
binding.webview.goBack()
622634
} else {
623635
super.onBackPressed()

0 commit comments

Comments
 (0)