2 * Copyright © 2019 Soren Stoutner <soren@stoutner.com>.
4 * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
6 * Privacy Browser 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 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. If not, see <http://www.gnu.org/licenses/>.
20 package com.stoutner.privacybrowser.views;
22 import android.content.Context;
23 import android.graphics.Bitmap;
24 import android.graphics.drawable.BitmapDrawable;
25 import android.graphics.drawable.Drawable;
26 import android.util.AttributeSet;
27 import android.view.MotionEvent;
28 import android.webkit.HttpAuthHandler;
29 import android.webkit.SslErrorHandler;
30 import android.webkit.WebView;
32 import androidx.annotation.NonNull;
33 import androidx.core.content.ContextCompat;
34 import androidx.core.view.NestedScrollingChild2;
35 import androidx.core.view.NestedScrollingChildHelper;
36 import androidx.core.view.ViewCompat;
38 import com.stoutner.privacybrowser.R;
40 import java.util.ArrayList;
41 import java.util.Collections;
42 import java.util.Date;
43 import java.util.List;
45 // NestedScrollWebView extends WebView to handle nested scrolls (scrolling the app bar off the screen).
46 public class NestedScrollWebView extends WebView implements NestedScrollingChild2 {
47 // These constants identify the blocklists.
48 public final static int BLOCKED_REQUESTS = 0;
49 public final static int EASY_LIST = 1;
50 public final static int EASY_PRIVACY = 2;
51 public final static int FANBOYS_ANNOYANCE_LIST = 3;
52 public final static int FANBOYS_SOCIAL_BLOCKING_LIST = 4;
53 public final static int ULTRA_PRIVACY = 5;
54 public final static int THIRD_PARTY_REQUESTS = 6;
56 // Keep a copy of the WebView fragment ID.
57 private long webViewFragmentId;
59 // Store the handlers.
60 private SslErrorHandler sslErrorHandler;
61 private HttpAuthHandler httpAuthHandler;
63 // Track if domain settings are applied to this nested scroll WebView and, if so, the database ID.
64 private boolean domainSettingsApplied;
65 private int domainSettingsDatabaseId;
67 // Keep track of when the domain name changes so that domain settings can be reapplied. This should never be null.
68 private String currentDomainName = "";
70 // Track the status of first-party cookies.
71 private boolean acceptFirstPartyCookies;
73 // Track the domain settings JavaScript status. This can be removed once night mode does not require JavaScript.
74 private boolean domainSettingsJavaScriptEnabled;
76 // Track the resource requests.
77 private List<String[]> resourceRequests = Collections.synchronizedList(new ArrayList<>()); // Using a synchronized list makes adding resource requests thread safe.
78 private boolean easyListEnabled;
79 private boolean easyPrivacyEnabled;
80 private boolean fanboysAnnoyanceListEnabled;
81 private boolean fanboysSocialBlockingListEnabled;
82 private boolean ultraPrivacyEnabled;
83 private boolean blockAllThirdPartyRequests;
84 private int blockedRequests;
85 private int easyListBlockedRequests;
86 private int easyPrivacyBlockedRequests;
87 private int fanboysAnnoyanceListBlockedRequests;
88 private int fanboysSocialBlockingListBlockedRequests;
89 private int ultraPrivacyBlockedRequests;
90 private int thirdPartyBlockedRequests;
92 // The pinned SSL certificate variables.
93 private boolean hasPinnedSslCertificate;
94 private String pinnedSslIssuedToCName;
95 private String pinnedSslIssuedToOName;
96 private String pinnedSslIssuedToUName;
97 private String pinnedSslIssuedByCName;
98 private String pinnedSslIssuedByOName;
99 private String pinnedSslIssuedByUName;
100 private Date pinnedSslStartDate;
101 private Date pinnedSslEndDate;
103 // The current IP addresses variables.
104 private boolean hasCurrentIpAddresses;
105 private String currentIpAddresses;
107 // The pinned IP addresses variables.
108 private boolean hasPinnedIpAddresses;
109 private String pinnedIpAddresses;
111 // The ignore pinned domain information tracker. This is set when a user proceeds past a pinned mismatch dialog to prevent the dialog from showing again until after the domain changes.
112 private boolean ignorePinnedDomainInformation;
114 // Track navigation of history.
115 private boolean navigatingHistory;
117 // The default or favorite icon.
118 private Bitmap favoriteOrDefaultIcon;
121 private boolean nightMode;
123 // Track swipe to refresh.
124 private boolean swipeToRefresh;
126 // The nested scrolling child helper is used throughout the class.
127 private NestedScrollingChildHelper nestedScrollingChildHelper;
129 // The previous Y position needs to be tracked between motion events.
130 private int previousYPosition;
134 // The basic constructor.
135 public NestedScrollWebView(Context context) {
136 // Roll up to the next constructor.
140 // The intermediate constructor.
141 public NestedScrollWebView(Context context, AttributeSet attributeSet) {
142 // Roll up to the next constructor.
143 this(context, attributeSet, android.R.attr.webViewStyle);
146 // The full constructor.
147 public NestedScrollWebView(Context context, AttributeSet attributeSet, int defaultStyle) {
148 // Run the default commands.
149 super(context, attributeSet, defaultStyle);
151 // Initialize the nested scrolling child helper.
152 nestedScrollingChildHelper = new NestedScrollingChildHelper(this);
154 // Enable nested scrolling by default.
155 nestedScrollingChildHelper.setNestedScrollingEnabled(true);
160 // WebView Fragment ID.
161 public void setWebViewFragmentId(long webViewFragmentId) {
162 // Store the WebView fragment ID.
163 this.webViewFragmentId = webViewFragmentId;
166 public long getWebViewFragmentId() {
167 // Return the WebView fragment ID.
168 return webViewFragmentId;
172 // SSL error handler.
173 public void setSslErrorHandler(SslErrorHandler sslErrorHandler) {
174 // Store the current SSL error handler.
175 this.sslErrorHandler = sslErrorHandler;
178 public SslErrorHandler getSslErrorHandler() {
179 // Return the current SSL error handler.
180 return sslErrorHandler;
183 public void resetSslErrorHandler() {
184 // Reset the current SSL error handler.
185 sslErrorHandler = null;
189 // HTTP authentication handler.
190 public void setHttpAuthHandler(HttpAuthHandler httpAuthHandler) {
191 // Store the current HTTP authentication handler.
192 this.httpAuthHandler = httpAuthHandler;
195 public HttpAuthHandler getHttpAuthHandler() {
196 // Return the current HTTP authentication handler.
197 return httpAuthHandler;
200 public void resetHttpAuthHandler() {
201 // Reset the current HTTP authentication handler.
202 httpAuthHandler = null;
207 public void setDomainSettingsApplied(boolean applied) {
208 // Store the domain settings applied status.
209 domainSettingsApplied = applied;
212 public boolean getDomainSettingsApplied() {
213 // Return the domain settings applied status.
214 return domainSettingsApplied;
218 // Domain settings database ID.
219 public void setDomainSettingsDatabaseId(int databaseId) {
220 // Store the domain settings database ID.
221 domainSettingsDatabaseId = databaseId;
224 public int getDomainSettingsDatabaseId() {
225 // Return the domain settings database ID.
226 return domainSettingsDatabaseId;
230 // Current domain name. To function well when called, the domain name should never be allowed to be null.
231 public void setCurrentDomainName(@NonNull String domainName) {
232 // Store the current domain name.
233 currentDomainName = domainName;
236 public void resetCurrentDomainName() {
237 // Reset the current domain name.
238 currentDomainName = "";
241 public String getCurrentDomainName() {
242 // Return the current domain name.
243 return currentDomainName;
247 // First-party cookies.
248 public void setAcceptFirstPartyCookies(boolean status) {
249 // Store the accept first-party cookies status.
250 acceptFirstPartyCookies = status;
253 public boolean getAcceptFirstPartyCookies() {
254 // Return the accept first-party cookies status.
255 return acceptFirstPartyCookies;
259 // Domain settings JavaScript enabled. This can be removed once night mode does not require JavaScript.
260 public void setDomainSettingsJavaScriptEnabled(boolean status) {
261 // Store the domain settings JavaScript status.
262 domainSettingsJavaScriptEnabled = status;
265 public boolean getDomainSettingsJavaScriptEnabled() {
266 // Return the domain settings JavaScript status.
267 return domainSettingsJavaScriptEnabled;
271 // Resource requests.
272 public void addResourceRequest(String[] resourceRequest) {
273 // Add the resource request to the list.
274 resourceRequests.add(resourceRequest);
277 public List<String[]> getResourceRequests() {
278 // Return the list of resource requests as an array list.
279 return resourceRequests;
282 public void clearResourceRequests() {
283 // Clear the resource requests.
284 resourceRequests.clear();
289 public void enableBlocklist(int blocklist, boolean status) {
290 // Update the status of the indicated blocklist.
293 // Update the status of the blocklist.
294 easyListEnabled = status;
298 // Update the status of the blocklist.
299 easyPrivacyEnabled = status;
302 case FANBOYS_ANNOYANCE_LIST:
303 // Update the status of the blocklist.
304 fanboysAnnoyanceListEnabled = status;
307 case FANBOYS_SOCIAL_BLOCKING_LIST:
308 // Update the status of the blocklist.
309 fanboysSocialBlockingListEnabled = status;
313 // Update the status of the blocklist.
314 ultraPrivacyEnabled = status;
317 case THIRD_PARTY_REQUESTS:
318 // Update the status of the blocklist.
319 blockAllThirdPartyRequests = status;
324 public boolean isBlocklistEnabled(int blocklist) {
325 // Get the status of the indicated blocklist.
328 // Return the status of the blocklist.
329 return easyListEnabled;
332 // Return the status of the blocklist.
333 return easyPrivacyEnabled;
335 case FANBOYS_ANNOYANCE_LIST:
336 // Return the status of the blocklist.
337 return fanboysAnnoyanceListEnabled;
339 case FANBOYS_SOCIAL_BLOCKING_LIST:
340 // Return the status of the blocklist.
341 return fanboysSocialBlockingListEnabled;
344 // Return the status of the blocklist.
345 return ultraPrivacyEnabled;
347 case THIRD_PARTY_REQUESTS:
348 // Return the status of the blocklist.
349 return blockAllThirdPartyRequests;
352 // The default value is required but should never be used.
358 // Resource request counters.
359 public void resetRequestsCounters() {
360 // Reset all the resource request counters.
362 easyListBlockedRequests = 0;
363 easyPrivacyBlockedRequests = 0;
364 fanboysAnnoyanceListBlockedRequests = 0;
365 fanboysSocialBlockingListBlockedRequests = 0;
366 ultraPrivacyBlockedRequests = 0;
367 thirdPartyBlockedRequests = 0;
370 public void incrementRequestsCount(int blocklist) {
371 // Increment the count of the indicated blocklist.
373 case BLOCKED_REQUESTS:
374 // Increment the blocked requests count.
379 // Increment the EasyList blocked requests count.
380 easyListBlockedRequests++;
384 // Increment the EasyPrivacy blocked requests count.
385 easyPrivacyBlockedRequests++;
388 case FANBOYS_ANNOYANCE_LIST:
389 // Increment the Fanboy's Annoyance List blocked requests count.
390 fanboysAnnoyanceListBlockedRequests++;
393 case FANBOYS_SOCIAL_BLOCKING_LIST:
394 // Increment the Fanboy's Social Blocking List blocked requests count.
395 fanboysSocialBlockingListBlockedRequests++;
399 // Increment the UltraPrivacy blocked requests count.
400 ultraPrivacyBlockedRequests++;
403 case THIRD_PARTY_REQUESTS:
404 // Increment the Third Party blocked requests count.
405 thirdPartyBlockedRequests++;
410 public int getRequestsCount(int blocklist) {
411 // Get the count of the indicated blocklist.
413 case BLOCKED_REQUESTS:
414 // Return the blocked requests count.
415 return blockedRequests;
418 // Return the EasyList blocked requests count.
419 return easyListBlockedRequests;
422 // Return the EasyPrivacy blocked requests count.
423 return easyPrivacyBlockedRequests;
425 case FANBOYS_ANNOYANCE_LIST:
426 // Return the Fanboy's Annoyance List blocked requests count.
427 return fanboysAnnoyanceListBlockedRequests;
429 case FANBOYS_SOCIAL_BLOCKING_LIST:
430 // Return the Fanboy's Social Blocking List blocked requests count.
431 return fanboysSocialBlockingListBlockedRequests;
434 // Return the UltraPrivacy blocked requests count.
435 return ultraPrivacyBlockedRequests;
437 case THIRD_PARTY_REQUESTS:
438 // Return the Third Party blocked requests count.
439 return thirdPartyBlockedRequests;
442 // Return 0. This should never end up being called.
448 // Pinned SSL certificates.
449 public boolean hasPinnedSslCertificate() {
450 // Return the status of the pinned SSL certificate.
451 return hasPinnedSslCertificate;
454 public void setPinnedSslCertificate(String issuedToCName, String issuedToOName, String issuedToUName, String issuedByCName, String issuedByOName, String issuedByUName, Date startDate, Date endDate) {
455 // Store the pinned SSL certificate information.
456 pinnedSslIssuedToCName = issuedToCName;
457 pinnedSslIssuedToOName = issuedToOName;
458 pinnedSslIssuedToUName = issuedToUName;
459 pinnedSslIssuedByCName = issuedByCName;
460 pinnedSslIssuedByOName = issuedByOName;
461 pinnedSslIssuedByUName = issuedByUName;
462 pinnedSslStartDate = startDate;
463 pinnedSslEndDate = endDate;
465 // Set the pinned SSL certificate tracker.
466 hasPinnedSslCertificate = true;
469 public ArrayList<Object> getPinnedSslCertificate() {
470 // Initialize an array list.
471 ArrayList<Object> arrayList = new ArrayList<>();
473 // Create the SSL certificate string array.
474 String[] sslCertificateStringArray = new String[] {pinnedSslIssuedToCName, pinnedSslIssuedToOName, pinnedSslIssuedToUName, pinnedSslIssuedByCName, pinnedSslIssuedByOName, pinnedSslIssuedByUName};
476 // Create the SSL certificate date array.
477 Date[] sslCertificateDateArray = new Date[] {pinnedSslStartDate, pinnedSslEndDate};
479 // Add the arrays to the array list.
480 arrayList.add(sslCertificateStringArray);
481 arrayList.add(sslCertificateDateArray);
483 // Return the pinned SSL certificate array list.
487 public void clearPinnedSslCertificate() {
488 // Clear the pinned SSL certificate.
489 pinnedSslIssuedToCName = null;
490 pinnedSslIssuedToOName = null;
491 pinnedSslIssuedToUName = null;
492 pinnedSslIssuedByCName = null;
493 pinnedSslIssuedByOName = null;
494 pinnedSslIssuedByUName = null;
495 pinnedSslStartDate = null;
496 pinnedSslEndDate = null;
498 // Clear the pinned SSL certificate tracker.
499 hasPinnedSslCertificate = false;
503 // Current IP addresses.
504 public boolean hasCurrentIpAddresses() {
505 // Return the status of the current IP addresses.
506 return hasCurrentIpAddresses;
509 public void setCurrentIpAddresses(String ipAddresses) {
510 // Store the current IP addresses.
511 currentIpAddresses = ipAddresses;
513 // Set the current IP addresses tracker.
514 hasCurrentIpAddresses = true;
517 public String getCurrentIpAddresses() {
518 // Return the current IP addresses.
519 return currentIpAddresses;
522 public void clearCurrentIpAddresses() {
523 // Clear the current IP addresses.
524 currentIpAddresses = null;
526 // Clear the current IP addresses tracker.
527 hasCurrentIpAddresses = false;
531 // Pinned IP addresses.
532 public boolean hasPinnedIpAddresses() {
533 // Return the status of the pinned IP addresses.
534 return hasPinnedIpAddresses;
537 public void setPinnedIpAddresses(String ipAddresses) {
538 // Store the pinned IP addresses.
539 pinnedIpAddresses = ipAddresses;
541 // Set the pinned IP addresses tracker.
542 hasPinnedIpAddresses = true;
545 public String getPinnedIpAddresses() {
546 // Return the pinned IP addresses.
547 return pinnedIpAddresses;
550 public void clearPinnedIpAddresses() {
551 // Clear the pinned IP addresses.
552 pinnedIpAddresses = null;
554 // Clear the pinned IP addresses tracker.
555 hasPinnedIpAddresses = false;
559 // Ignore pinned information.
560 public void setIgnorePinnedDomainInformation(boolean status) {
561 // Set the status of the ignore pinned domain information tracker.
562 ignorePinnedDomainInformation = status;
565 // The syntax looks better as written, even if it is always inverted.
566 @SuppressWarnings("BooleanMethodIsAlwaysInverted")
567 public boolean ignorePinnedDomainInformation() {
568 // Return the status of the ignore pinned domain information tracker.
569 return ignorePinnedDomainInformation;
573 // Navigating history.
574 public void setNavigatingHistory(boolean status) {
575 // Set the status of navigating history.
576 navigatingHistory = status;
579 public boolean getNavigatingHistory() {
580 // Return the status of navigating history.
581 return navigatingHistory;
585 // Favorite or default icon.
586 public void initializeFavoriteIcon() {
587 // Get the default favorite icon drawable. `ContextCompat` must be used until API >= 21.
588 Drawable favoriteIconDrawable = ContextCompat.getDrawable(getContext(), R.drawable.world);
590 // Cast the favorite icon drawable to a bitmap drawable.
591 BitmapDrawable favoriteIconBitmapDrawable = (BitmapDrawable) favoriteIconDrawable;
593 // Remove the incorrect warning below that the favorite icon bitmap drawable might be null.
594 assert favoriteIconBitmapDrawable != null;
596 // Store the default icon bitmap.
597 favoriteOrDefaultIcon = favoriteIconBitmapDrawable.getBitmap();
600 public void setFavoriteOrDefaultIcon(Bitmap icon) {
601 // Scale the favorite icon bitmap down if it is larger than 256 x 256. Filtering uses bilinear interpolation.
602 if ((icon.getHeight() > 256) || (icon.getWidth() > 256)) {
603 favoriteOrDefaultIcon = Bitmap.createScaledBitmap(icon, 256, 256, true);
605 // Store the icon as presented.
606 favoriteOrDefaultIcon = icon;
610 public Bitmap getFavoriteOrDefaultIcon() {
611 // Return the favorite or default icon.
612 return favoriteOrDefaultIcon;
617 public void setNightMode(boolean status) {
618 // Store the night mode status.
622 public boolean getNightMode() {
623 // Return the night mode status.
629 public void setSwipeToRefresh(boolean status) {
630 // Store the swipe to refresh status.
631 swipeToRefresh = status;
634 public boolean getSwipeToRefresh() {
635 // Return the swipe to refresh status.
636 return swipeToRefresh;
641 public int getHorizontalScrollRange() {
642 // Return the horizontal scroll range.
643 return computeHorizontalScrollRange();
646 public int getVerticalScrollRange() {
647 // Return the vertical scroll range.
648 return computeVerticalScrollRange();
654 public boolean onTouchEvent(MotionEvent motionEvent) {
655 // Initialize a tracker to return if this motion event is handled.
656 boolean motionEventHandled;
658 // Run the commands for the given motion event action.
659 switch (motionEvent.getAction()) {
660 case MotionEvent.ACTION_DOWN:
661 // Start nested scrolling along the vertical axis. `ViewCompat` must be used until the minimum API >= 21.
662 startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL);
664 // Save the current Y position. Action down will not be called again until a new motion starts.
665 previousYPosition = (int) motionEvent.getY();
667 // Run the default commands.
668 motionEventHandled = super.onTouchEvent(motionEvent);
671 case MotionEvent.ACTION_MOVE:
672 // Get the current Y position.
673 int currentYMotionPosition = (int) motionEvent.getY();
675 // Calculate the pre-scroll delta Y.
676 int preScrollDeltaY = previousYPosition - currentYMotionPosition;
678 // Initialize a variable to track how much of the scroll is consumed.
679 int[] consumedScroll = new int[2];
681 // Initialize a variable to track the offset in the window.
682 int[] offsetInWindow = new int[2];
684 // Get the WebView Y position.
685 int webViewYPosition = getScrollY();
687 // Set the scroll delta Y to initially be the same as the pre-scroll delta Y.
688 int scrollDeltaY = preScrollDeltaY;
690 // Dispatch the nested pre-school. This scrolls the app bar if it needs it. `offsetInWindow` will be returned with an updated value.
691 if (dispatchNestedPreScroll(0, preScrollDeltaY, consumedScroll, offsetInWindow)) {
692 // Update the scroll delta Y if some of it was consumed.
693 // There is currently a bug in Android where if scrolling up at a certain slow speed the input can lock the pre scroll and continue to consume it after the app bar is fully displayed.
694 scrollDeltaY = preScrollDeltaY - consumedScroll[1];
697 // Check to see if the WebView is at the top and and the scroll action is downward.
698 if ((webViewYPosition == 0) && (scrollDeltaY < 0)) { // Swipe to refresh is being engaged.
699 // 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.
701 } else { // Swipe to refresh is not being engaged.
702 // Start the nested scroll so that the app bar can scroll off the screen.
703 startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL);
705 // 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.
706 dispatchNestedScroll(0, scrollDeltaY, 0, 0, offsetInWindow);
708 // Store the current Y position for use in the next action move.
709 previousYPosition = previousYPosition - scrollDeltaY;
712 // Run the default commands.
713 motionEventHandled = super.onTouchEvent(motionEvent);
718 // Stop nested scrolling.
721 // Run the default commands.
722 motionEventHandled = super.onTouchEvent(motionEvent);
725 // Perform a click. This is required by the Android accessibility guidelines.
728 // Return the status of the motion event.
729 return motionEventHandled;
732 // The Android accessibility guidelines require overriding `performClick()` and calling it from `onTouchEvent()`.
734 public boolean performClick() {
735 return super.performClick();
739 // Method from NestedScrollingChild.
741 public void setNestedScrollingEnabled(boolean status) {
742 // Set the status of the nested scrolling.
743 nestedScrollingChildHelper.setNestedScrollingEnabled(status);
746 // Method from NestedScrollingChild.
748 public boolean isNestedScrollingEnabled() {
749 // Return the status of nested scrolling.
750 return nestedScrollingChildHelper.isNestedScrollingEnabled();
754 // Method from NestedScrollingChild.
756 public boolean startNestedScroll(int axes) {
757 // Start a nested scroll along the indicated axes.
758 return nestedScrollingChildHelper.startNestedScroll(axes);
761 // Method from NestedScrollingChild2.
763 public boolean startNestedScroll(int axes, int type) {
764 // Start a nested scroll along the indicated axes for the given type of input which caused the scroll event.
765 return nestedScrollingChildHelper.startNestedScroll(axes, type);
769 // Method from NestedScrollingChild.
771 public void stopNestedScroll() {
772 // Stop the nested scroll.
773 nestedScrollingChildHelper.stopNestedScroll();
776 // Method from NestedScrollingChild2.
778 public void stopNestedScroll(int type) {
779 // Stop the nested scroll of the given type of input which caused the scroll event.
780 nestedScrollingChildHelper.stopNestedScroll(type);
784 // Method from NestedScrollingChild.
786 public boolean hasNestedScrollingParent() {
787 // Return the status of the nested scrolling parent.
788 return nestedScrollingChildHelper.hasNestedScrollingParent();
791 // Method from NestedScrollingChild2.
793 public boolean hasNestedScrollingParent(int type) {
794 // return the status of the nested scrolling parent for the given type of input which caused the scroll event.
795 return nestedScrollingChildHelper.hasNestedScrollingParent(type);
799 // Method from NestedScrollingChild.
801 public boolean dispatchNestedPreScroll(int deltaX, int deltaY, int[] consumed, int[] offsetInWindow) {
802 // Dispatch a nested pre-scroll with the specified deltas, which lets a parent to consume some of the scroll if desired.
803 return nestedScrollingChildHelper.dispatchNestedPreScroll(deltaX, deltaY, consumed, offsetInWindow);
806 // Method from NestedScrollingChild2.
808 public boolean dispatchNestedPreScroll(int deltaX, int deltaY, int[] consumed, int[] offsetInWindow, int type) {
809 // 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.
810 return nestedScrollingChildHelper.dispatchNestedPreScroll(deltaX, deltaY, consumed, offsetInWindow, type);
814 // Method from NestedScrollingChild.
816 public boolean dispatchNestedScroll(int deltaXConsumed, int deltaYConsumed, int deltaXUnconsumed, int deltaYUnconsumed, int[] offsetInWindow) {
817 // Dispatch a nested scroll with the specified deltas.
818 return nestedScrollingChildHelper.dispatchNestedScroll(deltaXConsumed, deltaYConsumed, deltaXUnconsumed, deltaYUnconsumed, offsetInWindow);
821 // Method from NestedScrollingChild2.
823 public boolean dispatchNestedScroll(int deltaXConsumed, int deltaYConsumed, int deltaXUnconsumed, int deltaYUnconsumed, int[] offsetInWindow, int type) {
824 // Dispatch a nested scroll with the specified deltas for the given type of input which caused the scroll event.
825 return nestedScrollingChildHelper.dispatchNestedScroll(deltaXConsumed, deltaYConsumed, deltaXUnconsumed, deltaYUnconsumed, offsetInWindow, type);
829 // Method from NestedScrollingChild.
831 public boolean dispatchNestedPreFling(float velocityX, float velocityY) {
832 // Dispatch a nested pre-fling with the specified velocity, which lets a parent consume the fling if desired.
833 return nestedScrollingChildHelper.dispatchNestedPreFling(velocityX, velocityY);
836 // Method from NestedScrollingChild.
838 public boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed) {
839 // Dispatch a nested fling with the specified velocity.
840 return nestedScrollingChildHelper.dispatchNestedFling(velocityX, velocityY, consumed);