Merge branch 'master' of https://codefirst.iut.uca.fr/git/jade.van_brabandt/3.01-QCM_MuscuMaths
continuous-integration/drone/push Build is passing Details

master
BelsethUwU 1 year ago
commit b1e79e1689

@ -10,7 +10,7 @@ android {
defaultConfig { defaultConfig {
applicationId "com.example.mathseduc" applicationId "com.example.mathseduc"
minSdk 21 minSdk 21
targetSdk 34 targetSdk 33
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
@ -34,7 +34,6 @@ android {
} }
dependencies { dependencies {
implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0' implementation 'com.google.android.material:material:1.11.0'
@ -44,4 +43,5 @@ dependencies {
implementation("com.squareup.okhttp3:okhttp:4.10.0") implementation("com.squareup.okhttp3:okhttp:4.10.0")
implementation("com.google.code.gson:gson:2.10.1") implementation("com.google.code.gson:gson:2.10.1")
implementation "org.mindrot:jbcrypt:0.4"
} }

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

@ -0,0 +1,79 @@
package com.example.mathseduc
import android.app.AlertDialog
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.ImageButton
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.example.mathseduc.controllers.ControllerPlayer
class ConnexionPlayerActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_connexion_player)
val buttonLogin = findViewById<Button>(R.id.buttonLogin)
val editTextNickname = findViewById<EditText>(R.id.editTextNickname)
val editTextPassword = findViewById<EditText>(R.id.editTextPassword)
buttonLogin.setOnClickListener {
val nickname = editTextNickname.text.toString()
val password = editTextPassword.text.toString()
val isAuthenticated = ControllerPlayer.authenticateUser(nickname,password)
if (isAuthenticated != -1) {
// Save authentication status for global accessibility
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
MainActivity.idPlayerConnected = isAuthenticated
Toast.makeText(this, "Connexion réussi, bienvenue $nickname !", Toast.LENGTH_SHORT).show()
} else {
// Show an error toast
Toast.makeText(this, "Connexion échoué. Veuillez réessayer.", Toast.LENGTH_SHORT).show()
}
}
val btnReturn = findViewById<ImageButton>(R.id.btnReturn)
val btnRegister = findViewById<Button>(R.id.registerButton)
btnReturn.setOnClickListener {
//val intent = Intent(this, MainActivity::class.java)
//startActivity(intent)
this.finish();
}
btnRegister.setOnClickListener {
showRegisterDialog()
}
}
private fun showRegisterDialog() {
val builder = AlertDialog.Builder(this)
val inflater = layoutInflater
val dialogView = inflater.inflate(R.layout.dialog_register, null)
val etNickname = dialogView.findViewById<EditText>(R.id.nickname)
val etPassword = dialogView.findViewById<EditText>(R.id.password)
val btnSave = dialogView.findViewById<Button>(R.id.buttonSave)
val btnDismiss = dialogView.findViewById<Button>(R.id.buttonDismiss)
val dialog = builder.setView(dialogView).create()
btnSave.setOnClickListener {
val nickname = etNickname.text.toString()
val password = etPassword.text.toString()
// Faites quelque chose avec le nom d'utilisateur et le mot de passe
dialog.dismiss()
}
btnDismiss.setOnClickListener {
dialog.dismiss()
}
dialog.show()
}
}

