Allow disabling page turning with volume keys

This commit is contained in:
FooIbar committed 2025-09-09 22:04:41 +08:00
1 parent 19d9bb198f
commit c4cd375c04
14 files changed
+41 -14

No files matched your search

@@ -169,7 +169,8 @@ object Settings : DataStorePreferences(null) {
val keepScreenOn = boolPref("pref_keep_screen_on_key", true)
val readerLongTapAction = boolPref("reader_long_tap", true)
val pageTransitions = boolPref("pref_enable_transitions_key", true)
val readerReverseControls = boolPref("reader_volume_keys_inverted", false)
val readWithVolumeKeys = boolPref("reader_volume_keys", false)
val readWithVolumeKeysInverted = boolPref("reader_volume_keys_inverted", false)
val grayScale = boolPref("pref_grayscale", false)
val invertedColors = boolPref("pref_inverted_colors", false)
val readerWebtoonNav = intPref("reader_navigation_mode_webtoon", 0)
@@ -8,15 +8,17 @@ import androidx.compose.ui.input.key.onPreviewKeyEvent
import androidx.compose.ui.input.key.type
fun Modifier.keyEventHandler(
enabled: () -> Boolean,
reverse: () -> Boolean,
volumeKeysEnabled: () -> Boolean,
volumeKeysInverted: () -> Boolean,
movePrevious: () -> Unit,
moveNext: () -> Unit,
) = onPreviewKeyEvent {
if (enabled() && it.type == KeyEventType.KeyDown) {
if (it.type == KeyEventType.KeyDown) {
when (it.key) {
Key.DirectionUp, Key.PageUp, Key.VolumeUp -> if (reverse()) moveNext() else movePrevious()
Key.DirectionDown, Key.PageDown, Key.VolumeDown -> if (reverse()) movePrevious() else moveNext()
Key.DirectionUp, Key.PageUp -> movePrevious()
Key.DirectionDown, Key.PageDown -> moveNext()
Key.VolumeUp if volumeKeysEnabled() -> if (volumeKeysInverted()) moveNext() else movePrevious()
Key.VolumeDown if volumeKeysEnabled() -> if (volumeKeysInverted()) movePrevious() else moveNext()
else -> return@onPreviewKeyEvent false
}
true
@@ -63,8 +63,15 @@ fun ReaderGeneralSetting() = Column(modifier = Modifier.verticalScroll(rememberS
title = stringResource(id = R.string.pref_page_transitions),
field = Settings.pageTransitions.asMutableState(),
)
val volume = Settings.readWithVolumeKeys.asMutableState()
SwitchChoice(
title = stringResource(id = R.string.settings_read_reverse_controls),
field = Settings.readerReverseControls.asMutableState(),
title = stringResource(id = R.string.settings_read_volume_page),
field = volume,
)
AnimatedVisibility(visible = volume.value) {
SwitchChoice(
title = stringResource(id = R.string.settings_read_reverse_volume),
field = Settings.readWithVolumeKeysInverted.asMutableState(),
)
}
}
@@ -200,7 +200,8 @@ fun ReaderScreen(pageLoader: PageLoader, info: BaseGalleryInfo?) {
}
val showSeekbar by Settings.showReaderSeekbar.collectAsState()
val readingMode by Settings.readingMode.collectAsState { ReadingModeType.fromPreference(it) }
val reverseControls by Settings.readerReverseControls.collectAsState()
val volumeKeysEnabled by Settings.readWithVolumeKeys.collectAsState()
val volumeKeysInverted by Settings.readWithVolumeKeysInverted.collectAsState()
val fullscreen by Settings.fullscreen.collectAsState()
val cutoutShort by Settings.cutoutShort.collectAsState()
val keepScreenOn by Settings.keepScreenOn.collectAsState()
@@ -220,8 +221,8 @@ fun ReaderScreen(pageLoader: PageLoader, info: BaseGalleryInfo?) {
val focusRequester = remember { FocusRequester() }
Box(
Modifier.keyEventHandler(
enabled = { !appbarVisible },
reverse = { reverseControls },
volumeKeysEnabled = { volumeKeysEnabled && !appbarVisible },
volumeKeysInverted = { volumeKeysInverted },
movePrevious = { launch { if (isWebtoon) lazyListState.scrollUp() else pagerState.moveToPrevious() } },
moveNext = { launch { if (isWebtoon) lazyListState.scrollDown() else pagerState.moveToNext() } },
).focusRequester(focusRequester).focusable().thenIf(keepScreenOn) { keepScreenOn() },
@@ -327,7 +327,8 @@
<string name="settings_eh_tag_translations_source_url">https://placeholder</string>
<string name="settings_eh_filter">Blockers</string>
<string name="settings_eh_filter_summary">Block gallery or comment by title, uploader, tags and commenter</string>
<string name="settings_read_reverse_controls">Reverse physical key controls</string>
<string name="settings_read_volume_page">Use volume keys to turn pages</string>
<string name="settings_read_reverse_volume">Reverse volume keys</string>
<string name="settings_block_extraneous_ads">[Experimental] Block extraneous ads</string>
<string name="settings_ads_placeholder">[Optional] Pick placeholder to replace ads</string>
<string name="settings_download">Download</string>
@@ -232,6 +232,7 @@
<string name="settings_eh_show_jpn_title">Japanische Titel anzeigen</string>
<string name="settings_eh_filter">Galerie-Blocker</string>
<string name="settings_eh_filter_summary">Nach Titel, Uploader order Etiketten die unerwünschten Galerien verstecken</string>
<string name="settings_read_volume_page">Seiten mit Lautstärketaste umblättern</string>
<string name="settings_download">Download</string>
<string name="settings_download_download_location">Downloadziel</string>
<string name="settings_download_cant_get_download_location">Downloadziel konnte nicht geladen werden</string>
@@ -254,6 +254,8 @@
<string name="settings_eh_filter">Filtrado de galerías</string>
<string name="settings_eh_filter_summary">Filtrado de galerías por título, uploader y etiquetas. Para más detalles presiona el ícono (i) en la parte superior del menú</string>
<string name="settings_read_volume_page">Pasar páginas con botón del volumen</string>
<string name="settings_download">Descargas</string>
<string name="settings_download_download_location">Ruta de descargas</string>
<string name="settings_download_cant_get_download_location">No se puede obtener ruta de descargas</string>
@@ -286,6 +286,8 @@
<string name="settings_eh_filter">Bloqueur des galeries</string>
<string name="settings_eh_filter_summary">Filtrer les galerie par les titres, les uploaders ou les tags</string>
<string name="settings_read_volume_page">Tourner la page avec les Volumes</string>
<!-- My Tags Activity -->
<string name="my_tags">Tags suivis</string>
@@ -314,7 +314,8 @@
<string name="settings_eh_tag_translations_source_url">https://placeholder</string>
<string name="settings_eh_filter">ギャラリーをブロック</string>
<string name="settings_eh_filter_summary">タイトル、アップローダー、タグ、コメントの投稿者またはギャラリーをブロックします</string>
<string name="settings_read_reverse_controls">物理ボタンのコントロールを反転</string>
<string name="settings_read_volume_page">音量ボタンでページをめくる</string>
<string name="settings_read_reverse_volume">音量ボタンを入れ替える</string>
<string name="settings_block_extraneous_ads">[試験的] 関係のない広告をブロック</string>
<string name="settings_ads_placeholder">[任意] 広告を置換するプレースホルダーを選択</string>
<string name="settings_download">ダウンロード</string>
@@ -262,6 +262,8 @@
<string name="settings_eh_tag_translations_source">Placeholder</string>
<string name="settings_eh_tag_translations_source_url">https://placeholder</string>
<string name="settings_read_volume_page">볼륨 키로 페이지 넘기기</string>
<string name="settings_download">다운로드</string>
<string name="settings_download_download_location">다운로드 위치</string>
<string name="settings_download_cant_get_download_location">다운로드 위치를 가져올 수 없습니다.</string>
@@ -277,6 +277,8 @@
<string name="settings_eh_tag_translations_source">Placeholder</string>
<string name="settings_eh_tag_translations_source_url">https://placeholder</string>
<string name="settings_read_volume_page">ใช้ปุ่มปรับเสียงเพื่อเปลี่ยนหน้า</string>
<string name="settings_download">การดาวน์โหลด</string>
<string name="settings_download_download_location">ตำแหน่งแหล่งดาวน์โหลด</string>
<string name="settings_download_cant_get_download_location">ไม่สามารถเข้าถึงแหล่งดาวน์โหลดได้</string>
@@ -311,7 +311,8 @@
<string name="settings_eh_tag_translations_source_url">https://github.com/EhTagTranslation/Editor/wiki</string>
<string name="settings_eh_filter">屏蔽列表</string>
<string name="settings_eh_filter_summary">根据标题、上传者、标签、评论者屏蔽画廊或评论</string>
<string name="settings_read_reverse_controls">反转物理按键控制</string>
<string name="settings_read_volume_page">使用音量键翻页</string>
<string name="settings_read_reverse_volume">反转音量键</string>
<string name="settings_block_extraneous_ads">[实验性] 屏蔽外部广告</string>
<string name="settings_ads_placeholder">[可选] 选择替换外部广告的图片</string>
<string name="settings_download">下载</string>
@@ -312,6 +312,8 @@
<string name="settings_eh_filter">屏蔽畫廊</string>
<string name="settings_eh_filter_summary">根據標題、上傳者、標籤屏蔽畫廊</string>
<string name="settings_read_volume_page">使用音量鍵翻頁</string>
<string name="settings_download">下載</string>
<string name="settings_download_download_location">下載路徑</string>
<string name="settings_download_cant_get_download_location">無法獲取下載路徑</string>
@@ -309,6 +309,8 @@
<string name="settings_eh_tag_translations_source_url">https://github.com/EhTagTranslation/Editor/wiki</string>
<string name="settings_eh_filter">隱藏圖庫</string>
<string name="settings_eh_filter_summary">根據標題、上傳者、標籤、評論者隱藏圖庫或評論</string>
<string name="settings_read_volume_page">使用音量鍵翻頁</string>
<string name="settings_read_reverse_volume">反轉音量鍵</string>
<string name="settings_download">下載</string>
<string name="settings_download_download_location">下載路徑</string>
<string name="settings_download_cant_get_download_location">無法取得下載路徑</string>