Maxence GUITARD 1 year ago
commit 5b2f5f0d67

@ -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"
@ -44,4 +44,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,6 @@
<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" />
</application> </application>
</manifest> </manifest>

@ -0,0 +1,40 @@
package com.example.mathseduc
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.example.mathseduc.controllers.ControllerPlayer
import org.mindrot.jbcrypt.BCrypt
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()
}
}
}
}

@ -6,7 +6,8 @@ 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.models.Lobby import com.example.mathseduc.controllers.ControllerUtiliser
import okhttp3.MultipartBody
import org.json.JSONObject import org.json.JSONObject
@ -34,30 +35,46 @@ class CreateLobbyActivity : AppCompatActivity() {
buttonCreateLobby.setOnClickListener { buttonCreateLobby.setOnClickListener {
val lobbyName = findViewById<EditText>(R.id.editTextLobbyName).text.toString() val lobbyName = findViewById<EditText>(R.id.editTextLobbyName).text.toString()
val password = findViewById<EditText>(R.id.editTextPassword).text.toString() val password = findViewById<EditText>(R.id.editTextPassword).text.toString()
val nbPlayers = findViewById<EditText>(R.id.editTextNbPlayers).text.toString().toInt() val nbPlayers = findViewById<EditText>(R.id.editTextNbPlayers).text.toString()
val difficulty = findViewById<Spinner>(R.id.spinnerDifficulty).selectedItemPosition + 1 val difficulty = findViewById<Spinner>(R.id.spinnerDifficulty).selectedItemPosition + 1
val selectedChapterPosition = findViewById<Spinner>(R.id.spinnerChapter).selectedItemPosition val selectedChapterPosition = findViewById<Spinner>(R.id.spinnerChapter).selectedItemPosition
val chapterId = chaptersFromApi?.getOrNull(selectedChapterPosition)?.id?.toInt() ?: -1 val idChapter = chaptersFromApi?.getOrNull(selectedChapterPosition)?.id?: -1
// Créer un objet Lobby avec les valeurs du formulaire if (lobbyName.isNullOrBlank() || password.isNullOrBlank() || nbPlayers.isNullOrBlank() || nbPlayers.toInt() <= 0) {
val lobbyData = JSONObject().apply { Toast.makeText(this, "Échec de la création du lobby. Veuillez réessayer.", Toast.LENGTH_SHORT).show()
put("name", lobbyName)
put("password", password)
put("nbplayers", nbPlayers)
put("idplayercreator", 53)
put("idchapter", chapterId)
put("difficulty", difficulty)
} }
else
{
// Create form data
val formDataBuilder = MultipartBody.Builder().setType(MultipartBody.FORM)
// Appeler la fonction pour créer le lobby // Add fields to form data
val lobbyCreatedSuccessfully = ControllerLobby.createLobby(lobbyData) formDataBuilder.addFormDataPart("name", lobbyName)
formDataBuilder.addFormDataPart("password", password)
formDataBuilder.addFormDataPart("nbplayers", nbPlayers.toString())
formDataBuilder.addFormDataPart("idplayercreator", MainActivity.idPlayerConnected.toString())
formDataBuilder.addFormDataPart("idchapter", idChapter.toString())
formDataBuilder.addFormDataPart("difficulty", difficulty.toString())
// Vérifier si la création du lobby a réussi // Appeler la fonction pour créer le lobby
if (lobbyCreatedSuccessfully) { val idLobbyCreatedSuccessfully = ControllerLobby.createLobby(formDataBuilder)
val intent = Intent(this, ServerDetailsActivity::class.java)
startActivity(intent) // Vérifier si la création du lobby a réussi
} else { if (idLobbyCreatedSuccessfully != -1) {
Toast.makeText(this, "Échec de la création du lobby. Veuillez réessayer.", Toast.LENGTH_SHORT).show() 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)
intent.putExtra("serverName", lobbyName)
intent.putExtra("lobbyId", idLobbyCreatedSuccessfully)
startActivity(intent)
} else {
Toast.makeText(this, "Échec de la création du lobby. Veuillez réessayer.", Toast.LENGTH_SHORT).show()
}
} }
} }
} }

