+ public Cursor getCursorForDomainName(String domainName) {
+ // Get a readable database handle.
+ SQLiteDatabase domainsDatabase = this.getReadableDatabase();
+
+ // Return a cursor for the requested domain name.
+ return domainsDatabase.query(DOMAINS_TABLE, null, DOMAIN_NAME + " = " + "\"" + domainName + "\"", null, null, null, null);
+
+ }
+
+ public int addDomain(String domainName) {
+ // Store the domain data in a `ContentValues`.
+ ContentValues domainContentValues = new ContentValues();
+
+ // Get a handle for the shared preference.
+ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(appContext);
+
+ // Get the default settings.
+ boolean javaScript = sharedPreferences.getBoolean("javascript", false);
+ boolean firstPartyCookies = sharedPreferences.getBoolean("first_party_cookies", false);
+ boolean thirdPartyCookies = sharedPreferences.getBoolean("third_party_cookies", false);
+ boolean domStorage = sharedPreferences.getBoolean("dom_storage", false);
+ boolean saveFormData = sharedPreferences.getBoolean("save_form_data", false); // Form data can be removed once the minimum API >= 26.
+ boolean easyList = sharedPreferences.getBoolean("easylist", true);
+ boolean easyPrivacy = sharedPreferences.getBoolean("easyprivacy", true);
+ boolean fanboyAnnoyanceList = sharedPreferences.getBoolean("fanboys_annoyance_list", true);
+ boolean fanboySocialBlockingList = sharedPreferences.getBoolean("fanboys_social_blocking_list", true);
+ boolean ultraList = sharedPreferences.getBoolean("ultralist", true);
+ boolean ultraPrivacy = sharedPreferences.getBoolean("ultraprivacy", true);
+ boolean blockAllThirdPartyRequests = sharedPreferences.getBoolean("block_all_third_party_requests", false);
+
+ // Create entries for the database fields. The ID is created automatically. The pinned SSL certificate information is not created unless added by the user.
+ domainContentValues.put(DOMAIN_NAME, domainName);
+ domainContentValues.put(ENABLE_JAVASCRIPT, javaScript);
+ domainContentValues.put(ENABLE_FIRST_PARTY_COOKIES, firstPartyCookies);
+ domainContentValues.put(ENABLE_THIRD_PARTY_COOKIES, thirdPartyCookies);
+ domainContentValues.put(ENABLE_DOM_STORAGE, domStorage);
+ domainContentValues.put(ENABLE_FORM_DATA, saveFormData); // Form data can be removed once the minimum API >= 26.
+ domainContentValues.put(ENABLE_EASYLIST, easyList);
+ domainContentValues.put(ENABLE_EASYPRIVACY, easyPrivacy);
+ domainContentValues.put(ENABLE_FANBOYS_ANNOYANCE_LIST, fanboyAnnoyanceList);
+ domainContentValues.put(ENABLE_FANBOYS_SOCIAL_BLOCKING_LIST, fanboySocialBlockingList);
+ domainContentValues.put(ULTRALIST, ultraList);
+ domainContentValues.put(ENABLE_ULTRAPRIVACY, ultraPrivacy);
+ domainContentValues.put(BLOCK_ALL_THIRD_PARTY_REQUESTS, blockAllThirdPartyRequests);
+ domainContentValues.put(USER_AGENT, "System default user agent");
+ domainContentValues.put(FONT_SIZE, 0);
+ domainContentValues.put(SWIPE_TO_REFRESH, 0);
+ domainContentValues.put(NIGHT_MODE, 0);
+ domainContentValues.put(WIDE_VIEWPORT, 0);
+ domainContentValues.put(DISPLAY_IMAGES, 0);
+
+ // Get a writable database handle.
+ SQLiteDatabase domainsDatabase = this.getWritableDatabase();
+
+ // Insert a new row and store the resulting database ID. The second argument is `null`, which makes it so that a completely null row cannot be created.
+ int newDomainDatabaseId = (int) domainsDatabase.insert(DOMAINS_TABLE, null, domainContentValues);
+
+ // Close the database handle.
+ domainsDatabase.close();
+
+ // Return the new domain database ID.
+ return newDomainDatabaseId;
+ }
+
+ void addDomain(ContentValues contentValues) {
+ // Get a writable database handle.
+ SQLiteDatabase domainsDatabase = this.getWritableDatabase();
+
+ // Add the new domain.
+ domainsDatabase.insert(DOMAINS_TABLE, null, contentValues);
+
+ // Close the database handle.
+ domainsDatabase.close();
+ }
+
+ public void updateDomain(int databaseId, String domainName, boolean javaScript, boolean firstPartyCookies, boolean thirdPartyCookies, boolean domStorage, boolean formData, boolean easyList,
+ boolean easyPrivacy, boolean fanboysAnnoyance, boolean fanboysSocialBlocking, boolean ultraList, boolean ultraPrivacy, boolean blockAllThirdPartyRequests, String userAgent,
+ int fontSize, int swipeToRefresh, int nightMode, int wideViewport, int displayImages, boolean pinnedSslCertificate, boolean pinnedIpAddresses) {
+
+ // Store the domain data in a `ContentValues`.