Skip to content

Commit

Permalink
Merge pull request #252 from braille-systems/feature/241-greek-latin
Browse files Browse the repository at this point in the history
Feature/241 greek latin
  • Loading branch information
winter-yuki authored Sep 26, 2020
2 parents 9865497 + a81052a commit bce1c93
Show file tree
Hide file tree
Showing 32 changed files with 1,478 additions and 351 deletions.
15 changes: 3 additions & 12 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 @@ -18,6 +18,7 @@ interface PreferenceRepository {
val brailleTrainerEnabled: Boolean get() = false // Uncomment in android manifest when set true
val speechRecognitionEnabled: Boolean
val golubinaBookStepsEnabled: Boolean
val slateStylusStepsEnabled: Boolean
val traverseDotsInEnumerationOrder: Boolean
val inputOnFlyCheck: Boolean
val additionalAnnouncementsEnabled: Boolean
Expand Down Expand Up @@ -72,6 +73,13 @@ class PreferenceRepositoryImpl(
)
}

override val slateStylusStepsEnabled: Boolean by logged {
context.preferences.getBoolean(
context.getString(R.string.preference_slate_stylus_steps_enabled),
true
)
}

override val traverseDotsInEnumerationOrder: Boolean by logged {
context.preferences.getBoolean(
context.getString(R.string.preference_traverse_dots_in_enumeration_order),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ class TheoryRepositoryImpl(
private val actionsRepository: MutableActionsRepository
) : MutableTheoryRepository {

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

@Suppress("ReturnCount")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import com.github.braillesystems.learnbraille.utils.lazyWithContext
val prepopulationData by data(
materials = content,
stepAnnotationNames = listOf(
StepAnnotation.golubinaBookRequired
StepAnnotation.golubinaBookRequired,
StepAnnotation.slateStylusRequired
),
knownMaterials = knownMaterials
) {
Expand Down Expand Up @@ -61,41 +62,65 @@ val prepopulationData by data(
// All cards deck should always exist and be first in the list
deck(DeckTags.all) { true }

deck(DeckTags.allWithRus) { data ->
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
}
deck(DeckTags.latinLetters) { data ->
data is Symbol && data.type == SymbolType.latin
}
deck(DeckTags.greekLetters) { data ->
data is Symbol && data.type == SymbolType.greek
}
deck(DeckTags.special) { data ->
data is Symbol && data.type == SymbolType.special
}
deck(DeckTags.markers) {data ->
deck(DeckTags.markers) { data ->
data is MarkerSymbol
}
deck(DeckTags.digits) { data ->
data is Symbol && data.type == SymbolType.digit
}
deck(DeckTags.math) { data ->
data is Symbol && data.type == SymbolType.math
}
}
}

object StepAnnotation {
const val golubinaBookRequired = "golubina_book_required"
const val slateStylusRequired = "brl_slate_stylus_required"
}

object DeckTags {
const val all = "all"
const val allWithRus = "all_with_rus"
const val ruLetters = "ru_letters"
const val latinLetters = "latin_letters"
const val greekLetters = "greek_letters"
const val digits = "digits"
const val markers = "markers"
const val special = "special"
const val math = "math"
}

val Context.deckTagToName: Map<String, String> by lazyWithContext {
DeckTags.run {
mapOf(
all to getString(R.string.deck_name_all),
allWithRus to getString(R.string.deck_name_all_but_foreign),
ruLetters to getString(R.string.deck_name_ru_letters),
latinLetters to getString(R.string.deck_name_latin_letters),
greekLetters to getString(R.string.deck_name_greek_letters),
digits to getString(R.string.deck_name_digits),
markers to getString(R.string.deck_name_markers),
special to getString(R.string.deck_name_punctuation)
special to getString(R.string.deck_name_punctuation),
math to getString(R.string.deck_name_math)
)
}
}
Expand Down
Loading

0 comments on commit bce1c93

Please sign in to comment.