/*
- * Copyright © 2019-2020 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2019-2021 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
*
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";
// 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<String[]> resourceRequests = Collections.synchronizedList(new ArrayList<>()); // Using a synchronized list makes adding resource requests thread safe.
+ private final List<String[]> resourceRequests = Collections.synchronizedList(new ArrayList<>()); // Using a synchronized list makes adding resource requests thread safe.
private boolean easyListEnabled;
private boolean easyPrivacyEnabled;
private boolean fanboysAnnoyanceListEnabled;
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;
}
- // 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;
}
@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:
// 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:
// 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() {
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);
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);