From ca257c4e4e68b1b60df9bed84f77bc8f579d7517 Mon Sep 17 00:00:00 2001 From: zuevval Date: Sat, 3 Oct 2020 11:56:21 +0300 Subject: [PATCH 1/8] #278 add text on braille dots --- .idea/codeStyles/codeStyleConfig.xml | 1 + .../learnbraille/ui/views/BrailleDotsView.kt | 42 +++++++++---------- app/src/main/res/drawable/round_checkbox.xml | 6 +-- app/src/main/res/layout/braille_dots_view.xml | 6 +++ app/src/main/res/values/strings.xml | 7 ++++ app/src/main/res/values/styles.xml | 5 ++- 6 files changed, 42 insertions(+), 25 deletions(-) diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml index 79ee123c..6e6eec11 100644 --- a/.idea/codeStyles/codeStyleConfig.xml +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -1,5 +1,6 @@ \ No newline at end of file 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 c4dc0a99..2783ef3e 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 @@ -117,27 +117,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) } } diff --git a/app/src/main/res/drawable/round_checkbox.xml b/app/src/main/res/drawable/round_checkbox.xml index cd049921..e67a3adc 100644 --- a/app/src/main/res/drawable/round_checkbox.xml +++ b/app/src/main/res/drawable/round_checkbox.xml @@ -1,6 +1,6 @@ - - - + + + \ No newline at end of file diff --git a/app/src/main/res/layout/braille_dots_view.xml b/app/src/main/res/layout/braille_dots_view.xml index 1535a5e8..9408f492 100644 --- a/app/src/main/res/layout/braille_dots_view.xml +++ b/app/src/main/res/layout/braille_dots_view.xml @@ -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" @@ -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" @@ -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" @@ -58,6 +61,7 @@ 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:text="@string/braille_dot_4_text" app:layout_constraintBottom_toTopOf="@+id/dotButton5" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" @@ -72,6 +76,7 @@ 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:text="@string/braille_dot_5_text" app:layout_constraintBottom_toTopOf="@+id/dotButton6" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" @@ -86,6 +91,7 @@ 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:text="@string/braille_dot_6_text" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.5" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4c2357f1..50322d8f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -405,6 +405,13 @@ точка пять точка шесть + 1 + 2 + 3 + 4 + 5 + 6 + Справка diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index d2cfacdc..87514914 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -44,7 +44,10 @@ wrap_content @dimen/braille_dots_scale_of_one_dot @dimen/braille_dots_scale_of_one_dot - @drawable/round_checkbox + @null + @drawable/round_checkbox + center + @drawable/round_checkbox