From fb0d4f89f89bcfe0e9cf5b4859c885c4f0348482 Mon Sep 17 00:00:00 2001 From: zuevval Date: Sat, 3 Oct 2020 11:57:15 +0300 Subject: [PATCH] #278 replace flipColumns toasts with announcement for accessibility --- .../ui/screens/browser/MarkerViewFragment.kt | 4 ---- .../ui/screens/browser/SymbolViewFragment.kt | 2 -- .../ui/screens/practice/CardFragment.kt | 6 +----- .../screens/theory/steps/AbstractStepFragment.kt | 9 +-------- .../steps/input/AbstractInputStepFragment.kt | 2 -- .../theory/steps/show/AbstractShowStepFragment.kt | 2 -- .../learnbraille/ui/views/BrailleDotsView.kt | 15 +++++++++++---- app/src/main/res/values/strings.xml | 4 ++-- 8 files changed, 15 insertions(+), 29 deletions(-) diff --git a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/browser/MarkerViewFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/browser/MarkerViewFragment.kt index 555f3cd3..3e1a82a6 100644 --- a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/browser/MarkerViewFragment.kt +++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/browser/MarkerViewFragment.kt @@ -11,7 +11,6 @@ import com.github.braillesystems.learnbraille.data.entities.MarkerSymbol import com.github.braillesystems.learnbraille.data.entities.Material import com.github.braillesystems.learnbraille.databinding.FragmentMarkerViewBinding import com.github.braillesystems.learnbraille.res.showMarkerPrintRules -import com.github.braillesystems.learnbraille.ui.dotsMode import com.github.braillesystems.learnbraille.ui.screens.AbstractFragmentWithHelp import com.github.braillesystems.learnbraille.ui.screens.BrailleDotsInfo import com.github.braillesystems.learnbraille.ui.screens.FragmentBinding @@ -47,12 +46,9 @@ class MarkerViewFragment : AbstractFragmentWithHelp(R.string.browser_marker_view val text = showMarkerPrintRules.getValue(m.data.type) infoTextView.text = text checkedAnnounce(text) - brailleDots.dotsState.display(m.data.brailleDots) - checkedToast(dotsMode(brailleDots.mode)) flipButton.setOnClickListener { brailleDots.reflect().display(m.data.brailleDots) - checkedToast(dotsMode(brailleDots.mode)) } }.root diff --git a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/browser/SymbolViewFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/browser/SymbolViewFragment.kt index ef427766..dd29e978 100644 --- a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/browser/SymbolViewFragment.kt +++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/browser/SymbolViewFragment.kt @@ -48,10 +48,8 @@ class SymbolViewFragment : AbstractFragmentWithHelp(R.string.browser_symbol_view checkedAnnounce(showPrint(m.data)) brailleDots.dotsState.display(m.data.brailleDots) - checkedToast(dotsMode(brailleDots.mode)) flipButton.setOnClickListener { brailleDots.reflect().display(m.data.brailleDots) - checkedToast(dotsMode(brailleDots.mode)) } }.root diff --git a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/CardFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/CardFragment.kt index 8590d13b..2ea31ff6 100644 --- a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/CardFragment.kt +++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/CardFragment.kt @@ -86,7 +86,6 @@ class CardFragment : AbstractFragmentWithHelp(R.string.practice_help) { binding.flipButton.setOnClickListener { dotsState = binding.brailleDots.reflect().apply { dotsState.subscribe(viewModel) - checkedToast(dotsMode(binding.brailleDots.mode)) if (viewModel.state == DotsChecker.State.HINT) { viewModel.expectedDots?.let { display(it) } } @@ -158,10 +157,7 @@ class CardFragment : AbstractFragmentWithHelp(R.string.practice_help) { getString(R.string.practice_deck_name_disabled_template) } toast( - template.format( - deckTagToName.getValue(tag), - dotsMode(binding.brailleDots.mode) - ) + template.format(deckTagToName.getValue(tag)) ) } ) diff --git a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/AbstractStepFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/AbstractStepFragment.kt index 110f2a5c..1d9bc363 100644 --- a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/AbstractStepFragment.kt +++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/AbstractStepFragment.kt @@ -9,7 +9,6 @@ import android.widget.TextView import com.github.braillesystems.learnbraille.COURSE import com.github.braillesystems.learnbraille.R import com.github.braillesystems.learnbraille.data.entities.Step -import com.github.braillesystems.learnbraille.ui.dotsMode import com.github.braillesystems.learnbraille.ui.screens.AbstractFragmentWithHelp import com.github.braillesystems.learnbraille.ui.screens.BrailleDotsInfo import com.github.braillesystems.learnbraille.ui.screens.FragmentBinding @@ -18,7 +17,7 @@ import com.github.braillesystems.learnbraille.ui.screens.theory.getStepArg import com.github.braillesystems.learnbraille.ui.screens.theory.toCurrentStep import com.github.braillesystems.learnbraille.ui.screens.theory.toNextStep import com.github.braillesystems.learnbraille.ui.screens.theory.toPrevStep -import com.github.braillesystems.learnbraille.utils.checkedToast +import com.github.braillesystems.learnbraille.utils.checkedAnnounce import com.github.braillesystems.learnbraille.utils.navigate import com.github.braillesystems.learnbraille.utils.title @@ -83,12 +82,6 @@ abstract class AbstractStepFragment(helpMsgId: HelpMsgId) : AbstractFragmentWith protected open fun iniStepHelper() = Unit - protected fun toastDotsMode() { - binding.brailleDotsInfo?.view?.mode?.let { - checkedToast(dotsMode(it)) - } - } - override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { inflater.inflate( if (preferenceRepository.extendedAccessibilityEnabled) R.menu.steps_menu_hide diff --git a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/input/AbstractInputStepFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/input/AbstractInputStepFragment.kt index 58028265..26049080 100644 --- a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/input/AbstractInputStepFragment.kt +++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/input/AbstractInputStepFragment.kt @@ -51,14 +51,12 @@ abstract class AbstractInputStepFragment(helpMsgId: HelpMsgId) : AbstractStepFra val buzzer: Vibrator? = activity?.getSystemService() - toastDotsMode() stepBinding.flipButton?.setOnClickListener { dotsState = stepBinding.brailleDotsInfo!!.view.reflect().apply { subscribe(View.OnClickListener { viewModel.onSoftCheck() userTouchedDots = true }) - toastDotsMode() if (viewModel.state == DotsChecker.State.HINT) { display(expectedDots) } diff --git a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/show/AbstractShowStepFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/show/AbstractShowStepFragment.kt index 8f233250..47106b6d 100644 --- a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/show/AbstractShowStepFragment.kt +++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/show/AbstractShowStepFragment.kt @@ -13,10 +13,8 @@ abstract class AbstractShowStepFragment(helpMsgId: HelpMsgId) : AbstractStepFrag require(data is BaseShow) stepBinding.brailleDotsInfo?.view?.dotsState?.display(data.brailleDots) ?: error("Show step should have braille dots") - toastDotsMode() stepBinding.flipButton?.setOnClickListener { stepBinding.brailleDotsInfo?.view?.reflect()?.display(data.brailleDots) - toastDotsMode() } } } diff --git a/app/src/main/java/com/github/braillesystems/learnbraille/ui/views/BrailleDotsView.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/views/BrailleDotsView.kt index 2783ef3e..75d5ef2d 100644 --- a/app/src/main/java/com/github/braillesystems/learnbraille/ui/views/BrailleDotsView.kt +++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/views/BrailleDotsView.kt @@ -18,9 +18,7 @@ import com.github.braillesystems.learnbraille.data.entities.spelling import com.github.braillesystems.learnbraille.data.repository.PreferenceRepository import com.github.braillesystems.learnbraille.ui.views.BrailleDotsViewMode.Reading import com.github.braillesystems.learnbraille.ui.views.BrailleDotsViewMode.Writing -import com.github.braillesystems.learnbraille.utils.chainify -import com.github.braillesystems.learnbraille.utils.forEach -import com.github.braillesystems.learnbraille.utils.unreachable +import com.github.braillesystems.learnbraille.utils.* import kotlinx.android.synthetic.main.braille_dots_view.view.* import org.koin.core.KoinComponent import org.koin.core.inject @@ -108,6 +106,15 @@ class BrailleDotsView : ConstraintLayout, KoinComponent { Timber.w("API level < 22, unable co control accessibility traversal order") } + runIf(preferenceRepository.additionalAnnouncementsEnabled) { + context.announce( + when (mode) { + Writing -> context.getString(R.string.braille_dots_mode_writing) + Reading -> context.getString(R.string.braille_dots_mode_reading) + } + ) + } + this.mode = mode } @@ -135,7 +142,7 @@ class BrailleDotsView : ConstraintLayout, KoinComponent { Triple(dotButton6, R.string.braille_dot_6, R.string.braille_dot_6_text) ) } - dotsMapping.forEach{ (dotButton, desc_id, caption_id) -> + dotsMapping.forEach { (dotButton, desc_id, caption_id) -> dotButton.contentDescription = context.getString(desc_id) dotButton.text = context.getString(caption_id) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 50322d8f..721cb503 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -129,10 +129,10 @@ Практика: %d из %d Практика - Колода: \"%s\"\n\"%s\"\nПовторять только изученные: включено + Колода: \"%s\"\nПовторять только изученные: включено - Колода: \"%s\"\n\"%s\"\nПовторять только изученные: выключено + Колода: \"%s\"\nПовторять только изученные: выключено Список колод