Skip to content

Commit

Permalink
Fix caption mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
winter-yuki committed Sep 25, 2020
1 parent d43c1b5 commit 678df65
Show file tree
Hide file tree
Showing 20 changed files with 332 additions and 268 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ There are handy DSL that allows write content in the typesafe way.

- All app content should be placed into `com.github.braillesystems.learnbraille.res` package.
- Use `DslTest.kt` file as DSL tutorial.

Symbols that are not from particular alphabet and does not exist on classical american keyboard should be treated as special and added via `enum class`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.github.braillesystems.learnbraille.res

import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.github.braillesystems.learnbraille.utils.get
import org.junit.Assert.assertNotNull
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class ResourceTest {

private lateinit var context: Context

@Before
fun before() {
context = InstrumentationRegistry.getInstrumentation().targetContext
}

@Test
fun inputSymbolPrintRulesTest() {
content.symbols.keys.forEach {
assertNotNull(context.inputSymbolPrintRules[it])
}
}

@Test
fun showSymbolPrintRulesTest() {
content.symbols.keys.forEach {
assertNotNull(context.showSymbolPrintRules[it])
}
}

@Test
fun inputMarkerPrintRulesTest() {
content.markers.keys.forEach {
assertNotNull(context.inputMarkerPrintRules[it])
}
}

@Test
fun showMarkerPrintRulesTest() {
content.markers.keys.forEach {
assertNotNull(context.showMarkerPrintRules[it])
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,5 @@ private val MIGRATION_17_18 = object : Migration(17, 18), KoinComponent {
Timber.i("Actions table created")
}
}

// TODO materials migration
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.github.braillesystems.learnbraille.data.repository
import com.github.braillesystems.learnbraille.data.entities.*
import com.github.braillesystems.learnbraille.res.StepAnnotation
import com.github.braillesystems.learnbraille.utils.devnull
import com.github.braillesystems.learnbraille.utils.runIf
import com.github.braillesystems.learnbraille.utils.scope
import kotlinx.coroutines.launch

Expand Down Expand Up @@ -31,19 +30,13 @@ class TheoryRepositoryImpl(
private val actionsRepository: MutableActionsRepository
) : MutableTheoryRepository {

private fun getProscribedAnnotation(): List<String> {
val result = arrayListOf<String>()
listOf(
!preferenceRepository.golubinaBookStepsEnabled to StepAnnotation.golubinaBookRequired,
!preferenceRepository.slateStylusStepsEnabled to StepAnnotation.slateStylusRequired
).forEach {
runIf (it.first) { result.add(it.second) }
}
return result
}

private val proscribedAnnotations
get() = getProscribedAnnotation()
private val proscribedAnnotations: List<String>
get() = listOfNotNull(
if (preferenceRepository.golubinaBookStepsEnabled) null
else StepAnnotation.golubinaBookRequired,
if (preferenceRepository.slateStylusStepsEnabled) null
else StepAnnotation.slateStylusRequired
)

@Suppress("ReturnCount")
override suspend fun getNextStepAndUpdate(thisStep: Step, markThisAsPassed: Boolean): Step? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ val prepopulationData by data(
decks {
// All cards deck should always exist and be first in the list
deck(DeckTags.all) { true }

deck(DeckTags.allWithRus) { data ->
data is Symbol && data.type !in listOf(
SymbolType.greek,
SymbolType.latin
)
|| data !is Symbol
val isNative = data is Symbol
&& data.type != SymbolType.greek
&& data.type != SymbolType.latin
isNative || data !is Symbol
}
deck(DeckTags.ruLetters) { data ->
data is Symbol && data.type == SymbolType.ru
Expand All @@ -86,10 +86,9 @@ val prepopulationData by data(
deck(DeckTags.digits) { data ->
data is Symbol && data.type == SymbolType.digit
}
deck(DeckTags.math) {data ->
deck(DeckTags.math) { data ->
data is Symbol && data.type == SymbolType.math
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.github.braillesystems.learnbraille.data.dsl.lessons
import com.github.braillesystems.learnbraille.data.entities.*
import com.github.braillesystems.learnbraille.data.entities.BrailleDot.E
import com.github.braillesystems.learnbraille.data.entities.BrailleDot.F
import com.github.braillesystems.learnbraille.res.PunctuationSigns.Hyphen

internal val golubinaIntroLessons by lessons {

Expand Down Expand Up @@ -917,7 +918,7 @@ internal val golubinaIntroLessons by lessons {
точки буквы Ц — в верхней трети шеститочия, точки дефиса — в самой нижней.
"""
)
+Show(content.symbols.getValue(''))
+Show(content.symbols.getValue(Hyphen.c))
+Info(
"""
Переверните страницу в пособии. На странице 31 найдите по центру знак "дефис",
Expand All @@ -927,11 +928,11 @@ internal val golubinaIntroLessons by lessons {
+Info(
"""Введите по символам слово ПОЛ-ЛИМОНА"""
)
inputChars("ПОЛЛИМОНА")
inputChars("ПОЛ${Hyphen.c}ЛИМОНА")
+Info(
"""И последнее слово, которое нужно ввести в этом уроке — местоимение ГДЕ-ЛИБО"""
)
inputChars("ГДЕЛИБО")
inputChars("ГДЕ${Hyphen.c}ЛИБО")
+Info(
"""
Теперь рекомендуем Вам записать на брайлевском приборе изученные слова:
Expand Down Expand Up @@ -1270,7 +1271,7 @@ internal val golubinaIntroLessons by lessons {
В конце поставьте литературную точку.
"""
)
inputChars("ЛЕНИНГРАДГОРОДГЕРОЙ.")
inputChars("ЛЕНИНГРАД${Hyphen.c}ГОРОД${Hyphen.c}ГЕРОЙ.")
+Info(
"""
Теперь запишите на брайлевском приборе то же самое предложение:
Expand Down Expand Up @@ -1302,7 +1303,7 @@ internal val golubinaIntroLessons by lessons {
Введите цифровой знак, запятую, дефис и точку"""
)
+Input(content.markers.getValue(MarkerType.NumberSign))
inputChars(",.")
inputChars(",${Hyphen.c}.")
+Info(
"""
Переходим к изучению точечного состава буквы Ы.
Expand Down
Loading

0 comments on commit 678df65

Please sign in to comment.