2 * Copyright 2019-2024 Soren Stoutner <soren@stoutner.com>.
4 * This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
6 * Privacy Browser Android is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * Privacy Browser Android is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Privacy Browser Android. If not, see <http://www.gnu.org/licenses/>.
20 package com.stoutner.privacybrowser.views
22 import android.animation.ObjectAnimator
23 import android.annotation.SuppressLint
24 import android.content.Context
25 import android.graphics.Bitmap
26 import android.graphics.drawable.Drawable
27 import android.os.Bundle
28 import android.util.AttributeSet
29 import android.view.MotionEvent
30 import android.webkit.HttpAuthHandler
31 import android.webkit.SslErrorHandler
32 import android.webkit.WebView
34 import androidx.core.view.NestedScrollingChild2
35 import androidx.core.view.NestedScrollingChildHelper
36 import androidx.core.view.ViewCompat
38 import com.stoutner.privacybrowser.activities.MainWebViewActivity
40 import java.util.Collections
43 import kotlin.collections.ArrayList
45 // Define the public constants.
46 const val BLOCKED_REQUESTS = 0
47 const val EASYLIST = 1
48 const val EASYPRIVACY = 2
49 const val FANBOYS_ANNOYANCE_LIST = 3
50 const val FANBOYS_SOCIAL_BLOCKING_LIST = 4
51 const val ULTRALIST = 5
52 const val ULTRAPRIVACY = 6
53 const val THIRD_PARTY_REQUESTS = 7
55 // Define the private class constants.
56 private const val ACCEPT_COOKIES = "A"
57 private const val BLOCK_ALL_THIRD_PARTY_REQUESTS = "B"
58 private const val CURRENT_DOMAIN_NAME = "C"
59 private const val CURRENT_URL = "D"
60 private const val DOM_STORAGE_ENABLED = "E"
61 private const val DOMAIN_SETTINGS_APPLIED = "F"
62 private const val DOMAIN_SETTINGS_DATABASE_ID = "G"
63 private const val EASYLIST_ENABLED = "H"
64 private const val EASYPRIVACY_ENABLED = "I"
65 private const val FANBOYS_ANNOYANCE_LIST_ENABLED = "J"
66 private const val FANBOYS_SOCIAL_BLOCKING_LIST_ENABLED = "K"
67 private const val FONT_SIZE = "L"
68 private const val HAS_PINNED_SSL_CERTIFICATE = "M"
69 private const val IGNORE_PINNED_DOMAIN_INFORMATION = "N"
70 private const val JAVASCRIPT_ENABLED = "O"
71 private const val PINNED_IP_ADDRESSES = "P"
72 private const val PINNED_SSL_END_DATE = "Q"
73 private const val PINNED_SSL_ISSUED_BY_CNAME = "R"
74 private const val PINNED_SSL_ISSUED_BY_ONAME = "S"
75 private const val PINNED_SSL_ISSUED_BY_UNAME = "T"
76 private const val PINNED_SSL_ISSUED_TO_CNAME = "U"
77 private const val PINNED_SSL_ISSUED_TO_ONAME = "V"
78 private const val PINNED_SSL_ISSUED_TO_UNAME = "W"
79 private const val PINNED_SSL_START_DATE = "X"
80 private const val SWIPE_TO_REFRESH = "Y"
81 private const val ULTRALIST_ENABLED = "Z"
82 private const val ULTRAPRIVACY_ENABLED = "AA"
83 private const val USER_AGENT = "AB"
84 private const val WIDE_VIEWPORT = "AC"
86 // NestedScrollWebView extends WebView to handle nested scrolls (scrolling the app bar off the screen). It also stores extra information about the state of the WebView used by Privacy Browser.
87 class NestedScrollWebView @JvmOverloads constructor(context: Context, attributeSet: AttributeSet? = null, defaultStyle: Int = android.R.attr.webViewStyle) : WebView(context, attributeSet, defaultStyle),
88 NestedScrollingChild2 {
90 // Define the public variables.
91 var acceptCookies = false
92 var blockAllThirdPartyRequests = false
93 var currentDomainName = ""
94 var currentIpAddresses = ""
96 var domainSettingsApplied = false
97 var domainSettingsDatabaseId = 0
98 var easyListEnabled = true
99 var easyPrivacyEnabled = true
100 var fanboysAnnoyanceListEnabled = true
101 var fanboysSocialBlockingListEnabled = true
102 var httpAuthHandler: HttpAuthHandler? = null
103 var ignorePinnedDomainInformation = false
104 var pinnedIpAddresses = ""
105 var previousFavoriteIconDrawable: Drawable? = null
106 var previousWebpageTitle = ""
107 var sslErrorHandler: SslErrorHandler? = null
108 var swipeToRefresh = false
109 var ultraListEnabled = true
110 var ultraPrivacyEnabled = true
111 var waitingForProxyUrlString = ""
112 var webViewFragmentId: Long = 0
114 // Define the private variables.
115 private val nestedScrollingChildHelper: NestedScrollingChildHelper = NestedScrollingChildHelper(this)
116 private lateinit var favoriteIcon: Bitmap
117 private var favoriteIconHeight = 0
118 private var previousYPosition = 0 // The previous Y position needs to be tracked between motion events.
119 private var hasPinnedSslCertificate = false
120 private var pinnedSslIssuedToCName = ""
121 private var pinnedSslIssuedToOName = ""
122 private var pinnedSslIssuedToUName = ""
123 private var pinnedSslIssuedByCName = ""
124 private var pinnedSslIssuedByOName = ""
125 private var pinnedSslIssuedByUName = ""
126 private var pinnedSslStartDate = Date(0)
127 private var pinnedSslEndDate = Date(0)
128 private val resourceRequests = Collections.synchronizedList(ArrayList<Array<String>>()) // Using a synchronized list makes adding resource requests thread safe.
129 private var blockedRequests = 0
130 private var easyListBlockedRequests = 0
131 private var easyPrivacyBlockedRequests = 0
132 private var fanboysAnnoyanceListBlockedRequests = 0
133 private var fanboysSocialBlockingListBlockedRequests = 0
134 private var ultraListBlockedRequests = 0
135 private var ultraPrivacyBlockedRequests = 0
136 private var thirdPartyBlockedRequests = 0
139 // Enable nested scrolling by default.
140 nestedScrollingChildHelper.isNestedScrollingEnabled = true
142 // Initialize the favorite icon.
146 // Favorite or default icon.
147 fun resetFavoriteIcon() {
148 // Store the default icon bitmap.
149 favoriteIcon = MainWebViewActivity.defaultFavoriteIconBitmap
151 // Set the favorite icon height to be 0. This way any favorite icons presented by the website will overwrite it.
152 favoriteIconHeight = 0
155 fun setFavoriteIcon(icon: Bitmap) {
156 // Store the current favorite icon height.
157 favoriteIconHeight = icon.height
159 // Scale the favorite icon bitmap down if it is larger than 256 x 256. Filtering uses bilinear interpolation.
160 favoriteIcon = if (icon.height > 256 || icon.width > 256) {
161 Bitmap.createScaledBitmap(icon, 256, 256, true)
163 // Store the icon as presented.
168 fun getFavoriteIcon(): Bitmap {
169 // Return the favorite icon. This is the only way to return a non-nullable variable while retaining the custom initialization and setter functions above.
173 fun getFavoriteIconHeight(): Int {
174 // Return the favorite icon height.
175 return favoriteIconHeight
178 // Reset the handlers.
179 fun resetSslErrorHandler() {
180 // Reset the current SSL error handler.
181 sslErrorHandler = null
184 fun resetHttpAuthHandler() {
185 // Reset the current HTTP authentication handler.
186 httpAuthHandler = null
190 // Pinned SSL certificates.
191 fun hasPinnedSslCertificate(): Boolean {
192 // Return the status of the pinned SSL certificate.
193 return hasPinnedSslCertificate
196 fun setPinnedSslCertificate(issuedToCName: String, issuedToOName: String, issuedToUName: String, issuedByCName: String, issuedByOName: String, issuedByUName: String, startDate: Date, endDate: Date) {
197 // Store the pinned SSL certificate information.
198 pinnedSslIssuedToCName = issuedToCName
199 pinnedSslIssuedToOName = issuedToOName
200 pinnedSslIssuedToUName = issuedToUName
201 pinnedSslIssuedByCName = issuedByCName
202 pinnedSslIssuedByOName = issuedByOName
203 pinnedSslIssuedByUName = issuedByUName
204 pinnedSslStartDate = startDate
205 pinnedSslEndDate = endDate
207 // Set the pinned SSL certificate tracker.
208 hasPinnedSslCertificate = true
211 fun getPinnedSslCertificate(): Pair<Array<String>, Array<Date>> {
212 // Create the SSL certificate string array.
213 val sslCertificateStringArray = arrayOf(pinnedSslIssuedToCName, pinnedSslIssuedToOName, pinnedSslIssuedToUName, pinnedSslIssuedByCName, pinnedSslIssuedByOName, pinnedSslIssuedByUName)
215 // Create the SSL certificate date array.
216 val sslCertificateDateArray = arrayOf(pinnedSslStartDate, pinnedSslEndDate)
218 // Return the pinned SSL certificate pair.
219 return Pair(sslCertificateStringArray, sslCertificateDateArray)
222 fun clearPinnedSslCertificate() {
223 // Clear the pinned SSL certificate.
224 pinnedSslIssuedToCName = ""
225 pinnedSslIssuedToOName = ""
226 pinnedSslIssuedToUName = ""
227 pinnedSslIssuedByCName = ""
228 pinnedSslIssuedByOName = ""
229 pinnedSslIssuedByUName = ""
230 pinnedSslStartDate = Date(0)
231 pinnedSslEndDate = Date(0)
233 // Clear the pinned SSL certificate tracker.
234 hasPinnedSslCertificate = false
238 // Resource requests.
239 fun addResourceRequest(resourceRequest: Array<String>) {
240 // Add the resource request to the list.
241 resourceRequests.add(resourceRequest)
244 fun getResourceRequests(): List<Array<String>> {
245 // Return the list of resource requests as an array list.
246 return resourceRequests
249 fun clearResourceRequests() {
250 // Clear the resource requests.
251 resourceRequests.clear()
255 // Resource request counters.
256 fun incrementRequestsCount(filterList: Int) {
257 // Increment the count of the indicated filter list.
259 BLOCKED_REQUESTS -> blockedRequests++
260 EASYLIST -> easyListBlockedRequests++
261 EASYPRIVACY -> easyPrivacyBlockedRequests++
262 FANBOYS_ANNOYANCE_LIST -> fanboysAnnoyanceListBlockedRequests++
263 FANBOYS_SOCIAL_BLOCKING_LIST -> fanboysSocialBlockingListBlockedRequests++
264 ULTRALIST -> ultraListBlockedRequests++
265 ULTRAPRIVACY -> ultraPrivacyBlockedRequests++
266 THIRD_PARTY_REQUESTS -> thirdPartyBlockedRequests++
270 fun getRequestsCount(filterList: Int): Int {
271 // Return the count of the indicated filter list.
272 return when (filterList) {
273 BLOCKED_REQUESTS -> blockedRequests
274 EASYLIST -> easyListBlockedRequests
275 EASYPRIVACY -> easyPrivacyBlockedRequests
276 FANBOYS_ANNOYANCE_LIST -> fanboysAnnoyanceListBlockedRequests
277 FANBOYS_SOCIAL_BLOCKING_LIST -> fanboysSocialBlockingListBlockedRequests
278 ULTRALIST -> ultraListBlockedRequests
279 ULTRAPRIVACY -> ultraPrivacyBlockedRequests
280 THIRD_PARTY_REQUESTS -> thirdPartyBlockedRequests
281 else -> 0 // Return 0. This should never be called, but it is required by the return when statement.
285 fun resetRequestsCounters() {
286 // Reset all the resource request counters.
288 easyListBlockedRequests = 0
289 easyPrivacyBlockedRequests = 0
290 fanboysAnnoyanceListBlockedRequests = 0
291 fanboysSocialBlockingListBlockedRequests = 0
292 ultraListBlockedRequests = 0
293 ultraPrivacyBlockedRequests = 0
294 thirdPartyBlockedRequests = 0
298 // Publicly expose the scroll ranges.
299 fun getHorizontalScrollRange(): Int {
300 // Return the horizontal scroll range.
301 return computeHorizontalScrollRange()
304 fun getVerticalScrollRange(): Int {
305 // Return the vertical scroll range.
306 return computeVerticalScrollRange()
309 override fun onOverScrolled(scrollX: Int, scrollY: Int, clampedX: Boolean, clampedY: Boolean) {
310 // Run the default commands.
311 super.onOverScrolled(scrollX, scrollY, clampedX, clampedY)
313 // Display the bottom app bar if it has been hidden and the WebView was over-scrolled at the top of the screen.
314 if ((MainWebViewActivity.appBarLayout.translationY != 0f) && (scrollY == 0) && clampedY) {
315 // Animate the bottom app bar onto the screen.
316 val objectAnimator = ObjectAnimator.ofFloat(MainWebViewActivity.appBarLayout, "translationY", 0f)
319 objectAnimator.start()
324 @SuppressLint("ClickableViewAccessibility")
325 override fun onTouchEvent(motionEvent: MotionEvent): Boolean {
326 // Run the commands for the given motion event action.
327 when (motionEvent.action) {
328 MotionEvent.ACTION_DOWN -> {
329 // Start nested scrolling along the vertical axis. `ViewCompat` must be used until the minimum API >= 21.
330 startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL)
332 // Save the current Y position. Action down will not be called again until a new motion starts.
333 previousYPosition = motionEvent.y.toInt()
335 MotionEvent.ACTION_MOVE -> {
336 // Get the current Y position.
337 val currentYMotionPosition = motionEvent.y.toInt()
339 // Calculate the pre-scroll delta Y.
340 val preScrollDeltaY = previousYPosition - currentYMotionPosition
342 // Initialize a variable to track how much of the scroll is consumed.
343 val consumedScroll = IntArray(2)
345 // Initialize a variable to track the offset in the window.
346 val offsetInWindow = IntArray(2)
348 // Get the WebView Y position.
349 val webViewYPosition = scrollY
351 // Set the scroll delta Y to initially be the same as the pre-scroll delta Y.
352 var scrollDeltaY = preScrollDeltaY
354 // Dispatch the nested pre-school. This scrolls the app bar if it needs it. `offsetInWindow` will be returned with an updated value.
355 if (dispatchNestedPreScroll(0, preScrollDeltaY, consumedScroll, offsetInWindow)) {
356 // Update the scroll delta Y if some of it was consumed.
357 scrollDeltaY = preScrollDeltaY - consumedScroll[1]
360 // Check to see if the WebView is at the top and and the scroll action is downward.
361 if (webViewYPosition == 0 && scrollDeltaY < 0) { // Swipe to refresh is being engaged.
362 // Stop the nested scroll so that swipe to refresh has complete control. This way releasing the scroll to refresh circle doesn't scroll the WebView at the same time.
364 } else { // Swipe to refresh is not being engaged.
365 // Start the nested scroll so that the app bar can scroll off the screen.
366 startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL)
368 // Dispatch the nested scroll. This scrolls the WebView. The delta Y unconsumed normally controls the swipe refresh layout, but that is handled with the `if` statement above.
369 dispatchNestedScroll(0, scrollDeltaY, 0, 0, offsetInWindow)
371 // Store the current Y position for use in the next action move.
372 previousYPosition -= scrollDeltaY
375 else -> stopNestedScroll() // Stop nested scrolling.
378 // Perform a click. This is required by the Android accessibility guidelines.
381 // Run the default commands and return the result.
382 return super.onTouchEvent(motionEvent)
387 fun saveNestedScrollWebViewState(): Bundle {
388 // Create a saved state bundle.
389 val savedState = Bundle()
391 // Populate the saved state bundle.
392 savedState.putBoolean(ACCEPT_COOKIES, acceptCookies)
393 savedState.putBoolean(BLOCK_ALL_THIRD_PARTY_REQUESTS, blockAllThirdPartyRequests)
394 savedState.putString(CURRENT_DOMAIN_NAME, currentDomainName)
395 savedState.putString(CURRENT_URL, currentUrl)
396 savedState.putBoolean(DOM_STORAGE_ENABLED, this.settings.domStorageEnabled)
397 savedState.putBoolean(DOMAIN_SETTINGS_APPLIED, domainSettingsApplied)
398 savedState.putInt(DOMAIN_SETTINGS_DATABASE_ID, domainSettingsDatabaseId)
399 savedState.putBoolean(EASYLIST_ENABLED, easyListEnabled)
400 savedState.putBoolean(EASYPRIVACY_ENABLED, easyPrivacyEnabled)
401 savedState.putBoolean(FANBOYS_ANNOYANCE_LIST_ENABLED, fanboysAnnoyanceListEnabled)
402 savedState.putBoolean(FANBOYS_SOCIAL_BLOCKING_LIST_ENABLED, fanboysSocialBlockingListEnabled)
403 savedState.putInt(FONT_SIZE, this.settings.textZoom)
404 savedState.putBoolean(HAS_PINNED_SSL_CERTIFICATE, hasPinnedSslCertificate)
405 savedState.putBoolean(IGNORE_PINNED_DOMAIN_INFORMATION, ignorePinnedDomainInformation)
406 savedState.putBoolean(JAVASCRIPT_ENABLED, this.settings.javaScriptEnabled)
407 savedState.putString(PINNED_IP_ADDRESSES, pinnedIpAddresses)
408 savedState.putLong(PINNED_SSL_END_DATE, pinnedSslEndDate.time)
409 savedState.putString(PINNED_SSL_ISSUED_BY_CNAME, pinnedSslIssuedByCName)
410 savedState.putString(PINNED_SSL_ISSUED_BY_ONAME, pinnedSslIssuedByOName)
411 savedState.putString(PINNED_SSL_ISSUED_BY_UNAME, pinnedSslIssuedByUName)
412 savedState.putString(PINNED_SSL_ISSUED_TO_CNAME, pinnedSslIssuedToCName)
413 savedState.putString(PINNED_SSL_ISSUED_TO_ONAME, pinnedSslIssuedToOName)
414 savedState.putString(PINNED_SSL_ISSUED_TO_UNAME, pinnedSslIssuedToUName)
415 savedState.putLong(PINNED_SSL_START_DATE, pinnedSslStartDate.time)
416 savedState.putBoolean(SWIPE_TO_REFRESH, swipeToRefresh)
417 savedState.putBoolean(ULTRALIST_ENABLED, ultraListEnabled)
418 savedState.putBoolean(ULTRAPRIVACY_ENABLED, ultraPrivacyEnabled)
419 savedState.putString(USER_AGENT, this.settings.userAgentString)
420 savedState.putBoolean(WIDE_VIEWPORT, this.settings.useWideViewPort)
422 // Return the saved state bundle.
426 // Restore the state.
427 fun restoreNestedScrollWebViewState(savedState: Bundle) {
428 // Restore the class variables.
429 acceptCookies = savedState.getBoolean(ACCEPT_COOKIES)
430 blockAllThirdPartyRequests = savedState.getBoolean(BLOCK_ALL_THIRD_PARTY_REQUESTS)
431 currentDomainName = savedState.getString(CURRENT_DOMAIN_NAME)!!
432 currentUrl = savedState.getString(CURRENT_URL)!!
433 this.settings.domStorageEnabled = savedState.getBoolean(DOM_STORAGE_ENABLED)
434 domainSettingsApplied = savedState.getBoolean(DOMAIN_SETTINGS_APPLIED)
435 domainSettingsDatabaseId = savedState.getInt(DOMAIN_SETTINGS_DATABASE_ID)
436 easyListEnabled = savedState.getBoolean(EASYLIST_ENABLED)
437 easyPrivacyEnabled = savedState.getBoolean(EASYPRIVACY_ENABLED)
438 fanboysAnnoyanceListEnabled = savedState.getBoolean(FANBOYS_ANNOYANCE_LIST_ENABLED)
439 fanboysSocialBlockingListEnabled = savedState.getBoolean(FANBOYS_SOCIAL_BLOCKING_LIST_ENABLED)
440 this.settings.textZoom = savedState.getInt(FONT_SIZE)
441 hasPinnedSslCertificate = savedState.getBoolean(HAS_PINNED_SSL_CERTIFICATE)
442 ignorePinnedDomainInformation = savedState.getBoolean(IGNORE_PINNED_DOMAIN_INFORMATION)
443 this.settings.javaScriptEnabled = savedState.getBoolean(JAVASCRIPT_ENABLED)
444 pinnedIpAddresses = savedState.getString(PINNED_IP_ADDRESSES)!!
445 pinnedSslEndDate = Date(savedState.getLong(PINNED_SSL_END_DATE))
446 pinnedSslIssuedByCName = savedState.getString(PINNED_SSL_ISSUED_BY_CNAME)!!
447 pinnedSslIssuedByOName = savedState.getString(PINNED_SSL_ISSUED_BY_ONAME)!!
448 pinnedSslIssuedByUName = savedState.getString(PINNED_SSL_ISSUED_BY_UNAME)!!
449 pinnedSslIssuedToCName = savedState.getString(PINNED_SSL_ISSUED_TO_CNAME)!!
450 pinnedSslIssuedToOName = savedState.getString(PINNED_SSL_ISSUED_TO_ONAME)!!
451 pinnedSslIssuedToUName = savedState.getString(PINNED_SSL_ISSUED_TO_UNAME)!!
452 pinnedSslStartDate = Date(savedState.getLong(PINNED_SSL_START_DATE))
453 swipeToRefresh = savedState.getBoolean(SWIPE_TO_REFRESH)
454 ultraListEnabled = savedState.getBoolean(ULTRALIST_ENABLED)
455 ultraPrivacyEnabled = savedState.getBoolean(ULTRAPRIVACY_ENABLED)
456 this.settings.userAgentString = savedState.getString(USER_AGENT)
457 this.settings.useWideViewPort = savedState.getBoolean(WIDE_VIEWPORT)
461 // Method from NestedScrollingChild.
462 override fun setNestedScrollingEnabled(status: Boolean) {
463 // Set the status of the nested scrolling.
464 nestedScrollingChildHelper.isNestedScrollingEnabled = status
467 // Method from NestedScrollingChild.
468 override fun isNestedScrollingEnabled(): Boolean {
469 // Return the status of nested scrolling.
470 return nestedScrollingChildHelper.isNestedScrollingEnabled
473 // Method from NestedScrollingChild.
474 override fun startNestedScroll(axes: Int): Boolean {
475 // Start a nested scroll along the indicated axes.
476 return nestedScrollingChildHelper.startNestedScroll(axes)
479 // Method from NestedScrollingChild2.
480 override fun startNestedScroll(axes: Int, type: Int): Boolean {
481 // Start a nested scroll along the indicated axes for the given type of input which caused the scroll event.
482 return nestedScrollingChildHelper.startNestedScroll(axes, type)
485 // Method from NestedScrollingChild.
486 override fun stopNestedScroll() {
487 // Stop the nested scroll.
488 nestedScrollingChildHelper.stopNestedScroll()
491 // Method from NestedScrollingChild2.
492 override fun stopNestedScroll(type: Int) {
493 // Stop the nested scroll of the given type of input which caused the scroll event.
494 nestedScrollingChildHelper.stopNestedScroll(type)
497 // Method from NestedScrollingChild.
498 override fun hasNestedScrollingParent(): Boolean {
499 // Return the status of the nested scrolling parent.
500 return nestedScrollingChildHelper.hasNestedScrollingParent()
503 // Method from NestedScrollingChild2.
504 override fun hasNestedScrollingParent(type: Int): Boolean {
505 // return the status of the nested scrolling parent for the given type of input which caused the scroll event.
506 return nestedScrollingChildHelper.hasNestedScrollingParent(type)
509 // Method from NestedScrollingChild.
510 override fun dispatchNestedPreScroll(deltaX: Int, deltaY: Int, consumed: IntArray?, offsetInWindow: IntArray?): Boolean {
511 // Dispatch a nested pre-scroll with the specified deltas, which lets a parent to consume some of the scroll if desired.
512 return nestedScrollingChildHelper.dispatchNestedPreScroll(deltaX, deltaY, consumed, offsetInWindow)
515 // Method from NestedScrollingChild2.
516 override fun dispatchNestedPreScroll(deltaX: Int, deltaY: Int, consumed: IntArray?, offsetInWindow: IntArray?, type: Int): Boolean {
517 // Dispatch a nested pre-scroll with the specified deltas for the given type of input which caused the scroll event, which lets a parent to consume some of the scroll if desired.
518 return nestedScrollingChildHelper.dispatchNestedPreScroll(deltaX, deltaY, consumed, offsetInWindow, type)
521 // Method from NestedScrollingChild.
522 override fun dispatchNestedScroll(deltaXConsumed: Int, deltaYConsumed: Int, deltaXUnconsumed: Int, deltaYUnconsumed: Int, offsetInWindow: IntArray?): Boolean {
523 // Dispatch a nested scroll with the specified deltas.
524 return nestedScrollingChildHelper.dispatchNestedScroll(deltaXConsumed, deltaYConsumed, deltaXUnconsumed, deltaYUnconsumed, offsetInWindow)
527 // Method from NestedScrollingChild2.
528 override fun dispatchNestedScroll(deltaXConsumed: Int, deltaYConsumed: Int, deltaXUnconsumed: Int, deltaYUnconsumed: Int, offsetInWindow: IntArray?, type: Int): Boolean {
529 // Dispatch a nested scroll with the specified deltas for the given type of input which caused the scroll event.
530 return nestedScrollingChildHelper.dispatchNestedScroll(deltaXConsumed, deltaYConsumed, deltaXUnconsumed, deltaYUnconsumed, offsetInWindow, type)
533 // Method from NestedScrollingChild.
534 override fun dispatchNestedPreFling(velocityX: Float, velocityY: Float): Boolean {
535 // Dispatch a nested pre-fling with the specified velocity, which lets a parent consume the fling if desired.
536 return nestedScrollingChildHelper.dispatchNestedPreFling(velocityX, velocityY)
539 // Method from NestedScrollingChild.
540 override fun dispatchNestedFling(velocityX: Float, velocityY: Float, consumed: Boolean): Boolean {
541 // Dispatch a nested fling with the specified velocity.
542 return nestedScrollingChildHelper.dispatchNestedFling(velocityX, velocityY, consumed)