Skip to content

Commit

Permalink
Merge pull request braille-systems#283 from braille-systems/feature/2…
Browse files Browse the repository at this point in the history
…78-text-on-dots

Feature/278 text on dots
  • Loading branch information
winter-yuki authored Oct 17, 2020
2 parents fc8e555 + 708647d commit b1c679d
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 63 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,13 @@ class BrailleDotsView : ConstraintLayout, KoinComponent {
Timber.w("API level < 22, unable co control accessibility traversal order")
}

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 All @@ -117,27 +122,27 @@ class BrailleDotsView : ConstraintLayout, KoinComponent {
}

private fun setDescriptionMode(mode: BrailleDotsViewMode) {
when (mode) {
Writing -> forEach(
dotButton4 to R.string.braille_dot_1,
dotButton5 to R.string.braille_dot_2,
dotButton6 to R.string.braille_dot_3,
dotButton1 to R.string.braille_dot_4,
dotButton2 to R.string.braille_dot_5,
dotButton3 to R.string.braille_dot_6
) { (dotButton, id) ->
dotButton.contentDescription = context.getString(id)
}
Reading -> forEach(
dotButton1 to R.string.braille_dot_1,
dotButton2 to R.string.braille_dot_2,
dotButton3 to R.string.braille_dot_3,
dotButton4 to R.string.braille_dot_4,
dotButton5 to R.string.braille_dot_5,
dotButton6 to R.string.braille_dot_6
) { (dotButton, id) ->
dotButton.contentDescription = context.getString(id)
}
val dotsMapping = when (mode) {
Writing -> listOf(
Triple(dotButton4, R.string.braille_dot_1, R.string.braille_dot_1_text),
Triple(dotButton5, R.string.braille_dot_2, R.string.braille_dot_2_text),
Triple(dotButton6, R.string.braille_dot_3, R.string.braille_dot_3_text),
Triple(dotButton1, R.string.braille_dot_4, R.string.braille_dot_4_text),
Triple(dotButton2, R.string.braille_dot_5, R.string.braille_dot_5_text),
Triple(dotButton3, R.string.braille_dot_6, R.string.braille_dot_6_text)
)
Reading -> listOf(
Triple(dotButton1, R.string.braille_dot_1, R.string.braille_dot_1_text),
Triple(dotButton2, R.string.braille_dot_2, R.string.braille_dot_2_text),
Triple(dotButton3, R.string.braille_dot_3, R.string.braille_dot_3_text),
Triple(dotButton4, R.string.braille_dot_4, R.string.braille_dot_4_text),
Triple(dotButton5, R.string.braille_dot_5, R.string.braille_dot_5_text),
Triple(dotButton6, R.string.braille_dot_6, R.string.braille_dot_6_text)
)
}
dotsMapping.forEach { (dotButton, desc_id, caption_id) ->
dotButton.contentDescription = context.getString(desc_id)
dotButton.text = context.getString(caption_id)
}
}

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/drawable/round_checkbox.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/checked_round_checkbox" android:state_checked="true" />
<item android:drawable="@drawable/checked_round_checkbox" android:state_pressed="true" />
<item android:drawable="@drawable/unchecked_round_checkbox" android:state_pressed="false" />
<item android:color="@color/colorBackground" android:drawable="@drawable/checked_round_checkbox" android:state_checked="true" />
<item android:color="@color/colorBackground" android:drawable="@drawable/checked_round_checkbox" android:state_pressed="true" />
<item android:color="@color/colorPrimary" android:drawable="@drawable/unchecked_round_checkbox" android:state_pressed="false" />
</selector>
10 changes: 0 additions & 10 deletions app/src/main/res/drawable/to_progress.xml

This file was deleted.

9 changes: 9 additions & 0 deletions app/src/main/res/layout/braille_dots_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
android:layout_marginEnd="@dimen/braille_dots_inner_horizontal_margin"
android:layout_marginBottom="@dimen/braille_dots_inner_vertical_margin"
android:contentDescription="@string/braille_dot_1"
android:text="@string/braille_dot_1_text"
app:layout_constraintBottom_toTopOf="@+id/dotButton2"
app:layout_constraintEnd_toStartOf="@+id/dotButton4"
app:layout_constraintHorizontal_bias="0.5"
Expand All @@ -30,6 +31,7 @@
android:layout_marginEnd="@dimen/braille_dots_outer_horizontal_margin"
android:layout_marginBottom="@dimen/braille_dots_inner_vertical_margin"
android:contentDescription="@string/braille_dot_2"
android:text="@string/braille_dot_2_text"
app:layout_constraintBottom_toTopOf="@+id/dotButton3"
app:layout_constraintEnd_toStartOf="@+id/dotButton5"
app:layout_constraintHorizontal_bias="0.5"
Expand All @@ -44,6 +46,7 @@
android:layout_marginEnd="@dimen/braille_dots_outer_horizontal_margin"
android:layout_marginBottom="@dimen/braille_dots_outer_vertical_margin"
android:contentDescription="@string/braille_dot_3"
android:text="@string/braille_dot_3_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/dotButton6"
app:layout_constraintHorizontal_bias="0.5"
Expand All @@ -58,6 +61,8 @@
android:layout_marginEnd="@dimen/braille_dots_outer_horizontal_margin"
android:layout_marginBottom="@dimen/braille_dots_inner_vertical_margin"
android:contentDescription="@string/braille_dot_4"
android:paddingEnd="@dimen/braille_dots_right_column_text_padding"
android:text="@string/braille_dot_4_text"
app:layout_constraintBottom_toTopOf="@+id/dotButton5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
Expand All @@ -72,6 +77,8 @@
android:layout_marginEnd="@dimen/braille_dots_outer_horizontal_margin"
android:layout_marginBottom="@dimen/braille_dots_inner_vertical_margin"
android:contentDescription="@string/braille_dot_5"
android:paddingEnd="@dimen/braille_dots_right_column_text_padding"
android:text="@string/braille_dot_5_text"
app:layout_constraintBottom_toTopOf="@+id/dotButton6"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
Expand All @@ -86,6 +93,8 @@
android:layout_marginEnd="@dimen/braille_dots_outer_horizontal_margin"
android:layout_marginBottom="@dimen/braille_dots_outer_vertical_margin"
android:contentDescription="@string/braille_dot_6"
android:paddingEnd="@dimen/braille_dots_right_column_text_padding"
android:text="@string/braille_dot_6_text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-sw320dp/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<dimen name="braille_dots_scale_of_one_dot">2.6</dimen>
<dimen name="braille_dots_scale_of_view">1.1</dimen>

<dimen name="braille_dots_right_column_text_padding">0dp</dimen>

<dimen name="practice_dots_vertical_bias">0.85</dimen>
<dimen name="practice_buttons_vertical_bias">0.9</dimen>

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-sw360dp/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<dimen name="braille_dots_scale_of_one_dot">2.6</dimen>
<dimen name="braille_dots_scale_of_view">1.25</dimen>

<dimen name="braille_dots_right_column_text_padding">0dp</dimen>

<dimen name="letter_practice_scale_of_view">1</dimen>
<dimen name="practice_dots_vertical_bias">0.85</dimen>
<dimen name="practice_buttons_vertical_bias">0.9</dimen>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-sw400dp/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<dimen name="braille_dots_scale_of_one_dot">2.6</dimen>
<dimen name="braille_dots_scale_of_view">1.5</dimen>

<dimen name="braille_dots_right_column_text_padding">0dp</dimen>

<dimen name="practice_dots_vertical_bias">0.85</dimen>
<dimen name="practice_buttons_vertical_bias">0.9</dimen>

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-sw600dp/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<dimen name="braille_dots_scale_of_one_dot">2.6</dimen>
<dimen name="braille_dots_scale_of_view">1.8</dimen>

<dimen name="braille_dots_right_column_text_padding">1dp</dimen>

<dimen name="side_buttons_extended_width">80dp</dimen>
<dimen name="side_buttons_width">65dp</dimen>
<dimen name="practice_buttons_height">300dp</dimen>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-sw720dp/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<dimen name="braille_dots_scale_of_one_dot">2.6</dimen>
<dimen name="braille_dots_scale_of_view">2.1</dimen>

<dimen name="braille_dots_right_column_text_padding">1dp</dimen>

<dimen name="side_buttons_extended_width">90dp</dimen>
<dimen name="side_buttons_width">75dp</dimen>
<dimen name="practice_buttons_height">320dp</dimen>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<dimen name="braille_dots_inner_vertical_margin">25dp</dimen>
<dimen name="braille_dots_scale_of_one_dot">2.6</dimen>
<dimen name="braille_dots_scale_of_view">1</dimen>
<!-- For whatever reason dots numbers in the right column appear not strictly in the middle, so we use padding to fix it-->
<dimen name="braille_dots_right_column_text_padding">1dp</dimen>

<dimen name="practice_dots_vertical_bias">0.85</dimen>
<dimen name="practice_buttons_vertical_bias">0.9</dimen>
Expand Down
11 changes: 9 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 Expand Up @@ -405,6 +405,13 @@
<string name="braille_dot_5">точка пять</string>
<string name="braille_dot_6">точка шесть</string>

<string name="braille_dot_1_text">1</string>
<string name="braille_dot_2_text">2</string>
<string name="braille_dot_3_text">3</string>
<string name="braille_dot_4_text">4</string>
<string name="braille_dot_5_text">5</string>
<string name="braille_dot_6_text">6</string>

<!-- Action menu-->

<string name="menu_title_help">Справка</string>
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@
<item name="android:layout_height">wrap_content</item>
<item name="android:scaleX">@dimen/braille_dots_scale_of_one_dot</item>
<item name="android:scaleY">@dimen/braille_dots_scale_of_one_dot</item>
<item name="android:button">@drawable/round_checkbox</item>
<item name="android:button">@null</item>
<item name="android:background">@drawable/round_checkbox</item>
<item name="android:gravity">center</item>
<item name="android:textColor">@drawable/round_checkbox</item>
<item name="android:fontFamily">sans-serif-light</item>
</style>

<style name="bigLetterStyle">
Expand Down

0 comments on commit b1c679d

Please sign in to comment.