Skip to content

Commit c392030

Browse files
authored
Merge pull request #90 from elimu-ai/content-provider-1.4.66
Content provider 1.4.66
2 parents df83f89 + 52d2e7c commit c392030

File tree

3 files changed

+39
-46
lines changed

3 files changed

+39
-46
lines changed

app/src/main/java/ai/elimu/maneno/LetterSoundActivity.kt

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ import java.util.UUID
2121
class 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)

app/src/main/res/layout/activity_letter_sound.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@
3232
android:animateLayoutChanges="true">
3333

3434
<TextView
35-
android:id="@+id/word1TextView"
35+
android:id="@+id/letter1TextView"
3636
android:layout_width="wrap_content"
3737
android:layout_height="wrap_content"
3838
android:padding="@dimen/activity_horizontal_margin"
3939
tools:text="c"
4040
android:textSize="128sp" />
4141

4242
<TextView
43-
android:id="@+id/word2TextView"
43+
android:id="@+id/letter2TextView"
4444
android:layout_width="wrap_content"
4545
android:layout_height="wrap_content"
4646
android:padding="@dimen/activity_horizontal_margin"
4747
tools:text="a"
4848
android:textSize="128sp" />
4949

5050
<TextView
51-
android:id="@+id/word3TextView"
51+
android:id="@+id/letter3TextView"
5252
android:layout_width="wrap_content"
5353
android:layout_height="wrap_content"
5454
android:padding="@dimen/activity_horizontal_margin"

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
elimuContentProvider = "1.4.65"
2+
elimuContentProvider = "1.4.66"
33
junit = "4.13.2"
44
appCompat = "1.7.1"
55
cardview = "1.0.0"

0 commit comments

Comments
 (0)