@@ -21,13 +21,13 @@ import java.util.UUID
2121class LetterSoundActivity : AppCompatActivity () {
2222
2323 private val TAG = " LetterSoundActivity"
24- private var wordsWith3Letters : MutableList <WordGson >? = null
24+ private var wordsWith3LetterSounds : MutableList <WordGson >? = null
2525
2626 private var wordsSeen: MutableList <WordGson ?>? = null
2727
28- private var word1TextView : TextView ? = null
29- private var word2TextView : TextView ? = null
30- private var word3TextView : TextView ? = null
28+ private var letter1TextView : TextView ? = null
29+ private var letter2TextView : TextView ? = null
30+ private var letter3TextView : TextView ? = null
3131
3232 private var nextButton: ImageButton ? = null
3333 private lateinit var ttsViewModel: TextToSpeechViewModel
@@ -42,9 +42,9 @@ class LetterSoundActivity : AppCompatActivity() {
4242
4343 wordsSeen = ArrayList <WordGson ?>()
4444
45- word1TextView = findViewById<View ?>(R .id.word1TextView ) as TextView
46- word2TextView = findViewById<View ?>(R .id.word2TextView ) as TextView
47- word3TextView = findViewById<View ?>(R .id.word3TextView ) as TextView
45+ letter1TextView = findViewById<View ?>(R .id.letter1TextView ) as TextView
46+ letter2TextView = findViewById<View ?>(R .id.letter2TextView ) as TextView
47+ letter3TextView = findViewById<View ?>(R .id.letter3TextView ) as TextView
4848
4949 nextButton = findViewById<View ?>(R .id.nextButton) as ImageButton
5050 nextButton!! .setOnClickListener(object : View .OnClickListener {
@@ -55,29 +55,22 @@ class LetterSoundActivity : AppCompatActivity() {
5555 }
5656 })
5757
58- val allWords: List <WordGson > =
59- getAllWordGsons(applicationContext, BuildConfig .CONTENT_PROVIDER_APPLICATION_ID )
60- // TODO: dynamically fetch words that only contain the student's unlocked letter-sound correspondences
61- Log .i(TAG , " allWords.size(): " + allWords.size)
58+ val allWords: List <WordGson > = getAllWordGsons(applicationContext, BuildConfig .CONTENT_PROVIDER_APPLICATION_ID )
59+ Log .i(TAG , " allWords.size: " + allWords.size)
6260
63- // TODO: filter words by SpellingConsistency?
64- wordsWith3Letters = ArrayList <WordGson >()
61+ wordsWith3LetterSounds = ArrayList <WordGson >()
6562 for (word in allWords) {
66- Log .i(
67- TAG ,
68- " word.getText(): " + word.text + " , word.getWordType(): " + word.wordType
69- )
70-
71- // TODO: dynamically start with shorter words, then gradually increase length
72- if (word.text.length == 3 ) {
73- wordsWith3Letters!! .add(word)
63+ Log .i(TAG , " word: " + word + " , word.wordType: " + word.wordType)
64+
65+ if (word.letterSounds.size == 3 ) {
66+ wordsWith3LetterSounds!! .add(word)
7467 }
7568
76- if (wordsWith3Letters !! .size == 10 ) {
69+ if (wordsWith3LetterSounds !! .size == 10 ) {
7770 break
7871 }
7972 }
80- Log .i(TAG , " wordsWith3Letters .size() : " + wordsWith3Letters !! .size)
73+ Log .i(TAG , " wordsWith3LetterSounds .size: " + wordsWith3LetterSounds !! .size)
8174 }
8275
8376 override fun onStart () {
@@ -90,57 +83,57 @@ class LetterSoundActivity : AppCompatActivity() {
9083 private fun loadNextWord () {
9184 Log .i(TAG , " loadNextWord" )
9285
93- if (wordsSeen!! .size == wordsWith3Letters !! .size) {
86+ if (wordsSeen!! .size == wordsWith3LetterSounds !! .size) {
9487 // TODO: show congratulations page
9588 finish()
9689 return
9790 }
9891
99- word1TextView !! .visibility = View .INVISIBLE
100- word2TextView !! .visibility = View .INVISIBLE
101- word3TextView !! .visibility = View .INVISIBLE
92+ letter1TextView !! .visibility = View .INVISIBLE
93+ letter2TextView !! .visibility = View .INVISIBLE
94+ letter3TextView !! .visibility = View .INVISIBLE
10295 nextButton!! .setVisibility(View .INVISIBLE )
10396
104- val currentWord = wordsWith3Letters !! [wordsSeen!! .size]
105- Log .i(TAG , " currentWord.getText() : " + currentWord.text )
97+ val currentWord = wordsWith3LetterSounds !! [wordsSeen!! .size]
98+ Log .i(TAG , " currentWord: " + currentWord)
10699
107- word1TextView !! .postDelayed(object : Runnable {
100+ letter1TextView !! .postDelayed(object : Runnable {
108101 override fun run () {
109102 val letter1 = currentWord.text.substring(0 , 1 )
110103 Log .i(TAG , " letter1: $letter1 " )
111- word1TextView !! .text = letter1
104+ letter1TextView !! .text = " ${ letter1} "
112105
113106 val letter2 = currentWord.text.substring(1 , 2 )
114107 Log .i(TAG , " letter2: $letter2 " )
115- word2TextView !! .text = letter2
108+ letter2TextView !! .text = " ${ letter2} "
116109
117110 val letter3 = currentWord.text.substring(2 , 3 )
118111 Log .i(TAG , " letter3: $letter3 " )
119- word3TextView !! .text = letter3
112+ letter3TextView !! .text = " ${ letter3} "
120113
121- word1TextView !! .visibility = View .VISIBLE
122- word1TextView !! .postDelayed(object : Runnable {
114+ letter1TextView !! .visibility = View .VISIBLE
115+ letter1TextView !! .postDelayed(object : Runnable {
123116 override fun run () {
124117 playLetterSound(letter1)
125118
126119
127- word2TextView !! .postDelayed(object : Runnable {
120+ letter2TextView !! .postDelayed(object : Runnable {
128121 override fun run () {
129- word2TextView !! .visibility = View .VISIBLE
130- word2TextView !! .postDelayed(object : Runnable {
122+ letter2TextView !! .visibility = View .VISIBLE
123+ letter2TextView !! .postDelayed(object : Runnable {
131124 override fun run () {
132125 playLetterSound(letter2)
133126
134127
135- word3TextView !! .postDelayed(object : Runnable {
128+ letter3TextView !! .postDelayed(object : Runnable {
136129 override fun run () {
137- word3TextView !! .visibility = View .VISIBLE
138- word3TextView !! .postDelayed(object : Runnable {
130+ letter3TextView !! .visibility = View .VISIBLE
131+ letter3TextView !! .postDelayed(object : Runnable {
139132 override fun run () {
140133 playLetterSound(letter3)
141134
142135
143- word3TextView !! .postDelayed(object :
136+ letter3TextView !! .postDelayed(object :
144137 Runnable {
145138 override fun run () {
146139 playWord(currentWord)
0 commit comments