X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fviews%2FNestedScrollWebView.java;h=5d6dc8620e9e546cd0ac0719db5861a218600a9c;hp=4d97670d87210da1139873701353d858f480e401;hb=4c00dd29a0a8592dff337d8b01870f06134c070b;hpb=86e63c8ed007311ab392d4beb7dd7ba64b9c3c70 diff --git a/app/src/main/java/com/stoutner/privacybrowser/views/NestedScrollWebView.java b/app/src/main/java/com/stoutner/privacybrowser/views/NestedScrollWebView.java index 4d97670d..5d6dc862 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/views/NestedScrollWebView.java +++ b/app/src/main/java/com/stoutner/privacybrowser/views/NestedScrollWebView.java @@ -1,5 +1,5 @@ /* - * Copyright © 2019-2020 Soren Stoutner . + * Copyright © 2019-2021 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -60,7 +60,7 @@ public class NestedScrollWebView extends WebView implements NestedScrollingChild private final String DOMAIN_SETTINGS_DATABASE_ID = "domain_settings_database_id"; private final String CURRENT_URl = "current_url"; private final String CURRENT_DOMAIN_NAME = "current_domain_name"; - private final String ACCEPT_FIRST_PARTY_COOKIES = "accept_first_party_cookies"; + private final String ACCEPT_COOKIES = "accept_cookies"; private final String EASYLIST_ENABLED = "easylist_enabled"; private final String EASYPRIVACY_ENABLED = "easyprivacy_enabled"; private final String FANBOYS_ANNOYANCE_LIST_ENABLED = "fanboys_annoyance_list_enabled"; @@ -104,11 +104,11 @@ public class NestedScrollWebView extends WebView implements NestedScrollingChild // Keep track of when the domain name changes so that domain settings can be reapplied. This should never be null. private String currentDomainName = ""; - // Track the status of first-party cookies. This is necessary because first-party cookie status is app wide instead of WebView specific. - private boolean acceptFirstPartyCookies; + // Track the cookie status, which is necessary because cookie status is app wide instead of WebView specific. + private boolean acceptCookies; // Track the resource requests. - private List resourceRequests = Collections.synchronizedList(new ArrayList<>()); // Using a synchronized list makes adding resource requests thread safe. + private final List resourceRequests = Collections.synchronizedList(new ArrayList<>()); // Using a synchronized list makes adding resource requests thread safe. private boolean easyListEnabled; private boolean easyPrivacyEnabled; private boolean fanboysAnnoyanceListEnabled; @@ -157,7 +157,7 @@ public class NestedScrollWebView extends WebView implements NestedScrollingChild private String waitingForProxyUrlString = ""; // The nested scrolling child helper is used throughout the class. - private NestedScrollingChildHelper nestedScrollingChildHelper; + private final NestedScrollingChildHelper nestedScrollingChildHelper; // The previous Y position needs to be tracked between motion events. private int previousYPosition; @@ -289,15 +289,15 @@ public class NestedScrollWebView extends WebView implements NestedScrollingChild } - // First-party cookies. - public void setAcceptFirstPartyCookies(boolean status) { - // Store the accept first-party cookies status. - acceptFirstPartyCookies = status; + // Cookies. + public void setAcceptCookies(boolean status) { + // Store the accept cookies status. + acceptCookies = status; } - public boolean getAcceptFirstPartyCookies() { - // Return the accept first-party cookies status. - return acceptFirstPartyCookies; + public boolean getAcceptCookies() { + // Return the accept cookies status. + return acceptCookies; } @@ -694,9 +694,6 @@ public class NestedScrollWebView extends WebView implements NestedScrollingChild @Override public boolean onTouchEvent(MotionEvent motionEvent) { - // Initialize a tracker to return if this motion event is handled. - boolean motionEventHandled; - // Run the commands for the given motion event action. switch (motionEvent.getAction()) { case MotionEvent.ACTION_DOWN: @@ -705,9 +702,6 @@ public class NestedScrollWebView extends WebView implements NestedScrollingChild // Save the current Y position. Action down will not be called again until a new motion starts. previousYPosition = (int) motionEvent.getY(); - - // Run the default commands. - motionEventHandled = super.onTouchEvent(motionEvent); break; case MotionEvent.ACTION_MOVE: @@ -750,25 +744,19 @@ public class NestedScrollWebView extends WebView implements NestedScrollingChild // Store the current Y position for use in the next action move. previousYPosition = previousYPosition - scrollDeltaY; } - - // Run the default commands. - motionEventHandled = super.onTouchEvent(motionEvent); break; default: // Stop nested scrolling. stopNestedScroll(); - - // Run the default commands. - motionEventHandled = super.onTouchEvent(motionEvent); } // Perform a click. This is required by the Android accessibility guidelines. performClick(); - // Return the status of the motion event. - return motionEventHandled; + // Run the default commands and return the result. + return super.onTouchEvent(motionEvent); } public Bundle saveNestedScrollWebViewState() { @@ -793,7 +781,7 @@ public class NestedScrollWebView extends WebView implements NestedScrollingChild savedState.putInt(DOMAIN_SETTINGS_DATABASE_ID, domainSettingsDatabaseId); savedState.putString(CURRENT_URl, currentUrl); savedState.putString(CURRENT_DOMAIN_NAME, currentDomainName); - savedState.putBoolean(ACCEPT_FIRST_PARTY_COOKIES, acceptFirstPartyCookies); + savedState.putBoolean(ACCEPT_COOKIES, acceptCookies); savedState.putBoolean(EASYLIST_ENABLED, easyListEnabled); savedState.putBoolean(EASYPRIVACY_ENABLED, easyPrivacyEnabled); savedState.putBoolean(FANBOYS_ANNOYANCE_LIST_ENABLED, fanboysAnnoyanceListEnabled); @@ -830,7 +818,7 @@ public class NestedScrollWebView extends WebView implements NestedScrollingChild domainSettingsDatabaseId = savedState.getInt(DOMAIN_SETTINGS_DATABASE_ID); currentUrl = savedState.getString(CURRENT_URl); currentDomainName = savedState.getString(CURRENT_DOMAIN_NAME); - acceptFirstPartyCookies = savedState.getBoolean(ACCEPT_FIRST_PARTY_COOKIES); + acceptCookies = savedState.getBoolean(ACCEPT_COOKIES); easyListEnabled = savedState.getBoolean(EASYLIST_ENABLED); easyPrivacyEnabled = savedState.getBoolean(EASYPRIVACY_ENABLED); fanboysAnnoyanceListEnabled = savedState.getBoolean(FANBOYS_ANNOYANCE_LIST_ENABLED);