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 EASYLIST = 1;
50 public final static int EASYPRIVACY = 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 ULTRALIST = 5;
54 public final static int ULTRAPRIVACY = 6;
55 public final static int THIRD_PARTY_REQUESTS = 7;
57 // Keep a copy of the WebView fragment ID.
58 private long webViewFragmentId;
60 // Store the handlers.
61 private SslErrorHandler sslErrorHandler;
62 private HttpAuthHandler httpAuthHandler;
64 // Track if domain settings are applied to this nested scroll WebView and, if so, the database ID.
65 private boolean domainSettingsApplied;
66 private int domainSettingsDatabaseId;
68 // Keep track of the current URL. This is used to not block resource requests to the main URL.
69 private String currentUrl;
71 // Keep track of when the domain name changes so that domain settings can be reapplied. This should never be null.
72 private String currentDomainName = "";
74 // Track the status of first-party cookies.
75 private boolean acceptFirstPartyCookies;
77 // Track the domain settings JavaScript status. This can be removed once night mode does not require JavaScript.
78 private boolean domainSettingsJavaScriptEnabled;
80 // Track the resource requests.
81 private List<String[]> resourceRequests = Collections.synchronizedList(new ArrayList<>()); // Using a synchronized list makes adding resource requests thread safe.
82 private boolean easyListEnabled;
83 private boolean easyPrivacyEnabled;
84 private boolean fanboysAnnoyanceListEnabled;
85 private boolean fanboysSocialBlockingListEnabled;
86 private boolean ultraListEnabled;
87 private boolean ultraPrivacyEnabled;
88 private boolean blockAllThirdPartyRequests;
89 private int blockedRequests;
90 private int easyListBlockedRequests;
91 private int easyPrivacyBlockedRequests;
92 private int fanboysAnnoyanceListBlockedRequests;
93 private int fanboysSocialBlockingListBlockedRequests;
94 private int ultraListBlockedRequests;
95 private int ultraPrivacyBlockedRequests;
96 private int thirdPartyBlockedRequests;
98 // The pinned SSL certificate variables.
99 private boolean hasPinnedSslCertificate;
100 private String pinnedSslIssuedToCName;
101 private String pinnedSslIssuedToOName;
102 private String pinnedSslIssuedToUName;
103 private String pinnedSslIssuedByCName;
104 private String pinnedSslIssuedByOName;
105 private String pinnedSslIssuedByUName;
106 private Date pinnedSslStartDate;
107 private Date pinnedSslEndDate;
109 // The current IP addresses variables.
110 private boolean hasCurrentIpAddresses;
111 private String currentIpAddresses;
113 // The pinned IP addresses variables.
114 private boolean hasPinnedIpAddresses;
115 private String pinnedIpAddresses;
117 // 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.
118 private boolean ignorePinnedDomainInformation;
120 // The default or favorite icon.
121 private Bitmap favoriteOrDefaultIcon;
124 private boolean nightMode;
126 // Track swipe to refresh.
127 private boolean swipeToRefresh;
129 // The nested scrolling child helper is used throughout the class.
130 private NestedScrollingChildHelper nestedScrollingChildHelper;
132 // The previous Y position needs to be tracked between motion events.
133 private int previousYPosition;
137 // The basic constructor.
138 public NestedScrollWebView(Context context) {
139 // Roll up to the next constructor.
143 // The intermediate constructor.
144 public NestedScrollWebView(Context context, AttributeSet attributeSet) {
145 // Roll up to the next constructor.
146 this(context, attributeSet, android.R.attr.webViewStyle);
149 // The full constructor.
150 public NestedScrollWebView(Context context, AttributeSet attributeSet, int defaultStyle) {
151 // Run the default commands.
152 super(context, attributeSet, defaultStyle);
154 // Initialize the nested scrolling child helper.
155 nestedScrollingChildHelper = new NestedScrollingChildHelper(this);
157 // Enable nested scrolling by default.
158 nestedScrollingChildHelper.setNestedScrollingEnabled(true);
163 // WebView Fragment ID.
164 public void setWebViewFragmentId(long webViewFragmentId) {
165 // Store the WebView fragment ID.
166 this.webViewFragmentId = webViewFragmentId;
169 public long getWebViewFragmentId() {
170 // Return the WebView fragment ID.
171 return webViewFragmentId;
175 // SSL error handler.
176 public void setSslErrorHandler(SslErrorHandler sslErrorHandler) {
177 // Store the current SSL error handler.
178 this.sslErrorHandler = sslErrorHandler;
181 public SslErrorHandler getSslErrorHandler() {
182 // Return the current SSL error handler.
183 return sslErrorHandler;
186 public void resetSslErrorHandler() {
187 // Reset the current SSL error handler.
188 sslErrorHandler = null;
192 // HTTP authentication handler.
193 public void setHttpAuthHandler(HttpAuthHandler httpAuthHandler) {
194 // Store the current HTTP authentication handler.
195 this.httpAuthHandler = httpAuthHandler;
198 public HttpAuthHandler getHttpAuthHandler() {
199 // Return the current HTTP authentication handler.
200 return httpAuthHandler;
203 public void resetHttpAuthHandler() {
204 // Reset the current HTTP authentication handler.
205 httpAuthHandler = null;
210 public void setDomainSettingsApplied(boolean applied) {
211 // Store the domain settings applied status.
212 domainSettingsApplied = applied;
215 public boolean getDomainSettingsApplied() {
216 // Return the domain settings applied status.
217 return domainSettingsApplied;
221 // Domain settings database ID.
222 public void setDomainSettingsDatabaseId(int databaseId) {
223 // Store the domain settings database ID.
224 domainSettingsDatabaseId = databaseId;
227 public int getDomainSettingsDatabaseId() {
228 // Return the domain settings database ID.
229 return domainSettingsDatabaseId;
234 public void setCurrentUrl(String url) {
235 // Store the current URL.
239 public String getCurrentUrl() {
240 // Return the current URL.
245 // Current domain name. To function well when called, the domain name should never be allowed to be null.
246 public void setCurrentDomainName(@NonNull String domainName) {
247 // Store the current domain name.
248 currentDomainName = domainName;
251 public void resetCurrentDomainName() {
252 // Reset the current domain name.
253 currentDomainName = "";
256 public String getCurrentDomainName() {
257 // Return the current domain name.
258 return currentDomainName;
262 // First-party cookies.
263 public void setAcceptFirstPartyCookies(boolean status) {
264 // Store the accept first-party cookies status.
265 acceptFirstPartyCookies = status;
268 public boolean getAcceptFirstPartyCookies() {
269 // Return the accept first-party cookies status.
270 return acceptFirstPartyCookies;
274 // Domain settings JavaScript enabled. This can be removed once night mode does not require JavaScript.
275 public void setDomainSettingsJavaScriptEnabled(boolean status) {
276 // Store the domain settings JavaScript status.
277 domainSettingsJavaScriptEnabled = status;
280 public boolean getDomainSettingsJavaScriptEnabled() {
281 // Return the domain settings JavaScript status.
282 return domainSettingsJavaScriptEnabled;
286 // Resource requests.
287 public void addResourceRequest(String[] resourceRequest) {
288 // Add the resource request to the list.
289 resourceRequests.add(resourceRequest);
292 public List<String[]> getResourceRequests() {
293 // Return the list of resource requests as an array list.
294 return resourceRequests;
297 public void clearResourceRequests() {
298 // Clear the resource requests.
299 resourceRequests.clear();
304 public void enableBlocklist(int blocklist, boolean status) {
305 // Update the status of the indicated blocklist.
308 // Update the status of the blocklist.
309 easyListEnabled = status;
313 // Update the status of the blocklist.
314 easyPrivacyEnabled = status;
317 case FANBOYS_ANNOYANCE_LIST:
318 // Update the status of the blocklist.
319 fanboysAnnoyanceListEnabled = status;
322 case FANBOYS_SOCIAL_BLOCKING_LIST:
323 // Update the status of the blocklist.
324 fanboysSocialBlockingListEnabled = status;
328 // Update the status of the blocklist.
329 ultraListEnabled = status;
333 // Update the status of the blocklist.
334 ultraPrivacyEnabled = status;
337 case THIRD_PARTY_REQUESTS:
338 // Update the status of the blocklist.
339 blockAllThirdPartyRequests = status;
344 public boolean isBlocklistEnabled(int blocklist) {
345 // Get the status of the indicated blocklist.
348 // Return the status of the blocklist.
349 return easyListEnabled;
352 // Return the status of the blocklist.
353 return easyPrivacyEnabled;
355 case FANBOYS_ANNOYANCE_LIST:
356 // Return the status of the blocklist.
357 return fanboysAnnoyanceListEnabled;
359 case FANBOYS_SOCIAL_BLOCKING_LIST:
360 // Return the status of the blocklist.
361 return fanboysSocialBlockingListEnabled;
364 // Return the status of the blocklist.
365 return ultraListEnabled;
368 // Return the status of the blocklist.
369 return ultraPrivacyEnabled;
371 case THIRD_PARTY_REQUESTS:
372 // Return the status of the blocklist.
373 return blockAllThirdPartyRequests;
376 // The default value is required but should never be used.
382 // Resource request counters.
383 public void resetRequestsCounters() {
384 // Reset all the resource request counters.
386 easyListBlockedRequests = 0;
387 easyPrivacyBlockedRequests = 0;
388 fanboysAnnoyanceListBlockedRequests = 0;
389 fanboysSocialBlockingListBlockedRequests = 0;
390 ultraListBlockedRequests = 0;
391 ultraPrivacyBlockedRequests = 0;
392 thirdPartyBlockedRequests = 0;
395 public void incrementRequestsCount(int blocklist) {
396 // Increment the count of the indicated blocklist.
398 case BLOCKED_REQUESTS:
399 // Increment the blocked requests count.
404 // Increment the EasyList blocked requests count.
405 easyListBlockedRequests++;
409 // Increment the EasyPrivacy blocked requests count.
410 easyPrivacyBlockedRequests++;
413 case FANBOYS_ANNOYANCE_LIST:
414 // Increment the Fanboy's Annoyance List blocked requests count.
415 fanboysAnnoyanceListBlockedRequests++;
418 case FANBOYS_SOCIAL_BLOCKING_LIST:
419 // Increment the Fanboy's Social Blocking List blocked requests count.
420 fanboysSocialBlockingListBlockedRequests++;
424 // Increment the UltraList blocked requests count.
425 ultraListBlockedRequests++;
429 // Increment the UltraPrivacy blocked requests count.
430 ultraPrivacyBlockedRequests++;
433 case THIRD_PARTY_REQUESTS:
434 // Increment the Third Party blocked requests count.
435 thirdPartyBlockedRequests++;
440 public int getRequestsCount(int blocklist) {
441 // Get the count of the indicated blocklist.
443 case BLOCKED_REQUESTS:
444 // Return the blocked requests count.
445 return blockedRequests;
448 // Return the EasyList blocked requests count.
449 return easyListBlockedRequests;
452 // Return the EasyPrivacy blocked requests count.
453 return easyPrivacyBlockedRequests;
455 case FANBOYS_ANNOYANCE_LIST:
456 // Return the Fanboy's Annoyance List blocked requests count.
457 return fanboysAnnoyanceListBlockedRequests;
459 case FANBOYS_SOCIAL_BLOCKING_LIST:
460 // Return the Fanboy's Social Blocking List blocked requests count.
461 return fanboysSocialBlockingListBlockedRequests;
464 // Return the UltraList blocked requests count.
465 return ultraListBlockedRequests;
468 // Return the UltraPrivacy blocked requests count.
469 return ultraPrivacyBlockedRequests;
471 case THIRD_PARTY_REQUESTS:
472 // Return the Third Party blocked requests count.
473 return thirdPartyBlockedRequests;
476 // Return 0. This should never end up being called.
482 // Pinned SSL certificates.
483 public boolean hasPinnedSslCertificate() {
484 // Return the status of the pinned SSL certificate.
485 return hasPinnedSslCertificate;
488 public void setPinnedSslCertificate(String issuedToCName, String issuedToOName, String issuedToUName, String issuedByCName, String issuedByOName, String issuedByUName, Date startDate, Date endDate) {
489 // Store the pinned SSL certificate information.
490 pinnedSslIssuedToCName = issuedToCName;
491 pinnedSslIssuedToOName = issuedToOName;
492 pinnedSslIssuedToUName = issuedToUName;
493 pinnedSslIssuedByCName = issuedByCName;
494 pinnedSslIssuedByOName = issuedByOName;
495 pinnedSslIssuedByUName = issuedByUName;
496 pinnedSslStartDate = startDate;
497 pinnedSslEndDate = endDate;
499 // Set the pinned SSL certificate tracker.
500 hasPinnedSslCertificate = true;
503 public ArrayList<Object> getPinnedSslCertificate() {
504 // Initialize an array list.
505 ArrayList<Object> arrayList = new ArrayList<>();
507 // Create the SSL certificate string array.
508 String[] sslCertificateStringArray = new String[] {pinnedSslIssuedToCName, pinnedSslIssuedToOName, pinnedSslIssuedToUName, pinnedSslIssuedByCName, pinnedSslIssuedByOName, pinnedSslIssuedByUName};
510 // Create the SSL certificate date array.
511 Date[] sslCertificateDateArray = new Date[] {pinnedSslStartDate, pinnedSslEndDate};
513 // Add the arrays to the array list.
514 arrayList.add(sslCertificateStringArray);
515 arrayList.add(sslCertificateDateArray);
517 // Return the pinned SSL certificate array list.
521 public void clearPinnedSslCertificate() {
522 // Clear the pinned SSL certificate.
523 pinnedSslIssuedToCName = null;
524 pinnedSslIssuedToOName = null;
525 pinnedSslIssuedToUName = null;
526 pinnedSslIssuedByCName = null;
527 pinnedSslIssuedByOName = null;
528 pinnedSslIssuedByUName = null;
529 pinnedSslStartDate = null;
530 pinnedSslEndDate = null;
532 // Clear the pinned SSL certificate tracker.
533 hasPinnedSslCertificate = false;
537 // Current IP addresses.
538 public boolean hasCurrentIpAddresses() {
539 // Return the status of the current IP addresses.
540 return hasCurrentIpAddresses;
543 public void setCurrentIpAddresses(String ipAddresses) {
544 // Store the current IP addresses.
545 currentIpAddresses = ipAddresses;
547 // Set the current IP addresses tracker.
548 hasCurrentIpAddresses = true;
551 public String getCurrentIpAddresses() {
552 // Return the current IP addresses.
553 return currentIpAddresses;
556 public void clearCurrentIpAddresses() {
557 // Clear the current IP addresses.
558 currentIpAddresses = null;
560 // Clear the current IP addresses tracker.
561 hasCurrentIpAddresses = false;
565 // Pinned IP addresses.
566 public boolean hasPinnedIpAddresses() {
567 // Return the status of the pinned IP addresses.
568 return hasPinnedIpAddresses;
571 public void setPinnedIpAddresses(String ipAddresses) {
572 // Store the pinned IP addresses.
573 pinnedIpAddresses = ipAddresses;
575 // Set the pinned IP addresses tracker.
576 hasPinnedIpAddresses = true;
579 public String getPinnedIpAddresses() {
580 // Return the pinned IP addresses.
581 return pinnedIpAddresses;
584 public void clearPinnedIpAddresses() {
585 // Clear the pinned IP addresses.
586 pinnedIpAddresses = null;
588 // Clear the pinned IP addresses tracker.
589 hasPinnedIpAddresses = false;
593 // Ignore pinned information.
594 public void setIgnorePinnedDomainInformation(boolean status) {
595 // Set the status of the ignore pinned domain information tracker.
596 ignorePinnedDomainInformation = status;
599 // The syntax looks better as written, even if it is always inverted.
600 @SuppressWarnings("BooleanMethodIsAlwaysInverted")
601 public boolean ignorePinnedDomainInformation() {
602 // Return the status of the ignore pinned domain information tracker.
603 return ignorePinnedDomainInformation;
607 // Favorite or default icon.
608 public void initializeFavoriteIcon() {
609 // Get the default favorite icon drawable. `ContextCompat` must be used until API >= 21.
610 Drawable favoriteIconDrawable = ContextCompat.getDrawable(getContext(), R.drawable.world);
612 // Cast the favorite icon drawable to a bitmap drawable.
613 BitmapDrawable favoriteIconBitmapDrawable = (BitmapDrawable) favoriteIconDrawable;
615 // Remove the incorrect warning below that the favorite icon bitmap drawable might be null.
616 assert favoriteIconBitmapDrawable != null;
618 // Store the default icon bitmap.
619 favoriteOrDefaultIcon = favoriteIconBitmapDrawable.getBitmap();
622 public void setFavoriteOrDefaultIcon(Bitmap icon) {
623 // Scale the favorite icon bitmap down if it is larger than 256 x 256. Filtering uses bilinear interpolation.
624 if ((icon.getHeight() > 256) || (icon.getWidth() > 256)) {
625 favoriteOrDefaultIcon = Bitmap.createScaledBitmap(icon, 256, 256, true);
627 // Store the icon as presented.
628 favoriteOrDefaultIcon = icon;
632 public Bitmap getFavoriteOrDefaultIcon() {
633 // Return the favorite or default icon.
634 return favoriteOrDefaultIcon;
639 public void setNightMode(boolean status) {
640 // Store the night mode status.
644 public boolean getNightMode() {
645 // Return the night mode status.
651 public void setSwipeToRefresh(boolean status) {
652 // Store the swipe to refresh status.
653 swipeToRefresh = status;
656 public boolean getSwipeToRefresh() {
657 // Return the swipe to refresh status.
658 return swipeToRefresh;
663 public int getHorizontalScrollRange() {
664 // Return the horizontal scroll range.
665 return computeHorizontalScrollRange();
668 public int getVerticalScrollRange() {
669 // Return the vertical scroll range.
670 return computeVerticalScrollRange();
676 public boolean onTouchEvent(MotionEvent motionEvent) {
677 // Initialize a tracker to return if this motion event is handled.
678 boolean motionEventHandled;
680 // Run the commands for the given motion event action.
681 switch (motionEvent.getAction()) {
682 case MotionEvent.ACTION_DOWN:
683 // Start nested scrolling along the vertical axis. `ViewCompat` must be used until the minimum API >= 21.
684 startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL);
686 // Save the current Y position. Action down will not be called again until a new motion starts.
687 previousYPosition = (int) motionEvent.getY();
689 // Run the default commands.
690 motionEventHandled = super.onTouchEvent(motionEvent);
693 case MotionEvent.ACTION_MOVE:
694 // Get the current Y position.
695 int currentYMotionPosition = (int) motionEvent.getY();
697 // Calculate the pre-scroll delta Y.
698 int preScrollDeltaY = previousYPosition - currentYMotionPosition;
700 // Initialize a variable to track how much of the scroll is consumed.
701 int[] consumedScroll = new int[2];
703 // Initialize a variable to track the offset in the window.
704 int[] offsetInWindow = new int[2];
706 // Get the WebView Y position.
707 int webViewYPosition = getScrollY();
709 // Set the scroll delta Y to initially be the same as the pre-scroll delta Y.
710 int scrollDeltaY = preScrollDeltaY;
712 // Dispatch the nested pre-school. This scrolls the app bar if it needs it. `offsetInWindow` will be returned with an updated value.
713 if (dispatchNestedPreScroll(0, preScrollDeltaY, consumedScroll, offsetInWindow)) {
714 // Update the scroll delta Y if some of it was consumed.
715 // 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.
716 scrollDeltaY = preScrollDeltaY - consumedScroll[1];
719 // Check to see if the WebView is at the top and and the scroll action is downward.
720 if ((webViewYPosition == 0) && (scrollDeltaY < 0)) { // Swipe to refresh is being engaged.
721 // 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.
723 } else { // Swipe to refresh is not being engaged.
724 // Start the nested scroll so that the app bar can scroll off the screen.
725 startNestedScroll(ViewCompat.SCROLL_AXIS_VERTICAL);
727 // 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.
728 dispatchNestedScroll(0, scrollDeltaY, 0, 0, offsetInWindow);
730 // Store the current Y position for use in the next action move.
731 previousYPosition = previousYPosition - scrollDeltaY;
734 // Run the default commands.
735 motionEventHandled = super.onTouchEvent(motionEvent);
740 // Stop nested scrolling.
743 // Run the default commands.
744 motionEventHandled = super.onTouchEvent(motionEvent);
747 // Perform a click. This is required by the Android accessibility guidelines.
750 // Return the status of the motion event.
751 return motionEventHandled;
754 // The Android accessibility guidelines require overriding `performClick()` and calling it from `onTouchEvent()`.
756 public boolean performClick() {
757 return super.performClick();
761 // Method from NestedScrollingChild.
763 public void setNestedScrollingEnabled(boolean status) {
764 // Set the status of the nested scrolling.
765 nestedScrollingChildHelper.setNestedScrollingEnabled(status);
768 // Method from NestedScrollingChild.
770 public boolean isNestedScrollingEnabled() {
771 // Return the status of nested scrolling.
772 return nestedScrollingChildHelper.isNestedScrollingEnabled();
776 // Method from NestedScrollingChild.
778 public boolean startNestedScroll(int axes) {
779 // Start a nested scroll along the indicated axes.
780 return nestedScrollingChildHelper.startNestedScroll(axes);
783 // Method from NestedScrollingChild2.
785 public boolean startNestedScroll(int axes, int type) {
786 // Start a nested scroll along the indicated axes for the given type of input which caused the scroll event.
787 return nestedScrollingChildHelper.startNestedScroll(axes, type);
791 // Method from NestedScrollingChild.
793 public void stopNestedScroll() {
794 // Stop the nested scroll.
795 nestedScrollingChildHelper.stopNestedScroll();
798 // Method from NestedScrollingChild2.
800 public void stopNestedScroll(int type) {
801 // Stop the nested scroll of the given type of input which caused the scroll event.
802 nestedScrollingChildHelper.stopNestedScroll(type);
806 // Method from NestedScrollingChild.
808 public boolean hasNestedScrollingParent() {
809 // Return the status of the nested scrolling parent.
810 return nestedScrollingChildHelper.hasNestedScrollingParent();
813 // Method from NestedScrollingChild2.
815 public boolean hasNestedScrollingParent(int type) {
816 // return the status of the nested scrolling parent for the given type of input which caused the scroll event.
817 return nestedScrollingChildHelper.hasNestedScrollingParent(type);
821 // Method from NestedScrollingChild.
823 public boolean dispatchNestedPreScroll(int deltaX, int deltaY, int[] consumed, int[] offsetInWindow) {
824 // Dispatch a nested pre-scroll with the specified deltas, which lets a parent to consume some of the scroll if desired.
825 return nestedScrollingChildHelper.dispatchNestedPreScroll(deltaX, deltaY, consumed, offsetInWindow);
828 // Method from NestedScrollingChild2.
830 public boolean dispatchNestedPreScroll(int deltaX, int deltaY, int[] consumed, int[] offsetInWindow, int type) {
831 // 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.
832 return nestedScrollingChildHelper.dispatchNestedPreScroll(deltaX, deltaY, consumed, offsetInWindow, type);
836 // Method from NestedScrollingChild.
838 public boolean dispatchNestedScroll(int deltaXConsumed, int deltaYConsumed, int deltaXUnconsumed, int deltaYUnconsumed, int[] offsetInWindow) {
839 // Dispatch a nested scroll with the specified deltas.
840 return nestedScrollingChildHelper.dispatchNestedScroll(deltaXConsumed, deltaYConsumed, deltaXUnconsumed, deltaYUnconsumed, offsetInWindow);
843 // Method from NestedScrollingChild2.
845 public boolean dispatchNestedScroll(int deltaXConsumed, int deltaYConsumed, int deltaXUnconsumed, int deltaYUnconsumed, int[] offsetInWindow, int type) {
846 // Dispatch a nested scroll with the specified deltas for the given type of input which caused the scroll event.
847 return nestedScrollingChildHelper.dispatchNestedScroll(deltaXConsumed, deltaYConsumed, deltaXUnconsumed, deltaYUnconsumed, offsetInWindow, type);
851 // Method from NestedScrollingChild.
853 public boolean dispatchNestedPreFling(float velocityX, float velocityY) {
854 // Dispatch a nested pre-fling with the specified velocity, which lets a parent consume the fling if desired.
855 return nestedScrollingChildHelper.dispatchNestedPreFling(velocityX, velocityY);
858 // Method from NestedScrollingChild.
860 public boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed) {
861 // Dispatch a nested fling with the specified velocity.
862 return nestedScrollingChildHelper.dispatchNestedFling(velocityX, velocityY, consumed);