import kotlin.collections.ArrayList
-import kotlin.jvm.JvmOverloads
-
-// Define the saved state constants.
+// Define the public constants.
+const val BLOCKED_REQUESTS = 0
+const val EASYLIST = 1
+const val EASYPRIVACY = 2
+const val FANBOYS_ANNOYANCE_LIST = 3
+const val FANBOYS_SOCIAL_BLOCKING_LIST = 4
+const val ULTRALIST = 5
+const val ULTRAPRIVACY = 6
+const val THIRD_PARTY_REQUESTS = 7
+
+// Define the private class constants.
private const val DOMAIN_SETTINGS_APPLIED = "domain_settings_applied"
private const val DOMAIN_SETTINGS_DATABASE_ID = "domain_settings_database_id"
private const val CURRENT_DOMAIN_NAME = "current_domain_name"
// 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.
class NestedScrollWebView @JvmOverloads constructor(context: Context, attributeSet: AttributeSet? = null, defaultStyle: Int = android.R.attr.webViewStyle) : WebView(context, attributeSet, defaultStyle),
NestedScrollingChild2 {
- companion object {
- // Define the public companion object constants. These can be moved to public class constants once the entire project has migrated to Kotlin.
- const val BLOCKED_REQUESTS = 0
- const val EASYLIST = 1
- const val EASYPRIVACY = 2
- const val FANBOYS_ANNOYANCE_LIST = 3
- const val FANBOYS_SOCIAL_BLOCKING_LIST = 4
- const val ULTRALIST = 5
- const val ULTRAPRIVACY = 6
- const val THIRD_PARTY_REQUESTS = 7
- }
// Define the public variables.
var acceptCookies = false
var waitingForProxyUrlString = ""
var webViewFragmentId: Long = 0
-
// Define the private variables.
private val nestedScrollingChildHelper: NestedScrollingChildHelper = NestedScrollingChildHelper(this)
private lateinit var favoriteIcon: Bitmap
initializeFavoriteIcon()
}
-
// Favorite or default icon.
fun initializeFavoriteIcon() {
// Get the default favorite icon drawable.
// Resource request counters.
- fun incrementRequestsCount(blocklist: Int) {
- // Increment the count of the indicated blocklist.
- when (blocklist) {
+ fun incrementRequestsCount(filterList: Int) {
+ // Increment the count of the indicated filter list.
+ when (filterList) {
BLOCKED_REQUESTS -> blockedRequests++
EASYLIST -> easyListBlockedRequests++
EASYPRIVACY -> easyPrivacyBlockedRequests++
}
}
- fun getRequestsCount(blocklist: Int): Int {
- // Return the count of the indicated blocklist.
- return when (blocklist) {
+ fun getRequestsCount(filterList: Int): Int {
+ // Return the count of the indicated filter list.
+ return when (filterList) {
BLOCKED_REQUESTS -> blockedRequests
EASYLIST -> easyListBlockedRequests
EASYPRIVACY -> easyPrivacyBlockedRequests