@ -6,6 +6,7 @@ import android.widget.*
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.example.mathseduc.controllers.ControllerChapter import com.example.mathseduc.controllers.ControllerChapter
import com.example.mathseduc.controllers.ControllerLobby import com.example.mathseduc.controllers.ControllerLobby
import com.example.mathseduc.controllers.ControllerUtiliser
import okhttp3.MultipartBody import okhttp3.MultipartBody
import org.json.JSONObject import org.json.JSONObject
@ -51,16 +52,25 @@ class CreateLobbyActivity : AppCompatActivity() {
formDataBuilder.addFormDataPart("name", lobbyName) formDataBuilder.addFormDataPart("name", lobbyName)
formDataBuilder.addFormDataPart("password", password) formDataBuilder.addFormDataPart("password", password)
formDataBuilder.addFormDataPart("nbplayers", nbPlayers.toString()) formDataBuilder.addFormDataPart("nbplayers", nbPlayers.toString())
formDataBuilder.addFormDataPart("idplayercreator", "53") formDataBuilder.addFormDataPart("idplayercreator", MainActivity.idPlayerConnected.toString())
formDataBuilder.addFormDataPart("idchapter", idChapter.toString()) formDataBuilder.addFormDataPart("idchapter", idChapter.toString())
formDataBuilder.addFormDataPart("difficulty", difficulty.toString()) formDataBuilder.addFormDataPart("difficulty", difficulty.toString())
// Appeler la fonction pour créer le lobby // Appeler la fonction pour créer le lobby
val lobbyCreatedSuccessfully = ControllerLobby.createLobby(formDataBuilder) val idLobbyCreatedSuccessfully = ControllerLobby.createLobby(formDataBuilder)
// Vérifier si la création du lobby a réussi // Vérifier si la création du lobby a réussi
if (lobbyCreatedSuccessfully) { if (idLobbyCreatedSuccessfully != -1) {
val formDataBuilder = MultipartBody.Builder().setType(MultipartBody.FORM)
formDataBuilder.addFormDataPart("idplayer", MainActivity.idPlayerConnected.toString())
formDataBuilder.addFormDataPart("idlobby", idLobbyCreatedSuccessfully.toString())
formDataBuilder.addFormDataPart("playertime", "0")
ControllerUtiliser.createUtiliserByIdLobby(formDataBuilder)
val intent = Intent(this, ServerDetailsActivity::class.java) val intent = Intent(this, ServerDetailsActivity::class.java)
intent.putExtra("serverName", lobbyName)
intent.putExtra("lobbyId", idLobbyCreatedSuccessfully)
startActivity(intent) startActivity(intent)
} else { } else {
Toast.makeText(this, "Échec de la création du lobby. Veuillez réessayer.", Toast.LENGTH_SHORT).show() Toast.makeText(this, "Échec de la création du lobby. Veuillez réessayer.", Toast.LENGTH_SHORT).show()

@ -3,24 +3,43 @@ package com.example.mathseduc
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.widget.Button import android.widget.Button
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
companion object {
var idPlayerConnected: Int = -1
}
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
var btnSolo = findViewById<Button>(R.id.btnSolo) val btnSolo = findViewById<Button>(R.id.btnSolo)
var btnMulti = findViewById<Button>(R.id.btnMulti) val btnMulti = findViewById<Button>(R.id.btnMulti)
val btnConnexion = findViewById<Button>(R.id.btnConnexion)
btnSolo.setOnClickListener { btnSolo.setOnClickListener {
// Traitement pour le bouton Solo // Traitement pour le bouton Solo
// Vous pouvez ajouter le code correspondant ici // Vous pouvez ajouter le code correspondant ici
val intent = Intent(this, QuizMultiActivity::class.java)
startActivity(intent)
} }
btnMulti.setOnClickListener { btnMulti.setOnClickListener {
val intent = Intent(this, MultiActivity::class.java) if (MainActivity.idPlayerConnected != -1){
val intent = Intent(this, MultiActivity::class.java)
startActivity(intent)
}
else {
Toast.makeText(this, "Vous n'êtes pas connecté", Toast.LENGTH_SHORT).show()
val intent = Intent(this, ConnexionPlayerActivity::class.java)
startActivity(intent)
}
}
btnConnexion.setOnClickListener {
val intent = Intent(this, ConnexionPlayerActivity::class.java)
startActivity(intent) startActivity(intent)
} }
} }

@ -3,20 +3,26 @@ package com.example.mathseduc
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ArrayAdapter import android.widget.*
import android.widget.Button
import android.widget.ListView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.example.mathseduc.controllers.ControllerChapter
import com.example.mathseduc.controllers.ControllerLobby import com.example.mathseduc.controllers.ControllerLobby
import com.example.mathseduc.controllers.ControllerUtiliser
import com.example.mathseduc.models.Lobby import com.example.mathseduc.models.Lobby
import okhttp3.MultipartBody
class MultiActivity : AppCompatActivity() { class MultiActivity : AppCompatActivity() {
private lateinit var lobbyAdapter: LobbyAdapter
private val handler = Handler(Looper.getMainLooper())
private val refreshInterval: Long = 3000 // Refresh every 3 seconds
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_multi) setContentView(R.layout.activity_multi)
@ -29,14 +35,30 @@ class MultiActivity : AppCompatActivity() {
val listView = findViewById<ListView>(R.id.listView) val listView = findViewById<ListView>(R.id.listView)
val adapter = LobbyAdapter(this, serverList) lobbyAdapter = LobbyAdapter(this, serverList)
listView.adapter = adapter listView.adapter = lobbyAdapter
listView.setOnItemClickListener { _, _, position, _ -> listView.setOnItemClickListener { _, _, position, _ ->
val intent = Intent(this, ServerDetailsActivity::class.java) if (ControllerLobby.getNbPlayerInLobby(serverList[position].id) < serverList[position].nbplayers) {
intent.putExtra("serverName", serverList[position].name) val formDataBuilder = MultipartBody.Builder().setType(MultipartBody.FORM)
startActivity(intent) formDataBuilder.addFormDataPart("idplayer", MainActivity.idPlayerConnected.toString())
formDataBuilder.addFormDataPart("idlobby", serverList[position].id.toString())
formDataBuilder.addFormDataPart("playertime", "0")
ControllerUtiliser.createUtiliserByIdLobby(formDataBuilder)
val intent = Intent(this, ServerDetailsActivity::class.java)
intent.putExtra("serverName", serverList[position].name)
intent.putExtra("lobbyId", serverList[position].id)
startActivity(intent)
} else {
Toast.makeText(this, "Oh nan, le serveur est déjà plein ! Réessayer plus tard.", Toast.LENGTH_SHORT).show()
}
} }
// Schedule periodic refresh using Handler and Runnable
handler.postDelayed(refreshRunnable, refreshInterval)
} else { } else {
Log.e("MultiActivity", "Error fetching server list") Log.e("MultiActivity", "Error fetching server list")
} }
@ -45,14 +67,43 @@ class MultiActivity : AppCompatActivity() {
val intent = Intent(this, CreateLobbyActivity::class.java) val intent = Intent(this, CreateLobbyActivity::class.java)
startActivity(intent) startActivity(intent)
} }
val btnReturn = findViewById<ImageButton>(R.id.btnReturn)
btnReturn.setOnClickListener {
//val intent = Intent(this, MainActivity::class.java)
//startActivity(intent)
finish()
}
}
override fun onDestroy() {
super.onDestroy()
// Remove callbacks to prevent memory leaks
handler.removeCallbacks(refreshRunnable)
}
private val refreshRunnable: Runnable = object : Runnable {
override fun run() {
// Refresh the server list
val serverList = ControllerLobby.getLobbies()
if (serverList != null) {
lobbyAdapter.clear()
lobbyAdapter.addAll(serverList)
lobbyAdapter.notifyDataSetChanged()
}
// Schedule the next refresh
handler.postDelayed(this, refreshInterval)
}
} }
class LobbyAdapter(context: Context, lobbies: ArrayList<Lobby>): ArrayAdapter<Lobby>(context, 0, lobbies), View.OnClickListener { class LobbyAdapter(context: Context, lobbies: ArrayList<Lobby>) :
ArrayAdapter<Lobby>(context, 0, lobbies), View.OnClickListener {
private val mContext: Context private val mContext: Context
private val mLobbies: ArrayList<Lobby> private val mLobbies: ArrayList<Lobby>
private var selectedItem = -1; private var selectedItem = -1
// Get Access to Context and Data Array // Get Access to Context and Data Array
init { init {
@ -73,8 +124,6 @@ class MultiActivity : AppCompatActivity() {
} }
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
//return super.getView(position, convertView, parent)
var currentLobbyView = convertView var currentLobbyView = convertView
if (currentLobbyView == null) { if (currentLobbyView == null) {
currentLobbyView = currentLobbyView =
@ -87,33 +136,19 @@ class MultiActivity : AppCompatActivity() {
val difficulty = currentLobbyView!!.findViewById<TextView>(R.id.difficulty) val difficulty = currentLobbyView!!.findViewById<TextView>(R.id.difficulty)
name.text = mLobbies[position].name name.text = mLobbies[position].name
nbplayers.text = mLobbies[position].nbplayers.toString() nbplayers.text = ControllerLobby.getNbPlayerInLobby(mLobbies[position].id).toString() + "/" + mLobbies[position].nbplayers.toString()
idchapter.text = mLobbies[position].idchapter.toString() idchapter.text = ControllerChapter.getChapterNameById(mLobbies[position].idchapter)
difficulty.text = mLobbies[position].difficulty.toString() difficulty.text = mLobbies[position].difficulty.toString()
// Visual Feedback for Selection
/*
if (selectedItem == position)
currentLobbyView.setBackgroundColor(Color.rgb(255, 255, 128))
else
currentLobbyView.setBackgroundColor(Color.rgb(255, 255, 192))
if (mProducts[position].prixht != null)
pxht.text = "%.2f".format(mLobbies[position].prixht.toFloat()) + "€ HT"
else
pxht.text = "Gratuit !"
*/
return currentLobbyView return currentLobbyView
} }
public fun setSelectedItem(position: Int) { fun setSelectedItem(position: Int) {
selectedItem = position selectedItem = position
notifyDataSetChanged(); notifyDataSetChanged()
} }
public fun getSelectedItem(): Lobby? { fun getSelectedItem(): Lobby? {
if (selectedItem != -1) if (selectedItem != -1)
return mLobbies[selectedItem] return mLobbies[selectedItem]
else else

@ -0,0 +1,68 @@
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
import com.example.mathseduc.controllers.ControllerLobby
import com.example.mathseduc.controllers.ControllerQuestion
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)
val lobbyId = intent.getIntExtra("lobbyId", -1)
var progressBar1 = findViewById<ProgressBar>(R.id.progressBar1)
var chrono = findViewById<ProgressBar>(R.id.chrono)
progressBar1.max = 100
chrono.max = 30
val toto = ControllerQuestion.getQuestionsForLobby(ControllerLobby.getIdQuestionsLobby(lobbyId))
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()
}
}

@ -1,20 +1,159 @@
package com.example.mathseduc package com.example.mathseduc
import android.content.Context
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.Button
import android.widget.ListView
import android.widget.TextView import android.widget.TextView
import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.example.mathseduc.controllers.ControllerLobby
import com.example.mathseduc.controllers.ControllerPlayer
import com.example.mathseduc.controllers.ControllerUtiliser
import com.example.mathseduc.models.Player
import okhttp3.MultipartBody
class ServerDetailsActivity : AppCompatActivity() { class ServerDetailsActivity : AppCompatActivity() {
private var playerList: List<Player> = emptyList()
private lateinit var playerAdapter: PlayerAdapter
private val handler = Handler(Looper.getMainLooper())
private val refreshInterval: Long = 2000
private val onBackPressedCallback: OnBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
myBackPressed()
}
}
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
setContentView(R.layout.activity_server_details) setContentView(R.layout.activity_server_details)
val serverName = intent.getStringExtra("serverName") val serverName = intent.getStringExtra("serverName")
// Now you can use the data as needed, for example, display it in a TextView
val serverNameTextView = findViewById<TextView>(R.id.titleServerDetails) val serverNameTextView = findViewById<TextView>(R.id.titleServerDetails)
serverNameTextView.text = serverName serverNameTextView.text = serverName
val lobbyId = intent.getIntExtra("lobbyId", -1)
if (savedInstanceState != null) {
playerList = savedInstanceState?.getParcelableArrayList("playerList") ?: emptyList()
} else {
val playerId = ControllerPlayer.getPlayersIdFromLobbyId(lobbyId)
if (playerId != null) {
playerList = playerId.mapNotNull { playerId ->
ControllerPlayer.getPlayerInfoById(playerId.toString())
}
}
}
val listViewPlayers = findViewById<ListView>(R.id.listViewPlayers)
playerAdapter = PlayerAdapter(this, playerList)
listViewPlayers.adapter = playerAdapter
handler.postDelayed(refreshRunnable, refreshInterval)
val btnLaunchQuiz = findViewById<Button>(R.id.btnLaunchQuiz)
if (ControllerLobby.playerCreatorIdPresentInLobby(MainActivity.idPlayerConnected, lobbyId)) {
btnLaunchQuiz.visibility = View.VISIBLE
btnLaunchQuiz.setOnClickListener {
val formDataBuilder = MultipartBody.Builder().setType(MultipartBody.FORM)
formDataBuilder.addFormDataPart("launched", "1")
ControllerLobby.updateLobbyLauched(lobbyId,formDataBuilder)
val intent = Intent(this, QuizMultiActivity::class.java)
intent.putExtra("lobbyId", lobbyId)
startActivity(intent)
}
} else {
btnLaunchQuiz.visibility = View.GONE
}
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putParcelableArrayList("playerList", ArrayList(playerList))
}
private val refreshRunnable: Runnable = object : Runnable {
override fun run() {
val lobbyId = intent.getIntExtra("lobbyId", -1)
val playerId = ControllerPlayer.getPlayersIdFromLobbyId(lobbyId)
if (playerId != null) {
playerList = playerId.mapNotNull { playerId ->
ControllerPlayer.getPlayerInfoById(playerId.toString())
}
playerAdapter.clear()
playerAdapter.addAll(playerList)
playerAdapter.notifyDataSetChanged()
}
val btnLaunchQuiz = findViewById<Button>(R.id.btnLaunchQuiz)
if (ControllerLobby.playerCreatorIdPresentInLobby(MainActivity.idPlayerConnected, lobbyId)) {
btnLaunchQuiz.visibility = View.VISIBLE
} else {
btnLaunchQuiz.visibility = View.GONE
}
if(ControllerLobby.lobbyIsLaunched(lobbyId)){
val intent = Intent(this@ServerDetailsActivity, QuizMultiActivity::class.java)
intent.putExtra("lobbyId", lobbyId)
startActivity(intent)
return
}
handler.postDelayed(this, refreshInterval)
}
}
private fun myBackPressed() {
val lobbyId = intent.getIntExtra("lobbyId", -1)
ControllerUtiliser.DeleteUtiliserForLobby(MainActivity.idPlayerConnected, lobbyId)
if (ControllerLobby.playerCreatorIdPresentInLobby(MainActivity.idPlayerConnected, lobbyId)) {
val idNextPlayerCreator = ControllerUtiliser.getIdNextPlayerInLobby(lobbyId)
if (idNextPlayerCreator == -1) {
ControllerLobby.deleteLobby(lobbyId)
} else {
val formDataBuilder = MultipartBody.Builder().setType(MultipartBody.FORM)
formDataBuilder.addFormDataPart("idplayercreator", idNextPlayerCreator.toString())
ControllerLobby.updateLobbyIdCreatorLobby(lobbyId, formDataBuilder)
}
}
handler.removeCallbacks(refreshRunnable)
finish()
}
class PlayerAdapter(context: Context, players: List<Player>) :
ArrayAdapter<Player>(context, 0, players) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
var currentPlayerView = convertView
if (currentPlayerView == null) {
currentPlayerView =
LayoutInflater.from(context).inflate(R.layout.list_view_player, parent, false)
}
val playerNameTextView = currentPlayerView!!.findViewById<TextView>(R.id.playerName)
playerNameTextView.text = getItem(position)?.nickname ?: "Unknown"
return currentPlayerView
}
} }
} }

