X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fhelpers%2FImportExportDatabaseHelper.kt;h=5dfd845e09c556bf4f10a44ef57d04c3c7005240;hp=13abb32a63c8e8e6edbe7776a2c5e14c5cc75af4;hb=e2d4437956f57b50bda1f27c9b4eea9367de7758;hpb=9338dfa2f8a295736d35e4f468f0c0ba573a1b58 diff --git a/app/src/main/java/com/stoutner/privacybrowser/helpers/ImportExportDatabaseHelper.kt b/app/src/main/java/com/stoutner/privacybrowser/helpers/ImportExportDatabaseHelper.kt index 13abb32a..5dfd845e 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/helpers/ImportExportDatabaseHelper.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/helpers/ImportExportDatabaseHelper.kt @@ -35,7 +35,7 @@ import java.io.InputStream import java.io.OutputStream // Define the private class constants. -private const val SCHEMA_VERSION = 14 +private const val SCHEMA_VERSION = 15 private const val PREFERENCES_TABLE = "preferences" // Define the private preferences constants. @@ -46,6 +46,7 @@ private const val DOM_STORAGE = "dom_storage" private const val SAVE_FORM_DATA = "save_form_data" private const val USER_AGENT = "user_agent" private const val CUSTOM_USER_AGENT = "custom_user_agent" +private const val X_REQUESTED_WITH_HEADER = "x_requested_with_header" private const val INCOGNITO_MODE = "incognito_mode" private const val ALLOW_SCREENSHOTS = "allow_screenshots" private const val EASYLIST = "easylist" @@ -55,9 +56,8 @@ private const val FANBOYS_SOCIAL_BLOCKING_LIST = "fanboys_social_blocking_list" private const val ULTRALIST = "ultralist" private const val ULTRAPRIVACY = "ultraprivacy" private const val BLOCK_ALL_THIRD_PARTY_REQUESTS = "block_all_third_party_requests" -private const val GOOGLE_ANALYTICS = "google_analytics" -private const val FACEBOOK_CLICK_IDS = "facebook_click_ids" -private const val TWITTER_AMP_REDIRECTS = "twitter_amp_redirects" +private const val TRACKING_QUERIES = "tracking_queries" +private const val AMP_REDIRECTS = "amp_redirects" private const val SEARCH = "search" private const val SEARCH_CUSTOM_URL = "search_custom_url" private const val PROXY = "proxy" @@ -137,7 +137,7 @@ class ImportExportDatabaseHelper { // Upgrade from schema version 2, first used in Privacy Browser 2.14, to schema version 3, first used in Privacy Browser 2.15. if (importDatabaseVersion < 3) { - // Once the SQLite version is >= 3.25.0 (API >= 30) `ALTER TABLE RENAME COLUMN` can be used. + // Once the SQLite version is >= 3.25.0 (Android API >= 30) `ALTER TABLE RENAME COLUMN` can be used. // // In the meantime, a new column must be created with the new name. There is no need to delete the old column on the temporary import database. @@ -151,8 +151,8 @@ class ImportExportDatabaseHelper { // Upgrade from schema version 3, first used in Privacy Browser 2.15, to schema version 4, first used in Privacy Browser 2.16. if (importDatabaseVersion < 4) { // Add the Pinned IP Addresses columns to the domains table. - importDatabase.execSQL("ALTER TABLE " + DomainsDatabaseHelper.DOMAINS_TABLE + " ADD COLUMN " + DomainsDatabaseHelper.PINNED_IP_ADDRESSES + " BOOLEAN") - importDatabase.execSQL("ALTER TABLE " + DomainsDatabaseHelper.DOMAINS_TABLE + " ADD COLUMN " + DomainsDatabaseHelper.IP_ADDRESSES + " TEXT") + importDatabase.execSQL("ALTER TABLE ${DomainsDatabaseHelper.DOMAINS_TABLE} ADD COLUMN ${DomainsDatabaseHelper.PINNED_IP_ADDRESSES} BOOLEAN") + importDatabase.execSQL("ALTER TABLE ${DomainsDatabaseHelper.DOMAINS_TABLE} ADD COLUMN ${DomainsDatabaseHelper.IP_ADDRESSES} TEXT") } // Upgrade from schema version 4, first used in Privacy Browser 2.16, to schema version 5, first used in Privacy Browser 2.17. @@ -168,17 +168,15 @@ class ImportExportDatabaseHelper { // Populate the preferences table with the current app bar values. // This can switch to using the variables directly once the API >= 30. // - if (hideAppBar) { + if (hideAppBar) importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $HIDE_APP_BAR = 1") - } else { + else importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $HIDE_APP_BAR = 0") - } - if (scrollAppBar) { + if (scrollAppBar) importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $SCROLL_APP_BAR = 1") - } else { + else importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $SCROLL_APP_BAR = 0") - } } // Upgrade from schema version 5, first used in Privacy Browser 2.17, to schema version 6, first used in Privacy Browser 3.0. @@ -192,65 +190,54 @@ class ImportExportDatabaseHelper { // Populate the preferences table with the current open intents value. // This can switch to using the variables directly once the API >= 30. // - if (openIntentsInNewTab) { + if (openIntentsInNewTab) importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $OPEN_INTENTS_IN_NEW_TAB = 1") - } else { + else importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $OPEN_INTENTS_IN_NEW_TAB = 0") - } } // Upgrade from schema version 6, first used in Privacy Browser 3.0, to schema version 7, first used in Privacy Browser 3.1. if (importDatabaseVersion < 7) { + // Previously this upgrade added `facebook_click_ids` to the Preferences table. But that is now removed in schema version 15. + // Add the wide viewport column to the domains table. - importDatabase.execSQL("ALTER TABLE " + DomainsDatabaseHelper.DOMAINS_TABLE + " ADD COLUMN " + DomainsDatabaseHelper.WIDE_VIEWPORT + " INTEGER") + importDatabase.execSQL("ALTER TABLE ${DomainsDatabaseHelper.DOMAINS_TABLE} ADD COLUMN ${DomainsDatabaseHelper.WIDE_VIEWPORT} INTEGER") - // Add the Google Analytics, Facebook Click IDs, Twitter AMP redirects, and wide viewport columns to the preferences table. - importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN $GOOGLE_ANALYTICS BOOLEAN") - importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN $FACEBOOK_CLICK_IDS BOOLEAN") - importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN $TWITTER_AMP_REDIRECTS BOOLEAN") + // Add the Google Analytics, Twitter AMP redirects, and wide viewport columns to the preferences table. + importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN google_analytics BOOLEAN") + importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN twitter_amp_redirects BOOLEAN") importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN $WIDE_VIEWPORT BOOLEAN") // Get the current preference values. - val googleAnalytics = sharedPreferences.getBoolean(GOOGLE_ANALYTICS, true) - val facebookClickIds = sharedPreferences.getBoolean(FACEBOOK_CLICK_IDS, true) - val twitterAmpRedirects = sharedPreferences.getBoolean(TWITTER_AMP_REDIRECTS, true) + val trackingQueries = sharedPreferences.getBoolean(TRACKING_QUERIES, true) + val ampRedirects = sharedPreferences.getBoolean(AMP_REDIRECTS, true) val wideViewport = sharedPreferences.getBoolean(WIDE_VIEWPORT, true) - // Populate the preferences with the current Google Analytics value. + // Populate the preferences with the current Tracking Queries value. Google Analytics was renamed Tracking Queries in schema version 15. // This can switch to using the variables directly once the API >= 30. // - if (googleAnalytics) { - importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $GOOGLE_ANALYTICS = 1") - } else { - importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $GOOGLE_ANALYTICS = 0") - } + if (trackingQueries) + importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET google_analytics = 1") + else + importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET google_analytics = 0") - // Populate the preferences with the current Facebook Click IDs value. - if (facebookClickIds) { - importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $FACEBOOK_CLICK_IDS = 1") - } else { - importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $FACEBOOK_CLICK_IDS = 0") - } - - // Populate the preferences table with the current Twitter AMP redirects value. - if (twitterAmpRedirects) { - importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $TWITTER_AMP_REDIRECTS = 1") - } else { - importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $TWITTER_AMP_REDIRECTS = 0") - } + // Populate the preferences table with the current AMP Redirects value. Twitter AMP Redirects was renamed AMP Redirects in schema version 15. + if (ampRedirects) + importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET twitter_amp_redirects = 1") + else + importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET twitter_amp_redirects = 0") // Populate the preferences table with the current wide viewport value. - if (wideViewport) { + if (wideViewport) importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $WIDE_VIEWPORT = 1") - } else { + else importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $WIDE_VIEWPORT = 0") - } } // Upgrade from schema version 7, first used in Privacy Browser 3.1, to schema version 8, first used in Privacy Browser 3.2. if (importDatabaseVersion < 8) { // Add the UltraList column to the tables. - importDatabase.execSQL("ALTER TABLE " + DomainsDatabaseHelper.DOMAINS_TABLE + " ADD COLUMN " + DomainsDatabaseHelper.ULTRALIST + " BOOLEAN") + importDatabase.execSQL("ALTER TABLE ${DomainsDatabaseHelper.DOMAINS_TABLE} ADD COLUMN ${DomainsDatabaseHelper.ULTRALIST} BOOLEAN") importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN $ULTRALIST BOOLEAN") // Get the current preference values. @@ -260,10 +247,10 @@ class ImportExportDatabaseHelper { // This can switch to using the variables directly once the API >= 30. // if (ultraList) { - importDatabase.execSQL("UPDATE " + DomainsDatabaseHelper.DOMAINS_TABLE + " SET " + DomainsDatabaseHelper.ULTRALIST + " = " + 1) + importDatabase.execSQL("UPDATE ${DomainsDatabaseHelper.DOMAINS_TABLE} SET ${DomainsDatabaseHelper.ULTRALIST} = 1") importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $ULTRALIST = 1") } else { - importDatabase.execSQL("UPDATE " + DomainsDatabaseHelper.DOMAINS_TABLE + " SET " + DomainsDatabaseHelper.ULTRALIST + " = " + 0) + importDatabase.execSQL("UPDATE ${DomainsDatabaseHelper.DOMAINS_TABLE} SET ${DomainsDatabaseHelper.ULTRALIST} = 0") importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $ULTRALIST = 0") } } @@ -325,7 +312,7 @@ class ImportExportDatabaseHelper { } // Add the WebView theme to the domains table. This defaults to 0, which is `System default`, so a separate step isn't needed to populate the database. - importDatabase.execSQL("ALTER TABLE " + DomainsDatabaseHelper.DOMAINS_TABLE + " ADD COLUMN " + DomainsDatabaseHelper.WEBVIEW_THEME + " INTEGER") + importDatabase.execSQL("ALTER TABLE ${DomainsDatabaseHelper.DOMAINS_TABLE} ADD COLUMN ${DomainsDatabaseHelper.WEBVIEW_THEME} INTEGER") // Add the WebView theme to the preferences table. importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN $WEBVIEW_THEME TEXT") @@ -348,11 +335,10 @@ class ImportExportDatabaseHelper { // Populate the preferences table with the current clear logcat value. // This can switch to using the variables directly once the API >= 30. // - if (clearLogcat) { + if (clearLogcat) importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $CLEAR_LOGCAT = 1") - } else { + else importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $CLEAR_LOGCAT = 0") - } } // Upgrade from schema version 12, first used in Privacy Browser 3.6, to schema version 13, first used in Privacy Browser 3.7. @@ -362,16 +348,16 @@ class ImportExportDatabaseHelper { if (importDatabaseVersion < 14) { // `enabledthirdpartycookies` was removed from the domains table. `do_not_track` and `third_party_cookies` were removed from the preferences table. - // Once the SQLite version is >= 3.25.0 `ALTER TABLE RENAME COLUMN` can be used. + // Once the SQLite version is >= 3.25.0 (Android API >= 30) `ALTER TABLE RENAME COLUMN` can be used. // // In the meantime, a new column must be created with the new name. There is no need to delete the old column on the temporary import database. // Create the new cookies columns. - importDatabase.execSQL("ALTER TABLE " + DomainsDatabaseHelper.DOMAINS_TABLE + " ADD COLUMN " + DomainsDatabaseHelper.COOKIES + " BOOLEAN") + importDatabase.execSQL("ALTER TABLE ${DomainsDatabaseHelper.DOMAINS_TABLE} ADD COLUMN ${DomainsDatabaseHelper.COOKIES} BOOLEAN") importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN $COOKIES BOOLEAN") // Copy the data from the old cookies columns to the new ones. - importDatabase.execSQL("UPDATE " + DomainsDatabaseHelper.DOMAINS_TABLE + " SET " + DomainsDatabaseHelper.COOKIES + " = enablefirstpartycookies") + importDatabase.execSQL("UPDATE ${DomainsDatabaseHelper.DOMAINS_TABLE} SET ${DomainsDatabaseHelper.COOKIES} = enablefirstpartycookies") importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $COOKIES = first_party_cookies") // Create the new download with external app and bottom app bar columns. @@ -385,22 +371,52 @@ class ImportExportDatabaseHelper { // Populate the preferences table with the current download with external app value. // This can switch to using the variables directly once the API >= 30. // - if (downloadWithExternalApp) { + if (downloadWithExternalApp) importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $DOWNLOAD_WITH_EXTERNAL_APP = 1") - } else { + else importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $DOWNLOAD_WITH_EXTERNAL_APP = 0") - } // Populate the preferences table with the current bottom app bar value. - if (bottomAppBar) { + if (bottomAppBar) importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $BOTTOM_APP_BAR = 1") - } else { + else importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $BOTTOM_APP_BAR = 0") - } + } + + // Upgrade from schema version 14, first used in Privacy Browser 3.8, to schema version 15, first used in Privacy Browser 3.11. + if (importDatabaseVersion < 15) { + // `facebook_click_ids` was removed from the preferences table. + + // Once the SQLite version is >= 3.25.0 (Android API >= 30) `ALTER TABLE RENAME COLUMN` can be used. + // + // In the meantime, a new column must be created with the new name. There is no need to delete the old column on the temporary import database. + + // Create the new URL modification columns. + importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN $TRACKING_QUERIES BOOLEAN") + importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN $AMP_REDIRECTS BOOLEAN") + + // Copy the data from the old columns to the new ones. + importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $TRACKING_QUERIES = google_analytics") + importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $AMP_REDIRECTS = twitter_amp_redirects") + + // Create the new X-Requested-with header columns. + importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN $X_REQUESTED_WITH_HEADER BOOLEAN") + importDatabase.execSQL("ALTER TABLE ${DomainsDatabaseHelper.DOMAINS_TABLE} ADD COLUMN ${DomainsDatabaseHelper.X_REQUESTED_WITH_HEADER} INTEGER") + + // Get the current X-Requested-With header preferences value. + val xRequestedWithHeader = sharedPreferences.getBoolean(X_REQUESTED_WITH_HEADER, true) + + // Populate the Preferences X-Requested-With header with the current value. The domains X-Requested-With header will default to 0, which is `System default`. + // This can switch to using the variables directly once the API >= 30. + // + if (xRequestedWithHeader) + importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $X_REQUESTED_WITH_HEADER = 1") + else + importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $X_REQUESTED_WITH_HEADER = 0") } // Get a cursor for the bookmarks table. - val importBookmarksCursor = importDatabase.rawQuery("SELECT * FROM " + BookmarksDatabaseHelper.BOOKMARKS_TABLE, null) + val importBookmarksCursor = importDatabase.rawQuery("SELECT * FROM ${BookmarksDatabaseHelper.BOOKMARKS_TABLE}", null) // Delete the current bookmarks database. context.deleteDatabase(BookmarksDatabaseHelper.BOOKMARKS_DATABASE) @@ -437,7 +453,7 @@ class ImportExportDatabaseHelper { // Get a cursor for the domains table. - val importDomainsCursor = importDatabase.rawQuery("SELECT * FROM " + DomainsDatabaseHelper.DOMAINS_TABLE + " ORDER BY " + DomainsDatabaseHelper.DOMAIN_NAME + " ASC", null) + val importDomainsCursor = importDatabase.rawQuery("SELECT * FROM ${DomainsDatabaseHelper.DOMAINS_TABLE} ORDER BY ${DomainsDatabaseHelper.DOMAIN_NAME} ASC", null) // Delete the current domains database. context.deleteDatabase(DomainsDatabaseHelper.DOMAINS_DATABASE) @@ -470,6 +486,7 @@ class ImportExportDatabaseHelper { domainContentValues.put(DomainsDatabaseHelper.BLOCK_ALL_THIRD_PARTY_REQUESTS, importDomainsCursor.getInt(importDomainsCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.BLOCK_ALL_THIRD_PARTY_REQUESTS))) domainContentValues.put(DomainsDatabaseHelper.USER_AGENT, importDomainsCursor.getString(importDomainsCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.USER_AGENT))) + domainContentValues.put(DomainsDatabaseHelper.X_REQUESTED_WITH_HEADER, importDomainsCursor.getInt(importDomainsCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.X_REQUESTED_WITH_HEADER))) domainContentValues.put(DomainsDatabaseHelper.FONT_SIZE, importDomainsCursor.getInt(importDomainsCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.FONT_SIZE))) domainContentValues.put(DomainsDatabaseHelper.SWIPE_TO_REFRESH, importDomainsCursor.getInt(importDomainsCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.SWIPE_TO_REFRESH))) domainContentValues.put(DomainsDatabaseHelper.WEBVIEW_THEME, importDomainsCursor.getInt(importDomainsCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.WEBVIEW_THEME))) @@ -519,6 +536,7 @@ class ImportExportDatabaseHelper { .putBoolean(SAVE_FORM_DATA, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(SAVE_FORM_DATA)) == 1) // Save form data can be removed once the minimum API >= 26. .putString(USER_AGENT, importPreferencesCursor.getString(importPreferencesCursor.getColumnIndexOrThrow(USER_AGENT))) .putString(CUSTOM_USER_AGENT, importPreferencesCursor.getString(importPreferencesCursor.getColumnIndexOrThrow(CUSTOM_USER_AGENT))) + .putBoolean(X_REQUESTED_WITH_HEADER, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(X_REQUESTED_WITH_HEADER)) == 1) .putBoolean(INCOGNITO_MODE, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(INCOGNITO_MODE)) == 1) .putBoolean(ALLOW_SCREENSHOTS, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(ALLOW_SCREENSHOTS)) == 1) .putBoolean(EASYLIST, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(EASYLIST)) == 1) @@ -528,9 +546,8 @@ class ImportExportDatabaseHelper { .putBoolean(ULTRALIST, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(ULTRALIST)) == 1) .putBoolean(ULTRAPRIVACY, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(ULTRAPRIVACY)) == 1) .putBoolean(BLOCK_ALL_THIRD_PARTY_REQUESTS, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(BLOCK_ALL_THIRD_PARTY_REQUESTS)) == 1) - .putBoolean(GOOGLE_ANALYTICS, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(GOOGLE_ANALYTICS)) == 1) - .putBoolean(FACEBOOK_CLICK_IDS, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(FACEBOOK_CLICK_IDS)) == 1) - .putBoolean(TWITTER_AMP_REDIRECTS, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(TWITTER_AMP_REDIRECTS)) == 1) + .putBoolean(TRACKING_QUERIES, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(TRACKING_QUERIES)) == 1) + .putBoolean(AMP_REDIRECTS, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(AMP_REDIRECTS)) == 1) .putString(SEARCH, importPreferencesCursor.getString(importPreferencesCursor.getColumnIndexOrThrow(SEARCH))) .putString(SEARCH_CUSTOM_URL, importPreferencesCursor.getString(importPreferencesCursor.getColumnIndexOrThrow(SEARCH_CUSTOM_URL))) .putString(PROXY, importPreferencesCursor.getString(importPreferencesCursor.getColumnIndexOrThrow(PROXY))) @@ -653,6 +670,7 @@ class ImportExportDatabaseHelper { domainContentValues.put(DomainsDatabaseHelper.ENABLE_ULTRAPRIVACY, domainsCursor.getInt(domainsCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.ENABLE_ULTRAPRIVACY))) domainContentValues.put(DomainsDatabaseHelper.BLOCK_ALL_THIRD_PARTY_REQUESTS, domainsCursor.getInt(domainsCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.BLOCK_ALL_THIRD_PARTY_REQUESTS))) domainContentValues.put(DomainsDatabaseHelper.USER_AGENT, domainsCursor.getString(domainsCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.USER_AGENT))) + domainContentValues.put(DomainsDatabaseHelper.X_REQUESTED_WITH_HEADER, domainsCursor.getInt(domainsCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.X_REQUESTED_WITH_HEADER))) domainContentValues.put(DomainsDatabaseHelper.FONT_SIZE, domainsCursor.getInt(domainsCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.FONT_SIZE))) domainContentValues.put(DomainsDatabaseHelper.SWIPE_TO_REFRESH, domainsCursor.getInt(domainsCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.SWIPE_TO_REFRESH))) domainContentValues.put(DomainsDatabaseHelper.WEBVIEW_THEME, domainsCursor.getInt(domainsCursor.getColumnIndexOrThrow(DomainsDatabaseHelper.WEBVIEW_THEME))) @@ -685,50 +703,50 @@ class ImportExportDatabaseHelper { // Prepare the preferences table SQL creation string. - val createPreferencesTable = "CREATE TABLE " + PREFERENCES_TABLE + " (" + - ID + " INTEGER PRIMARY KEY, " + - JAVASCRIPT + " BOOLEAN, " + - COOKIES + " BOOLEAN, " + - DOM_STORAGE + " BOOLEAN, " + - SAVE_FORM_DATA + " BOOLEAN, " + - USER_AGENT + " TEXT, " + - CUSTOM_USER_AGENT + " TEXT, " + - INCOGNITO_MODE + " BOOLEAN, " + - ALLOW_SCREENSHOTS + " BOOLEAN, " + - EASYLIST + " BOOLEAN, " + - EASYPRIVACY + " BOOLEAN, " + - FANBOYS_ANNOYANCE_LIST + " BOOLEAN, " + - FANBOYS_SOCIAL_BLOCKING_LIST + " BOOLEAN, " + - ULTRALIST + " BOOLEAN, " + - ULTRAPRIVACY + " BOOLEAN, " + - BLOCK_ALL_THIRD_PARTY_REQUESTS + " BOOLEAN, " + - GOOGLE_ANALYTICS + " BOOLEAN, " + - FACEBOOK_CLICK_IDS + " BOOLEAN, " + - TWITTER_AMP_REDIRECTS + " BOOLEAN, " + - SEARCH + " TEXT, " + - SEARCH_CUSTOM_URL + " TEXT, " + - PROXY + " TEXT, " + - PROXY_CUSTOM_URL + " TEXT, " + - FULL_SCREEN_BROWSING_MODE + " BOOLEAN, " + - HIDE_APP_BAR + " BOOLEAN, " + - CLEAR_EVERYTHING + " BOOLEAN, " + - CLEAR_COOKIES + " BOOLEAN, " + - CLEAR_DOM_STORAGE + " BOOLEAN, " + - CLEAR_FORM_DATA + " BOOLEAN, " + - CLEAR_LOGCAT + " BOOLEAN, " + - CLEAR_CACHE + " BOOLEAN, " + - HOMEPAGE + " TEXT, " + - FONT_SIZE + " TEXT, " + - OPEN_INTENTS_IN_NEW_TAB + " BOOLEAN, " + - SWIPE_TO_REFRESH + " BOOLEAN, " + - DOWNLOAD_WITH_EXTERNAL_APP + " BOOLEAN, " + - SCROLL_APP_BAR + " BOOLEAN, " + - BOTTOM_APP_BAR + " BOOLEAN, " + - DISPLAY_ADDITIONAL_APP_BAR_ICONS + " BOOLEAN, " + - APP_THEME + " TEXT, " + - WEBVIEW_THEME + " TEXT, " + - WIDE_VIEWPORT + " BOOLEAN, " + - DISPLAY_WEBPAGE_IMAGES + " BOOLEAN)" + val createPreferencesTable = "CREATE TABLE $PREFERENCES_TABLE (" + + "$ID INTEGER PRIMARY KEY, " + + "$JAVASCRIPT BOOLEAN, " + + "$COOKIES BOOLEAN, " + + "$DOM_STORAGE BOOLEAN, " + + "$SAVE_FORM_DATA BOOLEAN, " + + "$USER_AGENT TEXT, " + + "$CUSTOM_USER_AGENT TEXT, " + + "$X_REQUESTED_WITH_HEADER BOOLEAN, " + + "$INCOGNITO_MODE BOOLEAN, " + + "$ALLOW_SCREENSHOTS BOOLEAN, " + + "$EASYLIST BOOLEAN, " + + "$EASYPRIVACY BOOLEAN, " + + "$FANBOYS_ANNOYANCE_LIST BOOLEAN, " + + "$FANBOYS_SOCIAL_BLOCKING_LIST BOOLEAN, " + + "$ULTRALIST BOOLEAN, " + + "$ULTRAPRIVACY BOOLEAN, " + + "$BLOCK_ALL_THIRD_PARTY_REQUESTS BOOLEAN, " + + "$TRACKING_QUERIES BOOLEAN, " + + "$AMP_REDIRECTS BOOLEAN, " + + "$SEARCH TEXT, " + + "$SEARCH_CUSTOM_URL TEXT, " + + "$PROXY TEXT, " + + "$PROXY_CUSTOM_URL TEXT, " + + "$FULL_SCREEN_BROWSING_MODE BOOLEAN, " + + "$HIDE_APP_BAR BOOLEAN, " + + "$CLEAR_EVERYTHING BOOLEAN, " + + "$CLEAR_COOKIES BOOLEAN, " + + "$CLEAR_DOM_STORAGE BOOLEAN, " + + "$CLEAR_FORM_DATA BOOLEAN, " + + "$CLEAR_LOGCAT BOOLEAN, " + + "$CLEAR_CACHE BOOLEAN, " + + "$HOMEPAGE TEXT, " + + "$FONT_SIZE TEXT, " + + "$OPEN_INTENTS_IN_NEW_TAB BOOLEAN, " + + "$SWIPE_TO_REFRESH BOOLEAN, " + + "$DOWNLOAD_WITH_EXTERNAL_APP BOOLEAN, " + + "$SCROLL_APP_BAR BOOLEAN, " + + "$BOTTOM_APP_BAR BOOLEAN, " + + "$DISPLAY_ADDITIONAL_APP_BAR_ICONS BOOLEAN, " + + "$APP_THEME TEXT, " + + "$WEBVIEW_THEME TEXT, " + + "$WIDE_VIEWPORT BOOLEAN, " + + "$DISPLAY_WEBPAGE_IMAGES BOOLEAN)" // Create the temporary export database preferences table. temporaryExportDatabase.execSQL(createPreferencesTable) @@ -746,6 +764,7 @@ class ImportExportDatabaseHelper { preferencesContentValues.put(SAVE_FORM_DATA, sharedPreferences.getBoolean(SAVE_FORM_DATA, false)) // Save form data can be removed once the minimum API >= 26. preferencesContentValues.put(USER_AGENT, sharedPreferences.getString(USER_AGENT, context.getString(R.string.user_agent_default_value))) preferencesContentValues.put(CUSTOM_USER_AGENT, sharedPreferences.getString(CUSTOM_USER_AGENT, context.getString(R.string.custom_user_agent_default_value))) + preferencesContentValues.put(X_REQUESTED_WITH_HEADER, sharedPreferences.getBoolean(X_REQUESTED_WITH_HEADER, true)) preferencesContentValues.put(INCOGNITO_MODE, sharedPreferences.getBoolean(INCOGNITO_MODE, false)) preferencesContentValues.put(ALLOW_SCREENSHOTS, sharedPreferences.getBoolean(ALLOW_SCREENSHOTS, false)) preferencesContentValues.put(EASYLIST, sharedPreferences.getBoolean(EASYLIST, true)) @@ -755,9 +774,8 @@ class ImportExportDatabaseHelper { preferencesContentValues.put(ULTRALIST, sharedPreferences.getBoolean(ULTRALIST, true)) preferencesContentValues.put(ULTRAPRIVACY, sharedPreferences.getBoolean(ULTRAPRIVACY, true)) preferencesContentValues.put(BLOCK_ALL_THIRD_PARTY_REQUESTS, sharedPreferences.getBoolean(BLOCK_ALL_THIRD_PARTY_REQUESTS, false)) - preferencesContentValues.put(GOOGLE_ANALYTICS, sharedPreferences.getBoolean(GOOGLE_ANALYTICS, true)) - preferencesContentValues.put(FACEBOOK_CLICK_IDS, sharedPreferences.getBoolean(FACEBOOK_CLICK_IDS, true)) - preferencesContentValues.put(TWITTER_AMP_REDIRECTS, sharedPreferences.getBoolean(TWITTER_AMP_REDIRECTS, true)) + preferencesContentValues.put(TRACKING_QUERIES, sharedPreferences.getBoolean(TRACKING_QUERIES, true)) + preferencesContentValues.put(AMP_REDIRECTS, sharedPreferences.getBoolean(AMP_REDIRECTS, true)) preferencesContentValues.put(SEARCH, sharedPreferences.getString(SEARCH, context.getString(R.string.search_default_value))) preferencesContentValues.put(SEARCH_CUSTOM_URL, sharedPreferences.getString(SEARCH_CUSTOM_URL, context.getString(R.string.search_custom_url_default_value))) preferencesContentValues.put(PROXY, sharedPreferences.getString(PROXY, context.getString(R.string.proxy_default_value)))