Skip to content

Commit

Permalink
Merge pull request #164 from braille-systems/release/0.6googleplay
Browse files Browse the repository at this point in the history
release/0.6.0

Changelog:
- connected settings UI to settings
- added overflow menu in Theory
- fill step-by-step course until end (26 lessons)
- enable navigation through course (available from overflow menu)
- improve accessibility:
    - announce text in steps aloud
    - in steps with demonstration, tweak elements' labels
- miscellaneous improvements
  • Loading branch information
zuevval authored May 18, 2020
2 parents 1111aca + a387669 commit 5c41c28
Show file tree
Hide file tree
Showing 113 changed files with 5,127 additions and 2,360 deletions.
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ For building and running the app, your either need to download a virtual Android
Clone the repository and open 'android/' subfolder as an Android Studio project. Gradle build will start automatically and all libraries will be downloaded (an Internet connection is required). Then, if you have already set up an emulator or connected a physical device, you will be able to launch it (click green triangle screen button in the toolbar above the code editor).


## Adding content

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.
- Do not forget to add pluses in DSL to avoid loosing data!
22 changes: 21 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ apply plugin: 'kotlin-kapt'

apply plugin: 'androidx.navigation.safeargs'

apply plugin: 'kotlinx-serialization'

android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -23,9 +25,10 @@ android {
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "0.4.1"
versionName "0.6.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled = true
}
buildTypes {
release {
Expand All @@ -39,6 +42,7 @@ android {

dependencies {
def lifecycle_version = "2.2.0"
def koin_version = '2.1.5'

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Expand All @@ -56,6 +60,7 @@ dependencies {
kapt "androidx.room:room-compiler:$version_room"
implementation "androidx.room:room-ktx:$version_room"
testImplementation "androidx.room:room-testing:$version_room"
implementation "androidx.lifecycle:lifecycle-extensions:2.0.0"

// Testing
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
Expand All @@ -75,6 +80,21 @@ dependencies {
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'

// Serialization
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" // or "kotlin-stdlib-jdk8"
// Downgraded to '0.14.0' because of https://github.com/Kotlin/kotlinx.serialization/issues/576
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0" // JVM dependency

// Koin
implementation "org.koin:koin-core:$koin_version"
implementation "org.koin:koin-core-ext:$koin_version"
implementation "org.koin:koin-android:$koin_version"
implementation "org.koin:koin-android-viewmodel:$koin_version"
implementation "org.koin:koin-android-ext:$koin_version"

// Many methods
implementation 'com.android.support:multidex:1.0.3'

//Settings
implementation 'androidx.preference:preference:1.1.1'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
package com.github.braillesystems.learnbraille

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.github.braillesystems.learnbraille.data.dsl.*
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 org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith


private val content by materials {
+ruSymbols
+enSymbols
// ...
}

private val ruSymbols by symbols(symbolType = "ru") {
symbol(symbol = 'А', brailleDots = BrailleDots(F, E, E, E, E, E))
symbol(symbol = 'Б', brailleDots = BrailleDots(F, F, E, E, E, E))
// ...
}

private val enSymbols by symbols(symbolType = "en") {
symbol(symbol = 'Z', brailleDots = BrailleDots(F, F, F, E, E, E))
// ...
}


private val prepopulationData by data(
materials = content,
stepAnnotations = listOf("book", "bomb")
) {

users {
user("default1", "John Smith")
}

users {
user("default2", "")
user("default3", "")
// ...
}

courses {
course(
name = "Best course",
description = "The best"
) {
+courseLessons
// ...
}

course(
name = "Worst course",
description = "The worst",
lessons = worstLessons
)
}

decks {
deck("Ru letters") {
it is Symbol && it.type == "ru"
}
// ...
}

decks {
deck("En letters") {
it is Symbol && it.type == "en"
}
// ...
}
}

private val courseLessons by lessons {

lesson(
name = "Wow"
) {
+FirstInfo("first")
addSomeSteps()
}
}

/*
* Do not forget that builders is a regular Kotlin code, no magic.
*/
private fun StepsBuilder.addSomeSteps() {
+Info("with book").annotate("book")
+LastInfo("last")
}

private val worstLessons by lessons {

lesson("1") {
+FirstInfo("FirstInfo")
+Info("Open your book and boom your bomb").annotate("book", "bomb")
+ShowDots(
text = "Перед Вами полное шеститочие",
dots = BrailleDots(F, F, F, F, F, F)
)
+InputDots(
text = "Введите все шесть точек",
dots = BrailleDots(F, F, F, F, F, F)
)
+Show(content.symbols.getValue('Z'))
for (material in getMaterials('Б', 'Z')) {
+Input(material)
}
+LastInfo("LastInfo")
}
}

private fun getMaterials(vararg chars: Char) =
chars.map(content.symbols::getValue)


// Lists for testing

private val users = listOf(
// Zero ID's because of autoincrement
User(0, "default1", "John Smith"),
User(0, "default2", ""),
User(0, "default3", "")
)
private val mats = listOf(
Material(1, Symbol(symbol = 'А', brailleDots = BrailleDots(F, E, E, E, E, E), type = "ru")),
Material(2, Symbol(symbol = 'Б', brailleDots = BrailleDots(F, F, E, E, E, E), type = "ru")),
Material(3, Symbol(symbol = 'Z', brailleDots = BrailleDots(F, F, F, E, E, E), type = "en"))
)
private val decks = listOf(
Deck(1, "Ru letters"),
Deck(2, "En letters")
)
private val cards = listOf(
Card(1, 1),
Card(1, 2),
Card(2, 3)
)
private val courses = listOf(
Course(1, "Best course", "The best"),
Course(2, "Worst course", "The worst")
)
private val lessons = listOf(
Lesson(1, 1, "Wow", ""),
Lesson(1, 2, "1", "")
)
private val steps = listOf(
Step(1, 1, 1, FirstInfo("first")),
Step(2, 1, 1, Info("with book")),
Step(3, 1, 1, LastInfo("last")),

Step(1, 2, 1, FirstInfo("FirstInfo")),
Step(2, 2, 1, Info("Open your book and boom your bomb")),
Step(
3, 2, 1,
ShowDots(
text = "Перед Вами полное шеститочие",
dots = BrailleDots(F, F, F, F, F, F)
)
),
Step(
4, 2, 1,
InputDots(
text = "Введите все шесть точек",
dots = BrailleDots(F, F, F, F, F, F)
)
),
Step(5, 2, 1, Show(content.symbols.getValue('Z'))),
Step(6, 2, 1, Input(content.symbols.getValue('Б'))),
Step(7, 2, 1, Input(content.symbols.getValue('Z'))),
Step(8, 2, 1, LastInfo("LastInfo"))
)
private val stepAnnotations = listOf(
StepAnnotation(1, "book"),
StepAnnotation(2, "bomb")
)
private val stepHasAnnotations = listOf(
StepHasAnnotation(1, 1, 2, 1),
StepHasAnnotation(2, 1, 2, 1),
StepHasAnnotation(2, 1, 2, 2)
)


@RunWith(AndroidJUnit4::class)
class DslTest {

private lateinit var data: DataBuilder

@Before
fun getBuilder() {
prepopulationData.use {
data = this
}
}

@Test
fun testUsers() {
assertEquals(users, data.users)
}

@Test
fun testMaterials() {
assertEquals(mats, data.materials)
}

@Test
fun testDecks() {
assertEquals(decks, data.decks)
}

@Test
fun testCards() {
assertEquals(cards, data.cards)
}

@Test
fun testCourses() {
assertEquals(courses, data.courses)
}

@Test
fun testLessons() {
assertEquals(lessons, data.lessons)
}

@Test
fun testSteps() {
assertEquals(steps, data.steps)
}

@Test
fun testAnnotations() {
assertEquals(stepAnnotations, data.stepAnnotations)
}

@Test
fun testStepAnnotations() {
assertEquals(stepHasAnnotations, data.stepHasAnnotations)
}
}
Loading

0 comments on commit 5c41c28

Please sign in to comment.