@ -39,5 +39,34 @@ class ControllerChapter {
return null return null
} }
fun getChapterNameById(idchapter : Int): String? {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
// Client HTTP API
val client = OkHttpClient()
// API Access
val request = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/chapters/$idchapter/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
.build()
// API Response
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw IOException("Unexpected code $response")
// Gson deserialization
val gson = Gson()
val typeTokenProduct = object : TypeToken<ArrayList<Chapter>>() {}.type
// Parse API response and return the list of chapters
val chapter: ArrayList<Chapter> = gson.fromJson(response.body!!.string(), typeTokenProduct)
return chapter[0].name
}
return null
}
} }
} }

@ -3,13 +3,14 @@ package com.example.mathseduc.controllers
import android.os.StrictMode import android.os.StrictMode
import android.util.Log import android.util.Log
import com.example.mathseduc.models.Lobby import com.example.mathseduc.models.Lobby
import com.example.mathseduc.models.Utiliser
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.reflect.TypeToken import com.google.gson.reflect.TypeToken
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.MultipartBody import okhttp3.MultipartBody
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.Response
import org.json.JSONObject
import java.io.IOException import java.io.IOException
@ -25,7 +26,7 @@ class ControllerLobby {
// API Access // API Access
val request = Request.Builder() val request = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/all/lobbies/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO/1") .url("https://trusting-panini.87-106-126-109.plesk.page/api/all/lobbies/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
.build() .build()
// API Response // API Response
@ -41,11 +42,43 @@ class ControllerLobby {
return null return null
} }
fun createLobby(lobbyData: MultipartBody.Builder): Boolean { fun getIdQuestionsLobby(idLobby: Int): ArrayList<String> {
try { val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
// Log avant l'appel API StrictMode.setThreadPolicy(policy)
Log.d("CreateLobby", "Request Data: ${lobbyData.toString()}")
// Client HTTP API
val client = OkHttpClient()
// API Access
val request = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/propose/$idLobby/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
.build()
// API Response
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw IOException("Unexpected code $response")
// Gson deserialization
val gson = Gson()
val typeTokenProduct = object : TypeToken<ArrayList<Map<String, String>>>() {}.type
val questionList: ArrayList<Map<String, String>> = gson.fromJson(response.body!!.string(), typeTokenProduct)
// Extracting question IDs
val idList = ArrayList<String>()
for (question in questionList) {
val id = question["idquestion"]
if (id != null) {
idList.add(id)
}
}
return idList
}
}
fun createLobby(lobbyData: MultipartBody.Builder): Int {
try {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build() val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy) StrictMode.setThreadPolicy(policy)
@ -60,19 +93,184 @@ class ControllerLobby {
// API Response // API Response
client.newCall(request).execute().use { response -> client.newCall(request).execute().use { response ->
// Log après la réponse API if (response.isSuccessful) {
Log.d("CreateLobby", "Response Code: ${response.code}") // Si la réponse est réussie, extraire l'ID du lobby du corps de la réponse JSON
Log.d("CreateLobby", "Response Body: ${response.body?.string()}") val responseBody = response.body?.string()
val jsonObject = JSONObject(responseBody)
// Vérifier si la création du lobby a réussi // Retourner l'ID du lobby
return response.isSuccessful return jsonObject.optInt("lobby_id", -1)
}
} }
} catch (e: Exception) { } catch (e: Exception) {
// Log en cas d'erreur // Log en cas d'erreur
Log.e("CreateLobby", "Error creating lobby", e) Log.e("CreateLobby", "Error creating lobby", e)
return false
} }
return -1
}
fun playerCreatorIdPresentInLobby(idPlayer: Int, lobbyId: Int): Boolean {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
// Client HTTP API
val client = OkHttpClient()
// API Access
val request = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/lobbies/$lobbyId/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
.build()
// API Response
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw IOException("Unexpected code $response")
// Gson deserialization
val gson = Gson()
val typeTokenProduct = object : TypeToken<ArrayList<Lobby>>() {}.type
val lobby: ArrayList<Lobby> = gson.fromJson(response.body!!.string(), typeTokenProduct)
return lobby[0].idplayercreator == idPlayer
}
return false
} }
fun deleteLobby(lobbyId: Int) {
try {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
// Client HTTP API
val client = OkHttpClient()
// API Access - Suppression du lobby
val deleteRequest = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/lobbies/$lobbyId/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
.delete()
.build()
// API Response
val deleteResponse: Response = client.newCall(deleteRequest).execute()
// Vérifier si la suppression a réussi
if (!deleteResponse.isSuccessful) {
Log.e("deleteLobby", "Error deleting lobby")
}
} catch (e: Exception) {
// Log en cas d'erreur
Log.e("deleteLobby", "Error deleting lobby", e)
}
}
fun updateLobbyIdCreatorLobby(lobbyId: Int,lobbyData: MultipartBody.Builder) {
try {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
// Client HTTP API
val client = OkHttpClient()
// API Access - Mise à jour du lobby
val updateRequest = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/update/lobbies/idplayercreator/$lobbyId/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
// Ajoutez d'autres paramètres ou données pour la mise à jour si nécessaire
.post(lobbyData.build()) //TODO attention api pb
.build()
// API Response
val updateResponse: Response = client.newCall(updateRequest).execute()
// Vérifier si la mise à jour a réussi
if (!updateResponse.isSuccessful) {
Log.e("updateLobby", "Error updating lobby")
}
} catch (e: Exception) {
// Log en cas d'erreur
Log.e("updateLobby", "Error updating lobby", e)
}
}
fun updateLobbyLauched(lobbyId: Int,lobbyData: MultipartBody.Builder) {
try {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
// Client HTTP API
val client = OkHttpClient()
// API Access - Mise à jour du lobby
val updateRequest = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/update/lobbies/launched/$lobbyId/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
// Ajoutez d'autres paramètres ou données pour la mise à jour si nécessaire
.post(lobbyData.build()) //TODO attention api pb
.build()
// API Response
val updateResponse: Response = client.newCall(updateRequest).execute()
// Vérifier si la mise à jour a réussi
if (!updateResponse.isSuccessful) {
Log.e("updateLobby", "Error updating lobby")
}
} catch (e: Exception) {
// Log en cas d'erreur
Log.e("updateLobby", "Error updating lobby", e)
}
}
fun getNbPlayerInLobby(lobbyId: Int): Int {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
// Client HTTP API
val client = OkHttpClient()
// API Access
val request = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/utiliser/$lobbyId/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
.build()
// API Response
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw IOException("Unexpected code $response")
// Gson deserialization
val gson = Gson()
val typeTokenProduct = object : TypeToken<ArrayList<Utiliser>>() {}.type
val utiliser: ArrayList<Utiliser> = gson.fromJson(response.body!!.string(), typeTokenProduct)
return utiliser.size
}
return -1
}
fun lobbyIsLaunched(lobbyId: Int): Boolean {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
// Client HTTP API
val client = OkHttpClient()
// API Access
val request = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/lobbies/$lobbyId/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
.build()
// API Response
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw IOException("Unexpected code $response")
// Gson deserialization
val gson = Gson()
val typeTokenProduct = object : TypeToken<ArrayList<Lobby>>() {}.type
val lobby: ArrayList<Lobby> = gson.fromJson(response.body!!.string(), typeTokenProduct)
return lobby[0].launched == 1
}
return false
}
} }
} }

