diff --git a/app/schemas/com.jerboa.db.AppDB/30.json b/app/schemas/com.jerboa.db.AppDB/30.json new file mode 100644 index 000000000..06d457c98 --- /dev/null +++ b/app/schemas/com.jerboa.db.AppDB/30.json @@ -0,0 +1,279 @@ +{ + "formatVersion": 1, + "database": { + "version": 30, + "identityHash": "9ba87658605a1a57d0a4bebb42d35828", + "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, `verification_state` INTEGER NOT NULL DEFAULT 0, `is_admin` INTEGER NOT NULL, `is_mod` INTEGER NOT NULL, 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" + }, + { + "fieldPath": "verificationState", + "columnName": "verification_state", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "isAdmin", + "columnName": "is_admin", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "isMod", + "columnName": "is_mod", + "affinity": "INTEGER", + "notNull": true + } + ], + "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, `post_navigation_gesture_mode` INTEGER NOT NULL DEFAULT 0, `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, `markAsReadOnScroll` INTEGER NOT NULL DEFAULT 0, `backConfirmationMode` INTEGER NOT NULL DEFAULT 1, `show_post_link_previews` INTEGER NOT NULL DEFAULT 1, `post_actionbar_mode` INTEGER NOT NULL DEFAULT 0, `auto_play_gifs` INTEGER NOT NULL DEFAULT 0, `swipe_to_action_preset` INTEGER NOT NULL DEFAULT 0, `last_version_code_viewed` INTEGER NOT NULL DEFAULT 0)", + "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": "postNavigationGestureMode", + "columnName": "post_navigation_gesture_mode", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "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": "markAsReadOnScroll", + "columnName": "markAsReadOnScroll", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "backConfirmationMode", + "columnName": "backConfirmationMode", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "1" + }, + { + "fieldPath": "showPostLinkPreviews", + "columnName": "show_post_link_previews", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "1" + }, + { + "fieldPath": "postActionBarMode", + "columnName": "post_actionbar_mode", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "autoPlayGifs", + "columnName": "auto_play_gifs", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "swipeToActionPreset", + "columnName": "swipe_to_action_preset", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + }, + { + "fieldPath": "lastVersionCodeViewed", + "columnName": "last_version_code_viewed", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "0" + } + ], + "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, '9ba87658605a1a57d0a4bebb42d35828')" + ] + } +} \ 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 8fe0119ac..eadc9119a 100644 --- a/app/src/main/java/com/jerboa/db/AppDB.kt +++ b/app/src/main/java/com/jerboa/db/AppDB.kt @@ -41,11 +41,11 @@ val APP_SETTINGS_DEFAULT = showPostLinkPreviews = true, postActionBarMode = 0, autoPlayGifs = false, - swipeToActionPreset = SwipeToActionPreset.DEFAULT.ordinal, + swipeToActionPreset = SwipeToActionPreset.DISABLED.ordinal, ) @Database( - version = 29, + version = 30, 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 ef06d5d8a..cfabf9441 100644 --- a/app/src/main/java/com/jerboa/db/AppDBMigrations.kt +++ b/app/src/main/java/com/jerboa/db/AppDBMigrations.kt @@ -371,6 +371,53 @@ val MIGRATION_28_29 = } } +val MIGRATION_29_30 = + object : Migration(29, 30) { + override fun migrate(db: SupportSQLiteDatabase) { + // Add new default swipe_to_action_preset to 0 + + db.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, + `post_navigation_gesture_mode` INTEGER NOT NULL DEFAULT 0, + `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, + `markAsReadOnScroll` INTEGER NOT NULL DEFAULT 0, + `backConfirmationMode` INTEGER NOT NULL DEFAULT 1, + `show_post_link_previews` INTEGER NOT NULL DEFAULT 1, + `post_actionbar_mode` INTEGER NOT NULL DEFAULT 0, + `auto_play_gifs` INTEGER NOT NULL DEFAULT 0, + `swipe_to_action_preset` INTEGER NOT NULL DEFAULT 0, + `last_version_code_viewed` INTEGER NOT NULL DEFAULT 0 + ) + """.trimIndent(), + ) + + db.execSQL( + """ + INSERT INTO AppSettingsBackup SELECT * FROM AppSettings + """, + ) + db.execSQL("DROP TABLE AppSettings") + db.execSQL("ALTER TABLE AppSettingsBackup RENAME to AppSettings") + } + } + // Don't forget to test your migration with `./gradlew app:connectAndroidTest` val MIGRATIONS_LIST = arrayOf( @@ -402,4 +449,5 @@ val MIGRATIONS_LIST = MIGRATION_26_27, MIGRATION_27_28, MIGRATION_28_29, + MIGRATION_29_30, ) 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 65eaec55e..2f26c53e9 100644 --- a/app/src/main/java/com/jerboa/db/entity/AppSettings.kt +++ b/app/src/main/java/com/jerboa/db/entity/AppSettings.kt @@ -122,7 +122,7 @@ data class AppSettings( val autoPlayGifs: Boolean, @ColumnInfo( name = "swipe_to_action_preset", - defaultValue = "1", + defaultValue = "0", ) val swipeToActionPreset: Int, @ColumnInfo( diff --git a/app/src/main/java/com/jerboa/feat/SwipeToAction.kt b/app/src/main/java/com/jerboa/feat/SwipeToAction.kt index 02d130c17..5747a5170 100644 --- a/app/src/main/java/com/jerboa/feat/SwipeToAction.kt +++ b/app/src/main/java/com/jerboa/feat/SwipeToAction.kt @@ -18,7 +18,7 @@ enum class SwipeToActionType { ; companion object { - const val START_THRESHOLD = 0.05f + const val START_THRESHOLD = 0.10f fun getActionToRangeList(actions: List): List, SwipeToActionType>> { val start = START_THRESHOLD + 0.05f @@ -74,39 +74,44 @@ enum class SwipeToActionPreset( val resId: Int, ) { DISABLED(emptyList(), emptyList(), R.string.swipe_action_preset_disabled), - DEFAULT( + TWO_SIDES( listOf(SwipeToActionType.Reply, SwipeToActionType.Save), listOf(SwipeToActionType.Upvote, SwipeToActionType.Downvote), R.string.swipe_action_preset_default, ), LEFT_DOWNVOTE_RIGHT_UPVOTE( - listOf(SwipeToActionType.Downvote, SwipeToActionType.Reply), - listOf(SwipeToActionType.Upvote, SwipeToActionType.Save), + listOf(SwipeToActionType.Upvote, SwipeToActionType.Reply), + listOf(SwipeToActionType.Downvote, SwipeToActionType.Save), R.string.swipe_action_preset_downvote_on_left_upvote_on_right, ), ONLY_RIGHT( - emptyList(), listOf( SwipeToActionType.Upvote, SwipeToActionType.Downvote, SwipeToActionType.Reply, SwipeToActionType.Save, ), + emptyList(), R.string.only_right_swipe_action_preset, ), ONLY_LEFT( + emptyList(), listOf( SwipeToActionType.Upvote, SwipeToActionType.Downvote, SwipeToActionType.Reply, SwipeToActionType.Save, ), - emptyList(), R.string.only_left_swipe_action_preset, ), - ONLY_VOTES( + ONLY_VOTES_MIRRORED( listOf(SwipeToActionType.Downvote), listOf(SwipeToActionType.Upvote), + R.string.swipe_action_preset_only_votes_mirrored, + ), + ONLY_VOTES( + listOf(SwipeToActionType.Upvote), + listOf(SwipeToActionType.Downvote), R.string.swipe_action_preset_only_votes, ), } diff --git a/app/src/main/java/com/jerboa/ui/components/comment/CommentNode.kt b/app/src/main/java/com/jerboa/ui/components/comment/CommentNode.kt index d1a8f2572..3a2cd99fa 100644 --- a/app/src/main/java/com/jerboa/ui/components/comment/CommentNode.kt +++ b/app/src/main/java/com/jerboa/ui/components/comment/CommentNode.kt @@ -925,7 +925,7 @@ fun CommentNodesPreview() { blurNSFW = BlurNSFW.NSFW, account = AnonAccount, voteDisplayMode = VoteDisplayMode.Full, - swipeToActionPreset = SwipeToActionPreset.DEFAULT, + swipeToActionPreset = SwipeToActionPreset.TWO_SIDES, ) } diff --git a/app/src/main/java/com/jerboa/ui/components/common/SwipeToAction.kt b/app/src/main/java/com/jerboa/ui/components/common/SwipeToAction.kt index 2f79af93d..cd9f4817a 100644 --- a/app/src/main/java/com/jerboa/ui/components/common/SwipeToAction.kt +++ b/app/src/main/java/com/jerboa/ui/components/common/SwipeToAction.kt @@ -90,7 +90,7 @@ fun SwipeToAction( haptic.performHapticFeedback(HapticFeedbackType.TextHandleMove) lastSwipeAction.value = currentAction?.second } - spring(stiffness = 1800f) + spring(stiffness = 2000F) }, label = "swipe color animation", targetValueByState = { state -> diff --git a/app/src/main/java/com/jerboa/ui/components/post/PostListing.kt b/app/src/main/java/com/jerboa/ui/components/post/PostListing.kt index 4c844de51..d2bae8d77 100644 --- a/app/src/main/java/com/jerboa/ui/components/post/PostListing.kt +++ b/app/src/main/java/com/jerboa/ui/components/post/PostListing.kt @@ -870,7 +870,7 @@ fun PreviewPostListingCard() { showIfRead = true, voteDisplayMode = VoteDisplayMode.Full, postActionBarMode = PostActionBarMode.Long, - swipeToActionPreset = SwipeToActionPreset.DEFAULT, + swipeToActionPreset = SwipeToActionPreset.TWO_SIDES, ) } @@ -911,7 +911,7 @@ fun PreviewLinkPostListing() { showIfRead = true, voteDisplayMode = VoteDisplayMode.Full, postActionBarMode = PostActionBarMode.Long, - swipeToActionPreset = SwipeToActionPreset.DEFAULT, + swipeToActionPreset = SwipeToActionPreset.TWO_SIDES, ) } @@ -952,7 +952,7 @@ fun PreviewImagePostListingCard() { showIfRead = true, voteDisplayMode = VoteDisplayMode.Full, postActionBarMode = PostActionBarMode.Long, - swipeToActionPreset = SwipeToActionPreset.DEFAULT, + swipeToActionPreset = SwipeToActionPreset.TWO_SIDES, ) } @@ -993,7 +993,7 @@ fun PreviewImagePostListingSmallCard() { showIfRead = true, voteDisplayMode = VoteDisplayMode.Full, postActionBarMode = PostActionBarMode.Long, - swipeToActionPreset = SwipeToActionPreset.DEFAULT, + swipeToActionPreset = SwipeToActionPreset.TWO_SIDES, ) } @@ -1034,7 +1034,7 @@ fun PreviewLinkNoThumbnailPostListing() { showIfRead = true, voteDisplayMode = VoteDisplayMode.Full, postActionBarMode = PostActionBarMode.Long, - swipeToActionPreset = SwipeToActionPreset.DEFAULT, + swipeToActionPreset = SwipeToActionPreset.TWO_SIDES, ) } diff --git a/app/src/main/java/com/jerboa/ui/components/post/PostListings.kt b/app/src/main/java/com/jerboa/ui/components/post/PostListings.kt index 1b12df5b4..48eb4a89d 100644 --- a/app/src/main/java/com/jerboa/ui/components/post/PostListings.kt +++ b/app/src/main/java/com/jerboa/ui/components/post/PostListings.kt @@ -215,7 +215,7 @@ fun PreviewPostListings() { voteDisplayMode = VoteDisplayMode.Full, postActionBarMode = PostActionBarMode.Long, showPostAppendRetry = false, - swipeToActionPreset = SwipeToActionPreset.DEFAULT, + swipeToActionPreset = SwipeToActionPreset.TWO_SIDES, onReplyClick = {}, ) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 00be83559..dd73e1631 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -437,6 +437,7 @@ Unfeature in Local Preset for swipe gesture Only votes + Only votes (Mirrored) View votes Post votes Comment votes