Skip to content

Commit b6e5b06

Browse files
authored
Tab swiping: Disable swiping on error views (#6055)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1202552961248957/task/1210226097518216?focus=true ### Description This PR disables the swiping on the following views: - Loading error view - Malicious site protection view - SSL error view ### Steps to test this PR _Loading error view_ - [x] Enable flight mode - [x] Start the app - [x] Verify only the omnibar can swipe tabs, not the error content _Malicious site error view_ - [x] Apply the patch below ```kotlin Subject: [PATCH] Malicious site --- Index: app/src/main/java/com/duckduckgo/app/browser/webview/MaliciousSiteBlockerWebViewIntegration.kt IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/app/src/main/java/com/duckduckgo/app/browser/webview/MaliciousSiteBlockerWebViewIntegration.kt b/app/src/main/java/com/duckduckgo/app/browser/webview/MaliciousSiteBlockerWebViewIntegration.kt --- a/app/src/main/java/com/duckduckgo/app/browser/webview/MaliciousSiteBlockerWebViewIntegration.kt (revision e238a9d) +++ b/app/src/main/java/com/duckduckgo/app/browser/webview/MaliciousSiteBlockerWebViewIntegration.kt (date 1747129357867) @@ -32,6 +32,7 @@ import com.duckduckgo.di.scopes.AppScope import com.duckduckgo.malicioussiteprotection.api.MaliciousSiteProtection import com.duckduckgo.malicioussiteprotection.api.MaliciousSiteProtection.Feed +import com.duckduckgo.malicioussiteprotection.api.MaliciousSiteProtection.Feed.MALWARE import com.duckduckgo.malicioussiteprotection.api.MaliciousSiteProtection.IsMaliciousResult import com.duckduckgo.malicioussiteprotection.api.MaliciousSiteProtection.IsMaliciousResult.ConfirmedResult import com.duckduckgo.malicioussiteprotection.api.MaliciousSiteProtection.IsMaliciousResult.WaitForConfirmation @@ -151,6 +152,7 @@ } return withContext(dispatchers.io()) { + return@withContext IsMaliciousViewData.MaliciousSite(request.url, MALWARE, exempted = false, clientSideHit = true) val belongsToCurrentPage = documentUri?.host == request.requestHeaders["Referer"]?.toUri()?.host val isForIframe = (isForIframe(request) && belongsToCurrentPage) ``` - [x] Start the app - [x] Verify only the omnibar can swipe tabs, not the error content _SSL error view_ It's difficult to mock this error but it's the same custom view type as malicious site error, so it uses the same approach.
1 parent cb7bba0 commit b6e5b06

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,11 +978,15 @@ class BrowserTabFragment :
978978

979979
@SuppressLint("ClickableViewAccessibility")
980980
private fun disableSwipingOutsideTheOmnibar() {
981-
newBrowserTab.newTabLayout.setOnTouchListener { v, event ->
981+
newBrowserTab.newTabLayout.setOnTouchListener { v, _ ->
982982
v.parent.requestDisallowInterceptTouchEvent(true)
983983
true
984984
}
985-
binding.autoCompleteSuggestionsList.setOnTouchListener { v, event ->
985+
binding.autoCompleteSuggestionsList.setOnTouchListener { v, _ ->
986+
v.parent.requestDisallowInterceptTouchEvent(true)
987+
false
988+
}
989+
binding.includeErrorView.root.setOnTouchListener { v, _ ->
986990
v.parent.requestDisallowInterceptTouchEvent(true)
987991
false
988992
}

app/src/main/java/com/duckduckgo/app/browser/webview/MaliciousSiteBlockedWarningLayout.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,50 @@
1616

1717
package com.duckduckgo.app.browser.webview
1818

19+
import android.annotation.SuppressLint
1920
import android.content.Context
2021
import android.text.SpannableStringBuilder
2122
import android.text.TextPaint
2223
import android.text.method.LinkMovementMethod
2324
import android.text.style.ClickableSpan
2425
import android.text.style.URLSpan
2526
import android.util.AttributeSet
27+
import android.view.MotionEvent
2628
import android.view.View
2729
import android.widget.FrameLayout
2830
import androidx.annotation.StringRes
2931
import androidx.core.text.HtmlCompat
32+
import com.duckduckgo.anvil.annotations.InjectWith
3033
import com.duckduckgo.app.browser.R
3134
import com.duckduckgo.app.browser.databinding.ViewMaliciousSiteBlockedWarningBinding
3235
import com.duckduckgo.app.browser.webview.MaliciousSiteBlockedWarningLayout.Action.LearnMore
3336
import com.duckduckgo.app.browser.webview.MaliciousSiteBlockedWarningLayout.Action.LeaveSite
3437
import com.duckduckgo.app.browser.webview.MaliciousSiteBlockedWarningLayout.Action.ReportError
3538
import com.duckduckgo.app.browser.webview.MaliciousSiteBlockedWarningLayout.Action.VisitSite
39+
import com.duckduckgo.common.ui.tabs.SwipingTabsFeatureProvider
3640
import com.duckduckgo.common.ui.view.gone
3741
import com.duckduckgo.common.ui.view.show
3842
import com.duckduckgo.common.ui.view.text.DaxTextView
3943
import com.duckduckgo.common.ui.viewbinding.viewBinding
4044
import com.duckduckgo.common.utils.extensions.html
45+
import com.duckduckgo.di.scopes.ViewScope
4146
import com.duckduckgo.malicioussiteprotection.api.MaliciousSiteProtection.Feed
4247
import com.duckduckgo.malicioussiteprotection.api.MaliciousSiteProtection.Feed.MALWARE
4348
import com.duckduckgo.malicioussiteprotection.api.MaliciousSiteProtection.Feed.PHISHING
4449
import com.duckduckgo.malicioussiteprotection.api.MaliciousSiteProtection.Feed.SCAM
50+
import dagger.android.support.AndroidSupportInjection
51+
import javax.inject.Inject
4552

53+
@InjectWith(ViewScope::class)
4654
class MaliciousSiteBlockedWarningLayout @JvmOverloads constructor(
4755
context: Context,
4856
attrs: AttributeSet? = null,
4957
defStyle: Int = 0,
5058
) : FrameLayout(context, attrs, defStyle) {
5159

60+
@Inject
61+
lateinit var swipingTabsFeature: SwipingTabsFeatureProvider
62+
5263
sealed class Action {
5364
data object VisitSite : Action()
5465
data object LeaveSite : Action()
@@ -75,6 +86,20 @@ class MaliciousSiteBlockedWarningLayout @JvmOverloads constructor(
7586
}
7687
}
7788

89+
override fun onAttachedToWindow() {
90+
AndroidSupportInjection.inject(this)
91+
super.onAttachedToWindow()
92+
}
93+
94+
@SuppressLint("ClickableViewAccessibility")
95+
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
96+
if (swipingTabsFeature.isEnabled) {
97+
// disable tab swiping on this view
98+
parent.requestDisallowInterceptTouchEvent(true)
99+
}
100+
return super.dispatchTouchEvent(ev)
101+
}
102+
78103
private fun formatCopy(
79104
feed: Feed,
80105
actionHandler: (Action) -> Unit,

app/src/main/java/com/duckduckgo/app/browser/webview/SslWarningLayout.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616

1717
package com.duckduckgo.app.browser.webview
1818

19+
import android.annotation.SuppressLint
1920
import android.content.Context
2021
import android.util.AttributeSet
22+
import android.view.MotionEvent
2123
import android.view.View
2224
import android.webkit.SslErrorHandler
2325
import android.widget.FrameLayout
26+
import com.duckduckgo.anvil.annotations.InjectWith
2427
import com.duckduckgo.app.browser.R
2528
import com.duckduckgo.app.browser.SSLErrorType
2629
import com.duckduckgo.app.browser.SSLErrorType.WRONG_HOST
@@ -29,19 +32,27 @@ import com.duckduckgo.app.browser.databinding.ViewSslWarningBinding
2932
import com.duckduckgo.app.browser.webview.SslWarningLayout.Action.Advance
3033
import com.duckduckgo.app.browser.webview.SslWarningLayout.Action.LeaveSite
3134
import com.duckduckgo.app.browser.webview.SslWarningLayout.Action.Proceed
35+
import com.duckduckgo.common.ui.tabs.SwipingTabsFeatureProvider
3236
import com.duckduckgo.common.ui.view.gone
3337
import com.duckduckgo.common.ui.view.show
3438
import com.duckduckgo.common.ui.viewbinding.viewBinding
3539
import com.duckduckgo.common.utils.extensions.applyBoldSpanTo
3640
import com.duckduckgo.common.utils.extensions.html
3741
import com.duckduckgo.common.utils.extractDomain
42+
import com.duckduckgo.di.scopes.ViewScope
43+
import dagger.android.support.AndroidSupportInjection
44+
import javax.inject.Inject
3845

46+
@InjectWith(ViewScope::class)
3947
class SslWarningLayout @JvmOverloads constructor(
4048
context: Context,
4149
attrs: AttributeSet? = null,
4250
defStyle: Int = 0,
4351
) : FrameLayout(context, attrs, defStyle) {
4452

53+
@Inject
54+
lateinit var swipingTabsFeature: SwipingTabsFeatureProvider
55+
4556
sealed class Action {
4657

4758
data class Shown(val errorType: SSLErrorType) : Action()
@@ -66,6 +77,20 @@ class SslWarningLayout @JvmOverloads constructor(
6677
}
6778
}
6879

80+
override fun onAttachedToWindow() {
81+
AndroidSupportInjection.inject(this)
82+
super.onAttachedToWindow()
83+
}
84+
85+
@SuppressLint("ClickableViewAccessibility")
86+
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
87+
if (swipingTabsFeature.isEnabled) {
88+
// disable tab swiping on this view
89+
parent.requestDisallowInterceptTouchEvent(true)
90+
}
91+
return super.dispatchTouchEvent(ev)
92+
}
93+
6994
private fun resetViewState() {
7095
with(binding) {
7196
sslErrorAdvancedCTA.show()

0 commit comments

Comments
 (0)