From 54886b3f4afb48fcc167e2ca50d96da0db9acea7 Mon Sep 17 00:00:00 2001 From: Maarten Vercruysse <67873169+MV-GH@users.noreply.github.com> Date: Thu, 13 Jul 2023 13:20:48 +0200 Subject: [PATCH] Change default of show_parent_comment_navigation_buttons (#1027) * Change default of show_parent_comment_navigation_buttons * Different attempt * Revert "Change default of show_parent_comment_navigation_buttons" This reverts commit d38ee372177e6a3d5b5f833b21f87c09e56479bd. * Change default show_parent_comment_navigation_buttons properly * Fix formatting * Fix comment --- app/schemas/com.jerboa.db.AppDB/20.json | 211 ++++++++++++++++++ app/src/main/java/com/jerboa/db/AppDB.kt | 2 +- .../java/com/jerboa/db/AppDBMigrations.kt | 42 ++++ .../java/com/jerboa/db/entity/AppSettings.kt | 2 +- 4 files changed, 255 insertions(+), 2 deletions(-) create mode 100644 app/schemas/com.jerboa.db.AppDB/20.json diff --git a/app/schemas/com.jerboa.db.AppDB/20.json b/app/schemas/com.jerboa.db.AppDB/20.json new file mode 100644 index 000000000..543b81e44 --- /dev/null +++ b/app/schemas/com.jerboa.db.AppDB/20.json @@ -0,0 +1,211 @@ +{ + "formatVersion": 1, + "database": { + "version": 20, + "identityHash": "ad45348d127850603284a08efa23652a", + "entities": [ + { + "tableName": "Account", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `current` INTEGER NOT NULL, `instance` TEXT NOT NULL, `name` TEXT NOT NULL, `jwt` TEXT NOT NULL, `default_listing_type` INTEGER NOT NULL DEFAULT 0, `default_sort_type` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`id`))", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "current", + "columnName": "current", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "instance", + "columnName": "instance", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "jwt", + "columnName": "jwt", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "defaultListingType", + "columnName": "default_listing_type", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "defaultSortType", + "columnName": "default_sort_type", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + } + ], + "primaryKey": { + "autoGenerate": false, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "AppSettings", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `font_size` INTEGER NOT NULL DEFAULT 16, `theme` INTEGER NOT NULL DEFAULT 0, `theme_color` INTEGER NOT NULL DEFAULT 0, `viewed_changelog` INTEGER NOT NULL DEFAULT 0, `post_view_mode` INTEGER NOT NULL DEFAULT 0, `show_bottom_nav` INTEGER NOT NULL DEFAULT 1, `show_collapsed_comment_content` INTEGER NOT NULL DEFAULT 0, `show_comment_action_bar_by_default` INTEGER NOT NULL DEFAULT 1, `show_voting_arrows_in_list_view` INTEGER NOT NULL DEFAULT 1, `show_parent_comment_navigation_buttons` INTEGER NOT NULL DEFAULT 0, `navigate_parent_comments_with_volume_buttons` INTEGER NOT NULL DEFAULT 0, `use_custom_tabs` INTEGER NOT NULL DEFAULT 1, `use_private_tabs` INTEGER NOT NULL DEFAULT 0, `secure_window` INTEGER NOT NULL DEFAULT 0, `blur_nsfw` INTEGER NOT NULL DEFAULT 1, `show_text_descriptions_in_navbar` INTEGER NOT NULL DEFAULT 1, `backConfirmationMode` INTEGER NOT NULL DEFAULT 1)", + "fields": [ + { + "fieldPath": "id", + "columnName": "id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "fontSize", + "columnName": "font_size", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "16" + }, + { + "fieldPath": "theme", + "columnName": "theme", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "themeColor", + "columnName": "theme_color", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "viewedChangelog", + "columnName": "viewed_changelog", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "postViewMode", + "columnName": "post_view_mode", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "showBottomNav", + "columnName": "show_bottom_nav", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "1" + }, + { + "fieldPath": "showCollapsedCommentContent", + "columnName": "show_collapsed_comment_content", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "showCommentActionBarByDefault", + "columnName": "show_comment_action_bar_by_default", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "1" + }, + { + "fieldPath": "showVotingArrowsInListView", + "columnName": "show_voting_arrows_in_list_view", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "1" + }, + { + "fieldPath": "showParentCommentNavigationButtons", + "columnName": "show_parent_comment_navigation_buttons", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "navigateParentCommentsWithVolumeButtons", + "columnName": "navigate_parent_comments_with_volume_buttons", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "useCustomTabs", + "columnName": "use_custom_tabs", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "1" + }, + { + "fieldPath": "usePrivateTabs", + "columnName": "use_private_tabs", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "secureWindow", + "columnName": "secure_window", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "blurNSFW", + "columnName": "blur_nsfw", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "1" + }, + { + "fieldPath": "showTextDescriptionsInNavbar", + "columnName": "show_text_descriptions_in_navbar", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "1" + }, + { + "fieldPath": "backConfirmationMode", + "columnName": "backConfirmationMode", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "1" + } + ], + "primaryKey": { + "autoGenerate": true, + "columnNames": [ + "id" + ] + }, + "indices": [], + "foreignKeys": [] + } + ], + "views": [], + "setupQueries": [ + "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'ad45348d127850603284a08efa23652a')" + ] + } +} \ No newline at end of file diff --git a/app/src/main/java/com/jerboa/db/AppDB.kt b/app/src/main/java/com/jerboa/db/AppDB.kt index 30fd2f024..dd63bb183 100644 --- a/app/src/main/java/com/jerboa/db/AppDB.kt +++ b/app/src/main/java/com/jerboa/db/AppDB.kt @@ -37,7 +37,7 @@ val APP_SETTINGS_DEFAULT = AppSettings( ) @Database( - version = 19, + version = 20, entities = [Account::class, AppSettings::class], exportSchema = true, ) diff --git a/app/src/main/java/com/jerboa/db/AppDBMigrations.kt b/app/src/main/java/com/jerboa/db/AppDBMigrations.kt index b8bae7ec3..347f494b7 100644 --- a/app/src/main/java/com/jerboa/db/AppDBMigrations.kt +++ b/app/src/main/java/com/jerboa/db/AppDBMigrations.kt @@ -220,6 +220,47 @@ val MIGRATION_18_19 = object : Migration(18, 19) { } } +val MIGRATION_19_20 = object : Migration(19, 20) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL(UPDATE_APP_CHANGELOG_UNVIEWED) + // Add new default show_parent_comment_navigation_buttons to 0 + + database.execSQL( + """ + CREATE TABLE IF NOT EXISTS AppSettingsBackup ( + `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + `font_size` INTEGER NOT NULL DEFAULT 16, + `theme` INTEGER NOT NULL DEFAULT 0, + `theme_color` INTEGER NOT NULL DEFAULT 0, + `viewed_changelog` INTEGER NOT NULL DEFAULT 0, + `post_view_mode` INTEGER NOT NULL DEFAULT 0, + `show_bottom_nav` INTEGER NOT NULL DEFAULT 1, + `show_collapsed_comment_content` INTEGER NOT NULL DEFAULT 0, + `show_comment_action_bar_by_default` INTEGER NOT NULL DEFAULT 1, + `show_voting_arrows_in_list_view` INTEGER NOT NULL DEFAULT 1, + `show_parent_comment_navigation_buttons` INTEGER NOT NULL DEFAULT 0, + `navigate_parent_comments_with_volume_buttons` INTEGER NOT NULL DEFAULT 0, + `use_custom_tabs` INTEGER NOT NULL DEFAULT 1, + `use_private_tabs` INTEGER NOT NULL DEFAULT 0, + `secure_window` INTEGER NOT NULL DEFAULT 0, + `blur_nsfw` INTEGER NOT NULL DEFAULT 1, + `show_text_descriptions_in_navbar` INTEGER NOT NULL DEFAULT 1, + `backConfirmationMode` INTEGER NOT NULL DEFAULT 1 + ) + + """.trimIndent(), + ) + + database.execSQL( + """ + INSERT INTO AppSettingsBackup SELECT * FROM AppSettings + """, + ) + database.execSQL("DROP TABLE AppSettings") + database.execSQL("ALTER TABLE AppSettingsBackup RENAME to AppSettings") + } +} + // Don't forget to test your migration with `./gradlew app:connectAndroidTest` val MIGRATIONS_LIST = arrayOf( MIGRATION_1_2, @@ -240,4 +281,5 @@ val MIGRATIONS_LIST = arrayOf( MIGRATION_16_17, MIGRATION_17_18, MIGRATION_18_19, + MIGRATION_19_20, ) diff --git a/app/src/main/java/com/jerboa/db/entity/AppSettings.kt b/app/src/main/java/com/jerboa/db/entity/AppSettings.kt index fb099ff4f..e0aaba3e0 100644 --- a/app/src/main/java/com/jerboa/db/entity/AppSettings.kt +++ b/app/src/main/java/com/jerboa/db/entity/AppSettings.kt @@ -55,7 +55,7 @@ data class AppSettings( val showVotingArrowsInListView: Boolean, @ColumnInfo( name = "show_parent_comment_navigation_buttons", - defaultValue = "1", + defaultValue = "0", ) val showParentCommentNavigationButtons: Boolean, @ColumnInfo(