feat : ajout connexion d'un joueur + obligation d'être connecter pour jouer en multi
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
f0483bb479
commit
70bd4fffd8
@ -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, ServerDetailsActivity::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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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>
|
Loading…
Reference in new issue