commit
976abc2e25
@ -0,0 +1,123 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<option name="FORCE_REARRANGE_MODE" value="1" />
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
<arrangement>
|
||||
<rules>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:android</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:id</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
</rules>
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<runningDeviceTargetsSelectedWithDialog>
|
||||
<Target>
|
||||
<type value="RUNNING_DEVICE_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="SERIAL_NUMBER" />
|
||||
<value value="R52MA0DTKCR" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</runningDeviceTargetsSelectedWithDialog>
|
||||
<targetsSelectedWithDialog>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="C:\Users\draia\.android\avd\Pixel_3a_API_33_x86_64.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</targetsSelectedWithDialog>
|
||||
</component>
|
||||
</project>
|
@ -1,11 +1,71 @@
|
||||
package fr.iut.pm
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import fr.iut.pm.data.Stub
|
||||
import fr.iut.pm.model.TrueFalseQuestion
|
||||
|
||||
|
||||
class QuizActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_quiz)
|
||||
|
||||
val questions = Stub().loadQuestions()
|
||||
val textViewQuestion = findViewById<TextView>(R.id.textViewQuestion)
|
||||
val btnNext = findViewById<Button>(R.id.btnNext)
|
||||
val btnRestart = findViewById<Button>(R.id.btnRestart)
|
||||
|
||||
var iterator = questions.iterator()
|
||||
nextQuestion(textViewQuestion, iterator)
|
||||
|
||||
btnNext.setOnClickListener {
|
||||
nextQuestion(textViewQuestion, iterator)
|
||||
}
|
||||
|
||||
btnRestart.setOnClickListener {
|
||||
iterator = questions.iterator()
|
||||
nextQuestion(textViewQuestion, iterator)
|
||||
}
|
||||
}
|
||||
|
||||
private fun assignAnswerToButton(btn: Button, toast: String) {
|
||||
btn.setOnClickListener {
|
||||
Toast.makeText(this, toast, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
private fun nextQuestion(textView: TextView, iterator: Iterator<TrueFalseQuestion>) {
|
||||
if (iterator.hasNext()) {
|
||||
|
||||
val obj: TrueFalseQuestion = iterator.next()
|
||||
textView.text = resources.getString(obj.question)
|
||||
|
||||
val correct: Button
|
||||
val wrong: Button
|
||||
|
||||
if (obj.answer) {
|
||||
correct = findViewById(R.id.btnTrue)
|
||||
wrong = findViewById(R.id.btnFalse)
|
||||
} else {
|
||||
correct = findViewById(R.id.btnFalse)
|
||||
wrong = findViewById(R.id.btnTrue)
|
||||
}
|
||||
assignAnswerToButton(
|
||||
correct,
|
||||
resources.getString(R.string.correct_answer)
|
||||
)
|
||||
assignAnswerToButton(
|
||||
wrong,
|
||||
resources.getString(R.string.wrong_answer)
|
||||
)
|
||||
|
||||
} else {
|
||||
textView.text = resources.getString(R.string.no_more_questions)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package fr.iut.pm.data
|
||||
|
||||
import fr.iut.pm.R
|
||||
import fr.iut.pm.model.TrueFalseQuestion
|
||||
|
||||
class Stub {
|
||||
fun loadQuestions(): Collection<TrueFalseQuestion> {
|
||||
|
||||
|
||||
return listOf(
|
||||
TrueFalseQuestion(R.string.question1, true),
|
||||
TrueFalseQuestion(R.string.question2, false),
|
||||
TrueFalseQuestion(R.string.question3, true)
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
package fr.iut.pm.model
|
||||
|
||||
class TrueFalseQuestion(val question: Int, val answer: Boolean)
|
@ -1,58 +1,80 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="400dp"
|
||||
android:layout_gravity="center"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textViewQuestion"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/lorem_ipsum" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/btnLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/TVQuestion"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/question" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnTrue"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_margin="10dp"
|
||||
android:text="@string/true_btn" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnFalse"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_margin="10dp"
|
||||
android:text="@string/false_btn"
|
||||
app:layout_constraintLeft_toRightOf="@+id/btnTrue" />
|
||||
</LinearLayout>
|
||||
android:orientation="horizontal">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnTrue"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="10dp"
|
||||
android:backgroundTint="#888"
|
||||
android:text="@string/true_btn"
|
||||
android:textColor="@color/black"
|
||||
style="?android:attr/buttonBarButtonStyle" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnFalse"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="10dp"
|
||||
android:backgroundTint="#888"
|
||||
android:text="@string/false_btn"
|
||||
android:textColor="@color/black"
|
||||
style="?android:attr/buttonBarButtonStyle" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
<Button
|
||||
android:id="@+id/btnNext"
|
||||
android:layout_width="220dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="10dp"
|
||||
android:backgroundTint="#848"
|
||||
android:text="@string/next_question_btn"
|
||||
android:textColor="@color/black" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnRestart"
|
||||
android:layout_width="220dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="10dp"
|
||||
android:backgroundTint="#f88"
|
||||
android:text="@string/restart_btn"
|
||||
android:textColor="@color/black" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Quiz</string>
|
||||
<string name="in_the_middle">En plein milieu</string>
|
||||
<string name="false_btn">FAUX</string>
|
||||
<string name="true_btn">VRAI</string>
|
||||
<string name="lorem_ipsum">Lorem ipsum dolor sit amet</string>
|
||||
<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>
|
@ -1,7 +1,15 @@
|
||||
<resources>
|
||||
<string name="app_name">Quiz</string>
|
||||
<string name="in_the_middle">En plein milieu</string>
|
||||
<string name="in_the_middle">Right in the middle</string>
|
||||
<string name="false_btn">FALSE</string>
|
||||
<string name="true_btn">TRUE</string>
|
||||
<string name="question">azizugd aoidg azuig dapzazuopg dp</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="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…
Reference in new issue