From 003b585bef33145637c2e1453e9e0f801a4af119 Mon Sep 17 00:00:00 2001 From: sthomas727 Date: Sun, 20 Aug 2023 13:52:53 +1000 Subject: [PATCH 1/8] * Add setting to enable swipe to go back in Look and Feel settings. It is enabled by default. * Implemented settings check in SwipeToNavigateBack to facilitate disabling functionality. --- app/schemas/com.jerboa.db.AppDB/25.json | 13 +++- app/src/main/java/com/jerboa/MainActivity.kt | 39 ++++++------ app/src/main/java/com/jerboa/db/AppDB.kt | 1 + .../java/com/jerboa/db/entity/AppSettings.kt | 5 ++ .../components/common/SwipeToNavigateBack.kt | 60 +++++++++++-------- .../lookandfeel/LookAndFeelActivity.kt | 10 ++++ app/src/main/res/values/strings.xml | 1 + 7 files changed, 82 insertions(+), 47 deletions(-) diff --git a/app/schemas/com.jerboa.db.AppDB/25.json b/app/schemas/com.jerboa.db.AppDB/25.json index 8792ec6b1..96fe074cb 100644 --- a/app/schemas/com.jerboa.db.AppDB/25.json +++ b/app/schemas/com.jerboa.db.AppDB/25.json @@ -2,7 +2,7 @@ "formatVersion": 1, "database": { "version": 25, - "identityHash": "e7e957b63c2297483c5e9aeb1e263a1f", + "identityHash": "87cae1fe709d2ff3f061dd8c55baed5b", "entities": [ { "tableName": "Account", @@ -71,7 +71,7 @@ }, { "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, `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)", + "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, `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, `use_swipe_back` INTEGER NOT NULL DEFAULT 1)", "fields": [ { "fieldPath": "id", @@ -225,6 +225,13 @@ "affinity": "INTEGER", "notNull": true, "defaultValue": "0" + }, + { + "fieldPath": "useSwipeBack", + "columnName": "use_swipe_back", + "affinity": "INTEGER", + "notNull": true, + "defaultValue": "1" } ], "primaryKey": { @@ -240,7 +247,7 @@ "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, 'e7e957b63c2297483c5e9aeb1e263a1f')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '87cae1fe709d2ff3f061dd8c55baed5b')" ] } } \ No newline at end of file diff --git a/app/src/main/java/com/jerboa/MainActivity.kt b/app/src/main/java/com/jerboa/MainActivity.kt index fd96574f5..7e9294044 100644 --- a/app/src/main/java/com/jerboa/MainActivity.kt +++ b/app/src/main/java/com/jerboa/MainActivity.kt @@ -493,24 +493,27 @@ class MainActivity : AppCompatActivity() { ), ) { val args = Route.PostArgs(it) - SwipeToNavigateBack(appState::navigateUp) { - PostActivity( - id = Either.Left(args.id), - accountViewModel = accountViewModel, - appState = appState, - showCollapsedCommentContent = appSettings.showCollapsedCommentContent, - showActionBarByDefault = appSettings.showCommentActionBarByDefault, - showVotingArrowsInListView = appSettings.showVotingArrowsInListView, - showParentCommentNavigationButtons = appSettings.showParentCommentNavigationButtons, - navigateParentCommentsWithVolumeButtons = appSettings.navigateParentCommentsWithVolumeButtons, - siteViewModel = siteViewModel, - useCustomTabs = appSettings.useCustomTabs, - usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, - showPostLinkPreview = appSettings.showPostLinkPreviews, - postActionbarMode = appSettings.postActionbarMode, - ) - } + + SwipeToNavigateBack(appSettings.useSwipeBack, + appState::navigateUp) + { + PostActivity( + id = Either.Left(args.id), + accountViewModel = accountViewModel, + appState = appState, + showCollapsedCommentContent = appSettings.showCollapsedCommentContent, + showActionBarByDefault = appSettings.showCommentActionBarByDefault, + showVotingArrowsInListView = appSettings.showVotingArrowsInListView, + showParentCommentNavigationButtons = appSettings.showParentCommentNavigationButtons, + navigateParentCommentsWithVolumeButtons = appSettings.navigateParentCommentsWithVolumeButtons, + siteViewModel = siteViewModel, + useCustomTabs = appSettings.useCustomTabs, + usePrivateTabs = appSettings.usePrivateTabs, + blurNSFW = appSettings.blurNSFW, + showPostLinkPreview = appSettings.showPostLinkPreviews, + postActionbarMode = appSettings.postActionbarMode, + ) + } } composable( diff --git a/app/src/main/java/com/jerboa/db/AppDB.kt b/app/src/main/java/com/jerboa/db/AppDB.kt index ef3d30cfe..eaf36c9c5 100644 --- a/app/src/main/java/com/jerboa/db/AppDB.kt +++ b/app/src/main/java/com/jerboa/db/AppDB.kt @@ -38,6 +38,7 @@ val APP_SETTINGS_DEFAULT = AppSettings( showPostLinkPreviews = true, postActionbarMode = 0, autoPlayGifs = false, + useSwipeBack = true, ) @Database( 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 a716a77f6..f7f0b1cc2 100644 --- a/app/src/main/java/com/jerboa/db/entity/AppSettings.kt +++ b/app/src/main/java/com/jerboa/db/entity/AppSettings.kt @@ -113,4 +113,9 @@ data class AppSettings( defaultValue = "0", ) val autoPlayGifs: Boolean, + @ColumnInfo( + name = "use_swipe_back", + defaultValue = "1", + ) + val useSwipeBack: Boolean, ) diff --git a/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt b/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt index f905f15c0..8369c8342 100644 --- a/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt +++ b/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt @@ -16,34 +16,42 @@ import androidx.compose.ui.Modifier @OptIn(ExperimentalMaterialApi::class) @Composable fun SwipeToNavigateBack( + useSwipeBack: Boolean, onSwipeBack: () -> Unit, content: @Composable () -> Unit, ) { - val dismissState = rememberDismissState( - confirmStateChange = { - when (it) { - DismissValue.DismissedToEnd -> { - onSwipeBack() - true - } - else -> { false } - } - }, - ) + if (useSwipeBack) { + val dismissState = rememberDismissState( + confirmStateChange = { + when (it) { + DismissValue.DismissedToEnd -> { + onSwipeBack() + true + } - SwipeToDismiss( - state = dismissState, - background = { - Box( - modifier = Modifier - .fillMaxSize() - .background(MaterialTheme.colorScheme.background), - ) - }, - dismissContent = { - content() - }, - directions = setOf(DismissDirection.StartToEnd), - dismissThresholds = { FractionalThreshold(0.8f) }, - ) + else -> { + false + } + } + }, + ) + SwipeToDismiss( + state = dismissState, + background = { + Box( + modifier = Modifier + .fillMaxSize() + .background(MaterialTheme.colorScheme.background), + ) + }, + dismissContent = { + content() + }, + directions = setOf(DismissDirection.StartToEnd), + dismissThresholds = { FractionalThreshold(0.8f) }, + ) + } + else { + content() + } } diff --git a/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt b/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt index a1b192633..ba2a2a680 100644 --- a/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt @@ -97,6 +97,8 @@ fun LookAndFeelActivity( val markAsReadOnScroll = rememberBooleanSettingState(settings.markAsReadOnScroll) val autoPlayGifs = rememberBooleanSettingState(settings.autoPlayGifs) + val useSwipeBack = rememberBooleanSettingState(settings.useSwipeBack) + fun updateAppSettings() { appSettingsViewModel.update( @@ -123,6 +125,7 @@ fun LookAndFeelActivity( markAsReadOnScroll = markAsReadOnScroll.value, postActionbarMode = postActionbarMode.value, autoPlayGifs = autoPlayGifs.value, + useSwipeBack = useSwipeBack.value, ), ) } @@ -360,6 +363,13 @@ fun LookAndFeelActivity( }, onCheckedChange = { updateAppSettings() }, ) + SettingsCheckbox( + state = useSwipeBack, + title = { + Text(stringResource(id = R.string.look_and_feel_use_swipe_back)) + }, + onCheckedChange = { updateAppSettings() }, + ) } }, ) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 597bec541..0b94f9b53 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -203,6 +203,7 @@ Woodland Use custom tabs Use private custom tabs if available + Use swipe to navigate back on posts Mark as read Mark as unread Format as bold text From c9de42568ea42c8b53b34fb647d51b66fdb47e0e Mon Sep 17 00:00:00 2001 From: sthomas727 Date: Sun, 20 Aug 2023 14:18:33 +1000 Subject: [PATCH 2/8] * Add setting to enable swipe to go back in Look and Feel settings. It is enabled by default. * Implemented settings check in SwipeToNavigateBack to facilitate disabling functionality. --- app/src/main/java/com/jerboa/MainActivity.kt | 38 ++++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/jerboa/MainActivity.kt b/app/src/main/java/com/jerboa/MainActivity.kt index 7e9294044..e0a31b4d5 100644 --- a/app/src/main/java/com/jerboa/MainActivity.kt +++ b/app/src/main/java/com/jerboa/MainActivity.kt @@ -494,25 +494,25 @@ class MainActivity : AppCompatActivity() { ) { val args = Route.PostArgs(it) - SwipeToNavigateBack(appSettings.useSwipeBack, - appState::navigateUp) - { - PostActivity( - id = Either.Left(args.id), - accountViewModel = accountViewModel, - appState = appState, - showCollapsedCommentContent = appSettings.showCollapsedCommentContent, - showActionBarByDefault = appSettings.showCommentActionBarByDefault, - showVotingArrowsInListView = appSettings.showVotingArrowsInListView, - showParentCommentNavigationButtons = appSettings.showParentCommentNavigationButtons, - navigateParentCommentsWithVolumeButtons = appSettings.navigateParentCommentsWithVolumeButtons, - siteViewModel = siteViewModel, - useCustomTabs = appSettings.useCustomTabs, - usePrivateTabs = appSettings.usePrivateTabs, - blurNSFW = appSettings.blurNSFW, - showPostLinkPreview = appSettings.showPostLinkPreviews, - postActionbarMode = appSettings.postActionbarMode, - ) + SwipeToNavigateBack( + appSettings.useSwipeBack, + appState::navigateUp) { + PostActivity( + id = Either.Left(args.id), + accountViewModel = accountViewModel, + appState = appState, + showCollapsedCommentContent = appSettings.showCollapsedCommentContent, + showActionBarByDefault = appSettings.showCommentActionBarByDefault, + showVotingArrowsInListView = appSettings.showVotingArrowsInListView, + showParentCommentNavigationButtons = appSettings.showParentCommentNavigationButtons, + navigateParentCommentsWithVolumeButtons = appSettings.navigateParentCommentsWithVolumeButtons, + siteViewModel = siteViewModel, + useCustomTabs = appSettings.useCustomTabs, + usePrivateTabs = appSettings.usePrivateTabs, + blurNSFW = appSettings.blurNSFW, + showPostLinkPreview = appSettings.showPostLinkPreviews, + postActionbarMode = appSettings.postActionbarMode, + ) } } From 1c888008cebde43b0b2588343a6df4309ea9e1d5 Mon Sep 17 00:00:00 2001 From: sthomas727 Date: Sun, 20 Aug 2023 14:21:53 +1000 Subject: [PATCH 3/8] * Add setting to enable swipe to go back in Look and Feel settings. It is enabled by default. * Implemented settings check in SwipeToNavigateBack to facilitate disabling functionality. --- app/src/main/java/com/jerboa/MainActivity.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/jerboa/MainActivity.kt b/app/src/main/java/com/jerboa/MainActivity.kt index e0a31b4d5..65d1701fc 100644 --- a/app/src/main/java/com/jerboa/MainActivity.kt +++ b/app/src/main/java/com/jerboa/MainActivity.kt @@ -496,7 +496,9 @@ class MainActivity : AppCompatActivity() { SwipeToNavigateBack( appSettings.useSwipeBack, - appState::navigateUp) { + appState::navigateUp + ) + { PostActivity( id = Either.Left(args.id), accountViewModel = accountViewModel, @@ -513,7 +515,7 @@ class MainActivity : AppCompatActivity() { showPostLinkPreview = appSettings.showPostLinkPreviews, postActionbarMode = appSettings.postActionbarMode, ) - } + } } composable( From 5a7c93831823298bf662119c919156535a1b8425 Mon Sep 17 00:00:00 2001 From: sthomas727 Date: Sun, 20 Aug 2023 14:27:03 +1000 Subject: [PATCH 4/8] * Add setting to enable swipe to go back in Look and Feel settings. It is enabled by default. * Implemented settings check in SwipeToNavigateBack to facilitate disabling functionality. --- app/src/main/java/com/jerboa/MainActivity.kt | 5 ++--- .../com/jerboa/ui/components/common/SwipeToNavigateBack.kt | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/jerboa/MainActivity.kt b/app/src/main/java/com/jerboa/MainActivity.kt index 65d1701fc..786acbafd 100644 --- a/app/src/main/java/com/jerboa/MainActivity.kt +++ b/app/src/main/java/com/jerboa/MainActivity.kt @@ -496,9 +496,8 @@ class MainActivity : AppCompatActivity() { SwipeToNavigateBack( appSettings.useSwipeBack, - appState::navigateUp - ) - { + appState::navigateUp, + ) { PostActivity( id = Either.Left(args.id), accountViewModel = accountViewModel, diff --git a/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt b/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt index 8369c8342..70c843a69 100644 --- a/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt +++ b/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt @@ -50,8 +50,7 @@ fun SwipeToNavigateBack( directions = setOf(DismissDirection.StartToEnd), dismissThresholds = { FractionalThreshold(0.8f) }, ) - } - else { + } else { content() } } From 12d7abd5e06a0c3cc70bd4ccaf38a61c607e97b9 Mon Sep 17 00:00:00 2001 From: sthomas727 Date: Sun, 20 Aug 2023 14:31:03 +1000 Subject: [PATCH 5/8] * Add setting to enable swipe to go back in Look and Feel settings. It is enabled by default. * Implemented settings check in SwipeToNavigateBack to facilitate disabling functionality. --- .../ui/components/settings/lookandfeel/LookAndFeelActivity.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt b/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt index ba2a2a680..f93851ce7 100644 --- a/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt @@ -99,7 +99,6 @@ fun LookAndFeelActivity( val autoPlayGifs = rememberBooleanSettingState(settings.autoPlayGifs) val useSwipeBack = rememberBooleanSettingState(settings.useSwipeBack) - fun updateAppSettings() { appSettingsViewModel.update( AppSettings( From 4cf69995467b052c3a2194338a8f888913cc55e3 Mon Sep 17 00:00:00 2001 From: sthomas727 Date: Sun, 20 Aug 2023 22:58:49 +1000 Subject: [PATCH 6/8] * Add setting to enable swipe to go back in Look and Feel settings. It is enabled by default. * Implemented settings check in SwipeToNavigateBack to facilitate disabling functionality. --- app/schemas/com.jerboa.db.AppDB/25.json | 13 +- app/schemas/com.jerboa.db.AppDB/26.json | 253 ++++++++++++++++++ app/src/main/java/com/jerboa/MainActivity.kt | 2 +- app/src/main/java/com/jerboa/Utils.kt | 12 + app/src/main/java/com/jerboa/db/AppDB.kt | 4 +- .../java/com/jerboa/db/AppDBMigrations.kt | 18 ++ .../java/com/jerboa/db/entity/AppSettings.kt | 10 +- .../components/common/SwipeToNavigateBack.kt | 4 +- .../lookandfeel/LookAndFeelActivity.kt | 30 ++- app/src/main/res/values/strings.xml | 4 +- 10 files changed, 320 insertions(+), 30 deletions(-) create mode 100644 app/schemas/com.jerboa.db.AppDB/26.json diff --git a/app/schemas/com.jerboa.db.AppDB/25.json b/app/schemas/com.jerboa.db.AppDB/25.json index 96fe074cb..8792ec6b1 100644 --- a/app/schemas/com.jerboa.db.AppDB/25.json +++ b/app/schemas/com.jerboa.db.AppDB/25.json @@ -2,7 +2,7 @@ "formatVersion": 1, "database": { "version": 25, - "identityHash": "87cae1fe709d2ff3f061dd8c55baed5b", + "identityHash": "e7e957b63c2297483c5e9aeb1e263a1f", "entities": [ { "tableName": "Account", @@ -71,7 +71,7 @@ }, { "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, `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, `use_swipe_back` INTEGER NOT NULL DEFAULT 1)", + "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, `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)", "fields": [ { "fieldPath": "id", @@ -225,13 +225,6 @@ "affinity": "INTEGER", "notNull": true, "defaultValue": "0" - }, - { - "fieldPath": "useSwipeBack", - "columnName": "use_swipe_back", - "affinity": "INTEGER", - "notNull": true, - "defaultValue": "1" } ], "primaryKey": { @@ -247,7 +240,7 @@ "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, '87cae1fe709d2ff3f061dd8c55baed5b')" + "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'e7e957b63c2297483c5e9aeb1e263a1f')" ] } } \ No newline at end of file diff --git a/app/schemas/com.jerboa.db.AppDB/26.json b/app/schemas/com.jerboa.db.AppDB/26.json new file mode 100644 index 000000000..4a5345694 --- /dev/null +++ b/app/schemas/com.jerboa.db.AppDB/26.json @@ -0,0 +1,253 @@ +{ + "formatVersion": 1, + "database": { + "version": 26, + "identityHash": "bf20da38fc7d03e28121589dfb372eaf", + "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, 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" + } + ], + "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)", + "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" + } + ], + "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, 'bf20da38fc7d03e28121589dfb372eaf')" + ] + } +} \ No newline at end of file diff --git a/app/src/main/java/com/jerboa/MainActivity.kt b/app/src/main/java/com/jerboa/MainActivity.kt index 786acbafd..8060781a2 100644 --- a/app/src/main/java/com/jerboa/MainActivity.kt +++ b/app/src/main/java/com/jerboa/MainActivity.kt @@ -495,7 +495,7 @@ class MainActivity : AppCompatActivity() { val args = Route.PostArgs(it) SwipeToNavigateBack( - appSettings.useSwipeBack, + appSettings.postNavigationGestureMode, appState::navigateUp, ) { PostActivity( diff --git a/app/src/main/java/com/jerboa/Utils.kt b/app/src/main/java/com/jerboa/Utils.kt index 9adea58fc..d27d20714 100644 --- a/app/src/main/java/com/jerboa/Utils.kt +++ b/app/src/main/java/com/jerboa/Utils.kt @@ -835,6 +835,18 @@ enum class PostViewMode(val mode: Int) { List(R.string.look_and_feel_post_view_list), } +enum class NavigationGestureMode(val mode: Int) { + /** + * Disable all navigation gestures within posts. + */ + Disabled(R.string.look_and_feel_post_navigation_gesture_mode_disabled), + + /** + * Enable swiping left to navigate away from a post. + */ + SwipeLeft(R.string.look_and_feel_post_navigation_gesture_mode_swipe_left), +} + /** * For a given post, what sort of content Jerboa treats it as. */ diff --git a/app/src/main/java/com/jerboa/db/AppDB.kt b/app/src/main/java/com/jerboa/db/AppDB.kt index eaf36c9c5..d09b1c794 100644 --- a/app/src/main/java/com/jerboa/db/AppDB.kt +++ b/app/src/main/java/com/jerboa/db/AppDB.kt @@ -22,6 +22,7 @@ val APP_SETTINGS_DEFAULT = AppSettings( themeColor = 0, viewedChangelog = 0, postViewMode = 0, + postNavigationGestureMode = 0, showBottomNav = true, showCollapsedCommentContent = false, showCommentActionBarByDefault = true, @@ -38,11 +39,10 @@ val APP_SETTINGS_DEFAULT = AppSettings( showPostLinkPreviews = true, postActionbarMode = 0, autoPlayGifs = false, - useSwipeBack = true, ) @Database( - version = 25, + version = 26, 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 3a190e38e..d45a071da 100644 --- a/app/src/main/java/com/jerboa/db/AppDBMigrations.kt +++ b/app/src/main/java/com/jerboa/db/AppDBMigrations.kt @@ -338,6 +338,22 @@ val MIGRATION_25_24 = object : Migration(25, 24) { } } +val MIGRATION_25_26 = object : Migration(25, 26) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL( + "ALTER TABLE AppSettings ADD COLUMN post_navigation_gesture_mode INTEGER NOT NULL DEFAULT 0", + ) + } +} + +val MIGRATION_26_25 = object : Migration(26, 25) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL( + "ALTER TABLE AppSettings DROP COLUMN post_navigation_gesture_mode", + ) + } +} + // Don't forget to test your migration with `./gradlew app:connectAndroidTest` val MIGRATIONS_LIST = arrayOf( MIGRATION_1_2, @@ -368,4 +384,6 @@ val MIGRATIONS_LIST = arrayOf( MIGRATION_24_23, MIGRATION_24_25, MIGRATION_25_24, + MIGRATION_25_26, + MIGRATION_26_25, ) 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 f7f0b1cc2..9d9a0b0d8 100644 --- a/app/src/main/java/com/jerboa/db/entity/AppSettings.kt +++ b/app/src/main/java/com/jerboa/db/entity/AppSettings.kt @@ -38,6 +38,11 @@ data class AppSettings( defaultValue = "1", ) val showBottomNav: Boolean, + @ColumnInfo( + name = "post_navigation_gesture_mode", + defaultValue = "0", + ) + val postNavigationGestureMode: Int, @ColumnInfo( name = "show_collapsed_comment_content", defaultValue = "0", @@ -113,9 +118,4 @@ data class AppSettings( defaultValue = "0", ) val autoPlayGifs: Boolean, - @ColumnInfo( - name = "use_swipe_back", - defaultValue = "1", - ) - val useSwipeBack: Boolean, ) diff --git a/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt b/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt index 70c843a69..5665e437b 100644 --- a/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt +++ b/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt @@ -16,11 +16,11 @@ import androidx.compose.ui.Modifier @OptIn(ExperimentalMaterialApi::class) @Composable fun SwipeToNavigateBack( - useSwipeBack: Boolean, + useSwipeBack: Int, onSwipeBack: () -> Unit, content: @Composable () -> Unit, ) { - if (useSwipeBack) { + if (useSwipeBack == 1) { val dismissState = rememberDismissState( confirmStateChange = { when (it) { diff --git a/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt b/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt index f93851ce7..602353de4 100644 --- a/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt @@ -13,6 +13,7 @@ import androidx.compose.material.icons.outlined.FormatSize import androidx.compose.material.icons.outlined.Forum import androidx.compose.material.icons.outlined.Language import androidx.compose.material.icons.outlined.Palette +import androidx.compose.material.icons.outlined.Swipe import androidx.compose.material.icons.outlined.ViewList import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon @@ -34,6 +35,7 @@ import com.alorma.compose.settings.ui.SettingsList import com.alorma.compose.settings.ui.SettingsListDropdown import com.alorma.compose.settings.ui.SettingsSlider import com.jerboa.PostViewMode +import com.jerboa.NavigationGestureMode import com.jerboa.R import com.jerboa.ThemeColor import com.jerboa.ThemeMode @@ -71,6 +73,7 @@ fun LookAndFeelActivity( settings.fontSize.toFloat(), ) val postViewModeState = rememberIntSettingState(settings.postViewMode) + val postNavigationGestureModeState = rememberIntSettingState(settings.postNavigationGestureMode) val showBottomNavState = rememberBooleanSettingState(settings.showBottomNav) val showTextDescriptionsInNavbar = rememberBooleanSettingState(settings.showTextDescriptionsInNavbar) val showCollapsedCommentContentState = rememberBooleanSettingState(settings.showCollapsedCommentContent) @@ -97,7 +100,6 @@ fun LookAndFeelActivity( val markAsReadOnScroll = rememberBooleanSettingState(settings.markAsReadOnScroll) val autoPlayGifs = rememberBooleanSettingState(settings.autoPlayGifs) - val useSwipeBack = rememberBooleanSettingState(settings.useSwipeBack) fun updateAppSettings() { appSettingsViewModel.update( @@ -124,7 +126,7 @@ fun LookAndFeelActivity( markAsReadOnScroll = markAsReadOnScroll.value, postActionbarMode = postActionbarMode.value, autoPlayGifs = autoPlayGifs.value, - useSwipeBack = useSwipeBack.value, + postNavigationGestureMode = postNavigationGestureModeState.value, ), ) } @@ -229,6 +231,23 @@ fun LookAndFeelActivity( updateAppSettings() }, ) + SettingsList( + state = postNavigationGestureModeState, + items = NavigationGestureMode.entries.map {stringResource(it.mode) }, + icon = { + Icon( + imageVector = Icons.Outlined.Swipe, + contentDescription = null, + ) + }, + title = { + Text(text = stringResource(R.string.look_and_feel_post_navigation_gesture_mode)) + }, + onItemSelected = { i, _ -> + postNavigationGestureModeState.value = i + updateAppSettings() + }, + ) SettingsList( title = { Text(text = stringResource(R.string.confirm_exit)) @@ -362,13 +381,6 @@ fun LookAndFeelActivity( }, onCheckedChange = { updateAppSettings() }, ) - SettingsCheckbox( - state = useSwipeBack, - title = { - Text(stringResource(id = R.string.look_and_feel_use_swipe_back)) - }, - onCheckedChange = { updateAppSettings() }, - ) } }, ) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0b94f9b53..afbd0ad77 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -174,6 +174,9 @@ Show content for collapsed comments Font size: %1$s Look and feel + Post Navigation Gestures + Disabled + Swipe Left to Navigate Back Post View Card List @@ -203,7 +206,6 @@ Woodland Use custom tabs Use private custom tabs if available - Use swipe to navigate back on posts Mark as read Mark as unread Format as bold text From bdc19fa8aaccc26c34adf13bba843d1bb7b97d0e Mon Sep 17 00:00:00 2001 From: sthomas727 Date: Sun, 20 Aug 2023 23:11:25 +1000 Subject: [PATCH 7/8] * Add list to choose navigation gesture mode in Look and Feel settings. It is disabled by default. * Implemented settings check in SwipeToNavigateBack to facilitate disabling functionality. --- .../ui/components/settings/lookandfeel/LookAndFeelActivity.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt b/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt index 602353de4..f26c83392 100644 --- a/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt @@ -34,8 +34,8 @@ import com.alorma.compose.settings.ui.SettingsCheckbox import com.alorma.compose.settings.ui.SettingsList import com.alorma.compose.settings.ui.SettingsListDropdown import com.alorma.compose.settings.ui.SettingsSlider -import com.jerboa.PostViewMode import com.jerboa.NavigationGestureMode +import com.jerboa.PostViewMode import com.jerboa.R import com.jerboa.ThemeColor import com.jerboa.ThemeMode @@ -233,7 +233,7 @@ fun LookAndFeelActivity( ) SettingsList( state = postNavigationGestureModeState, - items = NavigationGestureMode.entries.map {stringResource(it.mode) }, + items = NavigationGestureMode.entries.map { stringResource(it.mode) }, icon = { Icon( imageVector = Icons.Outlined.Swipe, From deb175e6e35492b85f8d2da5420dca86e162a272 Mon Sep 17 00:00:00 2001 From: sthomas727 Date: Mon, 21 Aug 2023 20:06:43 +1000 Subject: [PATCH 8/8] * Add list to choose navigation gesture mode in Look and Feel settings. It is disabled by default. * Implemented settings check in SwipeToNavigateBack to facilitate disabling functionality. --- app/src/main/java/com/jerboa/Utils.kt | 12 ------------ .../com/jerboa/feat/PostNavigationGestureMode.kt | 15 +++++++++++++++ .../ui/components/common/SwipeToNavigateBack.kt | 3 ++- .../settings/lookandfeel/LookAndFeelActivity.kt | 4 ++-- app/src/main/res/values/strings.xml | 4 ++-- 5 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 app/src/main/java/com/jerboa/feat/PostNavigationGestureMode.kt diff --git a/app/src/main/java/com/jerboa/Utils.kt b/app/src/main/java/com/jerboa/Utils.kt index d27d20714..9adea58fc 100644 --- a/app/src/main/java/com/jerboa/Utils.kt +++ b/app/src/main/java/com/jerboa/Utils.kt @@ -835,18 +835,6 @@ enum class PostViewMode(val mode: Int) { List(R.string.look_and_feel_post_view_list), } -enum class NavigationGestureMode(val mode: Int) { - /** - * Disable all navigation gestures within posts. - */ - Disabled(R.string.look_and_feel_post_navigation_gesture_mode_disabled), - - /** - * Enable swiping left to navigate away from a post. - */ - SwipeLeft(R.string.look_and_feel_post_navigation_gesture_mode_swipe_left), -} - /** * For a given post, what sort of content Jerboa treats it as. */ diff --git a/app/src/main/java/com/jerboa/feat/PostNavigationGestureMode.kt b/app/src/main/java/com/jerboa/feat/PostNavigationGestureMode.kt new file mode 100644 index 000000000..2c0956af0 --- /dev/null +++ b/app/src/main/java/com/jerboa/feat/PostNavigationGestureMode.kt @@ -0,0 +1,15 @@ +package com.jerboa.feat + +import com.jerboa.R + +enum class PostNavigationGestureMode(val mode: Int) { + /** + * Disable all navigation gestures within posts. + */ + Disabled(R.string.look_and_feel_post_navigation_gesture_mode_disabled), + + /** + * Enable swiping left to navigate away from a post. + */ + SwipeLeft(R.string.look_and_feel_post_navigation_gesture_mode_swipe_left), +} diff --git a/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt b/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt index 5665e437b..231edace9 100644 --- a/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt +++ b/app/src/main/java/com/jerboa/ui/components/common/SwipeToNavigateBack.kt @@ -12,6 +12,7 @@ import androidx.compose.material.rememberDismissState import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import com.jerboa.feat.PostNavigationGestureMode @OptIn(ExperimentalMaterialApi::class) @Composable @@ -20,7 +21,7 @@ fun SwipeToNavigateBack( onSwipeBack: () -> Unit, content: @Composable () -> Unit, ) { - if (useSwipeBack == 1) { + if (useSwipeBack == PostNavigationGestureMode.SwipeLeft.ordinal) { val dismissState = rememberDismissState( confirmStateChange = { when (it) { diff --git a/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt b/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt index f26c83392..69793b864 100644 --- a/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt @@ -34,7 +34,6 @@ import com.alorma.compose.settings.ui.SettingsCheckbox import com.alorma.compose.settings.ui.SettingsList import com.alorma.compose.settings.ui.SettingsListDropdown import com.alorma.compose.settings.ui.SettingsSlider -import com.jerboa.NavigationGestureMode import com.jerboa.PostViewMode import com.jerboa.R import com.jerboa.ThemeColor @@ -43,6 +42,7 @@ import com.jerboa.db.APP_SETTINGS_DEFAULT import com.jerboa.db.entity.AppSettings import com.jerboa.feat.BackConfirmationMode import com.jerboa.feat.PostActionbarMode +import com.jerboa.feat.PostNavigationGestureMode import com.jerboa.getLangPreferenceDropdownEntries import com.jerboa.matchLocale import com.jerboa.model.AppSettingsViewModel @@ -233,7 +233,7 @@ fun LookAndFeelActivity( ) SettingsList( state = postNavigationGestureModeState, - items = NavigationGestureMode.entries.map { stringResource(it.mode) }, + items = PostNavigationGestureMode.entries.map { stringResource(it.mode) }, icon = { Icon( imageVector = Icons.Outlined.Swipe, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index afbd0ad77..b8d7f636e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -174,9 +174,9 @@ Show content for collapsed comments Font size: %1$s Look and feel - Post Navigation Gestures + Post navigation gestures Disabled - Swipe Left to Navigate Back + Swipe left to navigate back Post View Card List