@ -0,0 +1,102 @@
package com.example.mathseduc.controllers
import android.os.StrictMode
import com.example.mathseduc.models.*
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import okhttp3.FormBody
import okhttp3.OkHttpClient
import okhttp3.Request
import org.mindrot.jbcrypt.BCrypt
import java.io.IOException
class ControllerPlayer {
companion object {
fun getPlayersIdFromLobbyId(lobbyId: Int): List<Int>? {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
val client = OkHttpClient()
val request = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/utiliser/$lobbyId/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
.build()
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw IOException("Unexpected code $response")
val gson = Gson()
val typeTokenProduct = object : TypeToken<List<Utiliser>>() {}.type
val playerInfoList: List<Utiliser> = gson.fromJson(response.body!!.string(), typeTokenProduct)
// Extract player IDs from PlayerInfo list
val playerIds: List<Int> = playerInfoList.map { it.idplayer }
return playerIds
}
return null
}
fun getPlayerInfoById(playerId: String): Player? {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
val client = OkHttpClient()
val request = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/players/$playerId/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
.build()
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw IOException("Unexpected code $response")
val gson = Gson()
val playerInfo: List<Player> = gson.fromJson(response.body!!.string(), object : TypeToken<List<Player>>() {}.type)
// Assuming the API returns a list even for a single player, we take the first item
return playerInfo.firstOrNull()
}
return null
}
fun authenticateUser(nickname: String, password: String): Int {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
// Client HTTP API
val client = OkHttpClient()
// API Access
val request = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/verif/player/$nickname/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
.build()
// API Response
client.newCall(request).execute().use { response ->
if (response.isSuccessful) {
val responseData = response.body?.string()
// Use Gson to parse the JSON response
val gson = Gson()
val playerListType = object : TypeToken<List<Player>>() {}.type
val playerList: List<Player> = gson.fromJson(responseData, playerListType)
// Check if the list is not empty
if (playerList.isNotEmpty()) {
val storedPasswordHash = playerList[0].password
// Use BCrypt to check if the provided password matches the stored hash
if(BCrypt.checkpw(password, storedPasswordHash)){
return playerList[0].id
}
}
}
}
return -1
}
}
}