@ -3,9 +3,13 @@ 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)
@ -21,7 +25,17 @@ class MainActivity : AppCompatActivity() {
} }
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()
}
}
btnConnexion.setOnClickListener {
val intent = Intent(this, ConnexionPlayerActivity::class.java)
startActivity(intent) startActivity(intent)
} }

@ -13,7 +13,9 @@ import android.widget.ListView
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
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() {
@ -33,8 +35,16 @@ class MultiActivity : AppCompatActivity() {
listView.adapter = adapter listView.adapter = adapter
listView.setOnItemClickListener { _, _, position, _ -> listView.setOnItemClickListener { _, _, position, _ ->
val formDataBuilder = MultipartBody.Builder().setType(MultipartBody.FORM)
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) val intent = Intent(this, ServerDetailsActivity::class.java)
intent.putExtra("serverName", serverList[position].name) intent.putExtra("serverName", serverList[position].name)
intent.putExtra("lobbyId", serverList[position].id)
startActivity(intent) startActivity(intent)
} }
} else { } else {

@ -1,11 +1,18 @@
package com.example.mathseduc package com.example.mathseduc
import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.ListView
import android.widget.TextView import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import com.example.mathseduc.controllers.ControllerPlayer
import com.example.mathseduc.models.Player
class ServerDetailsActivity : AppCompatActivity() { class ServerDetailsActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_server_details) setContentView(R.layout.activity_server_details)
@ -16,5 +23,35 @@ class ServerDetailsActivity : AppCompatActivity() {
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)
val playerIds = ControllerPlayer.getPlayersIdFromLobbyId(lobbyId)
if (playerIds != null) {
val playerList = playerIds.mapNotNull { playerId ->
ControllerPlayer.getPlayerInfoById(playerId.toString())
}
val listViewPlayers = findViewById<ListView>(R.id.listViewPlayers)
val playerAdapter = PlayerAdapter(this, playerList)
listViewPlayers.adapter = playerAdapter
}
}
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"
// You can customize the view further if needed
return currentPlayerView
}
} }
} }

@ -5,13 +5,13 @@ import android.util.Log
import com.example.mathseduc.models.Lobby import com.example.mathseduc.models.Lobby
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.toMediaTypeOrNull import okhttp3.MultipartBody
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import org.json.JSONObject import org.json.JSONObject
import java.io.IOException import java.io.IOException
class ControllerLobby { class ControllerLobby {
companion object { companion object {
fun getLobbies(): ArrayList<Lobby>? { fun getLobbies(): ArrayList<Lobby>? {
@ -24,7 +24,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
@ -40,11 +40,8 @@ class ControllerLobby {
return null return null
} }
fun createLobby(lobbyData: JSONObject): Boolean { fun createLobby(lobbyData: MultipartBody.Builder): Int {
try { try {
// Log avant l'appel API
Log.d("CreateLobby", "Request Data: ${lobbyData.toString()}")
val policy = StrictMode.ThreadPolicy.Builder().permitAll().build() val policy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy) StrictMode.setThreadPolicy(policy)
@ -54,24 +51,25 @@ 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/add/lobbies/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO") .url("https://trusting-panini.87-106-126-109.plesk.page/api/add/lobbies/qUOGkWdoPCgbmuqxIC8xiaX0rV1Pw1LoPafkaoHOgszEyD9P2vcOu493xCDZpAqO")
.post(lobbyData.toString().toRequestBody("application/json".toMediaTypeOrNull())) .post(lobbyData.build())
.build() .build()
// 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
} }
} }
} }

@ -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,43 @@
package com.example.mathseduc.controllers
import android.os.StrictMode
import android.util.Log
import com.example.mathseduc.models.Lobby
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import okhttp3.MultipartBody
import okhttp3.OkHttpClient
import okhttp3.Request
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
}
}
}
}

