diff --git a/.gitignore b/.gitignore
index e5554ecf..11039858 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,252 +1,224 @@
-##---Python---
-**/.idea/
-*.pyc
+# Created by https://www.toptal.com/developers/gitignore/api/androidstudio,android,gradle
+# Edit at https://www.toptal.com/developers/gitignore?templates=androidstudio,android,gradle
-##---TeX---
+### Android ###
+# Built application files
+*.apk
+*.aar
+*.ap_
+*.aab
-## Binary output
-*.pdf
+# Files for the ART/Dalvik VM
+*.dex
-## Core latex/pdflatex auxiliary files:
-*.aux
-*.lof
+# Java class files
+*.class
+
+# Generated files
+bin/
+gen/
+out/
+# Uncomment the following line in case you need and you don't have the release build type files in your app
+# release/
+
+# Gradle files
+.gradle/
+build/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Log Files
*.log
-*.lot
-*.fls
-*.out
-*.toc
-*.fmt
-*.fot
-*.cb
-*.cb2
-.*.lb
-
-## Intermediate documents:
-*.dvi
-*.xdv
-*-converted-to.*
-# these rules might exclude image files for figures etc.
-# *.ps
-# *.eps
-# *.pdf
-
-## Generated if empty string is given at "Please type another file name for output:"
-.pdf
-
-## Bibliography auxiliary files (bibtex/biblatex/biber):
-*.bbl
-*.bcf
-*.blg
-*-blx.aux
-*-blx.bib
-*.run.xml
-
-## Build tool auxiliary files:
-*.fdb_latexmk
-*.synctex
-*.synctex(busy)
-*.synctex.gz
-*.synctex.gz(busy)
-*.pdfsync
-
-## Auxiliary and intermediate files from other packages:
-# algorithms
-*.alg
-*.loa
-
-# achemso
-acs-*.bib
-
-# amsthm
-*.thm
-
-# beamer
-*.nav
-*.pre
-*.snm
-*.vrb
-
-# changes
-*.soc
-
-# cprotect
-*.cpt
-
-# elsarticle (documentclass of Elsevier journals)
-*.spl
-
-# endnotes
-*.ent
-
-# fixme
-*.lox
-
-# feynmf/feynmp
-*.mf
-*.mp
-*.t[1-9]
-*.t[1-9][0-9]
-*.tfm
-
-#(r)(e)ledmac/(r)(e)ledpar
-*.end
-*.?end
-*.[1-9]
-*.[1-9][0-9]
-*.[1-9][0-9][0-9]
-*.[1-9]R
-*.[1-9][0-9]R
-*.[1-9][0-9][0-9]R
-*.eledsec[1-9]
-*.eledsec[1-9]R
-*.eledsec[1-9][0-9]
-*.eledsec[1-9][0-9]R
-*.eledsec[1-9][0-9][0-9]
-*.eledsec[1-9][0-9][0-9]R
-
-# glossaries
-*.acn
-*.acr
-*.glg
-*.glo
-*.gls
-*.glsdefs
-
-# gnuplottex
-*-gnuplottex-*
-
-# gregoriotex
-*.gaux
-*.gtex
-
-# htlatex
-*.4ct
-*.4tc
-*.idv
-*.lg
-*.trc
-*.xref
-
-# hyperref
-*.brf
-
-# knitr
-*-concordance.tex
-# TODO Comment the next line if you want to keep your tikz graphics files
-*.tikz
-*-tikzDictionary
-
-# listings
-*.lol
-
-# makeidx
-*.idx
-*.ilg
-*.ind
-*.ist
-
-# minitoc
-*.maf
-*.mlf
-*.mlt
-*.mtc[0-9]*
-*.slf[0-9]*
-*.slt[0-9]*
-*.stc[0-9]*
-
-# minted
-_minted*
-*.pyg
-
-# morewrites
-*.mw
-
-# nomencl
-*.nlg
-*.nlo
-*.nls
-
-# pax
-*.pax
-
-# pdfpcnotes
-*.pdfpc
-
-# sagetex
-*.sagetex.sage
-*.sagetex.py
-*.sagetex.scmd
-
-# scrwfile
-*.wrt
-
-# sympy
-*.sout
-*.sympy
-sympy-plots-for-*.tex/
-
-# pdfcomment
-*.upa
-*.upb
-
-# pythontex
-*.pytxcode
-pythontex-files-*/
-
-# thmtools
-*.loe
-
-# TikZ & PGF
-*.dpth
-*.md5
-*.auxlock
-
-# todonotes
-*.tdo
-# easy-todo
-*.lod
+# Android Studio Navigation editor temp files
+.navigation/
+
+# Android Studio captures folder
+captures/
+
+# IntelliJ
+*.iml
+.idea/workspace.xml
+.idea/tasks.xml
+.idea/gradle.xml
+.idea/assetWizardSettings.xml
+.idea/dictionaries
+.idea/libraries
+# Android Studio 3 in .gitignore file.
+.idea/caches
+.idea/modules.xml
+# Comment next line if keeping position of elements in Navigation Editor is relevant for you
+.idea/navEditor.xml
+
+# Keystore files
+# Uncomment the following lines if you do not want to check your keystore files in.
+#*.jks
+#*.keystore
+
+# External native build folder generated in Android Studio 2.2 and later
+.externalNativeBuild
+.cxx/
+
+# Google Services (e.g. APIs or Firebase)
+# google-services.json
+
+# Freeline
+freeline.py
+freeline/
+freeline_project_description.json
+
+# fastlane
+fastlane/report.xml
+fastlane/Preview.html
+fastlane/screenshots
+fastlane/test_output
+fastlane/readme.md
+
+# Version control
+vcs.xml
+
+# lint
+lint/intermediates/
+lint/generated/
+lint/outputs/
+lint/tmp/
+# lint/reports/
+
+### Android Patch ###
+gen-external-apklibs
+output.json
+
+# Replacement of .externalNativeBuild directories introduced
+# with Android Studio 3.5.
+
+### Gradle ###
+.gradle
+
+# Ignore Gradle GUI config
+gradle-app.setting
+
+# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
+!gradle-wrapper.jar
+
+# Cache of project
+.gradletasknamecache
+
+# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
+# gradle/wrapper/gradle-wrapper.properties
+
+### Gradle Patch ###
+**/build/
+
+### AndroidStudio ###
+# Covers files to be ignored for android development using Android Studio.
+
+# Built application files
+
+# Files for the ART/Dalvik VM
+
+# Java class files
+
+# Generated files
+
+# Gradle files
+
+# Signing files
+.signing/
+
+# Local configuration file (sdk path, etc)
+
+# Proguard folder generated by Eclipse
+
+# Log Files
+
+# Android Studio
+/*/build/
+/*/local.properties
+/*/out
+/*/*/build
+/*/*/production
+*.ipr
+*~
+*.swp
+
+# Android Patch
+
+# External native build folder generated in Android Studio 2.2 and later
+
+# NDK
+obj/
+
+# IntelliJ IDEA
+*.iws
+/out/
+
+# User-specific configurations
+.idea/caches/
+.idea/libraries/
+.idea/shelf/
+.idea/.name
+.idea/compiler.xml
+.idea/copyright/profiles_settings.xml
+.idea/encodings.xml
+.idea/misc.xml
+.idea/scopes/scope_settings.xml
+.idea/vcs.xml
+.idea/jsLibraryMappings.xml
+.idea/datasources.xml
+.idea/dataSources.ids
+.idea/sqlDataSources.xml
+.idea/dynamic.xml
+.idea/uiDesigner.xml
-# xmpincl
-*.xmpi
+# OS-specific files
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+ehthumbs.db
+Thumbs.db
-# xindy
-*.xdy
+# Legacy Eclipse project files
+.classpath
+.project
+.cproject
+.settings/
-# xypic precompiled matrices
-*.xyc
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
-# endfloat
-*.ttt
-*.fff
+# Package Files #
+*.war
+*.ear
-# Latexian
-TSWLatexianTemp*
+# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
+hs_err_pid*
-## Editors:
-# WinEdt
-*.bak
-*.sav
+## Plugin-specific files:
-# Texpad
-.texpadtmp
+# mpeltonen/sbt-idea plugin
+.idea_modules/
-# Kile
-*.backup
+# JIRA plugin
+atlassian-ide-plugin.xml
-# KBibTeX
-*~[0-9]*
+# Mongo Explorer plugin
+.idea/mongoSettings.xml
-# auto folder when using emacs and auctex
-./auto/*
-*.el
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
-# expex forward references with \gathertags
-*-tags.tex
+### AndroidStudio Patch ###
-# standalone packages
-*.sta
+!/gradle/wrapper/gradle-wrapper.jar
-# generated if using elsarticle.cls
-*.spl
+# End of https://www.toptal.com/developers/gitignore/api/androidstudio,android,gradle
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 00000000..ce889bd5
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,119 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ xmlns:android
+
+ ^$
+
+
+
+
+
+
+
+
+ xmlns:.*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+
+ ^$
+
+
+
+
+
+
+
+
+ style
+
+ ^$
+
+
+
+
+
+
+
+
+ .*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+
+ http://schemas.android.com/apk/res/android
+
+
+ ANDROID_ATTRIBUTE_ORDER
+
+
+
+
+
+
+ .*
+
+ .*
+
+
+ BY_NAME
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 00000000..a55e7a17
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 00000000..86627e98
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 00000000..eb2873e7
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/markdown-navigator-enh.xml b/.idea/markdown-navigator-enh.xml
new file mode 100644
index 00000000..12fb99d1
--- /dev/null
+++ b/.idea/markdown-navigator-enh.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/markdown-navigator.xml b/.idea/markdown-navigator.xml
new file mode 100644
index 00000000..4463382e
--- /dev/null
+++ b/.idea/markdown-navigator.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 00000000..7f68460d
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/.gitignore b/android/.gitignore
deleted file mode 100644
index 739bb616..00000000
--- a/android/.gitignore
+++ /dev/null
@@ -1,206 +0,0 @@
-
-# Created by https://www.gitignore.io/api/android,androidstudio
-# Edit at https://www.gitignore.io/?templates=android,androidstudio
-
-### Android ###
-# Built application files
-*.apk
-*.ap_
-*.aab
-
-# Files for the ART/Dalvik VM
-*.dex
-
-# Java class files
-*.class
-
-# Generated files
-bin/
-gen/
-out/
-release/
-
-# Gradle files
-.gradle/
-build/
-
-# Local configuration file (sdk path, etc)
-local.properties
-
-# Proguard folder generated by Eclipse
-proguard/
-
-# Log Files
-*.log
-
-# Android Studio Navigation editor temp files
-.navigation/
-
-# Android Studio captures folder
-captures/
-
-# IntelliJ
-*.iml
-.idea/workspace.xml
-.idea/tasks.xml
-.idea/gradle.xml
-.idea/assetWizardSettings.xml
-.idea/dictionaries
-.idea/libraries
-# Android Studio 3 in .gitignore file.
-.idea/caches
-.idea/modules.xml
-# Comment next line if keeping position of elements in Navigation Editor is relevant for you
-.idea/navEditor.xml
-
-# Keystore files
-# Uncomment the following lines if you do not want to check your keystore files in.
-#*.jks
-#*.keystore
-
-# External native build folder generated in Android Studio 2.2 and later
-.externalNativeBuild
-
-# Google Services (e.g. APIs or Firebase)
-# google-services.json
-
-# Freeline
-freeline.py
-freeline/
-freeline_project_description.json
-
-# fastlane
-fastlane/report.xml
-fastlane/Preview.html
-fastlane/screenshots
-fastlane/test_output
-fastlane/readme.md
-
-# Version control
-vcs.xml
-
-# lint
-lint/intermediates/
-lint/generated/
-lint/outputs/
-lint/tmp/
-# lint/reports/
-
-### Android Patch ###
-gen-external-apklibs
-output.json
-
-# Replacement of .externalNativeBuild directories introduced
-# with Android Studio 3.5.
-.cxx/
-
-### AndroidStudio ###
-# Covers files to be ignored for android development using Android Studio.
-
-# Built application files
-
-# Files for the ART/Dalvik VM
-
-# Java class files
-
-# Generated files
-
-# Gradle files
-.gradle
-
-# Signing files
-.signing/
-
-# Local configuration file (sdk path, etc)
-
-# Proguard folder generated by Eclipse
-
-# Log Files
-
-# Android Studio
-/*/build/
-/*/local.properties
-/*/out
-/*/*/build
-/*/*/production
-*.ipr
-*~
-*.swp
-
-# Android Patch
-
-# External native build folder generated in Android Studio 2.2 and later
-
-# NDK
-obj/
-
-# IntelliJ IDEA
-*.iws
-/out/
-
-# User-specific configurations
-.idea/caches/
-.idea/libraries/
-.idea/shelf/
-.idea/.name
-.idea/compiler.xml
-.idea/copyright/profiles_settings.xml
-.idea/encodings.xml
-.idea/misc.xml
-.idea/scopes/scope_settings.xml
-.idea/vcs.xml
-.idea/jsLibraryMappings.xml
-.idea/datasources.xml
-.idea/dataSources.ids
-.idea/sqlDataSources.xml
-.idea/dynamic.xml
-.idea/uiDesigner.xml
-
-# OS-specific files
-.DS_Store
-.DS_Store?
-._*
-.Spotlight-V100
-.Trashes
-ehthumbs.db
-Thumbs.db
-
-# Legacy Eclipse project files
-.classpath
-.project
-.cproject
-.settings/
-
-# Mobile Tools for Java (J2ME)
-.mtj.tmp/
-
-# Package Files #
-*.war
-*.ear
-
-# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
-hs_err_pid*
-
-## Plugin-specific files:
-
-# mpeltonen/sbt-idea plugin
-.idea_modules/
-
-# JIRA plugin
-atlassian-ide-plugin.xml
-
-# Mongo Explorer plugin
-.idea/mongoSettings.xml
-
-# Crashlytics plugin (for Android Studio and IntelliJ)
-com_crashlytics_export_strings.xml
-crashlytics.properties
-crashlytics-build.properties
-fabric.properties
-
-### AndroidStudio Patch ###
-
-!/gradle/wrapper/gradle-wrapper.jar
-
-# End of https://www.gitignore.io/api/android,androidstudio
-
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/AbstractStepFragment.kt b/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/AbstractStepFragment.kt
deleted file mode 100644
index 389c930f..00000000
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/AbstractStepFragment.kt
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.github.braillesystems.learnbraille.ui.screens.theory.steps
-
-import android.view.Menu
-import android.view.MenuInflater
-import android.view.MenuItem
-import com.github.braillesystems.learnbraille.COURSE_ID
-import com.github.braillesystems.learnbraille.R
-import com.github.braillesystems.learnbraille.data.repository.PreferenceRepository
-import com.github.braillesystems.learnbraille.ui.screens.AbstractFragmentWithHelp
-import com.github.braillesystems.learnbraille.ui.screens.HelpMsgId
-import com.github.braillesystems.learnbraille.ui.screens.theory.toCurrentStep
-import com.github.braillesystems.learnbraille.utils.navigate
-import com.github.braillesystems.learnbraille.utils.updateTitle
-import org.koin.android.ext.android.inject
-
-
-/**
- * Base class for all steps.
- */
-abstract class AbstractStepFragment(helpMsgId: HelpMsgId) : AbstractFragmentWithHelp(helpMsgId) {
-
- private val preferenceRepository: PreferenceRepository by inject()
-
- override val helpMsg: String
- get() = getString(R.string.lessons_help_template).format(
- super.helpMsg, getString(R.string.lessons_help_common)
- )
-
- protected fun updateStepTitle(lessonId: Long, stepId: Long, msgId: Int) {
- updateTitle("$lessonId.$stepId ${getString(msgId)}")
- }
-
- override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
- inflater.inflate(
- if (preferenceRepository.additionalExitButtonsEnabled) R.menu.steps_menu_hide
- else R.menu.steps_menu,
- menu
- )
- }
-
- override fun onOptionsItemSelected(item: MenuItem) = false.also {
- when (item.itemId) {
- R.id.help -> navigateToHelp()
- R.id.lessons_list -> navigate(R.id.action_global_lessonsListFragment)
- R.id.current_course_pos -> toCurrentStep(COURSE_ID)
- }
- }
-
- companion object {
- const val stepArgName = "step"
- }
-}
diff --git a/android/app/src/main/res/layout/fragment_help.xml b/android/app/src/main/res/layout/fragment_help.xml
deleted file mode 100644
index ff2142ae..00000000
--- a/android/app/src/main/res/layout/fragment_help.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/app/.gitignore b/app/.gitignore
similarity index 100%
rename from android/app/.gitignore
rename to app/.gitignore
diff --git a/app/app.iml b/app/app.iml
new file mode 100644
index 00000000..2cc3fdd3
--- /dev/null
+++ b/app/app.iml
@@ -0,0 +1,258 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ generateDebugSources
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/app/build.gradle b/app/build.gradle
similarity index 95%
rename from android/app/build.gradle
rename to app/build.gradle
index a7f547d3..fd3fbcca 100644
--- a/android/app/build.gradle
+++ b/app/build.gradle
@@ -24,8 +24,8 @@ android {
applicationId "com.github.braillesystems.learnbraille"
minSdkVersion 19
targetSdkVersion 29
- versionCode 5
- versionName "1.0.0"
+ versionCode 7
+ versionName "1.0.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled = true
diff --git a/android/app/proguard-rules.pro b/app/proguard-rules.pro
similarity index 100%
rename from android/app/proguard-rules.pro
rename to app/proguard-rules.pro
diff --git a/android/app/src/androidTest/java/com/github/braillesystems/learnbraille/LearnBrailleDatabaseTest.kt b/app/src/androidTest/java/com/github/braillesystems/learnbraille/data/db/LearnBrailleDatabaseTest.kt
similarity index 94%
rename from android/app/src/androidTest/java/com/github/braillesystems/learnbraille/LearnBrailleDatabaseTest.kt
rename to app/src/androidTest/java/com/github/braillesystems/learnbraille/data/db/LearnBrailleDatabaseTest.kt
index 41c550d3..f4e735ba 100644
--- a/android/app/src/androidTest/java/com/github/braillesystems/learnbraille/LearnBrailleDatabaseTest.kt
+++ b/app/src/androidTest/java/com/github/braillesystems/learnbraille/data/db/LearnBrailleDatabaseTest.kt
@@ -1,9 +1,8 @@
-package com.github.braillesystems.learnbraille
+package com.github.braillesystems.learnbraille.data.db
import androidx.room.Room
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
-import com.github.braillesystems.learnbraille.data.db.LearnBrailleDatabase
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
diff --git a/android/app/src/androidTest/java/com/github/braillesystems/learnbraille/DslTest.kt b/app/src/androidTest/java/com/github/braillesystems/learnbraille/data/dsl/DslTest.kt
similarity index 93%
rename from android/app/src/androidTest/java/com/github/braillesystems/learnbraille/DslTest.kt
rename to app/src/androidTest/java/com/github/braillesystems/learnbraille/data/dsl/DslTest.kt
index 6bf8a4ba..c852ee70 100644
--- a/android/app/src/androidTest/java/com/github/braillesystems/learnbraille/DslTest.kt
+++ b/app/src/androidTest/java/com/github/braillesystems/learnbraille/data/dsl/DslTest.kt
@@ -1,7 +1,6 @@
-package com.github.braillesystems.learnbraille
+package com.github.braillesystems.learnbraille.data.dsl
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
@@ -30,9 +29,13 @@ private val enSymbols by symbols(symbolType = "en") {
}
+val knownMaterials by known()
+
+
private val prepopulationData by data(
materials = content,
- stepAnnotations = listOf("book", "bomb")
+ stepAnnotations = listOf("book", "bomb"),
+ knownMaterials = knownMaterials
) {
users {
@@ -109,7 +112,10 @@ private val worstLessons by lessons {
dots = BrailleDots(F, F, F, F, F, F)
)
+Show(content.symbols.getValue('Z'))
- for (material in getMaterials('Б', 'Z')) {
+ for (material in getMaterials(
+ 'Б',
+ 'Z'
+ )) {
+Input(material)
}
+LastInfo("LastInfo")
@@ -194,13 +200,11 @@ private val stepHasAnnotations = listOf(
@RunWith(AndroidJUnit4::class)
class DslTest {
- private lateinit var data: DataBuilder
+ private lateinit var data: Data
@Before
fun getBuilder() {
- prepopulationData.use {
- data = this
- }
+ data = prepopulationData
}
@Test
@@ -245,6 +249,6 @@ class DslTest {
@Test
fun testStepAnnotations() {
- assertEquals(stepHasAnnotations, data.stepHasAnnotations)
+ assertEquals(stepHasAnnotations, data.stepsHasAnnotations)
}
}
diff --git a/app/src/androidTest/java/com/github/braillesystems/learnbraille/data/entities/BrailleDotsTest.kt b/app/src/androidTest/java/com/github/braillesystems/learnbraille/data/entities/BrailleDotsTest.kt
new file mode 100644
index 00000000..04ce1e29
--- /dev/null
+++ b/app/src/androidTest/java/com/github/braillesystems/learnbraille/data/entities/BrailleDotsTest.kt
@@ -0,0 +1,18 @@
+package com.github.braillesystems.learnbraille.data.entities
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.Assert.assertEquals
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class BrailleDotsTest {
+
+ @Test
+ fun spelling() {
+ assertEquals(
+ "1, 3, 6",
+ BrailleDots(b1 = BrailleDot.F, b3 = BrailleDot.F, b6 = BrailleDot.F).spelling
+ )
+ }
+}
diff --git a/app/src/androidTest/java/com/github/braillesystems/learnbraille/data/repository/PracticeRepositoryTest.kt b/app/src/androidTest/java/com/github/braillesystems/learnbraille/data/repository/PracticeRepositoryTest.kt
new file mode 100644
index 00000000..97a4f541
--- /dev/null
+++ b/app/src/androidTest/java/com/github/braillesystems/learnbraille/data/repository/PracticeRepositoryTest.kt
@@ -0,0 +1,14 @@
+package com.github.braillesystems.learnbraille.data.repository
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class PracticeRepositoryTest {
+
+ @Test
+ fun practiceRepo() {
+ TODO()
+ }
+}
\ No newline at end of file
diff --git a/app/src/androidTest/java/com/github/braillesystems/learnbraille/data/repository/TheoryRepositoryTest.kt b/app/src/androidTest/java/com/github/braillesystems/learnbraille/data/repository/TheoryRepositoryTest.kt
new file mode 100644
index 00000000..48106d9a
--- /dev/null
+++ b/app/src/androidTest/java/com/github/braillesystems/learnbraille/data/repository/TheoryRepositoryTest.kt
@@ -0,0 +1,14 @@
+package com.github.braillesystems.learnbraille.data.repository
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class TheoryRepositoryTest {
+
+ @Test
+ fun theoryRepo() {
+ TODO()
+ }
+}
diff --git a/app/src/androidTest/java/com/github/braillesystems/learnbraille/ui/screens/DotsCheckerTest.kt b/app/src/androidTest/java/com/github/braillesystems/learnbraille/ui/screens/DotsCheckerTest.kt
new file mode 100644
index 00000000..850f943b
--- /dev/null
+++ b/app/src/androidTest/java/com/github/braillesystems/learnbraille/ui/screens/DotsCheckerTest.kt
@@ -0,0 +1,14 @@
+package com.github.braillesystems.learnbraille.ui.screens
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+class DotsCheckerTest {
+
+ @Test
+ fun dotsChecker() {
+ TODO()
+ }
+}
diff --git a/app/src/androidTest/java/com/github/braillesystems/learnbraille/utils/UtilsTest.kt b/app/src/androidTest/java/com/github/braillesystems/learnbraille/utils/UtilsTest.kt
new file mode 100644
index 00000000..57f10523
--- /dev/null
+++ b/app/src/androidTest/java/com/github/braillesystems/learnbraille/utils/UtilsTest.kt
@@ -0,0 +1,37 @@
+package com.github.braillesystems.learnbraille.utils
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import kotlinx.serialization.Serializable
+import org.junit.Assert.assertEquals
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@Serializable
+sealed class S
+
+@Serializable
+data class A(val s: String) : S()
+
+@Serializable
+data class B(val i: Long, val s: String) : S()
+
+@RunWith(AndroidJUnit4::class)
+class UtilsTest {
+
+ @Test
+ fun serializationBasic() {
+ @Serializable
+ data class D(val s: String, val i: Int)
+
+ val d = D("Wow", 100500)
+ assertEquals(d, parse(D.serializer(), stringify(D.serializer(), d)))
+ }
+
+ @Test
+ fun serializationVirtual() {
+ val s1: S = A("wow")
+ assertEquals(s1 as A, parse(S.serializer(), stringify(S.serializer(), s1)))
+ val s2: S = B(100500, "aaa")
+ assertEquals(s2 as B, parse(S.serializer(), stringify(S.serializer(), s2)))
+ }
+}
diff --git a/android/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
similarity index 100%
rename from android/app/src/main/AndroidManifest.xml
rename to app/src/main/AndroidManifest.xml
diff --git a/android/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png
similarity index 100%
rename from android/app/src/main/ic_launcher-playstore.png
rename to app/src/main/ic_launcher-playstore.png
diff --git a/android/app/src/main/icon_beta-playstore.png b/app/src/main/icon_beta-playstore.png
similarity index 100%
rename from android/app/src/main/icon_beta-playstore.png
rename to app/src/main/icon_beta-playstore.png
diff --git a/android/app/src/main/icon_univ-playstore.png b/app/src/main/icon_univ-playstore.png
similarity index 100%
rename from android/app/src/main/icon_univ-playstore.png
rename to app/src/main/icon_univ-playstore.png
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/LearnBrailleApplication.kt b/app/src/main/java/com/github/braillesystems/learnbraille/LearnBrailleApplication.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/LearnBrailleApplication.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/LearnBrailleApplication.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/db/Database.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/db/Database.kt
similarity index 57%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/db/Database.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/db/Database.kt
index 198c7b1b..645b5a09 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/db/Database.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/data/db/Database.kt
@@ -7,8 +7,8 @@ import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import androidx.sqlite.db.SupportSQLiteDatabase
+import com.github.braillesystems.learnbraille.data.dsl.Data
import com.github.braillesystems.learnbraille.data.entities.*
-import com.github.braillesystems.learnbraille.res.knownMaterials
import com.github.braillesystems.learnbraille.res.prepopulationData
import com.github.braillesystems.learnbraille.utils.scope
import kotlinx.coroutines.Job
@@ -17,6 +17,7 @@ import org.koin.core.KoinComponent
import org.koin.core.get
import timber.log.Timber
+
@Database(
entities =
[
@@ -30,7 +31,8 @@ import timber.log.Timber
)
@TypeConverters(
BrailleDotsConverters::class,
- MaterialDataTypeConverters::class, StepDataConverters::class
+ MaterialDataTypeConverters::class,
+ StepDataConverters::class
)
abstract class LearnBrailleDatabase : RoomDatabase(), KoinComponent {
@@ -54,28 +56,56 @@ abstract class LearnBrailleDatabase : RoomDatabase(), KoinComponent {
@Volatile
private var prepopulationFinished = true
- private lateinit var forcePrepopulationJob: Job
+ private var forcePrepopulationJob: Job? = null
+ private var callbackJob: Job? = null
+ /**
+ * Should be called at the start of application.
+ */
fun init(): LearnBrailleDatabase = this.also {
forcePrepopulationJob = scope().launch {
- if (userDao.getUser(1) != null) {
- Timber.i("DB has been already initialized")
- } else {
- prepopulationFinished = false
- }
+ // Request value from database to force database callbacks evaluation
+ Timber.i("userDao.getUser(1) = ${userDao.getUser(1)}")
}
}
val isInitialized: Boolean
- get() = (forcePrepopulationJob.isCompleted && prepopulationFinished).also {
- if (it) Timber.i("DB has been prepopulated")
- else Timber.i(
- "DB has not been prepopulated: " +
- "forcePrepopulationJob.isCompleted = ${forcePrepopulationJob.isCompleted}, " +
- "prepopulationFinished = $prepopulationFinished"
- )
+ @SuppressLint("BinaryOperationInTimber")
+ get() {
+ val forceJobCompleted = forcePrepopulationJob
+ ?.isCompleted
+ ?: error("Call database init function before")
+ val callbackJobCompleted = callbackJob?.isCompleted == true || callbackJob == null
+ return (prepopulationFinished && forceJobCompleted && callbackJobCompleted).also {
+ if (it) Timber.i("DB has been prepopulated")
+ else Timber.i(
+ "DB has not been prepopulated: " +
+ "prepopulationFinished = $prepopulationFinished, " +
+ "forceJobCompleted = $forceJobCompleted, " +
+ "callbackJobCompleted = $callbackJobCompleted"
+ )
+ }
}
+ private fun prepopulate(data: Data): Job = scope().launch {
+ Timber.i("Start database prepopulation")
+ prepopulationFinished = false
+ data.apply {
+ users?.let { userDao.insert(it) }
+ materials?.let { materialDao.insert(it) }
+ decks?.let { deckDao.insert(it) }
+ cards?.let { cardDao.insert(it) }
+ courses?.let { courseDao.insert(it) }
+ lessons?.let { lessonDao.insert(it) }
+ steps?.let { stepDao.insert(it) }
+ stepAnnotations?.let { stepAnnotationDao.insert(it) }
+ stepsHasAnnotations?.let { stepHasAnnotationDao.insert(it) }
+ knownMaterials?.let { knownMaterialDao.insert(it) }
+ }
+ prepopulationFinished = true
+ Timber.i("Finnish database prepopulation")
+ }
+
companion object {
const val name = "learn_braille_database"
@@ -104,26 +134,7 @@ abstract class LearnBrailleDatabase : RoomDatabase(), KoinComponent {
private fun prepopulate() {
Timber.i("Prepopulate DB")
get().apply {
- prepopulationData.use {
- scope().launch {
- Timber.i("Start database prepopulation")
-
- userDao.insert(users)
- materialDao.insert(materials)
- deckDao.insert(decks)
- cardDao.insert(cards)
- courseDao.insert(courses)
- lessonDao.insert(lessons)
- stepDao.insert(steps)
- stepAnnotationDao.insert(stepAnnotations)
- stepHasAnnotationDao.insert(stepHasAnnotations)
- // TODO apply for multiple users
- knownMaterialDao.insert(knownMaterials.map { it.copy(userId = 1) })
-
- Timber.i("Finnish database prepopulation")
- prepopulationFinished = true
- }
- }
+ callbackJob = prepopulate(prepopulationData)
}
}
})
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Courses.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Courses.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Courses.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Courses.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Data.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Data.kt
similarity index 79%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Data.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Data.kt
index ae9f1a90..4d9cefdd 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Data.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Data.kt
@@ -6,6 +6,20 @@ import com.github.braillesystems.learnbraille.utils.side
import kotlin.reflect.KProperty
+interface Data {
+ val users: List?
+ val materials: List?
+ val decks: List?
+ val cards: List?
+ val courses: List?
+ val lessons: List?
+ val steps: List?
+ val stepAnnotations: List?
+ val stepsHasAnnotations: List?
+ val knownMaterials: List?
+}
+
+
const val DEFAULT_ID = -1L
const val ALL_CARDS_DECK_ID = 1L
@@ -21,21 +35,11 @@ annotation class DataBuilderMarker
class data(
private val materials: MaterialsBuilder,
private val stepAnnotations: List,
+ private val knownMaterials: List,
private val block: DataBuilder.() -> Unit
) {
-
- internal operator fun getValue(thisRef: Any?, property: KProperty<*>): DataWrapper {
- require(property.name == "prepopulationData") {
- "This value is used to prepopulate database, do not change it's name"
- }
- val data = DataBuilder(materials, stepAnnotations, block)
- return DataWrapper(data)
- }
-}
-
-class DataWrapper(private val data: DataBuilder) {
-
- fun use(block: DataBuilder.() -> Unit) = data.block()
+ internal operator fun getValue(thisRef: Any?, property: KProperty<*>): Data =
+ DataBuilder(materials, stepAnnotations, knownMaterials, block)
}
@@ -43,43 +47,48 @@ class DataWrapper(private val data: DataBuilder) {
class DataBuilder(
private val _materials: MaterialsBuilder,
private val stepAnnotationNames: List,
+ private val _knownMaterials: List,
block: DataBuilder.() -> Unit
-) {
+) : Data {
private val _users = mutableListOf()
- internal val users: List
+ override val users: List
get() = _users
- internal val materials: List
+ override val materials: List
get() = _materials.materials
private val _decks = mutableListOf()
- internal val decks: List
+ override val decks: List
get() = _decks
private val _cards = mutableListOf()
- internal val cards: List
+ override val cards: List
get() = _cards
private val _courses = mutableListOf()
- internal val courses: List
+ override val courses: List
get() = _courses
private val _lessons = mutableListOf()
- internal val lessons: List
+ override val lessons: List
get() = _lessons
private val _steps = mutableListOf()
- internal val steps: List
+ override val steps: List
get() = _steps
private val _stepAnnotations = mutableListOf()
- internal val stepAnnotations: List
+ override val stepAnnotations: List
get() = _stepAnnotations
- private val _stepHasAnnotations = mutableListOf()
- internal val stepHasAnnotations: List
- get() = _stepHasAnnotations
+ private val _stepsHasAnnotations = mutableListOf()
+ override val stepsHasAnnotations: List
+ get() = _stepsHasAnnotations
+
+ override val knownMaterials: List by lazy {
+ _knownMaterials.map { it.copy(userId = 1) }
+ }
init {
block()
@@ -124,7 +133,7 @@ class DataBuilder(
stepAnnotationNames.forEach {
val stepAnnotation = annotationByName[it]?.id
?: error("Step annotated with not existing annotation: $it")
- _stepHasAnnotations += StepHasAnnotation(
+ _stepsHasAnnotations += StepHasAnnotation(
courseId = courseId,
lessonId = lessonId,
stepId = stepId,
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Lessons.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Lessons.kt
similarity index 99%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Lessons.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Lessons.kt
index 67d9643f..0e4ff4c7 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Lessons.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Lessons.kt
@@ -5,7 +5,6 @@ import com.github.braillesystems.learnbraille.utils.side
import kotlin.reflect.KProperty
class lessons(private val block: LessonsBuilder.() -> Unit) {
-
operator fun getValue(thisRef: Any?, property: KProperty<*>) = LessonsBuilder(block)
}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Materials.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Materials.kt
similarity index 93%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Materials.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Materials.kt
index 633100c2..3fbec36f 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Materials.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Materials.kt
@@ -83,12 +83,8 @@ class known(vararg chars: Char) {
private val cs = chars.map(Char::toUpperCase)
private var knownMaterials: List? = null
- operator fun getValue(thisRef: Any?, property: KProperty<*>): List {
- require(property.name == "knownMaterials") {
- "Property should have name knownMaterials to be used by database"
- }
- return knownMaterials ?: cs.map {
+ operator fun getValue(thisRef: Any?, property: KProperty<*>): List =
+ knownMaterials ?: cs.map {
KnownMaterial(DEFAULT_ID, content.symbols.getValue(it).id)
}.also { knownMaterials = it }
- }
}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Users.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Users.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Users.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/dsl/Users.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/BrailleDots.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/BrailleDots.kt
similarity index 78%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/BrailleDots.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/entities/BrailleDots.kt
index c76a3c9d..0bc3e7f9 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/BrailleDots.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/BrailleDots.kt
@@ -2,6 +2,7 @@ package com.github.braillesystems.learnbraille.data.entities
import androidx.room.TypeConverter
import com.github.braillesystems.learnbraille.data.entities.BrailleDot.E
+import com.github.braillesystems.learnbraille.data.entities.BrailleDot.F
import kotlinx.serialization.Serializable
@@ -58,13 +59,16 @@ val BrailleDots.list: List
get() = listOf(b1, b2, b3, b4, b5, b6)
val BrailleDots.spelling: String
+ get() = filled.joinToString(separator = ", ", transform = Int::toString)
+
+val BrailleDots.filled: List
get() = list
- .mapIndexed { index, brailleDot ->
- if (brailleDot == E) null
- else (index + 1).toString()
+ .mapIndexedNotNull { index, brailleDot ->
+ if (brailleDot == F) index + 1
+ else null
}
- .filterNotNull()
- .joinToString(separator = ", ")
+
+operator fun BrailleDots.contains(i: Int) = i in filled
class BrailleDotsConverters {
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Cards.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Cards.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Cards.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Cards.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/CoursePositions.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/CoursePositions.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/CoursePositions.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/entities/CoursePositions.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Courses.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Courses.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Courses.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Courses.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Decks.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Decks.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Decks.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Decks.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/KnownMaterials.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/KnownMaterials.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/KnownMaterials.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/entities/KnownMaterials.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Lessons.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Lessons.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Lessons.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Lessons.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/MaterialData.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/MaterialData.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/MaterialData.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/entities/MaterialData.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Materials.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Materials.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Materials.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Materials.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/StepAnnotations.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/StepAnnotations.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/StepAnnotations.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/entities/StepAnnotations.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/StepData.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/StepData.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/StepData.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/entities/StepData.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/StepHasAnnotations.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/StepHasAnnotations.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/StepHasAnnotations.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/entities/StepHasAnnotations.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Steps.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Steps.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Steps.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Steps.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Users.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Users.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Users.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/entities/Users.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/repository/PracticeRepository.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/repository/PracticeRepository.kt
similarity index 99%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/repository/PracticeRepository.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/repository/PracticeRepository.kt
index 1a8b4167..11aa7407 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/repository/PracticeRepository.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/data/repository/PracticeRepository.kt
@@ -8,13 +8,13 @@ import com.github.braillesystems.learnbraille.data.entities.DeckDao
import com.github.braillesystems.learnbraille.data.entities.Material
import com.github.braillesystems.learnbraille.utils.preferences
+
data class DeckNotEmpty(
val deck: Deck,
val containsCards: Boolean
)
interface PracticeRepository {
-
val currentDeckId: Long
suspend fun getNextMaterial(): Material?
suspend fun getCurrDeck(): Deck
@@ -22,7 +22,6 @@ interface PracticeRepository {
}
interface MutablePracticeRepository : PracticeRepository {
-
override var currentDeckId: Long
suspend fun getNextMaterialNotNull(): Material
}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/repository/PreferenceRepository.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/repository/PreferenceRepository.kt
similarity index 91%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/repository/PreferenceRepository.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/repository/PreferenceRepository.kt
index 1009a7b5..b10d3215 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/repository/PreferenceRepository.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/data/repository/PreferenceRepository.kt
@@ -22,7 +22,7 @@ interface PreferenceRepository {
val inputOnFlyCheck: Boolean
val additionalAnnouncementsEnabled: Boolean
val practiceUseOnlyKnownMaterials: Boolean
- val additionalExitButtonsEnabled: Boolean
+ val extendedAccessibilityEnabled: Boolean
val additionalQrCodeButtonEnabled: Boolean
val currentUserId: Long
@@ -89,7 +89,7 @@ class PreferenceRepositoryImpl(
override val additionalAnnouncementsEnabled: Boolean by logged {
context.preferences.getBoolean(
context.getString(R.string.preference_enable_additional_announcements),
- true
+ false
)
}
@@ -100,9 +100,9 @@ class PreferenceRepositoryImpl(
)
}
- override val additionalExitButtonsEnabled: Boolean by logged {
+ override val extendedAccessibilityEnabled: Boolean by logged {
context.preferences.getBoolean(
- context.getString(R.string.preference_additional_exit_buttons_enabled),
+ context.getString(R.string.preference_extended_accessibility),
true
)
}
@@ -121,7 +121,7 @@ class PreferenceRepositoryImpl(
}
override suspend fun getCurrentUser(): User =
- userDao.getUser(currentUserId)?.also {
- Timber.i("Current user = $it")
- } ?: error("Current user should always exist")
+ userDao.getUser(currentUserId)
+ ?.also { Timber.i("Current user = $it") }
+ ?: error("Current user should always exist")
}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/repository/TheoryRepository.kt b/app/src/main/java/com/github/braillesystems/learnbraille/data/repository/TheoryRepository.kt
similarity index 99%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/data/repository/TheoryRepository.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/data/repository/TheoryRepository.kt
index abff9f8e..32bb254c 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/data/repository/TheoryRepository.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/data/repository/TheoryRepository.kt
@@ -7,14 +7,12 @@ import com.github.braillesystems.learnbraille.utils.scope
import kotlinx.coroutines.launch
interface TheoryRepository {
-
suspend fun getCurrentStep(courseId: Long): Step
suspend fun getLastCourseStep(courseId: Long): Step
suspend fun getAllCourseLessons(courseId: Long): List
}
interface MutableTheoryRepository : TheoryRepository {
-
suspend fun getNextStepAndUpdate(thisStep: Step, markThisAsPassed: Boolean = false): Step?
suspend fun getPrevStepAndUpdate(thisStep: Step): Step?
suspend fun getCurrentStepAndUpdate(courseId: Long): Step
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/res/Data.kt b/app/src/main/java/com/github/braillesystems/learnbraille/res/Data.kt
similarity index 96%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/res/Data.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/res/Data.kt
index 8ce80794..c78823a7 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/res/Data.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/res/Data.kt
@@ -25,7 +25,8 @@ val prepopulationData by data(
materials = content,
stepAnnotations = listOf(
StepAnnotation.golubinaBookRequired
- )
+ ),
+ knownMaterials = knownMaterials
) {
users {
@@ -48,11 +49,9 @@ val prepopulationData by data(
description = """
Курс, основанный на методике В. В. Голубиной: символы изучаютсяв том порядке,
как их придумал Луи Брайль для французского языка.
- Одновременно изучаются и цифры."""
- ) {
- +golubinaIntroLessons
- +someMoreGolubinaLessons
- }
+ Одновременно изучаются и цифры.""",
+ lessons = golubinaIntroLessons
+ )
}
decks {
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/res/GolubinaCourse.kt b/app/src/main/java/com/github/braillesystems/learnbraille/res/GolubinaCourse.kt
similarity index 99%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/res/GolubinaCourse.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/res/GolubinaCourse.kt
index 3697d5e3..2237b9e0 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/res/GolubinaCourse.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/res/GolubinaCourse.kt
@@ -8,9 +8,8 @@ import com.github.braillesystems.learnbraille.data.entities.BrailleDot.F
internal val golubinaIntroLessons by lessons {
- val name1 = "Знакомство с шеститочием"
lesson(
- name = name1
+ name = "Знакомство с шеститочием"
) {
+FirstInfo(
"""Перед Вами пошаговый курс для обучения с нуля системе Луи Брайля.
@@ -241,15 +240,6 @@ internal val golubinaIntroLessons by lessons {
букву Х и цифру 8."""
)
}
-}
-
-/*
-* In lessons with words input I tried to bear a scheme '6+-2 words'
-* but there are several exceptions, e. g. where words are especially long/short
-* or when new symbols are difficult
-* */
-
-internal val someMoreGolubinaLessons by lessons {
lesson(
name = "Буква Х и цифра 8"
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/res/Materials.kt b/app/src/main/java/com/github/braillesystems/learnbraille/res/Materials.kt
similarity index 90%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/res/Materials.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/res/Materials.kt
index 9b8a4a22..2a297e53 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/res/Materials.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/res/Materials.kt
@@ -12,7 +12,7 @@ import com.github.braillesystems.learnbraille.utils.rules
/**
- * Do not forget to register new types of symbols in `symbolTypeDisplayList` below.
+ * Do not forget to register print rules below for the new types of symbols.
*
* Always use this variable to get materials.
*/
@@ -35,15 +35,13 @@ val knownMaterials by known(
val Context.inputSymbolPrintRules by rules(
{
- getString(R.string.input_letter_intro_template).let {
- ruSymbols.map::containsKey to { c: Char -> it.format(c) }
- }
+ val t = getString(R.string.input_letter_intro_template)
+ ruSymbols.map::containsKey to { c: Char -> t.format(c) }
},
{
- getString(R.string.input_digit_intro_template).let {
- uebDigits.map::containsKey to { c: Char -> it.format(c) }
- }
+ val t = getString(R.string.input_digit_intro_template)
+ uebDigits.map::containsKey to { c: Char -> t.format(c) }
},
{
@@ -66,15 +64,13 @@ val Context.inputSymbolPrintRules by rules(
val Context.showSymbolPrintRules by rules(
{
- getString(R.string.show_letter_intro_template).let {
- ruSymbols.map::containsKey to { c: Char -> it.format(c) }
- }
+ val t = getString(R.string.show_letter_intro_template)
+ ruSymbols.map::containsKey to { c: Char -> t.format(c) }
},
{
- getString(R.string.show_digit_intro_template).let {
- uebDigits.map::containsKey to { c: Char -> it.format(c) }
- }
+ val t = getString(R.string.show_digit_intro_template)
+ uebDigits.map::containsKey to { c: Char -> t.format(c) }
},
{
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/res/TestCourse.kt b/app/src/main/java/com/github/braillesystems/learnbraille/res/TestCourse.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/res/TestCourse.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/res/TestCourse.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/res/_DSL.kt b/app/src/main/java/com/github/braillesystems/learnbraille/res/_DSL.kt
similarity index 54%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/res/_DSL.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/res/_DSL.kt
index e70cd405..d3668e9e 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/res/_DSL.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/res/_DSL.kt
@@ -3,5 +3,7 @@ package com.github.braillesystems.learnbraille.res
import com.github.braillesystems.learnbraille.data.dsl.StepsBuilder
import com.github.braillesystems.learnbraille.data.entities.Input
-fun StepsBuilder.inputChars(s: String): Unit =
- s.map(Char::toUpperCase).forEach { c -> +Input(content.symbols.getValue(c)) }
+fun StepsBuilder.inputChars(chars: String): Unit =
+ chars
+ .map(Char::toUpperCase)
+ .forEach { c -> +Input(content.symbols.getValue(c)) }
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/Messages.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/Messages.kt
similarity index 56%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/Messages.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/Messages.kt
index 2d06111c..87aa3c78 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/Messages.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/Messages.kt
@@ -3,12 +3,13 @@ package com.github.braillesystems.learnbraille.ui
import android.content.Context
import androidx.fragment.app.Fragment
import com.github.braillesystems.learnbraille.R
+import com.github.braillesystems.learnbraille.data.entities.BrailleDot
import com.github.braillesystems.learnbraille.data.entities.BrailleDots
+import com.github.braillesystems.learnbraille.data.entities.list
import com.github.braillesystems.learnbraille.data.entities.spelling
import com.github.braillesystems.learnbraille.res.inputSymbolPrintRules
import com.github.braillesystems.learnbraille.res.showSymbolPrintRules
-import com.github.braillesystems.learnbraille.utils.checkedToast
-import com.github.braillesystems.learnbraille.utils.toast
+import com.github.braillesystems.learnbraille.utils.*
import timber.log.Timber
enum class PrintMode {
@@ -24,8 +25,30 @@ fun Fragment.showIncorrectToast(c: Char? = null): Unit =
printString(c, PrintMode.INPUT).orEmpty()
)
+val Context.dotsHintRules by lazyWithContext> {
+ 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)
+ )
+}
+
fun Fragment.showHintDotsToast(expectedDots: BrailleDots) =
- checkedToast(getString(R.string.input_dots_hint_template).format(expectedDots.spelling))
+ getString(R.string.input_dots_hint_template)
+ .format(
+ expectedDots.list
+ .mapIndexedNotNull { index, brailleDot ->
+ if (brailleDot == BrailleDot.F) application.dotsHintRules[index] else null
+ }
+ .joinToString(separator = ", ")
+ )
+ .side { checkedToast(it) }
+
+fun Fragment.showHintToast(expectedDots: BrailleDots) =
+ checkedToast(getString(R.string.input_hint_template).format(expectedDots.spelling))
fun Context.printString(c: Char, mode: PrintMode): String? =
when (mode) {
@@ -41,4 +64,6 @@ fun Fragment.printString(c: Char, mode: PrintMode): String? =
?.run { printString(c, mode) }
fun Fragment.printStringNotNullLogged(c: Char, mode: PrintMode): String =
- context?.printStringNotNullLogged(c, mode) ?: error("Context is not available")
+ context
+ ?.printStringNotNullLogged(c, mode)
+ ?: error("Context is not available")
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/BrailleTrainer.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/BrailleTrainer.kt
similarity index 86%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/BrailleTrainer.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/BrailleTrainer.kt
index 16ee5177..156bac28 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/BrailleTrainer.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/BrailleTrainer.kt
@@ -3,7 +3,7 @@ package com.github.braillesystems.learnbraille.ui.brailletrainer
import android.app.Activity
import com.github.braillesystems.learnbraille.data.entities.BrailleDots
import com.github.braillesystems.learnbraille.data.repository.PreferenceRepository
-import com.github.braillesystems.learnbraille.utils.executeIf
+import com.github.braillesystems.learnbraille.utils.runIf
import org.koin.core.KoinComponent
import org.koin.core.get
@@ -19,7 +19,7 @@ object BrailleTrainer : KoinComponent {
* All this class public functionality must be call via this method.
*/
private inline fun execute(block: () -> Unit) =
- executeIf(get().brailleTrainerEnabled, block)
+ runIf(get().brailleTrainerEnabled, block)
}
interface BrailleTrainerSignalHandler : UsbSignalHandler
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/UsbParser.java b/app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/UsbParser.java
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/UsbParser.java
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/UsbParser.java
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/UsbService.java b/app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/UsbService.java
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/UsbService.java
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/UsbService.java
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/UsbSignalHandler.java b/app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/UsbSignalHandler.java
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/UsbSignalHandler.java
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/brailletrainer/UsbSignalHandler.java
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/AbstractFragmentWithHelp.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/AbstractFragmentWithHelp.kt
similarity index 90%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/AbstractFragmentWithHelp.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/AbstractFragmentWithHelp.kt
index d60c007d..73bd6254 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/AbstractFragmentWithHelp.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/AbstractFragmentWithHelp.kt
@@ -24,9 +24,9 @@ abstract class AbstractFragmentWithHelp(private val helpMsgId: HelpMsgId) : Frag
}
override fun onOptionsItemSelected(item: MenuItem) =
- super.onOptionsItemSelected(item).also {
- if (item.itemId == R.id.help) navigateToHelp()
- }
+ super
+ .onOptionsItemSelected(item)
+ .also { if (item.itemId == R.id.help) navigateToHelp() }
protected fun navigateToHelp() {
navigateToHelp(helpMsg)
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/DotsChecker.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/DotsChecker.kt
similarity index 98%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/DotsChecker.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/DotsChecker.kt
index 6b023cc0..41732c16 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/DotsChecker.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/DotsChecker.kt
@@ -125,8 +125,8 @@ private class DotsCheckerImpl : MutableDotsChecker {
private val isCorrect: Boolean
get() = (enteredDots == expectedDots).also {
Timber.i(
- if (it) "Correct: " else "Incorrect: " +
- "entered = ${enteredDots}, expected = $expectedDots"
+ if (it) "Correct: "
+ else "Incorrect: entered = $enteredDots, expected = $expectedDots"
)
}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/MainActivity.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/MainActivity.kt
similarity index 93%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/MainActivity.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/MainActivity.kt
index 5ab7390d..7ba77c61 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/MainActivity.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/MainActivity.kt
@@ -31,7 +31,7 @@ class MainActivity : AppCompatActivity() {
override fun onSupportNavigateUp(): Boolean = try {
navController.navigateUp()
} catch (e: IllegalArgumentException) {
- Timber.e("Multitouch navigation", e)
+ Timber.e(e, "Multitouch navigation")
false
}
}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/exit/ExitFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/exit/ExitFragment.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/exit/ExitFragment.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/exit/ExitFragment.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/help/HelpFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/help/HelpFragment.kt
similarity index 82%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/help/HelpFragment.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/help/HelpFragment.kt
index 5967f1c7..cfe7c82c 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/help/HelpFragment.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/help/HelpFragment.kt
@@ -1,10 +1,8 @@
package com.github.braillesystems.learnbraille.ui.screens.help
import android.os.Bundle
-import android.text.method.ScrollingMovementMethod
import android.view.LayoutInflater
import android.view.ViewGroup
-import androidx.core.text.parseAsHtml
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import com.github.braillesystems.learnbraille.R
@@ -31,8 +29,7 @@ class HelpFragment : Fragment() {
title = getString(R.string.help_title)
val content = getStringArg(helpMessageArgName)
- helpMessage.text = content.parseAsHtml()
- helpMessage.movementMethod = ScrollingMovementMethod()
+ helpView.setSeparatedText(content)
checkedAnnounce(content.removeHtmlMarkup())
}.root
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/menu/MenuFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/menu/MenuFragment.kt
similarity index 94%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/menu/MenuFragment.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/menu/MenuFragment.kt
index 74a24187..819484d8 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/menu/MenuFragment.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/menu/MenuFragment.kt
@@ -81,7 +81,7 @@ class MenuFragment : AbstractFragmentWithHelp(R.string.menu_help) {
navigate(R.id.action_menuFragment_to_settingsFragment)
}
- if (preferenceRepository.additionalExitButtonsEnabled) {
+ if (preferenceRepository.extendedAccessibilityEnabled) {
exitButton.also {
buttons += it
}.setOnClickListener {
@@ -127,10 +127,10 @@ class MenuFragment : AbstractFragmentWithHelp(R.string.menu_help) {
}
private fun requestPermissions() {
- executeIf(preferenceRepository.speechRecognitionEnabled) {
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return@executeIf
+ runIf(preferenceRepository.speechRecognitionEnabled) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return@runIf
val permission = requireContext().checkSelfPermission(Manifest.permission.RECORD_AUDIO)
- if (permission == PackageManager.PERMISSION_GRANTED) return@executeIf
+ if (permission == PackageManager.PERMISSION_GRANTED) return@runIf
requestPermissions(arrayOf(Manifest.permission.RECORD_AUDIO), recordAudioPermissionCode)
}
}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/CardFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/CardFragment.kt
similarity index 90%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/CardFragment.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/CardFragment.kt
index 2435695f..cab053f3 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/CardFragment.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/CardFragment.kt
@@ -57,6 +57,14 @@ class CardFragment : AbstractFragmentWithHelp(R.string.practice_help) {
updateTitle(title)
setHasOptionsMenu(true)
+ if (preferenceRepository.extendedAccessibilityEnabled) {
+ hintButton.setSize(
+ width = resources.getDimension(R.dimen.side_buttons_extended_width).toInt()
+ )
+ nextButton.setSize(
+ width = resources.getDimension(R.dimen.side_buttons_extended_width).toInt()
+ )
+ }
dotsState = brailleDots.dotsState.apply {
subscribe(View.OnClickListener {
@@ -100,7 +108,7 @@ class CardFragment : AbstractFragmentWithHelp(R.string.practice_help) {
viewModel.observeEventHint(
viewLifecycleOwner, dotsState
) { expectedDots ->
- showHintDotsToast(expectedDots)
+ showHintToast(expectedDots)
}
viewModel.observeEventPassHint(
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/CardViewModel.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/CardViewModel.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/CardViewModel.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/CardViewModel.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/DecksList.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/DecksList.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/DecksList.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/practice/DecksList.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/settings/SettingsFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/settings/SettingsFragment.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/settings/SettingsFragment.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/settings/SettingsFragment.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/TheoryFreeNavigation.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/TheoryFreeNavigation.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/TheoryFreeNavigation.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/TheoryFreeNavigation.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/lessons/LessonsListFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/lessons/LessonsListFragment.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/lessons/LessonsListFragment.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/lessons/LessonsListFragment.kt
diff --git a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/AbstractInfoStepFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/AbstractInfoStepFragment.kt
new file mode 100644
index 00000000..31cf7165
--- /dev/null
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/AbstractInfoStepFragment.kt
@@ -0,0 +1,5 @@
+package com.github.braillesystems.learnbraille.ui.screens.theory.steps
+
+import com.github.braillesystems.learnbraille.ui.screens.HelpMsgId
+
+abstract class AbstractInfoStepFragment(helpMsgId: HelpMsgId) : AbstractStepFragment(helpMsgId)
diff --git a/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/AbstractStepFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/AbstractStepFragment.kt
new file mode 100644
index 00000000..d5ed7d68
--- /dev/null
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/AbstractStepFragment.kt
@@ -0,0 +1,109 @@
+package com.github.braillesystems.learnbraille.ui.screens.theory.steps
+
+import android.text.method.ScrollingMovementMethod
+import android.util.TypedValue
+import android.view.Menu
+import android.view.MenuInflater
+import android.view.MenuItem
+import android.widget.Button
+import android.widget.TextView
+import androidx.core.text.parseAsHtml
+import com.github.braillesystems.learnbraille.COURSE_ID
+import com.github.braillesystems.learnbraille.R
+import com.github.braillesystems.learnbraille.data.entities.Step
+import com.github.braillesystems.learnbraille.data.repository.PreferenceRepository
+import com.github.braillesystems.learnbraille.ui.screens.AbstractFragmentWithHelp
+import com.github.braillesystems.learnbraille.ui.screens.HelpMsgId
+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.*
+import org.koin.android.ext.android.inject
+import com.github.braillesystems.learnbraille.utils.updateTitle as utilUpdateTitle
+
+
+/**
+ * Base class for all steps.
+ */
+abstract class AbstractStepFragment(helpMsgId: HelpMsgId) : AbstractFragmentWithHelp(helpMsgId) {
+
+ protected val preferenceRepository: PreferenceRepository by inject()
+ protected lateinit var step: Step
+
+ override val helpMsg: String
+ get() = getString(R.string.lessons_help_template).format(
+ super.helpMsg, getString(R.string.lessons_help_common)
+ )
+
+ protected fun initialize(
+ step: Step,
+ prevButton: Button? = null,
+ nextButton: Button? = null,
+ hintButton: Button? = null
+ ) {
+ this.step = step
+ setHasOptionsMenu(true)
+ if (preferenceRepository.extendedAccessibilityEnabled) {
+ prevButton?.setSize(
+ width = resources.getDimension(R.dimen.side_buttons_extended_width).toInt()
+ )
+ nextButton?.setSize(
+ width = resources.getDimension(R.dimen.side_buttons_extended_width).toInt()
+ )
+ hintButton?.setSize(
+ width = resources.getDimension(R.dimen.side_buttons_extended_width).toInt()
+ )
+ }
+ }
+
+ protected fun setText(text: String, infoTextView: TextView) {
+ infoTextView.text = text.parseAsHtml()
+ infoTextView.movementMethod = ScrollingMovementMethod()
+ checkedAnnounce(text)
+ if (preferenceRepository.extendedAccessibilityEnabled) {
+ infoTextView.setTextSize(
+ TypedValue.COMPLEX_UNIT_SP,
+ application.extendedTextSize
+ )
+ }
+ }
+
+ protected fun updateTitle(msg: String) {
+ utilUpdateTitle(
+ if (preferenceRepository.extendedAccessibilityEnabled) "${step.lessonId} ${step.id} $msg"
+ else "${step.lessonId}.${step.id} $msg"
+ )
+ }
+
+ protected fun setNextButton(button: Button) {
+ button.setOnClickListener {
+ toNextStep(step, markThisAsPassed = true)
+ }
+ }
+
+ protected fun setPrevButton(button: Button) {
+ button.setOnClickListener {
+ toPrevStep(step)
+ }
+ }
+
+ override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
+ inflater.inflate(
+ if (preferenceRepository.extendedAccessibilityEnabled) R.menu.steps_menu_hide
+ else R.menu.steps_menu,
+ menu
+ )
+ }
+
+ override fun onOptionsItemSelected(item: MenuItem) = false.also {
+ when (item.itemId) {
+ R.id.help -> navigateToHelp()
+ R.id.lessons_list -> navigate(R.id.action_global_lessonsListFragment)
+ R.id.current_course_pos -> toCurrentStep(COURSE_ID)
+ }
+ }
+
+ companion object {
+ const val stepArgName = "step"
+ }
+}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/FirstInfoFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/FirstInfoFragment.kt
similarity index 56%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/FirstInfoFragment.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/FirstInfoFragment.kt
index 4a5f1a8d..4728d261 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/FirstInfoFragment.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/FirstInfoFragment.kt
@@ -1,19 +1,15 @@
package com.github.braillesystems.learnbraille.ui.screens.theory.steps
import android.os.Bundle
-import android.text.method.ScrollingMovementMethod
import android.view.LayoutInflater
import android.view.ViewGroup
-import androidx.core.text.parseAsHtml
import androidx.databinding.DataBindingUtil
import com.github.braillesystems.learnbraille.R
import com.github.braillesystems.learnbraille.data.entities.FirstInfo
import com.github.braillesystems.learnbraille.databinding.FragmentLessonFirstInfoBinding
import com.github.braillesystems.learnbraille.ui.screens.theory.getStepArg
-import com.github.braillesystems.learnbraille.ui.screens.theory.toNextStep
-import com.github.braillesystems.learnbraille.utils.checkedAnnounce
-class FirstInfoFragment : AbstractStepFragment(R.string.lessons_help_info) {
+class FirstInfoFragment : AbstractInfoStepFragment(R.string.lessons_help_info) {
override fun onCreateView(
inflater: LayoutInflater,
@@ -28,16 +24,10 @@ class FirstInfoFragment : AbstractStepFragment(R.string.lessons_help_info) {
val step = getStepArg()
require(step.data is FirstInfo)
- infoTextView.text = step.data.text.parseAsHtml()
- infoTextView.movementMethod = ScrollingMovementMethod()
- checkedAnnounce(step.data.text)
-
- updateStepTitle(step.lessonId, step.id, R.string.lessons_title_info)
- setHasOptionsMenu(true)
-
- nextButton.setOnClickListener {
- toNextStep(step, markThisAsPassed = true)
- }
+ initialize(step, null, nextButton)
+ updateTitle(getString(R.string.lessons_title_info))
+ setText(step.data.text, infoTextView)
+ setNextButton(nextButton)
}.root
}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InfoFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InfoFragment.kt
similarity index 50%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InfoFragment.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InfoFragment.kt
index ebea518c..1f13ca98 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InfoFragment.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InfoFragment.kt
@@ -1,20 +1,15 @@
package com.github.braillesystems.learnbraille.ui.screens.theory.steps
import android.os.Bundle
-import android.text.method.ScrollingMovementMethod
import android.view.LayoutInflater
import android.view.ViewGroup
-import androidx.core.text.parseAsHtml
import androidx.databinding.DataBindingUtil
import com.github.braillesystems.learnbraille.R
import com.github.braillesystems.learnbraille.data.entities.Info
import com.github.braillesystems.learnbraille.databinding.FragmentLessonsInfoBinding
import com.github.braillesystems.learnbraille.ui.screens.theory.getStepArg
-import com.github.braillesystems.learnbraille.ui.screens.theory.toNextStep
-import com.github.braillesystems.learnbraille.ui.screens.theory.toPrevStep
-import com.github.braillesystems.learnbraille.utils.checkedAnnounce
-class InfoFragment : AbstractStepFragment(R.string.lessons_help_info) {
+class InfoFragment : AbstractInfoStepFragment(R.string.lessons_help_info) {
override fun onCreateView(
inflater: LayoutInflater,
@@ -29,19 +24,11 @@ class InfoFragment : AbstractStepFragment(R.string.lessons_help_info) {
val step = getStepArg()
require(step.data is Info)
- infoTextView.text = step.data.text.parseAsHtml()
- infoTextView.movementMethod = ScrollingMovementMethod()
- checkedAnnounce(step.data.text)
-
- updateStepTitle(step.lessonId, step.id, R.string.lessons_title_info)
- setHasOptionsMenu(true)
-
- prevButton.setOnClickListener {
- toPrevStep(step)
- }
- nextButton.setOnClickListener {
- toNextStep(step, markThisAsPassed = true)
- }
+ initialize(step, prevButton, nextButton)
+ updateTitle(getString(R.string.lessons_title_info))
+ setText(step.data.text, infoTextView)
+ setPrevButton(prevButton)
+ setNextButton(nextButton)
}.root
}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputDotsFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputDotsFragment.kt
similarity index 88%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputDotsFragment.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputDotsFragment.kt
index e4f0ed75..2d0cd0ee 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputDotsFragment.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputDotsFragment.kt
@@ -6,14 +6,12 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.getSystemService
-import androidx.core.text.parseAsHtml
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
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.data.repository.PreferenceRepository
import com.github.braillesystems.learnbraille.databinding.FragmentLessonsInputDotsBinding
import com.github.braillesystems.learnbraille.ui.screens.observeCheckedOnFly
import com.github.braillesystems.learnbraille.ui.screens.observeEventHint
@@ -29,7 +27,6 @@ import com.github.braillesystems.learnbraille.ui.views.*
import com.github.braillesystems.learnbraille.utils.application
import com.github.braillesystems.learnbraille.utils.checkedAnnounce
import com.github.braillesystems.learnbraille.utils.checkedBuzz
-import org.koin.android.ext.android.inject
import timber.log.Timber
class InputDotsFragment : AbstractStepFragment(R.string.lessons_help_input_dots) {
@@ -38,7 +35,6 @@ class InputDotsFragment : AbstractStepFragment(R.string.lessons_help_input_dots)
private lateinit var dotsState: BrailleDotsState
private var userTouchedDots: Boolean = false
private var buzzer: Vibrator? = null
- private val preferenceRepository: PreferenceRepository by inject()
private lateinit var viewModel: InputViewModel
override fun onCreateView(
@@ -56,15 +52,18 @@ class InputDotsFragment : AbstractStepFragment(R.string.lessons_help_input_dots)
val step = getStepArg()
require(step.data is InputDots)
- val infoText = step.data.text?.parseAsHtml()
- ?: getString(R.string.lessons_show_dots_info_template)
- .format(step.data.dots.spelling)
- infoTextView.text = infoText
- checkedAnnounce(infoText.toString())
+ initialize(step, prevButton, nextButton, hintButton)
+
+ val infoText = step.data.text
+ ?: getString(R.string.lessons_show_dots_info_template).format(step.data.dots.spelling)
+ setText(
+ text = infoText,
+ infoTextView = infoTextView
+ )
+ checkedAnnounce(infoText)
brailleDots.dotsState.display(step.data.dots)
- updateStepTitle(step.lessonId, step.id, R.string.lessons_title_input_dots)
- setHasOptionsMenu(true)
+ updateTitle(getString(R.string.lessons_title_input_dots))
expectedDots = step.data.dots
userTouchedDots = false
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputSymbolFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputSymbolFragment.kt
similarity index 92%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputSymbolFragment.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputSymbolFragment.kt
index eace0e97..ca0ce4cf 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputSymbolFragment.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputSymbolFragment.kt
@@ -12,7 +12,6 @@ import com.github.braillesystems.learnbraille.R
import com.github.braillesystems.learnbraille.data.entities.BrailleDots
import com.github.braillesystems.learnbraille.data.entities.Input
import com.github.braillesystems.learnbraille.data.entities.Symbol
-import com.github.braillesystems.learnbraille.data.repository.PreferenceRepository
import com.github.braillesystems.learnbraille.databinding.FragmentLessonsInputSymbolBinding
import com.github.braillesystems.learnbraille.ui.*
import com.github.braillesystems.learnbraille.ui.screens.observeCheckedOnFly
@@ -27,7 +26,6 @@ import com.github.braillesystems.learnbraille.utils.announce
import com.github.braillesystems.learnbraille.utils.application
import com.github.braillesystems.learnbraille.utils.checkedAnnounce
import com.github.braillesystems.learnbraille.utils.checkedBuzz
-import org.koin.android.ext.android.inject
import timber.log.Timber
class InputSymbolFragment : AbstractStepFragment(R.string.lessons_help_input_symbol) {
@@ -36,7 +34,6 @@ class InputSymbolFragment : AbstractStepFragment(R.string.lessons_help_input_sym
private lateinit var dotsState: BrailleDotsState
private var userTouchedDots: Boolean = false
private var buzzer: Vibrator? = null
- private val preferenceRepository: PreferenceRepository by inject()
private lateinit var viewModel: InputViewModel
override fun onCreateView(
@@ -54,14 +51,15 @@ class InputSymbolFragment : AbstractStepFragment(R.string.lessons_help_input_sym
val step = getStepArg()
require(step.data is Input)
+ initialize(step, prevButton, nextButton, hintButton)
+
require(step.data.material.data is Symbol)
val symbol = step.data.material.data
letter.text = symbol.char.toString()
brailleDots.dotsState.display(symbol.brailleDots)
checkedAnnounce(printStringNotNullLogged(symbol.char, PrintMode.INPUT))
- updateStepTitle(step.lessonId, step.id, R.string.lessons_title_input_symbol)
- setHasOptionsMenu(true)
+ updateTitle(getString(R.string.lessons_title_input_symbol))
expectedDots = symbol.brailleDots
userTouchedDots = false
@@ -112,7 +110,7 @@ class InputSymbolFragment : AbstractStepFragment(R.string.lessons_help_input_sym
viewModel.observeEventHint(
viewLifecycleOwner, dotsState
) {
- showHintDotsToast(expectedDots)
+ showHintToast(expectedDots)
userTouchedDots = true
}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputViewModel.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputViewModel.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputViewModel.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/InputViewModel.kt
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/LastInfoFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/LastInfoFragment.kt
similarity index 57%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/LastInfoFragment.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/LastInfoFragment.kt
index 3a029454..bd372c30 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/LastInfoFragment.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/LastInfoFragment.kt
@@ -1,19 +1,15 @@
package com.github.braillesystems.learnbraille.ui.screens.theory.steps
import android.os.Bundle
-import android.text.method.ScrollingMovementMethod
import android.view.LayoutInflater
import android.view.ViewGroup
-import androidx.core.text.parseAsHtml
import androidx.databinding.DataBindingUtil
import com.github.braillesystems.learnbraille.R
import com.github.braillesystems.learnbraille.data.entities.LastInfo
import com.github.braillesystems.learnbraille.databinding.FragmentLessonLastInfoBinding
import com.github.braillesystems.learnbraille.ui.screens.theory.getStepArg
-import com.github.braillesystems.learnbraille.ui.screens.theory.toPrevStep
-import com.github.braillesystems.learnbraille.utils.checkedAnnounce
-class LastInfoFragment : AbstractStepFragment(R.string.lessons_help_last_info) {
+class LastInfoFragment : AbstractInfoStepFragment(R.string.lessons_help_last_info) {
override fun onCreateView(
inflater: LayoutInflater,
@@ -28,16 +24,10 @@ class LastInfoFragment : AbstractStepFragment(R.string.lessons_help_last_info) {
val step = getStepArg()
require(step.data is LastInfo)
- infoTextView.text = step.data.text.parseAsHtml()
- infoTextView.movementMethod = ScrollingMovementMethod()
- checkedAnnounce(step.data.text)
-
- updateStepTitle(step.lessonId, step.id, R.string.lessons_title_info)
- setHasOptionsMenu(true)
-
- prevButton.setOnClickListener {
- toPrevStep(step)
- }
+ initialize(step, prevButton, null)
+ updateTitle(getString(R.string.lessons_title_last_info))
+ setText(step.data.text, infoTextView)
+ setPrevButton(prevButton)
}.root
}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/ShowDotsFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/ShowDotsFragment.kt
similarity index 67%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/ShowDotsFragment.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/ShowDotsFragment.kt
index a3c70f42..480f55a7 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/ShowDotsFragment.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/ShowDotsFragment.kt
@@ -3,15 +3,12 @@ package com.github.braillesystems.learnbraille.ui.screens.theory.steps
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
-import androidx.core.text.parseAsHtml
import androidx.databinding.DataBindingUtil
import com.github.braillesystems.learnbraille.R
import com.github.braillesystems.learnbraille.data.entities.ShowDots
import com.github.braillesystems.learnbraille.data.entities.spelling
import com.github.braillesystems.learnbraille.databinding.FragmentLessonsShowDotsBinding
import com.github.braillesystems.learnbraille.ui.screens.theory.getStepArg
-import com.github.braillesystems.learnbraille.ui.screens.theory.toNextStep
-import com.github.braillesystems.learnbraille.ui.screens.theory.toPrevStep
import com.github.braillesystems.learnbraille.ui.views.display
import com.github.braillesystems.learnbraille.ui.views.dotsState
import com.github.braillesystems.learnbraille.utils.checkedAnnounce
@@ -34,22 +31,20 @@ class ShowDotsFragment : AbstractStepFragment(R.string.lessons_help_show_dots) {
val step = getStepArg()
require(step.data is ShowDots)
- val infoText = step.data.text?.parseAsHtml()
- ?: getString(R.string.lessons_show_dots_info_template)
- .format(step.data.dots.spelling)
- infoTextView.text = infoText
- checkedAnnounce(infoText.toString())
+ initialize(step, prevButton, nextButton)
+
+ val infoText = step.data.text
+ ?: getString(R.string.lessons_show_dots_info_template).format(step.data.dots.spelling)
+ setText(
+ text = infoText,
+ infoTextView = infoTextView
+ )
+ checkedAnnounce(infoText)
brailleDots.dotsState.display(step.data.dots)
- updateStepTitle(step.lessonId, step.id, R.string.lessons_title_show_dots)
- setHasOptionsMenu(true)
-
- prevButton.setOnClickListener {
- toPrevStep(step)
- }
- nextButton.setOnClickListener {
- toNextStep(step, markThisAsPassed = true)
- }
+ updateTitle(getString(R.string.lessons_title_show_dots))
+ setPrevButton(prevButton)
+ setNextButton(nextButton)
}.root
}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/ShowSymbolFragment.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/ShowSymbolFragment.kt
similarity index 79%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/ShowSymbolFragment.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/ShowSymbolFragment.kt
index 5052b98b..e34a4d1b 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/ShowSymbolFragment.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/screens/theory/steps/ShowSymbolFragment.kt
@@ -11,8 +11,6 @@ import com.github.braillesystems.learnbraille.databinding.FragmentLessonsShowSym
import com.github.braillesystems.learnbraille.ui.PrintMode
import com.github.braillesystems.learnbraille.ui.printStringNotNullLogged
import com.github.braillesystems.learnbraille.ui.screens.theory.getStepArg
-import com.github.braillesystems.learnbraille.ui.screens.theory.toNextStep
-import com.github.braillesystems.learnbraille.ui.screens.theory.toPrevStep
import com.github.braillesystems.learnbraille.ui.views.display
import com.github.braillesystems.learnbraille.ui.views.dotsState
import com.github.braillesystems.learnbraille.utils.checkedAnnounce
@@ -35,20 +33,16 @@ class ShowSymbolFragment : AbstractStepFragment(R.string.lessons_help_show_symbo
val step = getStepArg()
require(step.data is Show)
+ initialize(step, prevButton, nextButton)
+
require(step.data.material.data is Symbol)
letter.text = step.data.material.data.char.toString()
brailleDots.dotsState.display(step.data.material.data.brailleDots)
checkedAnnounce(printStringNotNullLogged(step.data.material.data.char, PrintMode.SHOW))
- updateStepTitle(step.lessonId, step.id, R.string.lessons_title_show_symbol)
- setHasOptionsMenu(true)
-
- prevButton.setOnClickListener {
- toPrevStep(step)
- }
- nextButton.setOnClickListener {
- toNextStep(step, markThisAsPassed = true)
- }
+ updateTitle(getString(R.string.lessons_title_show_symbol))
+ setPrevButton(prevButton)
+ setNextButton(nextButton)
}.root
}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/ui/views/BigLetterView.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/views/BigLetterView.kt
similarity index 100%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/views/BigLetterView.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/views/BigLetterView.kt
diff --git a/android/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
similarity index 93%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/ui/views/BrailleDotsView.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/ui/views/BrailleDotsView.kt
index 0155d8d9..f249cfa9 100644
--- a/android/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
@@ -106,6 +106,6 @@ fun BrailleDotsState.subscribe(listener: View.OnClickListener) =
checkBoxes.forEach { it.setOnClickListener(listener) }
fun BrailleDotsState.display(brailleDots: BrailleDots): Unit =
- (checkBoxes zip brailleDots.list).forEach { (checkBox, dot) ->
- checkBox.isChecked = dot == BrailleDot.F
- }.also { clickable(false) }
+ (checkBoxes zip brailleDots.list)
+ .forEach { (checkBox, dot) -> checkBox.isChecked = dot == BrailleDot.F }
+ .also { clickable(false) }
diff --git a/app/src/main/java/com/github/braillesystems/learnbraille/ui/views/HelpView.kt b/app/src/main/java/com/github/braillesystems/learnbraille/ui/views/HelpView.kt
new file mode 100644
index 00000000..f9cb3434
--- /dev/null
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/ui/views/HelpView.kt
@@ -0,0 +1,47 @@
+package com.github.braillesystems.learnbraille.ui.views
+
+import android.content.Context
+import android.util.AttributeSet
+import android.util.TypedValue
+import android.widget.LinearLayout
+import android.widget.TextView
+import androidx.core.text.parseAsHtml
+import com.github.braillesystems.learnbraille.R
+import com.github.braillesystems.learnbraille.data.repository.PreferenceRepository
+import com.github.braillesystems.learnbraille.utils.extendedTextSize
+import org.koin.core.KoinComponent
+import org.koin.core.inject
+
+class HelpView : LinearLayout, KoinComponent {
+
+ private val preferenceRepository: PreferenceRepository by inject()
+
+ constructor(context: Context) : super(context)
+
+ constructor(context: Context, attrSet: AttributeSet) : super(context, attrSet)
+
+ constructor(
+ context: Context, attrSet: AttributeSet, defStyleAttr: Int
+ ) : super(
+ context, attrSet, defStyleAttr
+ )
+
+ fun setSeparatedText(text: String) {
+ val helpItems = text.split('&')
+ helpItems.forEach { helpItem ->
+ val textView = TextView(context).apply {
+ setPaddingRelative(30, 0, 20, 0)
+ setTextSize(
+ TypedValue.COMPLEX_UNIT_SP,
+ if (preferenceRepository.extendedAccessibilityEnabled) {
+ context.extendedTextSize
+ } else {
+ context.resources.getDimension(R.dimen.help_message_text_size)
+ }
+ )
+ this.text = helpItem.parseAsHtml()
+ }
+ addView(textView)
+ }
+ }
+}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/utils/SpeechRecognition.kt b/app/src/main/java/com/github/braillesystems/learnbraille/utils/SpeechRecognition.kt
similarity index 96%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/utils/SpeechRecognition.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/utils/SpeechRecognition.kt
index da1887d5..e44fbd47 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/utils/SpeechRecognition.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/utils/SpeechRecognition.kt
@@ -29,7 +29,7 @@ class SpeechRecognition(
private var mSpeechRecognizerIntent: Intent? = null
init {
- executeIf(preferenceRepository.speechRecognitionEnabled) {
+ runIf(preferenceRepository.speechRecognitionEnabled) {
try {
initialize()
} catch (e: Throwable) {
@@ -83,7 +83,7 @@ class SpeechRecognition(
mSpeechRecognizer?.setRecognitionListener(SpeechRecognitionListener(fragment))
}
- fun onDestroy() = executeIf(preferenceRepository.speechRecognitionEnabled) {
+ fun onDestroy() = runIf(preferenceRepository.speechRecognitionEnabled) {
try {
mSpeechRecognizer?.destroy()
} catch (e: Throwable) {
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/utils/Utils.kt b/app/src/main/java/com/github/braillesystems/learnbraille/utils/Utils.kt
similarity index 87%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/utils/Utils.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/utils/Utils.kt
index fb0333a4..e291f8f6 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/utils/Utils.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/utils/Utils.kt
@@ -1,9 +1,5 @@
package com.github.braillesystems.learnbraille.utils
-/**
- * This file contains suitable extension functions for this project.
- */
-
import android.content.Context
import android.os.Vibrator
import android.view.accessibility.AccessibilityEvent
@@ -12,6 +8,7 @@ import androidx.appcompat.app.ActionBar
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import com.github.braillesystems.learnbraille.LearnBrailleApplication
+import com.github.braillesystems.learnbraille.R
import com.github.braillesystems.learnbraille.data.repository.PreferenceRepository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -23,6 +20,9 @@ import org.koin.android.ext.android.get
import timber.log.Timber
import kotlin.reflect.KProperty
+/**
+ * This file contains suitable extension functions for this project.
+ */
val Fragment.application: LearnBrailleApplication
get() = requireNotNull(activity).application as LearnBrailleApplication
@@ -31,10 +31,10 @@ fun scope(job: Job = Job()) = CoroutineScope(Dispatchers.Main + job)
fun Vibrator?.checkedBuzz(pattern: BuzzPattern, preferenceRepository: PreferenceRepository) =
- executeIf(preferenceRepository.buzzEnabled) { buzz(pattern) }
+ runIf(preferenceRepository.buzzEnabled) { buzz(pattern) }
fun checkedToast(msg: String, context: Context?, preferenceRepository: PreferenceRepository) =
- executeIf(preferenceRepository.toastsEnabled) {
+ runIf(preferenceRepository.toastsEnabled) {
Toast.makeText(context, msg, preferenceRepository.toastDuration).show()
}
@@ -61,7 +61,7 @@ fun Fragment.announce(announcement: String) =
fun Fragment.checkedAnnounce(
announcement: String,
preferenceRepository: PreferenceRepository = get()
-) = executeIf(preferenceRepository.additionalAnnouncementsEnabled) {
+) = runIf(preferenceRepository.additionalAnnouncementsEnabled) {
announce(announcement)
}
@@ -86,11 +86,7 @@ fun Fragment.updateTitle(title: String) {
fun stringify(s: SerializationStrategy, obj: T) = Json.stringify(s, obj)
fun parse(d: DeserializationStrategy, s: String) = Json.parse(d, s)
-
-class logged(private val getter: C.(String) -> R) {
-
- operator fun getValue(thisRef: C, property: KProperty<*>): R =
- thisRef.getter(property.name).also {
- Timber.i("${property.name} -> $it")
- }
+val Context.extendedTextSize: Float by lazyWithContext {
+ // Size applied in runtime is different
+ resources.getDimension(R.dimen.lessons_info_text_size) / 5 * 3
}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/utils/_Android.kt b/app/src/main/java/com/github/braillesystems/learnbraille/utils/_Android.kt
similarity index 81%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/utils/_Android.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/utils/_Android.kt
index df48d58f..f0c9471b 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/utils/_Android.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/utils/_Android.kt
@@ -1,10 +1,5 @@
package com.github.braillesystems.learnbraille.utils
-/**
- * The file contains suitable extension functions for Android Framework
- * that are not specific for particular project.
- */
-
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
@@ -15,13 +10,19 @@ import android.os.Vibrator
import android.provider.Settings
import android.provider.Settings.SettingNotFoundException
import android.view.accessibility.AccessibilityManager
+import android.widget.Button
import androidx.fragment.app.Fragment
import androidx.navigation.NavDirections
import androidx.navigation.fragment.findNavController
import androidx.preference.PreferenceManager
import com.github.braillesystems.learnbraille.R
import timber.log.Timber
+import kotlin.reflect.KProperty
+/**
+ * The file contains suitable extension functions for Android Framework
+ * that are not specific for particular project.
+ */
val Context.usbManager get() = getSystemService(Context.USB_SERVICE) as UsbManager
val Context.accessibilityManager: AccessibilityManager?
@@ -78,7 +79,7 @@ val Context.isAccessibilityEnabled: Boolean by logged {
fun Fragment.navigate(id: Int): Unit = try {
findNavController().navigate(id)
} catch (e: IllegalArgumentException) {
- Timber.e("Multitouch navigation", e)
+ Timber.e(e, "Multitouch navigation")
}
/**
@@ -88,12 +89,29 @@ fun Fragment.navigate(id: Int): Unit = try {
fun Fragment.navigate(action: NavDirections) = try {
findNavController().navigate(action)
} catch (e: IllegalArgumentException) {
- Timber.e("Multitouch navigation", e)
+ Timber.e(e, "Multitouch navigation")
}
-val Context.appName: String by lazyWithContext { getString(R.string.app_name) }
+val Context.appName: String get() = getString(R.string.app_name)
val Fragment.appName: String
get() = context?.appName ?: error("Fragment is expected to have a context")
val Context.preferences: SharedPreferences
get() = PreferenceManager.getDefaultSharedPreferences(this)
+
+fun Button.setSize(width: Int? = null, height: Int? = null) {
+ layoutParams = layoutParams.apply {
+ width?.let { this.width = width }
+ height?.let { this.height = height }
+ }
+}
+
+class logged(
+ private val logger: (String) -> Unit = { Timber.d(it) },
+ private val getter: C.(KProperty<*>) -> R
+) {
+ operator fun getValue(thisRef: C, property: KProperty<*>): R =
+ thisRef.getter(property).also {
+ logger("${property.name} -> $it")
+ }
+}
diff --git a/android/app/src/main/java/com/github/braillesystems/learnbraille/utils/_Kotlin.kt b/app/src/main/java/com/github/braillesystems/learnbraille/utils/_Kotlin.kt
similarity index 67%
rename from android/app/src/main/java/com/github/braillesystems/learnbraille/utils/_Kotlin.kt
rename to app/src/main/java/com/github/braillesystems/learnbraille/utils/_Kotlin.kt
index cce418c0..a04cb4e0 100644
--- a/android/app/src/main/java/com/github/braillesystems/learnbraille/utils/_Kotlin.kt
+++ b/app/src/main/java/com/github/braillesystems/learnbraille/utils/_Kotlin.kt
@@ -19,42 +19,40 @@ operator fun MatchGroupCollection.component5() = get(4)
val Any?.devnull: Unit get() {}
-fun String.removeHtmlMarkup() = Regex("""<[^>]*>""").replace(this, "")
+fun String.removeHtmlMarkup() = Regex("""<[^>]*>|&""").replace(this, "")
-inline fun executeIf(cond: Boolean, block: () -> Unit) {
+inline fun runIf(cond: Boolean, block: () -> Unit) {
if (cond) block()
}
-inline fun T?.executeIf(cond: Boolean, block: T.() -> Unit) {
+inline fun T?.runIf(cond: Boolean, block: T.() -> Unit) {
if (this != null && cond) block()
}
-typealias P2F = Pair<(T) -> Boolean, (T) -> R>
+typealias Rule = Pair<(T) -> Boolean, (T) -> R>
-fun listOfP2F(vararg p2f: P2F): List> = p2f.toList()
-
-fun Iterable>.peek(key: T): R? {
- forEach { (p, f) -> if (p(key)) return f(key) }
+fun Iterable>.matchF(key: T): ((T) -> R)? {
+ forEach { (p, f) -> if (p(key)) return f }
return null
}
+fun Iterable>.match(key: T): R? = matchF(key)?.invoke(key)
-typealias Rule = P2F
class rules(private vararg val ruleProviders: C.() -> Rule) {
- var value: Rules? = null
+ private var value: Rules? = null
operator fun getValue(thisRef: C, property: KProperty<*>): Rules =
value ?: Rules(ruleProviders.map { thisRef.it() }).also { value = it }
}
class Rules(private val rules: Iterable>) {
- operator fun get(x: T): R? = rules.peek(x)
+ operator fun get(x: T): R? = rules.match(x)
}
class lazyWithContext(private val getter: C.(String) -> R) {
- var value: R? = null
+ private var value: R? = null
operator fun getValue(thisRef: C, property: KProperty<*>): R =
value ?: thisRef.getter(property.name).also { value = it }
}
diff --git a/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
similarity index 100%
rename from android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml
rename to app/src/main/res/drawable-v24/ic_launcher_foreground.xml
diff --git a/android/app/src/main/res/drawable/action_menu_help_button.xml b/app/src/main/res/drawable/action_menu_help_button.xml
similarity index 100%
rename from android/app/src/main/res/drawable/action_menu_help_button.xml
rename to app/src/main/res/drawable/action_menu_help_button.xml
diff --git a/android/app/src/main/res/drawable/checked_round_checkbox.xml b/app/src/main/res/drawable/checked_round_checkbox.xml
similarity index 100%
rename from android/app/src/main/res/drawable/checked_round_checkbox.xml
rename to app/src/main/res/drawable/checked_round_checkbox.xml
diff --git a/android/app/src/main/res/drawable/decks_list_button_icon.xml b/app/src/main/res/drawable/decks_list_button_icon.xml
similarity index 100%
rename from android/app/src/main/res/drawable/decks_list_button_icon.xml
rename to app/src/main/res/drawable/decks_list_button_icon.xml
diff --git a/android/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml
similarity index 100%
rename from android/app/src/main/res/drawable/ic_launcher_background.xml
rename to app/src/main/res/drawable/ic_launcher_background.xml
diff --git a/android/app/src/main/res/drawable/locked.xml b/app/src/main/res/drawable/locked.xml
similarity index 100%
rename from android/app/src/main/res/drawable/locked.xml
rename to app/src/main/res/drawable/locked.xml
diff --git a/android/app/src/main/res/drawable/navigate_left.xml b/app/src/main/res/drawable/navigate_left.xml
similarity index 100%
rename from android/app/src/main/res/drawable/navigate_left.xml
rename to app/src/main/res/drawable/navigate_left.xml
diff --git a/android/app/src/main/res/drawable/navigate_right.xml b/app/src/main/res/drawable/navigate_right.xml
similarity index 100%
rename from android/app/src/main/res/drawable/navigate_right.xml
rename to app/src/main/res/drawable/navigate_right.xml
diff --git a/android/app/src/main/res/drawable/practice_btn_shape.xml b/app/src/main/res/drawable/practice_btn_shape.xml
similarity index 100%
rename from android/app/src/main/res/drawable/practice_btn_shape.xml
rename to app/src/main/res/drawable/practice_btn_shape.xml
diff --git a/android/app/src/main/res/drawable/practice_hint_btn_shape.xml b/app/src/main/res/drawable/practice_hint_btn_shape.xml
similarity index 100%
rename from android/app/src/main/res/drawable/practice_hint_btn_shape.xml
rename to app/src/main/res/drawable/practice_hint_btn_shape.xml
diff --git a/android/app/src/main/res/drawable/round_checkbox.xml b/app/src/main/res/drawable/round_checkbox.xml
similarity index 100%
rename from android/app/src/main/res/drawable/round_checkbox.xml
rename to app/src/main/res/drawable/round_checkbox.xml
diff --git a/android/app/src/main/res/drawable/to_progress.xml b/app/src/main/res/drawable/to_progress.xml
similarity index 100%
rename from android/app/src/main/res/drawable/to_progress.xml
rename to app/src/main/res/drawable/to_progress.xml
diff --git a/android/app/src/main/res/drawable/unchecked_round_checkbox.xml b/app/src/main/res/drawable/unchecked_round_checkbox.xml
similarity index 100%
rename from android/app/src/main/res/drawable/unchecked_round_checkbox.xml
rename to app/src/main/res/drawable/unchecked_round_checkbox.xml
diff --git a/android/app/src/main/res/drawable/unlocked.xml b/app/src/main/res/drawable/unlocked.xml
similarity index 100%
rename from android/app/src/main/res/drawable/unlocked.xml
rename to app/src/main/res/drawable/unlocked.xml
diff --git a/android/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
similarity index 100%
rename from android/app/src/main/res/layout/activity_main.xml
rename to app/src/main/res/layout/activity_main.xml
diff --git a/android/app/src/main/res/layout/braille_dots_view.xml b/app/src/main/res/layout/braille_dots_view.xml
similarity index 100%
rename from android/app/src/main/res/layout/braille_dots_view.xml
rename to app/src/main/res/layout/braille_dots_view.xml
diff --git a/android/app/src/main/res/layout/decks_list_item.xml b/app/src/main/res/layout/decks_list_item.xml
similarity index 100%
rename from android/app/src/main/res/layout/decks_list_item.xml
rename to app/src/main/res/layout/decks_list_item.xml
diff --git a/android/app/src/main/res/layout/fragment_card.xml b/app/src/main/res/layout/fragment_card.xml
similarity index 94%
rename from android/app/src/main/res/layout/fragment_card.xml
rename to app/src/main/res/layout/fragment_card.xml
index 6b9d3a9e..4fbf3adf 100644
--- a/android/app/src/main/res/layout/fragment_card.xml
+++ b/app/src/main/res/layout/fragment_card.xml
@@ -45,7 +45,7 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/android/app/src/main/res/layout/fragment_lesson_first_info.xml b/app/src/main/res/layout/fragment_lesson_first_info.xml
similarity index 78%
rename from android/app/src/main/res/layout/fragment_lesson_first_info.xml
rename to app/src/main/res/layout/fragment_lesson_first_info.xml
index 4b9ef5fd..85684eb8 100644
--- a/android/app/src/main/res/layout/fragment_lesson_first_info.xml
+++ b/app/src/main/res/layout/fragment_lesson_first_info.xml
@@ -7,27 +7,25 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
-
-
-
-
-
-
+
+
0.85
0.9
- 40dp
+ 55dp
+ 40dp190dp85dp35dp
diff --git a/android/app/src/main/res/values-sw360dp/dimens.xml b/app/src/main/res/values-sw360dp/dimens.xml
similarity index 94%
rename from android/app/src/main/res/values-sw360dp/dimens.xml
rename to app/src/main/res/values-sw360dp/dimens.xml
index 7cd062fa..16dbc3ba 100644
--- a/android/app/src/main/res/values-sw360dp/dimens.xml
+++ b/app/src/main/res/values-sw360dp/dimens.xml
@@ -13,7 +13,8 @@
0.850.9
- 50dp
+ 65dp
+ 50dp230dp115dp50dp
diff --git a/android/app/src/main/res/values-sw400dp/dimens.xml b/app/src/main/res/values-sw400dp/dimens.xml
similarity index 94%
rename from android/app/src/main/res/values-sw400dp/dimens.xml
rename to app/src/main/res/values-sw400dp/dimens.xml
index 6c53dbdf..51a80913 100644
--- a/android/app/src/main/res/values-sw400dp/dimens.xml
+++ b/app/src/main/res/values-sw400dp/dimens.xml
@@ -13,7 +13,8 @@
0.850.9
- 50dp
+ 65dp
+ 50dp240dp125dp50dp
diff --git a/android/app/src/main/res/values-sw600dp/dimens.xml b/app/src/main/res/values-sw600dp/dimens.xml
similarity index 91%
rename from android/app/src/main/res/values-sw600dp/dimens.xml
rename to app/src/main/res/values-sw600dp/dimens.xml
index 83f75acc..f8fc6350 100644
--- a/android/app/src/main/res/values-sw600dp/dimens.xml
+++ b/app/src/main/res/values-sw600dp/dimens.xml
@@ -10,7 +10,8 @@
1.81.9
- 65dp
+ 80dp
+ 65dp300dp150dp70dp
@@ -29,7 +30,6 @@
175dp150sp
- 25sp30dp
diff --git a/android/app/src/main/res/values-sw720dp/dimens.xml b/app/src/main/res/values-sw720dp/dimens.xml
similarity index 91%
rename from android/app/src/main/res/values-sw720dp/dimens.xml
rename to app/src/main/res/values-sw720dp/dimens.xml
index 01abc79b..8685fd91 100644
--- a/android/app/src/main/res/values-sw720dp/dimens.xml
+++ b/app/src/main/res/values-sw720dp/dimens.xml
@@ -10,7 +10,8 @@
2.12.2
- 75dp
+ 90dp
+ 75dp320dp170dp90dp
@@ -29,7 +30,6 @@
175dp150sp
- 30sp30dp
diff --git a/android/app/src/main/res/values-tg/strings.xml b/app/src/main/res/values-tg/strings.xml
similarity index 100%
rename from android/app/src/main/res/values-tg/strings.xml
rename to app/src/main/res/values-tg/strings.xml
diff --git a/android/app/src/main/res/values-tk/strings.xml b/app/src/main/res/values-tk/strings.xml
similarity index 100%
rename from android/app/src/main/res/values-tk/strings.xml
rename to app/src/main/res/values-tk/strings.xml
diff --git a/android/app/src/main/res/values-tt/strings.xml b/app/src/main/res/values-tt/strings.xml
similarity index 100%
rename from android/app/src/main/res/values-tt/strings.xml
rename to app/src/main/res/values-tt/strings.xml
diff --git a/android/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml
similarity index 100%
rename from android/app/src/main/res/values-uk/strings.xml
rename to app/src/main/res/values-uk/strings.xml
diff --git a/android/app/src/main/res/values-uz/strings.xml b/app/src/main/res/values-uz/strings.xml
similarity index 100%
rename from android/app/src/main/res/values-uz/strings.xml
rename to app/src/main/res/values-uz/strings.xml
diff --git a/android/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
similarity index 100%
rename from android/app/src/main/res/values/colors.xml
rename to app/src/main/res/values/colors.xml
diff --git a/android/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
similarity index 93%
rename from android/app/src/main/res/values/dimens.xml
rename to app/src/main/res/values/dimens.xml
index da8ac235..a02eb8b1 100644
--- a/android/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -13,7 +13,9 @@
0.850.9
- 35dp
+ 35dp
+ 50dp
+
200dp75dp30dp
@@ -41,7 +43,7 @@
36dp50dp
- 18sp
+ 8sp20sp16dp
diff --git a/android/app/src/main/res/values/ic_launcher_background.xml b/app/src/main/res/values/ic_launcher_background.xml
similarity index 100%
rename from android/app/src/main/res/values/ic_launcher_background.xml
rename to app/src/main/res/values/ic_launcher_background.xml
diff --git a/android/app/src/main/res/values/icon_beta_background.xml b/app/src/main/res/values/icon_beta_background.xml
similarity index 100%
rename from android/app/src/main/res/values/icon_beta_background.xml
rename to app/src/main/res/values/icon_beta_background.xml
diff --git a/android/app/src/main/res/values/icon_univ_background.xml b/app/src/main/res/values/icon_univ_background.xml
similarity index 100%
rename from android/app/src/main/res/values/icon_univ_background.xml
rename to app/src/main/res/values/icon_univ_background.xml
diff --git a/android/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
similarity index 87%
rename from android/app/src/main/res/values/strings.xml
rename to app/src/main/res/values/strings.xml
index 591d48e8..cf01ae2e 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,4 +1,6 @@
+
+
@@ -17,13 +19,20 @@
traverse_dots_in_enumeration_orderenable_additional_announcementspractice_use_only_known_materials
- additional_exit_buttons_enabled
+ extended_accessibilityadditional_qrcode_button_enabledПравильно!Неправильно!
- Ответ: точки %sПодождите, задание загружается
+ Ответ: точки %s
+ Ответ: %s
+ точка 1 слева сверху
+ точка 2 слева посередине
+ точка 3 слева снизу
+ точка 4 справа сверху
+ точка 5 справа посередине
+ точка 6 справа снизуВведите букву: %sВведите цифру: %s
@@ -68,7 +77,7 @@
ЦифрыСпециальные символы
-
+
\“далее\”
справа.
-
+ &
По умолчанию выдаются только карточки с символами, изученными в разделе \"теория\". Чтобы
повторять любые символы, измените это в настройках приложения.
-
+ & Выход в меню приложения - кнопка вверху слева.
-
+ & Список колод - кнопка вверху справа.
-
+ &
Карточки объединены в колоды по типам символов, например, колода русских букв, колода цифр.
Эта кнопка ведёт в меню выбора колоды.
-
+ & Вызов справки - кнопка вверху справа, левее списка колод.
-
+ &
Если Вы забыли символ, можно нажать кнопку \"подсказка\" слева внизу экрана.
По нажатию этой кнопки будет выведено сообщение с верными номерами точек, шеститочие будет
заполнено правильными точками и недоступно для переключения. После этого нужно нажать кнопку
@@ -127,22 +136,22 @@
Обучение системе Луи Брайля: главное меню.
-
+ &
Теория: пошаговые уроки с демонстрацией плоскопечатных и
рельефно-точечных символов крупным шрифтом, вводом символов и поясняющими комментариями.
-
+ & Практика: Повторение символов.
-
+ & Настройки: Параметры приложения.
-
+ &
В настройках можно включить ещё одну кнопку - \"сканировать QR-код\".
-
+ & Сканировать QR-код: если у Вас есть набор карточек с текстом Брайля и
QR-кодами на обороте, по нажатию кнопки вы можете отсканировать QR-код и проверить,
что написано на карточке. Для этого необходимо дополнительное приложение.
Если его ещё нет, по нажатию кнопки Вы будете перенаправлены на страницу для скачивания приложения.
-
+ &
Находясь в любом разделе приложения, Вы всегда можете вызвать справку по данному разделу,
нажав экранную кнопку \"справка\" в правом верхнем углу экрана.
]]>
@@ -167,8 +176,8 @@
ТекстЗаключение
- Ввод точек
- Ввод точек
+ Введите точки
+ Введите точкиИзучениеТочкиУроки
@@ -176,7 +185,7 @@
+ &
%s
]]>
@@ -185,28 +194,30 @@
Переход к следующему шагу - кнопка \"вперёд\" справа по центру,
к предыдущему - кнопка назад слева по центру.
-
+ & Выход в меню приложения - кнопка \"перейти вверх\" в верхней панели слева.
-
+ & Вызов справки - кнопка в верхней панели справа.
-
+ & \"Другие функции\" - кнопка в верхней панели рядом с кнопкой \"справка\".
Нажатие этой кнопки вызывает выпадающее меню с функциями \"навигация по курсу\", то есть
переход к другому уроку, и \"к текущему шагу\", то есть переход к последнему
непройденному шагу.
-
+ &
Чтобы урок стал доступен в меню \"навигация по курсу\", надо пройти все шаги в
- предыдущих уроках. В уроке обычно от 20 до 30 шагов.
+ предыдущих уроках. В уроке обычно от 20 до 30 шагов. Заголовок шага содержит номер урока,
+ затем номер шага после точки с запятой, затем тип шага: \"введите точки\", или \"точки\"
+ (то есть демонстрация символа), или \"текст\".
]]>
шаг с вводом символа.
-
+ &
В верхней половине экрана крупным шрифтом выведен символ, который нужно ввести в шеститочии
в нижней половине экрана.
-
+ &
Над кнопкой "назад" находится кнопка подсказки, она работает так же, как и в практике.
]]>
@@ -313,13 +324,12 @@
Автоматически озвучивать длинные тексты (например, в справке и разделе \"теория\")
средством экранного чтения, не дожидаясь фокусировки на текстовом поле.
-
- Добавочные кнопки навигации
+
+ Режим повышенной доступности
-
- В главном меню кнопка \"Выход из приложения\", в разделе \"Теория\" -
- кнопка \"Скрыть это меню\" в списке \"Другие функции\" (удобно при использовании программы
- экранного доступа).
+
+ Крупный шрифт в разделе \"теория\". Дополнительные кнопки выхода (удобно при использовании программы
+ экранного доступа). Шире боковые кнопки в практике и теории.
Опция \"Сканирование QR-кода\"
diff --git a/android/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
similarity index 100%
rename from android/app/src/main/res/values/styles.xml
rename to app/src/main/res/values/styles.xml
diff --git a/android/app/src/main/res/xml/settings_hierarchy.xml b/app/src/main/res/xml/settings_hierarchy.xml
similarity index 93%
rename from android/app/src/main/res/xml/settings_hierarchy.xml
rename to app/src/main/res/xml/settings_hierarchy.xml
index 19501773..8ef1e57d 100644
--- a/android/app/src/main/res/xml/settings_hierarchy.xml
+++ b/app/src/main/res/xml/settings_hierarchy.xml
@@ -9,6 +9,30 @@
android:title="@string/preference_title_only_seen_materials"
app:iconSpaceReserved="false" />
+
+
+
+
+
+
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/build.gradle b/build.gradle
similarity index 92%
rename from android/build.gradle
rename to build.gradle
index d707e6b3..ba99822f 100644
--- a/android/build.gradle
+++ b/build.gradle
@@ -13,7 +13,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.5.3'
+ classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:$version_navigation"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
diff --git a/android/gradle.properties b/gradle.properties
similarity index 100%
rename from android/gradle.properties
rename to gradle.properties
diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
similarity index 100%
rename from android/gradle/wrapper/gradle-wrapper.jar
rename to gradle/wrapper/gradle-wrapper.jar
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
similarity index 78%
rename from android/gradle/wrapper/gradle-wrapper.properties
rename to gradle/wrapper/gradle-wrapper.properties
index 4a2a138a..9fa69657 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Fri Feb 07 01:30:12 MSK 2020
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
+#Thu Jun 25 00:38:40 MSK 2020
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
diff --git a/android/gradlew b/gradlew
old mode 100755
new mode 100644
similarity index 100%
rename from android/gradlew
rename to gradlew
diff --git a/android/gradlew.bat b/gradlew.bat
similarity index 100%
rename from android/gradlew.bat
rename to gradlew.bat
diff --git a/android/settings.gradle b/settings.gradle
similarity index 100%
rename from android/settings.gradle
rename to settings.gradle