@ -0,0 +1,63 @@
package com.example.mathseduc.controllers
import android.os.StrictMode
import android.util.Log
import com.example.mathseduc.models.Lobby
import com.example.mathseduc.models.Question
import com.example.mathseduc.models.Utiliser
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import okhttp3.MultipartBody
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import org.json.JSONObject
import java.io.IOException
class ControllerQuestion {
companion object {
fun getQuestionsForLobby(questionIds: ArrayList<String>): List<Question>? {
val questions = ArrayList<Question>()
for (questionId in questionIds) {
val question = getQuestionById(questionId)
if (question != null) {
questions.add(question)
}
}
return if (questions.isNotEmpty()) questions else null
}
private fun getQuestionById(questionId: String): Question? {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
// Client HTTP API
val client = OkHttpClient()
// API Access
val request = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/questions/$questionId/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
.build()
// API Response
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) {
// Handle error, log, or throw an exception as needed
return null
}
// Gson deserialization
val gson = Gson()
val typeTokenProduct = object : TypeToken<ArrayList<Question>>() {}.type
val question: ArrayList<Question> = gson.fromJson(response.body!!.string(), typeTokenProduct)
// Assuming the API returns a list with a single question
return if (question.isNotEmpty()) question[0] else null
}
}
}
}

@ -0,0 +1,100 @@
package com.example.mathseduc.controllers
import android.os.StrictMode
import android.util.Log
import com.example.mathseduc.models.Lobby
import com.example.mathseduc.models.Utiliser
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import okhttp3.MultipartBody
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import java.io.IOException
class ControllerUtiliser {
companion object {
fun createUtiliserByIdLobby(utiliserData: MultipartBody.Builder): Boolean {
try {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
// Client HTTP API
val client = OkHttpClient()
// API Access
val request = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/add/utiliser/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
.post(utiliserData.build())
.build()
// API Response
client.newCall(request).execute().use { response ->
// Vérifier si la création du lobby a réussi
return response.isSuccessful
}
} catch (e: Exception) {
// Log en cas d'erreur
Log.e("CreateLobby", "Error creating lobby", e)
return false
}
}
fun DeleteUtiliserForLobby(idPlayerConnected: Int, lobbyId: Int): Boolean {
try {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
// Client HTTP API
val client = OkHttpClient()
// API Access
val request = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/delete/utiliser/$lobbyId/$idPlayerConnected/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
.delete()
.build()
// API Response
val response: Response = client.newCall(request).execute()
// Vérifier si la suppression a réussi
return response.isSuccessful
} catch (e: Exception) {
// Log en cas d'erreur
Log.e("DeleteUtiliser", "Error deleting utiliser", e)
return false
}
}
fun getIdNextPlayerInLobby(lobbyId: Int): Int {
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
// Client HTTP API
val client = OkHttpClient()
// API Access
val request = Request.Builder()
.url("https://trusting-panini.87-106-126-109.plesk.page/api/utiliser/$lobbyId/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
.build()
// API Response
client.newCall(request).execute().use { response ->
if (!response.isSuccessful) throw IOException("Unexpected code $response")
// Gson deserialization
val gson = Gson()
val typeTokenProduct = object : TypeToken<ArrayList<Utiliser>>() {}.type
val utiliser: ArrayList<Utiliser> = gson.fromJson(response.body!!.string(), typeTokenProduct)
if (utiliser.isNotEmpty()){
return utiliser[0].idplayer
} else {
return -1
}
}
return -1
}
}
}

@ -1,11 +1,12 @@
package com.example.mathseduc.models package com.example.mathseduc.models
data class Lobby( data class Lobby(
val id: String, val id: Int,
val name: String, val name: String,
val password: String, val password: String,
val nbplayers: Int, val nbplayers: Int,
val idplayercreator: Int, val idplayercreator: Int,
val idchapter: Int, val idchapter: Int,
val difficulty: Int val difficulty: Int,
val launched: Int
) )

@ -0,0 +1,36 @@
package com.example.mathseduc.models
import android.os.Parcel
import android.os.Parcelable
data class Player(
val id: Int,
val nickname: String,
val password: String
) : Parcelable {
constructor(parcel: Parcel) : this(
parcel.readInt(),
parcel.readString() ?: "",
parcel.readString() ?: ""
)
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeInt(id)
parcel.writeString(nickname)
parcel.writeString(password)
}
override fun describeContents(): Int {
return 0
}
companion object CREATOR : Parcelable.Creator<Player> {
override fun createFromParcel(parcel: Parcel): Player {
return Player(parcel)
}
override fun newArray(size: Int): Array<Player?> {
return arrayOfNulls(size)
}
}
}

