+
+ // Upgrade from schema version 3.
+ case 3:
+ // Add the night mode column.
+ domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN nightmode INTEGER");
+
+ // Upgrade from schema version 4.
+ case 4:
+ // Add the block lists columns.
+ domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ENABLE_EASYLIST + " BOOLEAN");
+ domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ENABLE_EASYPRIVACY + " BOOLEAN");
+ domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ENABLE_FANBOYS_ANNOYANCE_LIST + " BOOLEAN");
+ domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ENABLE_FANBOYS_SOCIAL_BLOCKING_LIST + " BOOLEAN");
+
+ // Get a handle for the shared preference.
+ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(appContext);
+
+ // Get the default block list settings.
+ boolean easyListEnabled = sharedPreferences.getBoolean("easylist", true);
+ boolean easyPrivacyEnabled = sharedPreferences.getBoolean("easyprivacy", true);
+ boolean fanboyAnnoyanceListEnabled = sharedPreferences.getBoolean("fanboys_annoyance_list", true);
+ boolean fanboySocialBlockingListEnabled = sharedPreferences.getBoolean("fanboys_social_blocking_list", true);
+
+ // Set EasyList for existing rows according to the current system-wide default.
+ if (easyListEnabled) {
+ domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_EASYLIST + " = " + 1);
+ } else {
+ domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_EASYLIST + " = " + 0);
+ }
+
+ // Set EasyPrivacy for existing rows according to the current system-wide default.
+ if (easyPrivacyEnabled) {
+ domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_EASYPRIVACY + " = " + 1);
+ } else {
+ domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_EASYPRIVACY + " = " + 0);
+ }
+
+ // Set Fanboy's Annoyance List for existing rows according to the current system-wide default.
+ if (fanboyAnnoyanceListEnabled) {
+ domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_FANBOYS_ANNOYANCE_LIST + " = " + 1);
+ } else {
+ domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_FANBOYS_ANNOYANCE_LIST + " = " + 0);
+ }
+
+ // Set Fanboy's Social Blocking List for existing rows according to the current system-wide default.
+ if (fanboySocialBlockingListEnabled) {
+ domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_FANBOYS_SOCIAL_BLOCKING_LIST + " = " + 1);
+ } else {
+ domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_FANBOYS_SOCIAL_BLOCKING_LIST + " = " + 0);
+ }
+
+ // Upgrade from schema version 5.
+ case 5:
+ // Add the swipe to refresh column. This defaults to `0`, which is `System default`, so a separate step isn't needed to populate the column.
+ domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + SWIPE_TO_REFRESH + " INTEGER");
+
+ // Upgrade from schema version 6.
+ case 6:
+ // Add the block all third-party requests column. This defaults to `0`, which is off, so a separate step isn't needed to populate the column.
+ domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + BLOCK_ALL_THIRD_PARTY_REQUESTS + " BOOLEAN");
+
+ // Upgrade from schema version 7.
+ case 7:
+ // Add the UltraPrivacy column.
+ domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ENABLE_ULTRAPRIVACY + " BOOLEAN");
+
+ // Enable it for all existing rows.
+ domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ENABLE_ULTRAPRIVACY + " = " + 1);
+
+ // Upgrade from schema version 8.
+ case 8:
+ // Add the pinned IP addresses columns. These default to `0` and `""`, so a separate step isn't needed to populate the columns.
+ domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + PINNED_IP_ADDRESSES + " BOOLEAN");
+ domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + IP_ADDRESSES + " TEXT");
+
+ // Upgrade from schema version 9.
+ case 9:
+ // Add the wide viewport column. This defaults to `0`, which is `System default`, so a separate step isn't needed to populate the column.
+ domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + WIDE_VIEWPORT + " INTEGER");
+
+ // Upgrade from schema version 10.
+ case 10:
+ // Add the UltraList column.
+ domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + ULTRALIST + " BOOLEAN");
+
+ // Enable it for all existing rows.
+ domainsDatabase.execSQL("UPDATE " + DOMAINS_TABLE + " SET " + ULTRALIST + " = " + 1);
+
+ // Upgrade from schema version 11.
+ case 11:
+ // Add the WebView theme column. This defaults to `0`, which is `System default`, so a separate step isn't needed to populate the column.
+ domainsDatabase.execSQL("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + WEBVIEW_THEME + " INTEGER");
+
+ // SQLite amazingly doesn't include an easy command to delete a column. <https://www.sqlite.org/lang_altertable.html>
+ // Although a new table could be created and all the data copied to it, I think I will just leave the old night mode column. It will be wiped out the next time an import is run.