Let the Model be ignorant of the view

strings are strings
main
Alexis Drai 3 years ago
parent 976abc2e25
commit 2379243f81

@ -1,6 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="R52MA0DTKCR" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-10-03T08:49:19.257046Z" />
<runningDeviceTargetsSelectedWithDialog>
<Target>
<type value="RUNNING_DEVICE_TARGET" />

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.CAMERA"/>
<application
android:allowBackup="true"

@ -14,7 +14,8 @@ class QuizActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_quiz)
val questions = Stub().loadQuestions()
val questions = Stub().loadQuestions(resources)
val textViewQuestion = findViewById<TextView>(R.id.textViewQuestion)
val btnNext = findViewById<Button>(R.id.btnNext)
val btnRestart = findViewById<Button>(R.id.btnRestart)
@ -42,7 +43,7 @@ class QuizActivity : AppCompatActivity() {
if (iterator.hasNext()) {
val obj: TrueFalseQuestion = iterator.next()
textView.text = resources.getString(obj.question)
textView.text = obj.question
val correct: Button
val wrong: Button
@ -63,8 +64,6 @@ class QuizActivity : AppCompatActivity() {
resources.getString(R.string.wrong_answer)
)
} else {
textView.text = resources.getString(R.string.no_more_questions)
}
}

@ -1,16 +1,15 @@
package fr.iut.pm.data
import android.content.res.Resources
import fr.iut.pm.R
import fr.iut.pm.model.TrueFalseQuestion
class Stub {
fun loadQuestions(): Collection<TrueFalseQuestion> {
fun loadQuestions(resources: Resources): Collection<TrueFalseQuestion> {
return listOf(
TrueFalseQuestion(R.string.question1, true),
TrueFalseQuestion(R.string.question2, false),
TrueFalseQuestion(R.string.question3, true)
TrueFalseQuestion(resources.getString(R.string.question1), true),
TrueFalseQuestion(resources.getString(R.string.question2), false),
TrueFalseQuestion(resources.getString(R.string.question3), true),
)
}
}

@ -1,3 +1,3 @@
package fr.iut.pm.model
class TrueFalseQuestion(val question: Int, val answer: Boolean)
class TrueFalseQuestion(val question: String, val answer: Boolean)

@ -8,6 +8,5 @@
<string name="correct_answer">Oui!</string>
<string name="wrong_answer">Kwô?</string>
<string name="next_question_btn">SUIVANTE</string>
<string name="no_more_questions">Fin des questions</string>
<string name="restart_btn">RECOMMENCER</string>
</resources>

@ -3,13 +3,12 @@
<string name="in_the_middle">Right in the middle</string>
<string name="false_btn">FALSE</string>
<string name="true_btn">TRUE</string>
<string name="question1" translatable="false">Yo mama... something something</string>
<string name="lorem_ipsum">Lorem ipsum dolor sit amet</string>
<string name="correct_answer">That\'s right!</string>
<string name="wrong_answer">U wot m8?</string>
<string name="next_question_btn">NEXT</string>
<string name="question1" translatable="false">Yo mama... something something</string>
<string name="question2" translatable="false">My mama... yada yada yada</string>
<string name="question3" translatable="false">Their mama... blah blah</string>
<string name="no_more_questions">No further questions</string>
<string name="restart_btn">RESTART</string>
</resources>
Loading…
Cancel
Save