@ -0,0 +1,10 @@
package com.example.mathseduc.models
data class Question(
val id: Int,
val content: String,
val nbfails: Int,
val difficulty: Int,
val idchapter: Int,
val idanswergood: Int,
)

@ -0,0 +1,7 @@
package com.example.mathseduc.models
data class Utiliser (
val idlobby: Int,
val idplayer: Int,
val playertime: Int
)

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

@ -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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

@ -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,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/white" />
<corners android:radius="10dp" />
<stroke android:width="1dp"
android:color="@color/grey"/>
</shape>

@ -0,0 +1,112 @@
<?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"
tools:context=".ConnexionPlayerActivity">
<!--<Button
android:id="@+id/btnReturn"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="start"
android:layout_marginTop="16dp"
android:text="@string/fleche"
android:background="@android:color/transparent"
android:textSize="70sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.051"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />-->
<ImageButton
android:id="@+id/btnReturn"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="start"
android:layout_marginTop="16dp"
android:background="@drawable/arrow_small"
android:scaleType="center"
android:contentDescription="@string/retour"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.030"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="25dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="MissingConstraints">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="15dp"
android:fontFamily="@font/math_educ_font"
android:text="@string/connexion"
android:textColor="@color/white"
android:textSize="50sp" />
<!--<TextView
android:id="@+id/errorTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:text=""
android:textAlignment="center"
android:textColor="@android:color/holo_red_dark"
android:textSize="20sp" /> -->
<EditText
android:id="@+id/editTextNickname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:autofillHints=""
android:background="@drawable/rounded_corner"
android:hint="@string/nom_d_utilisateur"
android:inputType="text"
android:minHeight="50dp"
android:padding="8dp"
tools:ignore="RtlSymmetry" />
<EditText
android:id="@+id/editTextPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:autofillHints=""
android:background="@drawable/rounded_corner"
android:hint="@string/mot_de_passe"
android:inputType="textPassword"
android:minHeight="50dp"
android:padding="8dp"
tools:ignore="RtlSymmetry" />
<Button
android:id="@+id/buttonLogin"
android:layout_width="wrap_content"
android:layout_height="55dp"
android:layout_gravity="center"
android:layout_marginTop="13dp"
android:backgroundTint="@color/turquoise"
android:text="@string/se_connecter" />
<Button
android:id="@+id/registerButton"
android:layout_width="wrap_content"
android:layout_height="55dp"
android:layout_gravity="center"
android:layout_marginTop="3dp"
android:backgroundTint="@color/blue"
android:text="@string/s_inscrire" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -3,42 +3,51 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" android:orientation="vertical"
tools:context=".MainActivity" android:weightSum="10"
android:gravity="center"> tools:context=".MainActivity">
<ImageView
android:id="@+id/background_image" <FrameLayout
android:layout_width="165dp" android:layout_width="wrap_content"
android:layout_height="138dp" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_weight="1">
android:layout_marginTop="30dp"
android:contentDescription="@string/app_name" <ImageView
android:scaleType="centerCrop" android:id="@+id/background_image"
android:src="@drawable/logo" /> android:layout_width="160dp"
android:layout_height="130dp"
android:layout_gravity="center"
android:contentDescription="@string/app_name"
android:scaleType="centerCrop"
android:src="@drawable/logo" />
</FrameLayout>
<Button <Button
android:id="@+id/btnSolo" android:id="@+id/btnSolo"
android:layout_width="370dp" android:layout_width="370dp"
android:layout_height="90dp" android:layout_height="wrap_content"
android:layout_marginTop="40dp" android:layout_weight="0.25"
android:backgroundTint="@color/green" android:backgroundTint="@color/green"
android:text="@string/solo" /> android:text="@string/solo" />
<Button <Button
android:id="@+id/btnMulti" android:id="@+id/btnMulti"
android:layout_width="370dp" android:layout_width="370dp"
android:layout_height="90dp" android:layout_height="wrap_content"
android:layout_marginTop="30dp" android:layout_weight="0.25"
android:layout_marginTop="10dp"
android:backgroundTint="@color/orange" android:backgroundTint="@color/orange"
android:text="@string/multiplayer" /> android:text="@string/multiplayer" />
<Button <Button
android:id="@+id/btnConnexion" android:id="@+id/btnConnexion"
android:layout_width="200dp" android:layout_width="200dp"
android:layout_height="60dp" android:layout_height="wrap_content"
android:layout_marginTop="50dp" android:layout_weight="0.25"
android:layout_marginTop="10dp"
android:backgroundTint="@color/grey" android:backgroundTint="@color/grey"
android:text="@string/connexion" /> android:text="@string/connexion" />

