Skip to content

Commit

Permalink
Merge pull request #289 from braille-systems/release/1.2.1
Browse files Browse the repository at this point in the history
Release/1.2.1
  • Loading branch information
winter-yuki authored Oct 19, 2020
2 parents fc8e555 + 455268d commit 8033a3d
Show file tree
Hide file tree
Showing 21 changed files with 136 additions and 91 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
applicationId "com.github.braillesystems.learnbraille"
minSdkVersion 19
targetSdkVersion 29
versionCode 14
versionName "1.2.0"
versionCode 15
versionName "1.2.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,39 @@ fun Fragment.dotsMode(mode: BrailleDotsViewMode): String =
BrailleDotsViewMode.Reading -> getString(R.string.braille_dots_mode_reading)
}

private val Context.dotsHintRules by lazyWithContext<Context, List<String>> {
private val Context.dotsReadingHintRules by lazyWithContext<Context, List<String>> {
listOf(
getString(R.string.input_dots_hint_1),
getString(R.string.input_dots_hint_2),
getString(R.string.input_dots_hint_3),
getString(R.string.input_dots_hint_4),
getString(R.string.input_dots_hint_5),
getString(R.string.input_dots_hint_6)
getString(R.string.input_dots_reading_hint_1),
getString(R.string.input_dots_reading_hint_2),
getString(R.string.input_dots_reading_hint_3),
getString(R.string.input_dots_reading_hint_4),
getString(R.string.input_dots_reading_hint_5),
getString(R.string.input_dots_reading_hint_6)
)
}

fun Fragment.showHintDotsToast(expectedDots: BrailleDots) {
private val Context.dotsWritingHintRules by lazyWithContext<Context, List<String>> {
listOf(
getString(R.string.input_dots_writing_hint_1),
getString(R.string.input_dots_writing_hint_2),
getString(R.string.input_dots_writing_hint_3),
getString(R.string.input_dots_writing_hint_4),
getString(R.string.input_dots_writing_hint_5),
getString(R.string.input_dots_writing_hint_6)
)
}

fun Fragment.showHintDotsToast(expectedDots: BrailleDots, mode: BrailleDotsViewMode) {
val template = getString(R.string.input_dots_hint_template)
val hint = expectedDots
.filled
.joinToString(separator = ", ") {
contextNotNull.dotsHintRules[it - 1]
contextNotNull.run {
when (mode) {
BrailleDotsViewMode.Reading -> dotsReadingHintRules[it - 1]
BrailleDotsViewMode.Writing -> dotsWritingHintRules[it - 1]
}
}
}
checkedToast(template.format(hint))
}
Expand Down
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 @@ -5,6 +5,7 @@ import android.view.View
import androidx.core.content.getSystemService
import androidx.lifecycle.ViewModelProvider
import com.github.braillesystems.learnbraille.data.entities.BaseInput
import com.github.braillesystems.learnbraille.data.entities.BrailleDots
import com.github.braillesystems.learnbraille.data.entities.StepData
import com.github.braillesystems.learnbraille.ui.screens.*
import com.github.braillesystems.learnbraille.ui.screens.theory.steps.AbstractStepFragment
Expand Down Expand Up @@ -51,14 +52,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 All @@ -74,7 +73,7 @@ abstract class AbstractInputStepFragment(helpMsgId: HelpMsgId) : AbstractStepFra
viewModel.observeEventHint(
viewLifecycleOwner, { dotsState }
) {
showHintToast(expectedDots)
toastHint(expectedDots)
userTouchedDots = true
}

Expand Down Expand Up @@ -107,5 +106,9 @@ abstract class AbstractInputStepFragment(helpMsgId: HelpMsgId) : AbstractStepFra
showIncorrectToast()
}

protected open fun toastHint(expectedDots: BrailleDots) {
showHintToast(expectedDots)
}

protected open fun onPassHint(data: StepData) = Unit
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import android.widget.TextView
import androidx.core.text.parseAsHtml
import androidx.databinding.DataBindingUtil
import com.github.braillesystems.learnbraille.R
import com.github.braillesystems.learnbraille.data.entities.BrailleDots
import com.github.braillesystems.learnbraille.data.entities.InputDots
import com.github.braillesystems.learnbraille.data.entities.spelling
import com.github.braillesystems.learnbraille.databinding.FragmentLessonsInputDotsBinding
import com.github.braillesystems.learnbraille.ui.screens.BrailleDotsInfo
import com.github.braillesystems.learnbraille.ui.screens.theory.steps.StepBinding
import com.github.braillesystems.learnbraille.ui.showHintDotsToast
import com.github.braillesystems.learnbraille.ui.views.BrailleDotsViewMode
import com.github.braillesystems.learnbraille.utils.checkedAnnounce
import com.github.braillesystems.learnbraille.utils.removeHtmlMarkup
Expand Down Expand Up @@ -59,4 +61,12 @@ class InputDotsFragment : AbstractInputStepFragment(R.string.lessons_help_input_
lifecycleOwner = this@InputDotsFragment

}.root

override fun toastHint(expectedDots: BrailleDots) {
showHintDotsToast(
expectedDots,
stepBinding.brailleDotsInfo?.view?.mode
?: error("Input dots step should have dots")
)
}
}
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
Loading

0 comments on commit 8033a3d

Please sign in to comment.