feat : Page Quiz multi + debut chrono et progressBar

androidCompose
Yvan CALATAYUD 1 year ago
parent f08b3d1a23
commit 781d98f71c

@ -23,5 +23,6 @@
<activity android:name=".ServerDetailsActivity" />
<activity android:name=".CreateLobbyActivity" />
<activity android:name=".ConnexionPlayerActivity" />
<activity android:name=".QuizMultiActivity" />
</application>
</manifest>

@ -22,6 +22,8 @@ class MainActivity : AppCompatActivity() {
btnSolo.setOnClickListener {
// Traitement pour le bouton Solo
// Vous pouvez ajouter le code correspondant ici
val intent = Intent(this, QuizMultiActivity::class.java)
startActivity(intent)
}
btnMulti.setOnClickListener {

@ -0,0 +1,64 @@
package com.example.mathseduc
import android.os.Bundle
import android.os.CountDownTimer
import android.widget.Button
import android.widget.ProgressBar
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
class QuizMultiActivity : AppCompatActivity() {
private lateinit var countDownTimer: CountDownTimer
var progressBarValue : Int = 0
var chronoValue : Int = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_quiz_multi)
var progressBar1 = findViewById<ProgressBar>(R.id.progressBar1)
var chrono = findViewById<ProgressBar>(R.id.chrono)
progressBar1.max = 100
chrono.max = 30
var incrementeButton = findViewById<Button>(R.id.buttonValider)
// Initialiser le CountDownTimer
countDownTimer = object : CountDownTimer(30*1000, 1000) {
override fun onTick(millisUntilFinished: Long) {
// Incrémenter la valeur de la ProgressBar chaque seconde
chronoValue++
chrono.progress = chronoValue
progressBarValue++
progressBar1.progress = progressBarValue
}
override fun onFinish() {
// Code à exécuter lorsque le timer est terminé
}
}
incrementeButton.setOnClickListener {
progressBarValue += 10
progressBar1.progress = progressBarValue
}
// Démarrer le CountDownTimer
countDownTimer.start()
}
override fun onDestroy() {
super.onDestroy()
// Arrêter le CountDownTimer pour éviter les fuites de mémoire
countDownTimer.cancel()
}
}

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<shape android:shape="ring"
android:thickness="10dp"
android:useLevel="false">
<solid android:color="@color/black"/>
</shape>
</item>
<item android:id="@+id/chrono">
<shape android:shape="ring"
android:thickness="10dp"
android:useLevel="true">
<solid android:color="@color/white"/>
</shape>
</item>
</layer-list>

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- View border color and width -->
<stroke
android:width="1dp"
android:color="@color/white" >
</stroke>
<!-- The radius makes the corners rounded -->
<corners
android:radius="2dp" >
</corners>
</shape>

@ -0,0 +1,204 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ProgressBar
android:id="@+id/progressBar1"
android:layout_weight="0.05"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ProgressBar
android:id="@+id/progressBar2"
android:layout_weight="0.05"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ProgressBar
android:id="@+id/progressBar3"
android:layout_weight="0.05"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ProgressBar
android:id="@+id/progressBar4"
android:layout_weight="0.05"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ProgressBar
android:id="@+id/chrono"
android:layout_weight="0.05"
android:paddingHorizontal="10dp"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateOnly="false"
android:rotation="-90"
android:progressDrawable="@drawable/chrono"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingVertical="20dp"
android:orientation="horizontal">
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@drawable/question_border"
android:gravity="center"
android:text="Question"
android:layout_weight="5"
android:textColor="@color/white"
android:textSize="20sp" />
<Space
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:orientation="horizontal">
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25" />
<Button
android:id="@+id/button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="@color/blue"
android:text="Answer1" />
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5" />
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="@color/green"
android:text="Answer2" />
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25" />
<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="@color/orange"
android:text="Answer3" />
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5" />
<Button
android:id="@+id/button4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="@color/purple_500"
android:text="Answer4" />
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal">
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:id="@+id/buttonPasser"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="@color/red"
android:text="Passer" />
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.25" />
<Button
android:id="@+id/buttonValider"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="@color/green"
android:text="Valider" />
<Space
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>

@ -11,4 +11,5 @@
<color name="orange">#FFA500</color>
<color name="grey">#8C92AC</color>
<color name="blue">#0d6efd</color>
<color name="red">#FF0000</color>
</resources>
Loading…
Cancel
Save