@ -6,42 +6,55 @@
android:orientation="vertical" android:orientation="vertical"
tools:context=".MultiActivity"> tools:context=".MultiActivity">
<Button <ImageButton
android:id="@+id/btnReturn" android:id="@+id/btnReturn"
android:layout_width="100dp" android:layout_width="50dp"
android:layout_height="60dp" android:layout_height="50dp"
android:layout_marginTop="15dp"
android:layout_marginStart="20dp"
android:backgroundTint="@color/grey"
android:layout_gravity="start" android:layout_gravity="start"
android:text="@string/retour" /> android:layout_marginTop="16dp"
android:background="@drawable/arrow_small"
android:scaleType="center"
android:contentDescription="@string/retour"
android:layout_marginStart="15dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginVertical="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_weight="95"
android:layout_gravity="center"
android:fontFamily="@font/math_educ_font"
android:text="@string/listLobbies"
android:textColor="@color/white"
android:textSize="40sp" />
<Button
android:id="@+id/btnAddLobby"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="20dp"
android:layout_weight="5"
android:backgroundTint="@color/blue"
android:text="@string/addLobby" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="50dp"
android:fontFamily="@font/math_educ_font"
android:layout_marginTop="30dp"
android:layout_marginStart="20dp"
android:text="@string/listLobbies"
android:textColor="@color/white"
android:textSize="40sp" />
<Button
android:id="@+id/btnAddLobby"
android:layout_width="140dp"
android:layout_height="60dp"
android:layout_marginTop="5dp"
android:backgroundTint="@color/blue"
android:layout_gravity="end"
android:layout_marginEnd="15dp"
android:text="@string/addLobby" />
<include layout="@layout/header_list_lobby" /> <include layout="@layout/header_list_lobby" />
<ListView <ListView
android:id="@+id/listView" android:id="@+id/listView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="524dp" android:layout_height="0dp"
android:layout_weight="85"
android:background="@color/white" /> android:background="@color/white" />
</LinearLayout> </LinearLayout>

@ -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>