@ -1,7 +1,7 @@
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,

@ -0,0 +1,7 @@
package com.example.mathseduc.models
data class Player(
val id: Int,
val nickname: String,
val password: String
)

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

@ -1,99 +0,0 @@
<?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">
<Button
android:id="@+id/btnReturn"
android:layout_width="100dp"
android:layout_height="60dp"
android:layout_gravity="start"
android:layout_marginTop="16dp"
android:backgroundTint="@color/grey"
android:text="@string/retour"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.948"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
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="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="15dp"
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" />
<Button
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="55dp"
android:layout_gravity="center"
android:layout_marginTop="13dp"
android:backgroundTint="@color/blue"
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>

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:padding="16dp">
<EditText
android:id="@+id/editTextNickname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Nickname"
android:background="#FFFFFF"
android:padding="8dp"
android:textColor="#000000"
android:layout_marginBottom="16dp"/>
<EditText
android:id="@+id/editTextPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:background="#FFFFFF"
android:padding="8dp"
android:textColor="#000000"
android:layout_below="@id/editTextNickname"
android:layout_marginTop="8dp"
android:layout_marginBottom="16dp"/>
<Button
android:id="@+id/buttonLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"
android:background="#4CAF50"
android:textColor="#FFFFFF"
android:layout_below="@id/editTextPassword"
android:layout_marginTop="16dp"/>
</RelativeLayout>

@ -5,40 +5,50 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center"
android:orientation="vertical" android:orientation="vertical"
tools:context=".MainActivity"> android:weightSum="10"
tools:context=".MainActivity"
android:gravity="center">
<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,44 +6,44 @@
android:orientation="vertical" android:orientation="vertical"
tools:context=".MultiActivity"> tools:context=".MultiActivity">
<Button <LinearLayout
android:id="@+id/btnReturn" android:layout_width="match_parent"
android:layout_width="100dp" android:layout_height="match_parent"
android:layout_height="60dp" android:orientation="horizontal"
android:layout_marginTop="15dp" android:layout_marginVertical="10dp">
android:layout_marginStart="20dp"
android:backgroundTint="@color/grey" <TextView
android:layout_gravity="start" android:layout_width="wrap_content"
android:text="@string/retour" /> android:layout_height="wrap_content"
android:layout_marginStart="20dp"
<TextView android:layout_weight="95"
android:layout_width="wrap_content" android:layout_gravity="center"
android:layout_height="50dp" android:fontFamily="@font/math_educ_font"
android:layout_marginStart="20dp" android:text="@string/listLobbies"
android:layout_marginTop="30dp" android:textColor="@color/white"
android:fontFamily="@font/math_educ_font" android:textSize="40sp" />
android:text="@string/listLobbies"
android:textColor="@color/white" <Button
android:textSize="40sp" android:id="@+id/btnAddLobby"
tools:ignore="TextSizeCheck" /> android:layout_width="140dp"
android:layout_height="wrap_content"
<Button android:layout_gravity="center"
android:id="@+id/btnAddLobby" android:layout_marginEnd="20dp"
android:layout_width="140dp" android:layout_weight="5"
android:layout_height="60dp" android:backgroundTint="@color/blue"
android:layout_gravity="end" android:text="@string/addLobby" />
android:layout_marginTop="5dp"
android:layout_marginEnd="15dp" </LinearLayout>
android:backgroundTint="@color/blue"
android:text="@string/addLobby"
tools:ignore="TextSizeCheck" />
<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>

@ -2,15 +2,30 @@
<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" />
</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"
@ -25,7 +25,7 @@
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="10dp"
android:text="NbPlayers"/> android:text="NbPlayers"/>
@ -34,7 +34,7 @@
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="10dp"
android:text="Difficulty"/> android:text="Difficulty"/>
@ -43,7 +43,7 @@
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="10dp"
android:text="idChapter"/> android:text="idChapter"/>

@ -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>
Loading…
Cancel
Save