X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Fhelpers%2FImportExportDatabaseHelper.kt;h=5dfd845e09c556bf4f10a44ef57d04c3c7005240;hb=HEAD;hp=14d0cbc56b3edbda0e1694ba8ce071824e8cafd4;hpb=a94835709a5871399463fb956812026699d6e3f9;p=PrivacyBrowserAndroid.git 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 14d0cbc5..0b040748 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/helpers/ImportExportDatabaseHelper.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/helpers/ImportExportDatabaseHelper.kt @@ -1,5 +1,5 @@ /* - * Copyright 2018-2023 Soren Stoutner . + * Copyright 2018-2024 Soren Stoutner . * * This file is part of Privacy Browser Android . * @@ -38,7 +38,7 @@ import java.io.OutputStream import java.util.Date // Define the public constants. -const val IMPORT_EXPORT_SCHEMA_VERSION = 18 +const val IMPORT_EXPORT_SCHEMA_VERSION = 19 const val EXPORT_SUCCESSFUL = "A" const val IMPORT_SUCCESSFUL = "B" @@ -51,14 +51,13 @@ private const val CLEAR_CACHE = "clear_cache" private const val CLEAR_COOKIES = "clear_cookies" private const val CLEAR_DOM_STORAGE = "clear_dom_storage" private const val CLEAR_EVERYTHING = "clear_everything" -private const val CLEAR_FORM_DATA = "clear_form_data" // Clear form data can be removed once the minimum API >= 26. private const val CLEAR_LOGCAT = "clear_logcat" private const val CUSTOM_USER_AGENT = "custom_user_agent" private const val DISPLAY_ADDITIONAL_APP_BAR_ICONS = "display_additional_app_bar_icons" private const val DISPLAY_UNDER_CUTOUTS = "display_under_cutouts" private const val DISPLAY_WEBPAGE_IMAGES = "display_webpage_images" private const val DOM_STORAGE = "dom_storage" -private const val DOWNLOAD_WITH_EXTERNAL_APP = "download_with_external_app" +private const val DOWNLOAD_PROVIDER = "download_provider" private const val EASYLIST = "easylist" private const val EASYPRIVACY = "easyprivacy" private const val FANBOYS_ANNOYANCE_LIST = "fanboys_annoyance_list" @@ -75,7 +74,6 @@ private const val PREFERENCES_TABLE = "preferences" private const val PREFERENCES_USER_AGENT = "user_agent" private const val PROXY = "proxy" private const val PROXY_CUSTOM_URL = "proxy_custom_url" -private const val SAVE_FORM_DATA = "save_form_data" private const val SEARCH = "search" private const val SEARCH_CUSTOM_URL = "search_custom_url" private const val SCROLL_APP_BAR = "scroll_app_bar" @@ -357,22 +355,27 @@ class ImportExportDatabaseHelper { importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $COOKIES = first_party_cookies") // Create the new download with external app and bottom app bar columns. - importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN $DOWNLOAD_WITH_EXTERNAL_APP BOOLEAN") + importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN download_with_external_app BOOLEAN") importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN $BOTTOM_APP_BAR BOOLEAN") // Get the current values for the new columns. - val downloadWithExternalApp = sharedPreferences.getBoolean(DOWNLOAD_WITH_EXTERNAL_APP, false) val bottomAppBar = sharedPreferences.getBoolean(BOTTOM_APP_BAR, false) + val downloadProviderString = sharedPreferences.getString(DOWNLOAD_PROVIDER, context.getString(R.string.download_provider_default_value)) - // 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) - importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $DOWNLOAD_WITH_EXTERNAL_APP = 1") - else - importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $DOWNLOAD_WITH_EXTERNAL_APP = 0") + // Get the download provider entry values string array. + val tempDownloadProviderEntryValuesStringArray = context.resources.getStringArray(R.array.download_provider_entry_values) + + // Populate the new download with external app preference. It was added in this version of the schema, but removed in version 18. + // The new preference, `download_provider`, converts `download_with_external_app`, so it needs to exist. + // This code sets `download_with_external_app` to be as similar as possible to the current preference in the settings. + if (downloadProviderString == tempDownloadProviderEntryValuesStringArray[0]) // Download with Privacy Browser. + importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET download_with_external_app = 0") + else // Download with external app. + importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET download_with_external_app = 1") // Populate the preferences table with the current bottom app bar value. + // This can switch to using the variables directly once the API >= 30. + // if (bottomAppBar) importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $BOTTOM_APP_BAR = 1") else @@ -396,11 +399,14 @@ class ImportExportDatabaseHelper { } // Upgrade from schema version 15, first used in Privacy Browser 3.11, to schema version 16, first used in Privacy Browser 3.12. - // This upgrade removed the `x_requested_with_header` from the domains and preferences tables. + // This upgrade removed `x_requested_with_header` from the domains and preferences tables. // There is no need to delete the columns as they will simply be ignored by the import. // Upgrade from schema version 16, first used in Privacy Browser 3.12, to schema version 17, first used in Privacy Browser 3.15. if (importDatabaseVersion < 17) { + // This upgrade removed `parentfolder` from the Bookmarks table. + // There is no need to delete the column as they will simply be ignored by the import. + // Add the folder ID column. importDatabase.execSQL("ALTER TABLE $BOOKMARKS_TABLE ADD COLUMN $FOLDER_ID INTEGER") @@ -485,81 +491,10 @@ class ImportExportDatabaseHelper { // Close the bookmarks cursor. bookmarksCursor.close() - // This upgrade removed the old `parentfolder` string column. - // SQLite amazingly only added a command to drop a column in version 3.35.0. - // It will be a while before that is supported in Android. - // Although a new table could be created and all the data copied to it, I think I will just leave the old parent folder column. It will be wiped out the next time an import is run. - } - - // Upgrade from schema version 17, first used in Privacy Browser 3.15, to schema version 18, first used in Privacy Browser 3.17. - if (importDatabaseVersion < 18) { - // Create the new display under cutout column. - importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN $DISPLAY_UNDER_CUTOUTS BOOLEAN") - - // Get the current display under cutout value. - val displayUnderCutouts = sharedPreferences.getBoolean(DISPLAY_UNDER_CUTOUTS, false) - - // Populate the preferences table with the current display under cutouts value. - // This can switch to using the variables directly once the API >= 30. - // - if (displayUnderCutouts) - importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $DISPLAY_UNDER_CUTOUTS = 1") - else - importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $DISPLAY_UNDER_CUTOUTS = 0") - } - - /* End of database upgrade logic. */ - - - // Get a cursor for the bookmarks table. - val importBookmarksCursor = importDatabase.rawQuery("SELECT * FROM $BOOKMARKS_TABLE", null) - - // Delete the current bookmarks database. - context.deleteDatabase(BOOKMARKS_DATABASE) - - // Create a new bookmarks database. - val bookmarksDatabaseHelper = BookmarksDatabaseHelper(context) - - // Move to the first record. - importBookmarksCursor.moveToFirst() - - // Get the bookmarks colum indexes. - val bookmarkNameColumnIndex = importBookmarksCursor.getColumnIndexOrThrow(BOOKMARK_NAME) - val bookmarkUrlColumnIndex = importBookmarksCursor.getColumnIndexOrThrow(BOOKMARK_URL) - val bookmarkParentFolderIdColumnIndex = importBookmarksCursor.getColumnIndexOrThrow(PARENT_FOLDER_ID) - val bookmarkDisplayOrderColumnIndex = importBookmarksCursor.getColumnIndexOrThrow(DISPLAY_ORDER) - val bookmarkIsFolderColumnIndex = importBookmarksCursor.getColumnIndexOrThrow(IS_FOLDER) - val bookmarkFolderIdColumnIndex = importBookmarksCursor.getColumnIndexOrThrow(FOLDER_ID) - val bookmarkFavoriteIconColumnIndex = importBookmarksCursor.getColumnIndexOrThrow(FAVORITE_ICON) - - // Copy the data from the import bookmarks cursor into the bookmarks database. - for (i in 0 until importBookmarksCursor.count) { - // Create a bookmark content values. - val bookmarkContentValues = ContentValues() - - // Add the information for this bookmark to the content values. - bookmarkContentValues.put(BOOKMARK_NAME, importBookmarksCursor.getString(bookmarkNameColumnIndex)) - bookmarkContentValues.put(BOOKMARK_URL, importBookmarksCursor.getString(bookmarkUrlColumnIndex)) - bookmarkContentValues.put(PARENT_FOLDER_ID, importBookmarksCursor.getLong(bookmarkParentFolderIdColumnIndex)) - bookmarkContentValues.put(DISPLAY_ORDER, importBookmarksCursor.getInt(bookmarkDisplayOrderColumnIndex)) - bookmarkContentValues.put(IS_FOLDER, importBookmarksCursor.getInt(bookmarkIsFolderColumnIndex)) - bookmarkContentValues.put(FOLDER_ID, importBookmarksCursor.getLong(bookmarkFolderIdColumnIndex)) - bookmarkContentValues.put(FAVORITE_ICON, importBookmarksCursor.getBlob(bookmarkFavoriteIconColumnIndex)) - - // Insert the content values into the bookmarks database. - bookmarksDatabaseHelper.createBookmark(bookmarkContentValues) - - // Advance to the next record. - importBookmarksCursor.moveToNext() - } - - // Upgrade from schema version 16, first used in Privacy Browser 3.12, to schema version 17, first used in Privacy Browser 3.15. - if (importDatabaseVersion < 16) { // Get the current switch default values. val javaScriptDefaultValue = sharedPreferences.getBoolean(context.getString(R.string.javascript_key), false) val cookiesDefaultValue = sharedPreferences.getBoolean(context.getString(R.string.cookies_key), false) val domStorageDefaultValue = sharedPreferences.getBoolean(context.getString(R.string.dom_storage_key), false) - val formDataDefaultValue = sharedPreferences.getBoolean(context.getString(R.string.save_form_data_key), false) val easyListDefaultValue = sharedPreferences.getBoolean(context.getString(R.string.easylist_key), true) val easyPrivacyDefaultValue = sharedPreferences.getBoolean(context.getString(R.string.easyprivacy_key), true) val fanboysAnnoyanceListDefaultValue = sharedPreferences.getBoolean(context.getString(R.string.fanboys_annoyance_list_key), true) @@ -575,7 +510,6 @@ class ImportExportDatabaseHelper { val javaScriptColumnIndex = importDomainsConversionCursor.getColumnIndexOrThrow(ENABLE_JAVASCRIPT) val cookiesColumnIndex = importDomainsConversionCursor.getColumnIndexOrThrow(COOKIES) val domStorageColumnIndex = importDomainsConversionCursor.getColumnIndexOrThrow(ENABLE_DOM_STORAGE) - val formDataColumnIndex = importDomainsConversionCursor.getColumnIndexOrThrow(ENABLE_FORM_DATA) val easyListColumnIndex = importDomainsConversionCursor.getColumnIndexOrThrow(ENABLE_EASYLIST) val easyPrivacyColumnIndex = importDomainsConversionCursor.getColumnIndexOrThrow(ENABLE_EASYPRIVACY) val fanboysAnnoyanceListColumnIndex = importDomainsConversionCursor.getColumnIndexOrThrow(ENABLE_FANBOYS_ANNOYANCE_LIST) @@ -593,7 +527,6 @@ class ImportExportDatabaseHelper { val javaScriptDomainCurrentValue = importDomainsConversionCursor.getInt(javaScriptColumnIndex) val cookiesDomainCurrentValue = importDomainsConversionCursor.getInt(cookiesColumnIndex) val domStorageDomainCurrentValue = importDomainsConversionCursor.getInt(domStorageColumnIndex) - val formDataDomainCurrentValue = importDomainsConversionCursor.getInt(formDataColumnIndex) val easyListDomainCurrentValue = importDomainsConversionCursor.getInt(easyListColumnIndex) val easyPrivacyDomainCurrentValue = importDomainsConversionCursor.getInt(easyPrivacyColumnIndex) val fanboysAnnoyanceListCurrentValue = importDomainsConversionCursor.getInt(fanboysAnnoyanceListColumnIndex) @@ -609,7 +542,6 @@ class ImportExportDatabaseHelper { domainContentValues.put(ENABLE_JAVASCRIPT, convertFromSwitchToSpinner(javaScriptDefaultValue, javaScriptDomainCurrentValue)) domainContentValues.put(COOKIES, convertFromSwitchToSpinner(cookiesDefaultValue, cookiesDomainCurrentValue)) domainContentValues.put(ENABLE_DOM_STORAGE, convertFromSwitchToSpinner(domStorageDefaultValue, domStorageDomainCurrentValue)) - domainContentValues.put(ENABLE_FORM_DATA, convertFromSwitchToSpinner(formDataDefaultValue, formDataDomainCurrentValue)) domainContentValues.put(ENABLE_EASYLIST, convertFromSwitchToSpinner(easyListDefaultValue, easyListDomainCurrentValue)) domainContentValues.put(ENABLE_EASYPRIVACY, convertFromSwitchToSpinner(easyPrivacyDefaultValue, easyPrivacyDomainCurrentValue)) domainContentValues.put(ENABLE_FANBOYS_ANNOYANCE_LIST, convertFromSwitchToSpinner(fanboysAnnoyanceListDefaultValue, fanboysAnnoyanceListCurrentValue)) @@ -629,6 +561,95 @@ class ImportExportDatabaseHelper { importDomainsConversionCursor.close() } + // Upgrade from schema version 17, first used in Privacy Browser 3.15, to schema version 18, first used in Privacy Browser 3.17. + if (importDatabaseVersion < 18) { + // Create the new columns. + importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN $DISPLAY_UNDER_CUTOUTS BOOLEAN") + importDatabase.execSQL("ALTER TABLE $PREFERENCES_TABLE ADD COLUMN $DOWNLOAD_PROVIDER TEXT") + + // Get the current display under cutout value. + val displayUnderCutouts = sharedPreferences.getBoolean(DISPLAY_UNDER_CUTOUTS, false) + + // Populate the preferences table with the current display under cutouts value. + // This can switch to using the variables directly once the minimum API >= 30. + // + if (displayUnderCutouts) + importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $DISPLAY_UNDER_CUTOUTS = 1") + else + importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $DISPLAY_UNDER_CUTOUTS = 0") + + // Get the download with external app cursor. + val downloadWithExternalAppCursor = importDatabase.rawQuery("SELECT download_with_external_app FROM $PREFERENCES_TABLE", null) + + // Move to the first entry. + downloadWithExternalAppCursor.moveToFirst() + + // Get the old download with external app setting. + val downloadWithExternalApp = (downloadWithExternalAppCursor.getInt(downloadWithExternalAppCursor.getColumnIndexOrThrow("download_with_external_app")) == 1) + + // Close the cursor. + downloadWithExternalAppCursor.close() + + // Get the download provider entry values string array. + val downloadProviderEntryValuesStringArray = context.resources.getStringArray(R.array.download_provider_entry_values) + + // Populate the new download provider preference. + if (downloadWithExternalApp) // Download with external app. + importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $DOWNLOAD_PROVIDER = '${downloadProviderEntryValuesStringArray[2]}'") + else // Download with Privacy Browser. + importDatabase.execSQL("UPDATE $PREFERENCES_TABLE SET $DOWNLOAD_PROVIDER = '${downloadProviderEntryValuesStringArray[0]}'") + } + + // Upgrade from schema version 18, first used in Privacy Browser 3.17, to schema version 19, first used in Privacy Browser 3.18. + // This upgrade removed `enableformdata` from the Domains table and `save_form_data` and `clear_form_data` from the Preferences table. + // There is no need to delete the columns as they will simply be ignored by the import. + + + /* End of database upgrade logic. */ + + + // Get a cursor for the bookmarks table. + val importBookmarksCursor = importDatabase.rawQuery("SELECT * FROM $BOOKMARKS_TABLE", null) + + // Delete the current bookmarks database. + context.deleteDatabase(BOOKMARKS_DATABASE) + + // Create a new bookmarks database. + val bookmarksDatabaseHelper = BookmarksDatabaseHelper(context) + + // Move to the first record. + importBookmarksCursor.moveToFirst() + + // Get the bookmarks colum indexes. + val bookmarkNameColumnIndex = importBookmarksCursor.getColumnIndexOrThrow(BOOKMARK_NAME) + val bookmarkUrlColumnIndex = importBookmarksCursor.getColumnIndexOrThrow(BOOKMARK_URL) + val bookmarkParentFolderIdColumnIndex = importBookmarksCursor.getColumnIndexOrThrow(PARENT_FOLDER_ID) + val bookmarkDisplayOrderColumnIndex = importBookmarksCursor.getColumnIndexOrThrow(DISPLAY_ORDER) + val bookmarkIsFolderColumnIndex = importBookmarksCursor.getColumnIndexOrThrow(IS_FOLDER) + val bookmarkFolderIdColumnIndex = importBookmarksCursor.getColumnIndexOrThrow(FOLDER_ID) + val bookmarkFavoriteIconColumnIndex = importBookmarksCursor.getColumnIndexOrThrow(FAVORITE_ICON) + + // Copy the data from the import bookmarks cursor into the bookmarks database. + for (i in 0 until importBookmarksCursor.count) { + // Create a bookmark content values. + val bookmarkContentValues = ContentValues() + + // Add the information for this bookmark to the content values. + bookmarkContentValues.put(BOOKMARK_NAME, importBookmarksCursor.getString(bookmarkNameColumnIndex)) + bookmarkContentValues.put(BOOKMARK_URL, importBookmarksCursor.getString(bookmarkUrlColumnIndex)) + bookmarkContentValues.put(PARENT_FOLDER_ID, importBookmarksCursor.getLong(bookmarkParentFolderIdColumnIndex)) + bookmarkContentValues.put(DISPLAY_ORDER, importBookmarksCursor.getInt(bookmarkDisplayOrderColumnIndex)) + bookmarkContentValues.put(IS_FOLDER, importBookmarksCursor.getInt(bookmarkIsFolderColumnIndex)) + bookmarkContentValues.put(FOLDER_ID, importBookmarksCursor.getLong(bookmarkFolderIdColumnIndex)) + bookmarkContentValues.put(FAVORITE_ICON, importBookmarksCursor.getBlob(bookmarkFavoriteIconColumnIndex)) + + // Insert the content values into the bookmarks database. + bookmarksDatabaseHelper.createBookmark(bookmarkContentValues) + + // Advance to the next record. + importBookmarksCursor.moveToNext() + } + // Close the bookmarks cursor and database. importBookmarksCursor.close() bookmarksDatabaseHelper.close() @@ -651,7 +672,6 @@ class ImportExportDatabaseHelper { val domainJavaScriptColumnIndex = importDomainsCursor.getColumnIndexOrThrow(ENABLE_JAVASCRIPT) val domainCookiesColumnIndex = importDomainsCursor.getColumnIndexOrThrow(COOKIES) val domainDomStorageColumnIndex = importDomainsCursor.getColumnIndexOrThrow(ENABLE_DOM_STORAGE) - val domainFormDataColumnIndex = importDomainsCursor.getColumnIndexOrThrow(ENABLE_FORM_DATA) // Form data can be removed once the minimum API >= 26. val domainEasyListColumnIndex = importDomainsCursor.getColumnIndexOrThrow(ENABLE_EASYLIST) val domainEasyPrivacyColumnIndex = importDomainsCursor.getColumnIndexOrThrow(ENABLE_EASYPRIVACY) val domainFanboysAnnoyanceListColumnIndex = importDomainsCursor.getColumnIndexOrThrow(ENABLE_FANBOYS_ANNOYANCE_LIST) @@ -687,7 +707,6 @@ class ImportExportDatabaseHelper { domainContentValues.put(ENABLE_JAVASCRIPT, importDomainsCursor.getInt(domainJavaScriptColumnIndex)) domainContentValues.put(COOKIES, importDomainsCursor.getInt(domainCookiesColumnIndex)) domainContentValues.put(ENABLE_DOM_STORAGE, importDomainsCursor.getInt(domainDomStorageColumnIndex)) - domainContentValues.put(ENABLE_FORM_DATA, importDomainsCursor.getInt(domainFormDataColumnIndex)) // Form data can be removed once the minimum API >= 26. domainContentValues.put(ENABLE_EASYLIST, importDomainsCursor.getInt(domainEasyListColumnIndex)) domainContentValues.put(ENABLE_EASYPRIVACY, importDomainsCursor.getInt(domainEasyPrivacyColumnIndex)) domainContentValues.put(ENABLE_FANBOYS_ANNOYANCE_LIST, importDomainsCursor.getInt(domainFanboysAnnoyanceListColumnIndex)) @@ -736,7 +755,6 @@ class ImportExportDatabaseHelper { .putBoolean(JAVASCRIPT, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(JAVASCRIPT)) == 1) .putBoolean(COOKIES, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(COOKIES)) == 1) .putBoolean(DOM_STORAGE, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(DOM_STORAGE)) == 1) - .putBoolean(SAVE_FORM_DATA, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(SAVE_FORM_DATA)) == 1) // Save form data can be removed once the minimum API >= 26. .putString(PREFERENCES_USER_AGENT, importPreferencesCursor.getString(importPreferencesCursor.getColumnIndexOrThrow(PREFERENCES_USER_AGENT))) .putString(CUSTOM_USER_AGENT, importPreferencesCursor.getString(importPreferencesCursor.getColumnIndexOrThrow(CUSTOM_USER_AGENT))) .putBoolean(INCOGNITO_MODE, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(INCOGNITO_MODE)) == 1) @@ -760,14 +778,13 @@ class ImportExportDatabaseHelper { .putBoolean(CLEAR_EVERYTHING, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(CLEAR_EVERYTHING)) == 1) .putBoolean(CLEAR_COOKIES, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(CLEAR_COOKIES)) == 1) .putBoolean(CLEAR_DOM_STORAGE, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(CLEAR_DOM_STORAGE)) == 1) - .putBoolean(CLEAR_FORM_DATA, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(CLEAR_FORM_DATA)) == 1) // Clear form data can be removed once the minimum API >= 26. .putBoolean(CLEAR_LOGCAT, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(CLEAR_LOGCAT)) == 1) .putBoolean(CLEAR_CACHE, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(CLEAR_CACHE)) == 1) .putString(HOMEPAGE, importPreferencesCursor.getString(importPreferencesCursor.getColumnIndexOrThrow(HOMEPAGE))) .putString(PREFERENCES_FONT_SIZE, importPreferencesCursor.getString(importPreferencesCursor.getColumnIndexOrThrow(PREFERENCES_FONT_SIZE))) .putBoolean(OPEN_INTENTS_IN_NEW_TAB, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(OPEN_INTENTS_IN_NEW_TAB)) == 1) .putBoolean(PREFERENCES_SWIPE_TO_REFRESH, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(PREFERENCES_SWIPE_TO_REFRESH)) == 1) - .putBoolean(DOWNLOAD_WITH_EXTERNAL_APP, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(DOWNLOAD_WITH_EXTERNAL_APP)) == 1) + .putString(DOWNLOAD_PROVIDER, importPreferencesCursor.getString(importPreferencesCursor.getColumnIndexOrThrow(DOWNLOAD_PROVIDER))) .putBoolean(SCROLL_APP_BAR, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(SCROLL_APP_BAR)) == 1) .putBoolean(BOTTOM_APP_BAR, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(BOTTOM_APP_BAR)) == 1) .putBoolean(DISPLAY_ADDITIONAL_APP_BAR_ICONS, importPreferencesCursor.getInt(importPreferencesCursor.getColumnIndexOrThrow(DISPLAY_ADDITIONAL_APP_BAR_ICONS)) == 1) @@ -868,7 +885,6 @@ class ImportExportDatabaseHelper { val domainJavaScriptColumnIndex = domainsCursor.getColumnIndexOrThrow(ENABLE_JAVASCRIPT) val domainCookiesColumnIndex = domainsCursor.getColumnIndexOrThrow(COOKIES) val domainDomStorageColumnIndex = domainsCursor.getColumnIndexOrThrow(ENABLE_DOM_STORAGE) - val domainFormDataColumnIndex = domainsCursor.getColumnIndexOrThrow(ENABLE_FORM_DATA) // Form data can be removed once the minimum API >= 26. val domainEasyListColumnIndex = domainsCursor.getColumnIndexOrThrow(ENABLE_EASYLIST) val domainEasyPrivacyColumnIndex = domainsCursor.getColumnIndexOrThrow(ENABLE_EASYPRIVACY) val domainFanboysAnnoyanceListColumnIndex = domainsCursor.getColumnIndexOrThrow(ENABLE_FANBOYS_ANNOYANCE_LIST) @@ -904,7 +920,6 @@ class ImportExportDatabaseHelper { domainContentValues.put(ENABLE_JAVASCRIPT, domainsCursor.getInt(domainJavaScriptColumnIndex)) domainContentValues.put(COOKIES, domainsCursor.getInt(domainCookiesColumnIndex)) domainContentValues.put(ENABLE_DOM_STORAGE, domainsCursor.getInt(domainDomStorageColumnIndex)) - domainContentValues.put(ENABLE_FORM_DATA, domainsCursor.getInt(domainFormDataColumnIndex)) // Form data can be removed once the minimum API >= 26. domainContentValues.put(ENABLE_EASYLIST, domainsCursor.getInt(domainEasyListColumnIndex)) domainContentValues.put(ENABLE_EASYPRIVACY, domainsCursor.getInt(domainEasyPrivacyColumnIndex)) domainContentValues.put(ENABLE_FANBOYS_ANNOYANCE_LIST, domainsCursor.getInt(domainFanboysAnnoyanceListColumnIndex)) @@ -948,7 +963,6 @@ class ImportExportDatabaseHelper { "$JAVASCRIPT BOOLEAN, " + "$COOKIES BOOLEAN, " + "$DOM_STORAGE BOOLEAN, " + - "$SAVE_FORM_DATA BOOLEAN, " + "$PREFERENCES_USER_AGENT TEXT, " + "$CUSTOM_USER_AGENT TEXT, " + "$INCOGNITO_MODE BOOLEAN, " + @@ -972,14 +986,13 @@ class ImportExportDatabaseHelper { "$CLEAR_EVERYTHING BOOLEAN, " + "$CLEAR_COOKIES BOOLEAN, " + "$CLEAR_DOM_STORAGE BOOLEAN, " + - "$CLEAR_FORM_DATA BOOLEAN, " + "$CLEAR_LOGCAT BOOLEAN, " + "$CLEAR_CACHE BOOLEAN, " + "$HOMEPAGE TEXT, " + "$PREFERENCES_FONT_SIZE TEXT, " + "$OPEN_INTENTS_IN_NEW_TAB BOOLEAN, " + "$PREFERENCES_SWIPE_TO_REFRESH BOOLEAN, " + - "$DOWNLOAD_WITH_EXTERNAL_APP BOOLEAN, " + + "$DOWNLOAD_PROVIDER TEXT, " + "$SCROLL_APP_BAR BOOLEAN, " + "$BOTTOM_APP_BAR BOOLEAN, " + "$DISPLAY_ADDITIONAL_APP_BAR_ICONS BOOLEAN, " + @@ -1001,7 +1014,6 @@ class ImportExportDatabaseHelper { preferencesContentValues.put(JAVASCRIPT, sharedPreferences.getBoolean(JAVASCRIPT, false)) preferencesContentValues.put(COOKIES, sharedPreferences.getBoolean(COOKIES, false)) preferencesContentValues.put(DOM_STORAGE, sharedPreferences.getBoolean(DOM_STORAGE, false)) - preferencesContentValues.put(SAVE_FORM_DATA, sharedPreferences.getBoolean(SAVE_FORM_DATA, false)) // Save form data can be removed once the minimum API >= 26. preferencesContentValues.put(PREFERENCES_USER_AGENT, sharedPreferences.getString(PREFERENCES_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(INCOGNITO_MODE, sharedPreferences.getBoolean(INCOGNITO_MODE, false)) @@ -1025,14 +1037,13 @@ class ImportExportDatabaseHelper { preferencesContentValues.put(CLEAR_EVERYTHING, sharedPreferences.getBoolean(CLEAR_EVERYTHING, true)) preferencesContentValues.put(CLEAR_COOKIES, sharedPreferences.getBoolean(CLEAR_COOKIES, true)) preferencesContentValues.put(CLEAR_DOM_STORAGE, sharedPreferences.getBoolean(CLEAR_DOM_STORAGE, true)) - preferencesContentValues.put(CLEAR_FORM_DATA, sharedPreferences.getBoolean(CLEAR_FORM_DATA, true)) // Clear form data can be removed once the minimum API >= 26. preferencesContentValues.put(CLEAR_LOGCAT, sharedPreferences.getBoolean(CLEAR_LOGCAT, true)) preferencesContentValues.put(CLEAR_CACHE, sharedPreferences.getBoolean(CLEAR_CACHE, true)) preferencesContentValues.put(HOMEPAGE, sharedPreferences.getString(HOMEPAGE, context.getString(R.string.homepage_default_value))) preferencesContentValues.put(PREFERENCES_FONT_SIZE, sharedPreferences.getString(PREFERENCES_FONT_SIZE, context.getString(R.string.font_size_default_value))) preferencesContentValues.put(OPEN_INTENTS_IN_NEW_TAB, sharedPreferences.getBoolean(OPEN_INTENTS_IN_NEW_TAB, true)) preferencesContentValues.put(PREFERENCES_SWIPE_TO_REFRESH, sharedPreferences.getBoolean(PREFERENCES_SWIPE_TO_REFRESH, true)) - preferencesContentValues.put(DOWNLOAD_WITH_EXTERNAL_APP, sharedPreferences.getBoolean(DOWNLOAD_WITH_EXTERNAL_APP, false)) + preferencesContentValues.put(DOWNLOAD_PROVIDER, sharedPreferences.getString(DOWNLOAD_PROVIDER, context.getString(R.string.download_provider_default_value))) preferencesContentValues.put(SCROLL_APP_BAR, sharedPreferences.getBoolean(SCROLL_APP_BAR, true)) preferencesContentValues.put(BOTTOM_APP_BAR, sharedPreferences.getBoolean(BOTTOM_APP_BAR, false)) preferencesContentValues.put(DISPLAY_ADDITIONAL_APP_BAR_ICONS, sharedPreferences.getBoolean(DISPLAY_ADDITIONAL_APP_BAR_ICONS, false))