From 4aedea7e1522391ff1ad23b92461a76762c3dc80 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Tue, 6 Jul 2021 19:20:41 +0300 Subject: [PATCH] Improve accesibility in reader --- .../kotatsu/reader/ui/ReaderActivity.kt | 2 +- .../kotatsu/reader/ui/ReaderControlDelegate.kt | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/koitharu/kotatsu/reader/ui/ReaderActivity.kt b/app/src/main/java/org/koitharu/kotatsu/reader/ui/ReaderActivity.kt index 22d66a6c6..df407ca0d 100644 --- a/app/src/main/java/org/koitharu/kotatsu/reader/ui/ReaderActivity.kt +++ b/app/src/main/java/org/koitharu/kotatsu/reader/ui/ReaderActivity.kt @@ -220,7 +220,7 @@ class ReaderActivity : BaseFullscreenActivity(), } override fun onGridTouch(area: Int) { - controlDelegate.onGridTouch(area) + controlDelegate.onGridTouch(area, binding.container) } override fun onProcessTouch(rawX: Int, rawY: Int): Boolean { diff --git a/app/src/main/java/org/koitharu/kotatsu/reader/ui/ReaderControlDelegate.kt b/app/src/main/java/org/koitharu/kotatsu/reader/ui/ReaderControlDelegate.kt index eb408f5f7..f8c5d73c0 100644 --- a/app/src/main/java/org/koitharu/kotatsu/reader/ui/ReaderControlDelegate.kt +++ b/app/src/main/java/org/koitharu/kotatsu/reader/ui/ReaderControlDelegate.kt @@ -1,6 +1,8 @@ package org.koitharu.kotatsu.reader.ui import android.view.KeyEvent +import android.view.SoundEffectConstants +import android.view.View import androidx.lifecycle.LifecycleCoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.* @@ -30,18 +32,27 @@ class ReaderControlDelegate( }.launchIn(scope) } - fun onGridTouch(area: Int) { + fun onGridTouch(area: Int, view: View) { when (area) { GridTouchHelper.AREA_CENTER -> { listener.toggleUiVisibility() + view.playSoundEffect(SoundEffectConstants.CLICK) + } + GridTouchHelper.AREA_TOP -> if (isTapSwitchEnabled) { + listener.switchPageBy(-1) + view.playSoundEffect(SoundEffectConstants.NAVIGATION_UP) } - GridTouchHelper.AREA_TOP, GridTouchHelper.AREA_LEFT -> if (isTapSwitchEnabled) { listener.switchPageBy(-1) + view.playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT) + } + GridTouchHelper.AREA_BOTTOM -> if (isTapSwitchEnabled) { + listener.switchPageBy(1) + view.playSoundEffect(SoundEffectConstants.NAVIGATION_DOWN) } - GridTouchHelper.AREA_BOTTOM, GridTouchHelper.AREA_RIGHT -> if (isTapSwitchEnabled) { listener.switchPageBy(1) + view.playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT) } } }