Skip to content

Commit

Permalink
braille-systems#278 replace flipColumns toasts with announcement for …
Browse files Browse the repository at this point in the history
…accessibility
  • Loading branch information
zuevval committed Oct 3, 2020
1 parent ca257c4 commit fb0d4f8
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
Expand Down Expand Up @@ -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))
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@
<string name="practice_actionbar_title_template">Практика: %d из %d</string>
<string name="practice_actionbar_title">Практика</string>
<string name="practice_deck_name_enabled_template">
Колода: \"%s\"\n\"%s\"\nПовторять только изученные: включено
Колода: \"%s\"\nПовторять только изученные: включено
</string>
<string name="practice_deck_name_disabled_template">
Колода: \"%s\"\n\"%s\"\nПовторять только изученные: выключено
Колода: \"%s\"\nПовторять только изученные: выключено
</string>
<string name="decks_list_title">Список колод</string>
<string name="decks_list_no_material_in_deck">
Expand Down

0 comments on commit fb0d4f8

Please sign in to comment.