@ -2,15 +2,35 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingTop="16dp"
android:paddingRight="16dp"
android:paddingBottom="16dp"
tools:context=".ServerDetailsActivity"> tools:context=".ServerDetailsActivity">
<TextView <TextView
android:id="@+id/titleServerDetails" android:id="@+id/titleServerDetails"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerInParent="true" android:layout_weight="1"
android:text="LobbyTitle"
android:textColor="@color/white" android:textColor="@color/white"
android:text="Bonjour depuis le serveur" android:textSize="20dp"
android:textSize="18sp"/> android:paddingBottom="16dp"
</LinearLayout> android:layout_gravity="center"/>
<ListView
android:id="@+id/listViewPlayers"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="75"
android:background="@color/white" />
<Button
android:id="@+id/btnLaunchQuiz"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="350dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/rounded_corner"
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="15dp"
android:paddingTop="2dp"
android:fontFamily="@font/math_educ_font"
android:text="@string/creer_compte"
android:textColor="@color/black"
android:textSize="40sp"/>
<!--<TextView
android:id="@+id/errorTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:text=""
android:textAlignment="center"
android:textColor="@android:color/holo_red_dark"
android:textSize="20sp" /> -->
<EditText
android:id="@+id/nickname"
android:layout_width="320dp"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corner"
android:hint="@string/nom_d_utilisateur"
android:layout_gravity="center_horizontal"
android:paddingStart="8dp"
android:inputType="text"
android:minHeight="50dp"
android:autofillHints=""
tools:ignore="RtlSymmetry" />
<EditText
android:id="@+id/password"
android:layout_width="320dp"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:background="@drawable/rounded_corner"
android:layout_gravity="center_horizontal"
android:hint="@string/mot_de_passe"
android:inputType="textPassword"
android:minHeight="50dp"
android:paddingStart="8dp"
android:autofillHints=""
tools:ignore="RtlSymmetry" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="end"
android:layout_marginTop="15dp">
<Button
android:id="@+id/buttonDismiss"
android:layout_width="wrap_content"
android:layout_height="55dp"
android:layout_marginEnd="10dp"
android:backgroundTint="@color/blackgrey"
android:text="@string/fermer"
android:textColor="@color/white"
style="?android:attr/buttonBarButtonStyle" />
<Button
android:id="@+id/buttonSave"
android:layout_width="wrap_content"
android:layout_height="55dp"
android:layout_marginEnd="15dp"
android:backgroundTint="@color/blue"
android:text="@string/enregistrer"
android:textColor="@color/white"
style="?android:attr/buttonBarButtonStyle" />
</LinearLayout>
</LinearLayout>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="60dp" > android:layout_height="45dp" >
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -18,34 +18,34 @@
android:layout_weight="0.4" android:layout_weight="0.4"
android:gravity="left|center_vertical" android:gravity="left|center_vertical"
android:text="Name" android:text="Name"
android:textSize="16dp" /> android:textSize="18dp" />
<TextView <TextView
android:id="@+id/nbplayers" android:id="@+id/difficulty"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="0.2" android:layout_weight="0.2"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center|bottom" android:gravity="center"
android:textSize="10dp" android:textSize="14dp"
android:text="NbPlayers"/> android:text="Difficulty"/>
<TextView <TextView
android:id="@+id/difficulty" android:id="@+id/idchapter"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="0.2" android:layout_weight="0.2"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center|bottom" android:gravity="center"
android:textSize="10dp" android:textSize="14dp"
android:text="Difficulty"/> android:text="idChapter"/>
<TextView <TextView
android:id="@+id/idchapter" android:id="@+id/nbplayers"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="0.2" android:layout_weight="0.2"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center|center_vertical" android:gravity="center"
android:textSize="10dp" android:textSize="14dp"
android:text="idChapter"/> android:text="NbPlayers"/>
</LinearLayout> </LinearLayout>

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="60dp" >
<!-- res/layout/list_view_player.xml -->
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/playerName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:textSize="18sp"
android:textColor="@color/black"/>
</FrameLayout>

@ -11,4 +11,8 @@
<color name="orange">#FFA500</color> <color name="orange">#FFA500</color>
<color name="grey">#8C92AC</color> <color name="grey">#8C92AC</color>
<color name="blue">#0d6efd</color> <color name="blue">#0d6efd</color>
<color name="red">#FF0000</color>
<color name="blackgrey">#5c636a</color>
<color name="cyan">#00FFFF</color>
<color name="turquoise">#40E0D0</color>
</resources> </resources>

@ -11,6 +11,14 @@
<string name="listLobbies">Liste des lobbies</string> <string name="listLobbies">Liste des lobbies</string>
<string name="difficulty_prompt">Selectionne la difficulty</string> <string name="difficulty_prompt">Selectionne la difficulty</string>
<string name="chapter_prompt">Selectionne un chapter</string> <string name="chapter_prompt">Selectionne un chapter</string>
<string name="se_connecter">Se connecter</string>
<string name="mot_de_passe">Mot de passe</string>
<string name="s_inscrire">S\'inscrire</string>
<string name="nom_d_utilisateur">Nom d\'utilisateur</string>
<string name="creer_compte">Créer son compte</string>
<string name="fermer">Fermer</string>
<string name="enregistrer">Enregistrer</string>
<string name="fleche"></string>
<string-array name="difficulty_array"> <string-array name="difficulty_array">
<item>Facile</item> <item>Facile</item>

@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools"> <resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. --> <!-- Base application theme. -->
<style name="Theme.MathsEduc" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> <style name="Theme.MathsEduc" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. --> <!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item> <item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item> <item name="colorPrimaryVariant">@color/purple_700</item>
@ -14,5 +14,6 @@
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
<item name="android:windowBackground">@drawable/background</item> <item name="android:windowBackground">@drawable/background</item>
<!--<item name="android:fontFamily">@font/math_educ_font</item> --> <!--<item name="android:fontFamily">@font/math_educ_font</item> -->
<item name="android:homeAsUpIndicator"></item>
</style> </style>
</resources> </resources>
Loading…
Cancel
Save