AnnexesAndroid .pdf



Nom original: AnnexesAndroid.pdf

Ce document au format PDF 1.4 a été généré par Writer / LibreOffice 3.6, et a été envoyé sur fichier-pdf.fr le 04/06/2014 à 13:48, depuis l'adresse IP 88.121.x.x. La présente page de téléchargement du fichier a été vue 865 fois.
Taille du document: 438 Ko (40 pages).
Confidentialité: fichier public


Aperçu du document


Projet de fin d'année BTS IRIS

version 1.1

ANNEXES Android

Réalisé par:
Romain Gaillard
Version numérique :
http://urlz.fr/pOp

Promo 2014

Lycée Alfred Kastler

Tables des matières
I. LES FICHIERS XML.................................................................................................................................................. 3
1) ACTIVITY_CONNEXION.XML..............................................................................................................................................3
2) ACTIVITY_INSCRIPTION.XML.............................................................................................................................................5
3) ACTIVITY_ACCUEIL.XML...................................................................................................................................................8
4) ACTIVITY_AJ_ENFANT.XML ..............................................................................................................................................9
5) ANDROIDMANIFEST.XML...............................................................................................................................................12
II. LES FICHIERS JAVA............................................................................................................................................... 13
1) LES IHM – INTERFACES HOMME MARCHINE....................................................................................................................13

a. IHM_Connexion.java.............................................................................................................13
b. IHM_Inscription.java.............................................................................................................19
c. IHM_Accueil.java...................................................................................................................24
d. IHM_Enfant.java....................................................................................................................25

2) LES CLASSES................................................................................................................................................................32

a. CatalogueServices.java..........................................................................................................32
b. Client.java .............................................................................................................................33
c. Compte.java...........................................................................................................................37
d. Connexion.java......................................................................................................................38
e. Enfant.java.............................................................................................................................38
f. Service.java.............................................................................................................................39
g. Usager.java............................................................................................................................40

2/40

I. Les fichiers XML
Les fichiers XML (Extensible Markup Language) permettent de décrire les interfaces via des balises
libres. Ce code est généré automatiquement via l'assistant d'éclipse mais il peut être également
modifié manuellement.

1) activity_connexion.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="@+id/layout_main"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
tools:context=".IHM_Connexion">
<TextView
android:id="@+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:paddingTop="10dp"
android:text="Bienvenue"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/etEmail"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_below="@+id/tvTitle"
android:layout_centerHorizontal="true"
android:layout_marginTop="24dp"
android:ems="10"
android:hint="Adresse email"
android:imeOptions="actionDone"
android:inputType="textEmailAddress" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/etMdp"

3/40

android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_below="@+id/etEmail"
android:layout_centerHorizontal="true"
android:hint="Mot de passe"
android:imeOptions="actionDone"
android:inputType="textPassword" />
<TextView
android:id="@+id/tvMdpForget"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/etMdp"
android:layout_centerHorizontal="true"
android:paddingTop="15dp"
android:text="Mot de passe oublié ?"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="16sp" />
<Button
android:id="@+id/btInscription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btConnexion"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="Inscription"
android:width="180dp" />
<TextView
android:id="@+id/tvInfoService"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/btInscription"
android:layout_centerHorizontal="true"
android:layout_marginTop="34dp"
android:paddingBottom="5dp"
android:text="Informations sur les services"
android:textSize="20sp" />
<Button
android:id="@+id/btConnexion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tvMdpForget"
android:layout_centerHorizontal="true"
android:layout_marginTop="29dp"
android:text="Connexion"
android:width="180dp" />
</RelativeLayout>
</ScrollView>

4/40

2) activity_inscription.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ScrollView02"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="@+id/layout_inscription"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".IHM_Inscription"
tools:ignore="HardcodedText" >
<TextView
android:id="@+id/tvInscription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Inscription"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/etMdp2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/etEmail2"
android:layout_alignRight="@+id/etEmail2"
android:layout_below="@+id/etEmail2"
android:hint="Mot de passe"
android:inputType="textPassword"
android:textSize="16sp" />
<EditText
android:id="@+id/etMdp3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/etMdp2"
android:layout_alignRight="@+id/etMdp2"
android:layout_below="@+id/etMdp2"
android:hint="Confirmer mot de passe"
android:inputType="textPassword"
android:textSize="15sp" />
<EditText

5/40

android:id="@+id/etAdPostale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/etMdp3"
android:layout_alignRight="@+id/etMdp3"
android:layout_below="@+id/etMdp3"
android:hint="Adresse Postale"
android:inputType="textPostalAddress"
android:scrollHorizontally="true"
android:textSize="17sp" />
<TextView
android:id="@+id/tvNbEnfant"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/etAdPostale"
android:layout_below="@+id/etAdPostale"
android:paddingLeft="5dp"
android:paddingTop="20dp"
android:text="Nombre d'enfant:"
android:textSize="15sp" />
<EditText
android:id="@+id/etNbEnfant"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/tvNbEnfant"
android:layout_marginLeft="5dp"
android:layout_marginTop="20dp"
android:layout_toRightOf="@+id/tvNbEnfant"
android:clickable="false"
android:enabled="false"
android:inputType="number"
android:text="1"
android:textSize="16sp" />
<Button
android:id="@+id/btLess"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btMore"
android:layout_alignBottom="@+id/btMore"
android:layout_toRightOf="@+id/btMore"
android:text="-" />
<EditText
android:id="@+id/etEmail2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/etNom"
android:layout_centerHorizontal="true"

6/40

android:ems="10"
android:hint="Adresse email"
android:inputType="textEmailAddress"
android:textSize="17sp"
android:width="270dp" />
<EditText
android:id="@+id/etNom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/etEmail2"
android:layout_alignRight="@+id/etEmail2"
android:layout_below="@+id/tvInscription"
android:hint="Nom"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<Button
android:id="@+id/btMore"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/etNbEnfant"
android:layout_toRightOf="@+id/tvInscription"
android:text="+" />
<Button
android:id="@+id/btValider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btLess"
android:layout_marginTop="18dp"
android:layout_toLeftOf="@+id/btLess"
android:text="Valider" />
<Button
android:id="@+id/btAnnuler"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btValider"
android:layout_alignBottom="@+id/btValider"
android:layout_toLeftOf="@+id/etNbEnfant"
android:text="Annuler" />
</RelativeLayout>
</ScrollView>

7/40

3) activity_accueil.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ScrollView02"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/testing"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".IHM_Accueil"
tools:ignore="HardcodedText" >
<TextView
android:id="@+id/tvAccueil"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Accueil"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:ignore="HardcodedText" />
<QuickContactBadge
android:id="@+id/quickContactBadge1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/btAjEnfant"
android:layout_centerVertical="true" />
<Button
android:id="@+id/btAjEnfant"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btParametres"
android:layout_alignBottom="@+id/btParametres"
android:layout_alignParentLeft="true"
android:layout_marginLeft="18dp"
android:maxWidth="130dp"
android:minLines="2"
android:text="Ajouter un enfant"
android:textSize="15sp" />
<Button

8/40

android:id="@+id/btParametres"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:layout_below="@+id/tvAccueil"
android:layout_marginTop="44dp"
android:layout_toRightOf="@+id/tvAccueil"
android:maxLines="2"
android:maxWidth="130dp"
android:text="Paramètres"
android:textSize="14sp" />
</RelativeLayout>
<ScrollView/>

4) activity_aj_enfant.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ScrollView04"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".IHM_Enfant"
>
<TextView
android:id="@+id/tvAjEnfant"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Ajouter un enfant"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="@+id/etNom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/etPrenom"
android:layout_alignRight="@+id/tvAjEnfant"
android:layout_below="@+id/tvAjEnfant"
android:layout_marginTop="10dp"

9/40

android:hint="Nom"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/etPrenom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvAjEnfant"
android:layout_alignRight="@+id/tvAjEnfant"
android:layout_below="@+id/etNom"
android:hint="Prénom"
android:inputType="textPersonName" />
<TextView
android:id="@+id/tvDateNaiss"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/rgSexe"
android:layout_below="@+id/rgSexe"
android:layout_marginTop="5dp"
android:text="Date de naissance:" />
<TextView
android:id="@+id/tvActivites"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvDateNaiss"
android:layout_below="@+id/tvDateNaiss"
android:layout_marginTop="35dp"
android:text="Activités:"
android:textSize="14sp" />
<Button
android:id="@+id/btInscriptionActivitees"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tvActivites"
android:layout_alignRight="@+id/etPrenom"
android:layout_below="@+id/tvListActivite"
android:layout_marginTop="5dp"
android:minHeight="30dp"
android:minWidth="140dp"
android:text="S'inscrire aux activités"
android:textSize="15sp"
android:width="140dp" />
<Button
android:id="@+id/btValiderAjEnfant"

10/40

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/btAnnulerAjEnfant"
android:layout_marginLeft="150dp"
android:text="Valider" />
<Button
android:id="@+id/btAnnulerAjEnfant"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/tvAjEnfant"
android:layout_below="@id/btInscriptionActivitees"
android:layout_marginLeft="-15dp"
android:layout_marginTop="25dp"
android:text="Annuler" />
<RadioGroup
android:id="@+id/rgSexe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/etPrenom"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/rbGarcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/etPrenom"
android:layout_below="@+id/etPrenom"
android:text="Garçon" />
<RadioButton
android:id="@+id/rbFille"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/rbGarcon"
android:layout_alignBottom="@+id/rbGarcon"
android:layout_toRightOf="@+id/rbGarcon"
android:text="Fille" />
</RadioGroup>
<TextView
android:id="@+id/tvListActivite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvActivites"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="- Aucunes"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="16sp" />

11/40

<TextView
android:id="@+id/tvbtDateNaiss"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tvDateNaiss"
android:layout_centerHorizontal="true"
android:hint="jj/mm/aaaa"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
</ScrollView>

5) AndroidManifest.xml
Il s'agit du fichier de configuration de l'application.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.e_periscol_backup"
android:versionCode="1"
android:versionName="1.7" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk
android:minSdkVersion="13"
android:targetSdkVersion="13" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.e_periscol_backup.IHM_Connexion"
android:label="@string/app_name"
android:windowSoftInputMode="stateHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.e_periscol_backup.IHM_Inscription"
android:label="@string/title_activity_inscription"
android:windowSoftInputMode="stateHidden" >
</activity>

12/40

<activity
android:name="com.example.e_periscol_backup.IHM_Accueil"
android:label="@string/title_activity_accueil" >
</activity>
<activity
android:name="com.example.e_periscol_backup.IHM_Enfant"
android:label="@string/title_activity_aj_enfant" >
</activity>
<activity
android:name="com.example.e_periscol_backup.IHM_Parametres"
android:label="@string/title_activity_parametres" >
</activity>
</application>
</manifest>

II. Les fichiers JAVA
1) Les IHM – Interfaces Homme Marchine
a. IHM_Connexion.java
package com.example.e_periscol_backup;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.support.v4.content.Loader;
import android.text.InputType;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.*;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.app.AlertDialog;
import android.content.Context;
public class IHM_Connexion extends Activity{
private Button btConnexion = null;
private Button btInscription = null;
private EditText etEmail = null;
private EditText etMdp = null;
private TextView tvMdpForget = null;

13/40

private TextView tvInfoService = null;
public static String test="test";
final Context context = this;
public Client client;
private int NumErreur=-1; // pour MDP Forget et Connexion.
private boolean result=false; // pour get_all Service.
private ProgressDialog myProgressDialog;
public static final int MSG_MDP = 0;
public static final int MSG_SERVICES = 1;
public static final int MSG_CONNEXION = 2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
client = new Client();
// Récupération des vues:
btConnexion = (Button)findViewById(R.id.btConnexion);
btInscription = (Button)findViewById(R.id.btInscription);
etEmail = (EditText)findViewById(R.id.etEmail);
etMdp = (EditText)findViewById(R.id.etMdp);
tvMdpForget = (TextView)findViewById(R.id.tvMdpForget);
tvInfoService = (TextView)findViewById(R.id.tvInfoService);
// Définition des couleurs des textes:
tvMdpForget.setTextColor(Color.parseColor("#509CC7"));
tvInfoService.setTextColor(Color.parseColor("#609C43"));
// On attribue un listener adapté aux vues qui en ont besoin
btConnexion.setOnClickListener(button1Listener);
btInscription.setOnClickListener(button1Listener);
tvMdpForget.setOnClickListener(button1Listener);
tvInfoService.setOnClickListener(button1Listener);
etEmail.setOnClickListener(button1Listener);
etEmail.setOnTouchListener(touch1Listener);
etMdp.setOnTouchListener(touch1Listener);
tvInfoService.setOnTouchListener(touch1Listener);
/* Nom.addTextChangedListener(textWatcher);
Prenom.addTextChangedListener(textWatcher);*/
}
private OnTouchListener touch1Listener = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(v.getId()){
case R.id.etEmail:

14/40

etEmail.setTextColor(Color.parseColor("#000000"));
etEmail.setHintTextColor(Color.parseColor("#B9B9B9"));
etEmail.setSelectAllOnFocus(true);
break;
case R.id.etMdp:
etMdp.setTextColor(Color.parseColor("#000000"));
etMdp.setHintTextColor(Color.parseColor("#B9B9B9"));
etMdp.setSelectAllOnFocus(true);
break;
case R.id.tvInfoService:
tvInfoService.setTextColor(Color.parseColor("#89CE00"));
break;

}

}
return false;

};
private OnClickListener button1Listener = new OnClickListener(){
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.btConnexion:
if(Verif_ChampsVides())
{
myProgressDialog =
ProgressDialog.show(IHM_Connexion.this,"Chargement", "Veuillez patienter", true);
new Thread(new Runnable() {
public void run() {
NumErreur=-1;
NumErreur=client.Connect(etEmail.getText().toString(),etMdp.getText().toString());
myProgressDialog.dismiss();
Message msg =
mHandler.obtainMessage(MSG_CONNEXION);
mHandler.sendMessage(msg);
}
}).start();
}
break;
case R.id.tvMdpForget:
AlertDialog.Builder builder = new AlertDialog.Builder(IHM_Connexion.this);
builder.setTitle("Récupération de mot de passe");
builder.setMessage("Entrer votre adresse email:");
final EditText input = new EditText(context);
input.setText(etEmail.getText().toString());
input.setHint("Adresse email");
input.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
builder.setView(input);
builder.setPositiveButton("OK", new
DialogInterface.OnClickListener() {

15/40

public void onClick(DialogInterface dialog, int id) {
myProgressDialog =
ProgressDialog.show(IHM_Connexion.this,"Chargement", "Veuillez patienter", true);
new Thread(new Runnable() {
public void run() {
NumErreur=-1;
NumErreur =
client.mdp_oublie(input.getText().toString());
myProgressDialog.dismiss();
Message msg =
mHandler.obtainMessage(MSG_MDP);
mHandler.sendMessage(msg);
}
}).start();
}
});
builder.setNegativeButton("Annuler", new

DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog dialog = builder.create();
dialog.show();
break;
case R.id.btInscription:
Intent intent_Inscription = new
Intent(IHM_Connexion.this,IHM_Inscription.class);
startActivity(intent_Inscription);
break;

case R.id.tvInfoService:
myProgressDialog =
ProgressDialog.show(IHM_Connexion.this,"Chargement", "Veuillez patienter", true);
new Thread(new Runnable() {
public void run() {
result=false;
result=client.get_AllService();
myProgressDialog.dismiss();
Message msg = mHandler.obtainMessage(MSG_SERVICES);
mHandler.sendMessage(msg);
}
}).start();
break;
}
}
};
Handler mHandler = new Handler() {

16/40

public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_MDP:
GestionErreur_MDP(NumErreur);
break;
case MSG_SERVICES:
GestionErreur_Service(result);
break;

}

case MSG_CONNEXION:
GestionErreur_Connexion(NumErreur);
break;
}

};
// ========= METHODES PRIVEE: =========
private final void createDialog(String title, String text)
{
AlertDialog ad = new AlertDialog.Builder(this)
.setPositiveButton("Ok", null).setTitle(title).setMessage(text)
.create();
ad.show();
}
private boolean Verif_ChampsVides() // return true si les champs ne sont pas vides.
{
String email = ""+etEmail.getText().toString();
String mdp = ""+etMdp.getText().toString();
email=email.replace(" ",""); //on supprime les espaces.
etEmail.setText(email); // on affiche l'email sans les espaces.

}

if(email=="" || mdp=="") // On vérifie que les champs sont remplis
{
createDialog("Erreur","Champ(s) incomplet(s) !");
if(email=="")
etEmail.setHintTextColor(Color.parseColor("#DB2525"));
if(mdp=="")
etMdp.setHintTextColor(Color.parseColor("#DB2525"));
return(false);
}
else
return(true);

private void GestionErreur_Connexion(int numerreur)
{
if(numerreur>=0) // Communication serveur OK.
{

17/40

if(numerreur==1){ // pb email
etEmail.setTextColor(Color.parseColor("#DB2525"));
createDialog("Erreur","Adresse email incorrecte.");
}
if(numerreur==2){ // pb mdp
etMdp.setTextColor(Color.parseColor("#DB2525"));
createDialog("Erreur","Mot de passe incorrect.");
}
if(numerreur==0){ // Login OK. Vérification qu'il ne s'agit pas de l'admin.
if(client.Connexion_c.get_role()==true){ // role à false = admin sinon user.
Intent intent_Accueil = new Intent(IHM_Connexion.this,IHM_Accueil.class);
intent_Accueil.putExtra("IdFam",Integer.toString(client.Connexion_c.get_IdFam()));
startActivity(intent_Accueil);
}
else
createDialog("Erreur","Le compte admin n'est pas accessible depuis le client
Android.");
}
}
else
createDialog("Erreur","Echec connexion serveur.");
}
private void GestionErreur_Service(boolean reussite)
{
if(reussite==true)
createDialog("Liste des services
periscolaires",client.CataloguesServices_c.Consulter());
else
createDialog("Erreur","Echec connexion serveur.");
tvInfoService.setTextColor(Color.parseColor("#609C43"));
}
private void GestionErreur_MDP(int numerreur)
{
if(numerreur>=0){
if(numerreur==1)
createDialog("Erreur","Adresse email incorrecte.");
else if(numerreur==2)
createDialog("Erreur","Votre email d'inscription est incorrecte.
Contactez l'administrateur.");
else
createDialog("Terminé","Un email vous a été envoyé avec votre
nouveau mot de passe.");
}
else
createDialog("Erreur","Echec connexion serveur.");
}
}

18/40

b. IHM_Inscription.java
package com.example.e_periscol_backup;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent; // pour lancer nouvelle activité !
import android.graphics.Color;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.*;
public class IHM_Inscription extends Activity {
private Button btValider = null;
private Button btAnnuler = null;
private Button btMore = null;
private Button btLess = null;
private EditText etNom = null;
private EditText etEmail = null;
private EditText etMdp,etMdp2 = null;
private EditText etAdrPostale = null;
private EditText etNbEnfant = null;
private Client client;
private int numErreur=-1;
private ProgressDialog myProgressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_inscription);
client = new Client();
// Récupération des vues:
btValider = (Button)findViewById(R.id.btValider);
btAnnuler = (Button)findViewById(R.id.btAnnuler);
btMore = (Button)findViewById(R.id.btMore);
btLess = (Button)findViewById(R.id.btLess);

19/40

etNom = (EditText)findViewById(R.id.etNom);
etEmail = (EditText)findViewById(R.id.etEmail2);
etMdp = (EditText)findViewById(R.id.etMdp2);
etMdp2 = (EditText)findViewById(R.id.etMdp3);
etAdrPostale =(EditText)findViewById(R.id.etAdPostale);
etNbEnfant = (EditText)findViewById(R.id.etNbEnfant);
// On attribue un listener adapté aux vues qui en ont besoin
btValider.setOnClickListener(button1Listener);
btAnnuler.setOnClickListener(button1Listener);
btMore.setOnClickListener(button1Listener);
btLess.setOnClickListener(button1Listener);
etNom.setOnTouchListener(touch1Listener);
etEmail.setOnTouchListener(touch1Listener);
etMdp.setOnTouchListener(touch1Listener);
etMdp2.setOnTouchListener(touch1Listener);
etAdrPostale.setOnTouchListener(touch1Listener);
etNbEnfant.setOnTouchListener(touch1Listener);
// Définition des couleurs des textes:
etNbEnfant.setTextColor(Color.parseColor("#509CC7"));
}
private OnTouchListener touch1Listener = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(v.getId()){
case R.id.etNom:
etNom.setTextColor(Color.parseColor("#000000"));
etNom.setHintTextColor(Color.parseColor("#B9B9B9"));
etNom.setSelectAllOnFocus(true);
break;
case R.id.etEmail2:
etEmail.setTextColor(Color.parseColor("#000000"));
etEmail.setHintTextColor(Color.parseColor("#B9B9B9"));
etEmail.setSelectAllOnFocus(true);
break;
case R.id.etMdp2:
etMdp.setTextColor(Color.parseColor("#000000"));
etMdp.setHintTextColor(Color.parseColor("#B9B9B9"));
etMdp.setSelectAllOnFocus(true);
break;
case R.id.etMdp3:
etMdp2.setTextColor(Color.parseColor("#000000"));
etMdp2.setHintTextColor(Color.parseColor("#B9B9B9"));
etMdp2.setSelectAllOnFocus(true);
break;
case R.id.etAdPostale:
etAdrPostale.setTextColor(Color.parseColor("#000000"));
etAdrPostale.setHintTextColor(Color.parseColor("#B9B9B9"));
etAdrPostale.setSelectAllOnFocus(true);
break;

20/40

case R.id.etNbEnfant:
etNbEnfant.setTextColor(Color.parseColor("#000000"));
etNbEnfant.setHintTextColor(Color.parseColor("#B9B9B9"));
etNbEnfant.setSelectAllOnFocus(true);
break;
}
return false;
};

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.inscription, menu);
return true;
}
private OnClickListener button1Listener = new OnClickListener(){
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.btValider:
if(Verif_ChampsVides())
{
// RAJOUTER LA VERIF FORMAT EMAIL.
if(Verif_FormatMdp(etMdp.getText().toString())==true){
if(etMdp.getText().toString().equals(etMdp2.getText().toString())) //
vérifie que la confirm mdp est OK.
{
numErreur=-1;
myProgressDialog =
ProgressDialog.show(IHM_Inscription.this,"Chargement", "Veuillez patienter", true);
new Thread(new Runnable() {
public void run() {
numErreur=client.set_Compte(etEmail.getText().toString(),etMdp.getText().toString(),etNom.getText().toStr
ing(),Short.parseShort(etNbEnfant.getText().toString()), etAdrPostale.getText().toString());
myProgressDialog.dismiss();
Message msg = mHandler.obtainMessage();
mHandler.sendMessage(msg);
}
}).start();
}
else {
etMdp.setTextColor(Color.parseColor("#DB2525"));
etMdp2.setTextColor(Color.parseColor("#DB2525"));
createDialog("Erreur","Les deux mots de passe ne
correspondent pas.");
}
}
}
break;

21/40

case R.id.btAnnuler:
IHM_Inscription.this.finish();
break;
case R.id.btMore:
int Nb;
Nb = Integer.parseInt(etNbEnfant.getText().toString());
if(Nb<20)
Nb=Nb+1;
etNbEnfant.setText(Integer.toString(Nb));
break;

}
};

case R.id.btLess:
int Nb2;
Nb2 = Integer.parseInt(etNbEnfant.getText().toString());
if(Nb2>0)
Nb2=Nb2-1;
etNbEnfant.setText(Integer.toString(Nb2));
break;

}

Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
if(numErreur>=0)
{
if(numErreur==0){
AlertDialog.Builder builder = new
AlertDialog.Builder(IHM_Inscription.this);
builder.setMessage("Inscription Terminée, vous pouvez maintenant
vous connecter.").setTitle("Félicitation");
builder.setNeutralButton("OK", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
IHM_Inscription.this.finish();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
else if(numErreur==1)
createDialog("Erreur","Compte déjà existant.");
}
else
createDialog("Erreur","Echec connexion serveur.");
}
};
// ========= METHODES PRIVEE: =========

22/40

private void createDialog(String title, String text)
{
AlertDialog ad = new AlertDialog.Builder(this)
.setPositiveButton("Ok", null).setTitle(title).setMessage(text)
.create();
ad.show();
}
private boolean Verif_FormatMdp(String mdp)
{
boolean formatMdp=true;
int i,nb;
// On vérifie qu'il n'y a pas d'espace dans le mdp.
nb=mdp.length();
for(i=0;i<nb;i++)
{
char lettre;
lettre=mdp.charAt(i);
if(lettre==' '){
formatMdp=false;
etMdp.setTextColor(Color.parseColor("#DB2525"));
etMdp2.setTextColor(Color.parseColor("#DB2525"));
createDialog("Erreur de format","Le mot de passe ne peut pas contenir
d'espaces.");
i=nb;
}
}
return(formatMdp);
}
private boolean Verif_ChampsVides() // return true si les champs ne sont pas vides.
{
String email = ""+etEmail.getText().toString();
String mdp = ""+etMdp.getText().toString();
String mdp2 = ""+etMdp2.getText().toString();
String adr = ""+etAdrPostale.getText().toString();
String nom=""+etNom.getText().toString();
email=email.replace(" ",""); //on supprime les espaces dans l'email.
etEmail.setText(email); // on affiche l'email sans les espaces.
if(email=="" || mdp=="" || adr=="") // On vérifie que les champs sont remplis
{
createDialog("Erreur","Champ(s) incomplet(s) !");
if(nom=="")
etNom.setHintTextColor(Color.parseColor("#DB2525"));
if(email=="")
etEmail.setHintTextColor(Color.parseColor("#DB2525"));
if(mdp=="")
etMdp.setHintTextColor(Color.parseColor("#DB2525"));
if(mdp2=="")
etMdp2.setHintTextColor(Color.parseColor("#DB2525"));

23/40

if(adr=="")
etAdrPostale.setHintTextColor(Color.parseColor("#DB2525"));
return(false);
}
else
return(true);

}
}

c. IHM_Accueil.java
package com.example.e_periscol_backup;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class IHM_Accueil extends Activity {
private Button btAjEnfant = null;
private Button btParametres = null;
private int IdFam = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_accueil);
Intent intent = getIntent(); // Récupération de l'IDFAM.
if (intent != null) {
IdFam = Integer.parseInt(intent.getStringExtra("IdFam"));
}

}

// Récupération des vues:
btAjEnfant = (Button)findViewById(R.id.btAjEnfant);
btParametres = (Button)findViewById(R.id.btParametres);
// On attribue un listener adapté aux vues qui en ont besoin
btAjEnfant.setOnClickListener(button1Listener);
btParametres.setOnClickListener(button1Listener);

private OnClickListener button1Listener = new OnClickListener(){
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.btAjEnfant:
Intent intent_AjEnfant = new Intent(IHM_Accueil.this,IHM_Enfant.class);

24/40

}
};

intent_AjEnfant.putExtra("IdFam",Integer.toString(IdFam));
startActivity(intent_AjEnfant);
break;
case R.id.btParametres:
Intent intent_Parametres = new Intent(IHM_Accueil.this,IHM_Enfant.class);
intent_Parametres.putExtra("IdFam",Integer.toString(IdFam));
startActivity(intent_Parametres);
break;

}

}

// Cette partie du projet n'est pas terminé. Il manque l'affichage dynamique des enfants. Ainsi
qu'un bouton 'Déconnexion', 'Informations sur les services (identique à l'IHM de Connexion),
'Editer enfant' et un bouton 'Paramètres' pour modifier les paramètres du compte. J'ai commencé
la configuration de l'IHM Paramètres, mais je la trouve insuffisamment avancé pour la présenter.

d. IHM_Enfant.java
package com.example.e_periscol_backup;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.StringTokenizer;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.RadioButton;
import android.widget.RadioGroup;

25/40

public class IHM_Enfant extends Activity {
private EditText etNom = null;
private EditText etPrenom = null;
private Button btInscriptionActivites = null;
private Button btValiderAjEnfant = null;
private Button btAnnulerAjEnfant = null;
private RadioGroup rgSexe = null;
private RadioButton rbGarcon = null;
private RadioButton rbFille = null;
private TextView tvListActivite = null;
private TextView tvDateNaiss = null;
private TextView tvbtDateNaiss = null;
private int IdFam;
private boolean Sexe = true;
private ArrayList<Service> Activites;
private ArrayList<String> ChoixActivite;
DialogInterface.OnMultiChoiceClickListener MultiChoiceClickListener;
boolean[] mCheckedItems;
private Client client;
final int Date_Dialog_ID=0;
int cDay,cMonth,cYear; // variable de la date actuelle
Calendar cDate;
int sDay,sMonth,sYear; // date modifiée
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_aj_enfant);
client = new Client();
// Récupération de l'IDFAM.
Intent intent = getIntent();
if (intent != null) {
IdFam = Integer.parseInt(intent.getStringExtra("IdFam"));
}
// Recupération des Activités.
Recup_Activites();
// Récupération des vues:
etNom = (EditText)findViewById(R.id.etNom);
etPrenom = (EditText)findViewById(R.id.etPrenom);
btInscriptionActivites = (Button)findViewById(R.id.btInscriptionActivitees);
btValiderAjEnfant = (Button)findViewById(R.id.btValiderAjEnfant);
btAnnulerAjEnfant = (Button)findViewById(R.id.btAnnulerAjEnfant);
rbGarcon = (RadioButton) findViewById(R.id.rbGarcon);
rbFille = (RadioButton) findViewById(R.id.rbFille);
rgSexe = (RadioGroup) findViewById(R.id.rgSexe);
tvListActivite = (TextView)findViewById(R.id.tvListActivite);
tvDateNaiss = (TextView)findViewById(R.id.tvDateNaiss);
tvbtDateNaiss = (TextView)findViewById(R.id.tvbtDateNaiss);

26/40

// On attribue un listener adapté aux vues qui en ont besoin
btInscriptionActivites.setOnClickListener(button1Listener);
btValiderAjEnfant.setOnClickListener(button1Listener);
btAnnulerAjEnfant.setOnClickListener(button1Listener);
tvbtDateNaiss.setOnClickListener(button1Listener);
etNom.setOnTouchListener(touch1Listener);
etPrenom.setOnTouchListener(touch1Listener);
rbFille.setOnTouchListener(touch1Listener);
rbGarcon.setOnTouchListener(touch1Listener);
// Colorisation BT date naissance:
tvbtDateNaiss.setHintTextColor(Color.parseColor("#509CC7"));
// Mémorisation des services cochés. (checkbox - popup)
mCheckedItems = new boolean[Activites.size()];
for(int i=0;i<Activites.size();i++)
{
mCheckedItems[i]=false; // Initialisation: Aucune case de cochée.
}
//Récupération de la date actuelle
cDate=Calendar.getInstance();
cDay=cDate.get(Calendar.DAY_OF_MONTH);
cMonth=cDate.get(Calendar.MONTH);
cYear=cDate.get(Calendar.YEAR);
}
private OnTouchListener touch1Listener = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch(v.getId()){
case R.id.etNom:
etNom.setTextColor(Color.parseColor("#000000"));
etNom.setHintTextColor(Color.parseColor("#B9B9B9"));
etNom.setSelectAllOnFocus(true);
break;
case R.id.etPrenom:
etPrenom.setTextColor(Color.parseColor("#000000"));
etPrenom.setHintTextColor(Color.parseColor("#B9B9B9"));
etPrenom.setSelectAllOnFocus(true);
break;
case R.id.rbGarcon:
rbFille.setTextColor(Color.parseColor("#000000"));
rbGarcon.setTextColor(Color.parseColor("#000000"));
break;
case R.id.rbFille:
rbFille.setTextColor(Color.parseColor("#000000"));
rbGarcon.setTextColor(Color.parseColor("#000000"));
break;
}

27/40

return false;
};

}

private OnClickListener button1Listener = new OnClickListener(){
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.btInscriptionActivitees:
Recup_Activites(); // On récupère les activités disponible en fonction de la
date de naissance.
final ArrayList<Integer> mSelectedItems;
mSelectedItems = new ArrayList<Integer>();
CharSequence[] items = new String[Activites.size()];
for(int j=0;j<Activites.size();j++){
items[j]=Activites.get(j).get_Nom(); // On récupère le nom
des # services
}
MultiChoiceClickListener = new
DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int
indexSelected,boolean isChecked) {
if (isChecked) {
mSelectedItems.add(indexSelected);
mCheckedItems[indexSelected]=true;
} else if (mSelectedItems.contains(indexSelected)) {
mSelectedItems.remove(Integer.valueOf(indexSelected));
mCheckedItems[indexSelected]=false;
}
}
};
final boolean[] mCheckedItems_save = new
boolean[Activites.size()];
for(int i=0;i<Activites.size();i++)
mCheckedItems_save[i]=mCheckedItems[i];
AlertDialog.Builder builder = new AlertDialog.Builder(IHM_Enfant.this);
builder.setTitle("Liste des services periscolaires");
builder.setMultiChoiceItems(items,mCheckedItems,MultiChoiceClickListener);
builder.setPositiveButton("OK", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
String liste="";
int aucune = 0;
for(int j=0;j<Activites.size();j++)
{
if(mCheckedItems[j]==true)
liste=liste+"- "+Activites.get(j).get_Nom()+"\n";

28/40

else

}

aucune = aucune+1;
}
if(aucune==Activites.size())
{
liste="- Aucune \n";
}
tvListActivite.setText(liste);

});
builder.setNegativeButton("Annuler", new

DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
// Restauration
for(int i=0;i<Activites.size();i++)
mCheckedItems[i]=mCheckedItems_save[i];
}
});
AlertDialog dialog = builder.create();
dialog.show();
break;

case R.id.tvbtDateNaiss:
tvbtDateNaiss.setTextColor(Color.parseColor("#000000"));
showDialog(Date_Dialog_ID);
break;
case R.id.btValiderAjEnfant:
// VEIRIFIER CHAMPS VIDES ! A FAIRE plus tard.
// On récupère l'identifiant du bouton qui est coché
if(rgSexe.getCheckedRadioButtonId()==1)
Sexe = true; // garçon
else
Sexe = false; // fille
String photo; // pour plus tard
photo="http://ma_photo.com";
ChoixActivite = new ArrayList<String>();
for(int j=0;j<Activites.size();j++)
{
}

if(mCheckedItems[j]==true)
ChoixActivite.add(Activites.get(j).get_Nom());
Boolean aff;
aff=false;
if(Verif_ChampsVides())
{
try {

29/40

aff=client.set_Enfant(etNom.getText().toString(),etPrenom.getText().toString(),Sexe,tvbtDateNaiss.getText()
.toString(),ChoixActivite,photo,IdFam);
} catch (ParseException e) {e.printStackTrace();}
String test = "";
for(int a=0;a<client.Usager_c.get_Enfant(0).get_Activite().size();a+
+){

test =
test+client.Usager_c.get_Enfant(0).get_Activite().get(a);
test=test+" ";
}
if(test.equals(""))
test=" Aucun";
// Afficher si aucune activite cochée. MSG non définitif. Version
débug.
createDialog("OK",String.valueOf(aff)+" Inscription aux
services:"+test);
// Rajouter la gestion des erreur.
}
break;
case R.id.btAnnulerAjEnfant:
IHM_Enfant.this.finish();
break;
}

}

};
private OnDateSetListener onDateSet=new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,int dayOfMonth) {
sYear=year;
sMonth=monthOfYear;
sDay=dayOfMonth;
updateDateDisplay(sYear,sMonth,sDay);
}
};
// ========= METHODES PRIVEE: =========
private void createDialog(String title, String text)
{
AlertDialog ad = new AlertDialog.Builder(this)
.setPositiveButton("Ok", null).setTitle(title).setMessage(text)
.create();
ad.show();
}
protected Dialog onCreateDialog(int id) {

30/40

switch (id) {
case Date_Dialog_ID:
return new DatePickerDialog(this, onDateSet, cYear, cMonth,cDay);
}
return null;
}
private void updateDateDisplay(int year,int month,int date) {
tvbtDateNaiss.setText(date+"/"+(month+1)+"/"+year);
}
private void Recup_Activites()
{
// FAIRE LA GESTION DES ERREURS CONNEXION. +
// TOUT RECUPERER MAIS TRIER A L'AFFICHAGE LES ACTIVITES EN FCT DE LA DATE DE
NAISSANCE /!\

}

Activites = new ArrayList<Service>();
if(client.get_AllService())
{
for(int i=0;i<client.CataloguesServices_c.Taille();i++)
{
// Récupérer uniquement les activités dispo pour l'age ! A faire + tard
Activites.add(client.CataloguesServices_c.Get(i));
}
}

private boolean Verif_ChampsVides() // return true si les champs ne sont pas vides.
{
String nom = ""+etNom.getText().toString();
String prenom = ""+etPrenom.getText().toString();
String dateNaiss = ""+tvbtDateNaiss.getText().toString();
if(nom=="" || prenom=="" || dateNaiss=="" || rgSexe.getCheckedRadioButtonId()==-1) //
On vérifie que les champs sont remplis
{
createDialog("Erreur","Champ(s) incomplet(s) !");
if(nom=="")
etNom.setHintTextColor(Color.parseColor("#DB2525"));
if(prenom=="")
etPrenom.setHintTextColor(Color.parseColor("#DB2525"));
/* if(dateNaiss=="")
etDateNaiss.setHintTextColor(Color.parseColor("#DB2525")); */
if(rgSexe.getCheckedRadioButtonId()==-1){
rbFille.setTextColor(Color.parseColor("#DB2525"));
rbGarcon.setTextColor(Color.parseColor("#DB2525"));
}
return(false);

31/40

}
else
}

return(true);

}

// J'utilise un composant DatePicker pour la date de naissance. Cependant, je n'ai pas encore
réussi à récupérer la valeur que l'utilisateur défini en utilisant ce composant. C'est en cours de
réalisation.

2) Les classes
a. CatalogueServices.java
package com.example.e_periscol_backup;
import java.util.ArrayList;
import java.util.Iterator;
public class CatalogueServices {
// Création d'un ensemble illimité
private ArrayList<Service> Services;
public CatalogueServices(){Services = new ArrayList<Service>();}
public void Ajouter(String nom,String domaine,Short ageMin,Short ageMax){
Service temp = new Service();
temp.Ajouter(nom,domaine,ageMin,ageMax);
Services.add(temp);
}
public int Taille(){return Services.size();}
public void Delete(){Services.clear();}
public Service Get(int pos){return Services.get(pos);}
public String Consulter(){
String SrvSportif = "Sportifs:";
String SrvCultu = "\n Culturels:\n";
Service service_temp = new Service();
for(int i=0;i<Services.size();i++)
{
service_temp=Services.get(i);
if(service_temp.get_Domaine().equals("Sportif"))
{
SrvSportif=SrvSportif+"- "+service_temp.get_Nom()+"
("+service_temp.get_AgeMin()+
" à "+service_temp.get_AgeMax()+" ans)";
}
else

32/40

{
SrvCultu=SrvCultu+"- "+service_temp.get_Nom()+" ("+service_temp.get_AgeMin()

+

" à "+service_temp.get_AgeMax()+" ans)";

}
SrvSportif=SrvSportif+"\n";
SrvCultu=SrvCultu+"\n";
}

return SrvSportif+SrvCultu;

}
}

b. Client.java
package com.example.e_periscol_backup;
import java.util.ArrayList;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import android.app.ProgressDialog;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Client {
// SOAP
private String NAMESPACE = "http://192.168.3.5:8080/Actions_Client";
private String URL = "http://192.168.3.5:8080/E-periscol/Actions_Client?WSDL";
private String SOAP_ACTION = "http://192.168.3.5:8080/E-periscol/Actions_Client";
public Compte Compte_c;
public Usager Usager_c;
public Connexion Connexion_c;
public CatalogueServices CataloguesServices_c;
private boolean Reussite=false;
private int NumErreur=-1;
private boolean fin_Thread = false;
private void init_liaison(){Reussite=false;NumErreur=-1;fin_Thread=false;};
private void Synchro(int duree){
int i=0;
while(fin_Thread!=true && i<=duree){try {Thread.sleep(300);} catch (InterruptedException
e) {e.printStackTrace();} i++;}
};
public Client(){

33/40

}

Compte_c = new Compte();
Usager_c = new Usager();
Connexion_c = new Connexion();
CataloguesServices_c = new CatalogueServices();

public int Connect(String email,String mdp){
init_liaison();
Compte_c.Creer(email, mdp);
new Thread(new Runnable() {
public void run() {
try {
SoapObject request = new SoapObject(NAMESPACE,"SeConnecter");
request.addProperty("Email",Compte_c.get_Email());
request.addProperty("Mdp",Compte_c.get_Mdp());
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new
AndroidHttpTransport(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject) envelope.getResponse();
Connexion_c.Session(
Integer.parseInt(result.getProperty("ID_Fam").toString()),
Boolean.parseBoolean(result.getProperty("Role").toString()));
NumErreur = Integer.parseInt(result.getProperty("Erreur").toString());
} catch (Exception e) {NumErreur=-1;}
fin_Thread=true;

}

}
}).start();
Synchro(3);
return NumErreur;

public int set_Compte(String email,String mdp,String nom,short nbEnfant,String adrPostale){
init_liaison();
Compte_c.Creer(email, mdp);
Usager_c.Creer(nom, nbEnfant, adrPostale);
new Thread(new Runnable() {
public void run() {
try {
SoapObject request = new SoapObject(NAMESPACE,"CreerCompte");
request.addProperty("Email",Compte_c.get_Email());
request.addProperty("Mdp",Compte_c.get_Mdp());
request.addProperty("Nom",Usager_c.get_Nom());
request.addProperty("NbrEnfants",Usager_c.get_NbEnfant());

34/40

request.addProperty("AdrPostale",Usager_c.get_AdrPostale());
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new
AndroidHttpTransport(URL);

androidHttpTransport.call(SOAP_ACTION, envelope);

NumErreur = Integer.parseInt(envelope.getResponse().toString());
} catch (Exception e) {NumErreur=-1;}
fin_Thread=true;
}
}).start();
Synchro(3);
return NumErreur;
}
public boolean get_AllService(){
init_liaison();
new Thread(new Runnable() {
public void run() {
try {
SoapObject request = new SoapObject(NAMESPACE,"Get_All_Service");
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new
AndroidHttpTransport(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject result = (SoapObject) envelope.getResponse();
CataloguesServices_c.Delete();
// Récupérer tableau de serv
for(int i=0;i<result.getPropertyCount();i++)
{
SoapObject resultServices = (SoapObject) result.getProperty(i);
CataloguesServices_c.Ajouter(resultServices.getProperty("Nom").toString(),
resultServices.getProperty("Domaine").toString(),
Short.parseShort(resultServices.getProperty("AgeMin").toString()),
Short.parseShort(resultServices.getProperty("AgeMax").toString()));
}
Reussite=true;
} catch (Exception e) { Reussite=false;}
fin_Thread=true;

35/40

}

}
}).start();
Synchro(3);
return Reussite;

public int mdp_oublie(String email){
init_liaison();
Compte_c.set_Email(email);
new Thread(new Runnable(){
public void run(){
try{
SoapObject request = new SoapObject(NAMESPACE,"MdpOublie");
request.addProperty("Email",Compte_c.get_Email());
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new
AndroidHttpTransport(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
NumErreur = Integer.parseInt(envelope.getResponse().toString());
}catch (Exception e) { NumErreur=-1;}
fin_Thread=true;

}

}
}).start();
Synchro(5);
return NumErreur;

public boolean set_Enfant(String nom, String prenom, boolean sexe,String date,ArrayList<String>
choixActivite,String photo,int idFam) throws ParseException{
init_liaison();
Usager_c.Ajouter_Enfant(1,nom, prenom, sexe,date,choixActivite, photo);
Connexion_c.set_IdFam(idFam);
new Thread(new Runnable() {
public void run() {
try {
SoapObject request = new SoapObject(NAMESPACE,"AjouterEnfant");
request.addProperty("Nom",Usager_c.get_Enfant(0).get_Nom());
request.addProperty("Prenom",Usager_c.get_Enfant(0).get_Prenom());
request.addProperty("Sexe",Usager_c.get_Enfant(0).get_Sexe());
request.addProperty("DateNaiss",Usager_c.get_Enfant(0).get_Date());
for(int a=0; a<Usager_c.get_Enfant(0).get_Activite().size();a++)
{
request.addProperty("Activite",Usager_c.get_Enfant(0).get_Activite().get(a));
}

36/40

request.addProperty("Photo",Usager_c.get_Enfant(0).get_Photo());
request.addProperty("ID_Fam",Connexion_c.get_IdFam());
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
AndroidHttpTransport androidHttpTransport = new
AndroidHttpTransport(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
Reussite = Boolean.parseBoolean(envelope.getResponse().toString());
} catch (Exception e) {Reussite=false;}
fin_Thread=true;

}

}
}).start();
Synchro(3);
return Reussite;

}

c. Compte.java
package com.example.e_periscol_backup;
public class Compte {
private String Email;
private String Mdp;
public Compte(){
Email="";
Mdp="";
}
public String get_Email(){return(Email);}
public String get_Mdp(){return(Mdp);}
public void set_Email(String e){Email=e;}
public void Creer(String email,String mdp)
{
Email = email;
Mdp = mdp;
}
}

37/40

d. Connexion.java
package com.example.e_periscol_backup;
public class Connexion {
private int IdFam;
private boolean Role;
public Connexion(){
IdFam = 0;
Role = false;
}
public void Session(int id,boolean role){
IdFam = id;
Role = role; // role à false = admin sinon user.
}
public boolean get_role(){return(Role);}
public int get_IdFam(){return(IdFam);}
public void set_IdFam(int id){IdFam = id ;}
}

e. Enfant.java
package com.example.e_periscol_backup;
import java.util.ArrayList;
public class Enfant {
private int Id;
private String Nom;
private String Prenom;
private boolean Sexe;
private short Age;
private String DateNaiss;
private ArrayList<String> Activite;
private String Photo;
private static final boolean MASCULIN = true;
private static final boolean FEMININ = false;
public Enfant(){
Id=-1;
Nom="";
Prenom="";
Sexe=MASCULIN;
Age=1;
DateNaiss = "01/01/0001";

38/40

}

Activite = null;
Photo="";

public int get_Id(){return(Id);}
public String get_Nom(){return(Nom);}
public String get_Prenom(){return(Prenom);}
public boolean get_Sexe(){return(Sexe);}
public String get_Date(){return(DateNaiss);}
public ArrayList<String> get_Activite(){return(Activite);}
public String get_Photo(){return(Photo);}
public void Ajouter(int id, String nom,String prenom,boolean sexe,String date,ArrayList<String>
activite,String photo){
Id = id;
Nom=nom;
Prenom=prenom;
Sexe=sexe;
DateNaiss = date;
Activite = activite;
Photo=photo;
}
}

f. Service.java
package com.example.e_periscol_backup;
public class Service {
private String Nom;
private short AgeMin;
private short AgeMax;
private String Domaine; // Sportif ou Culturel
public Service(){
//Id=-1;
Nom="";
AgeMin=0;
AgeMax=0;
Domaine="";
}
public void Ajouter(String nom,String domaine, short ageMin, short ageMax){
Nom=nom;
AgeMin=ageMin;
AgeMax=ageMax;
Domaine=domaine;
};
public String get_Nom(){return(Nom);}
public short get_AgeMin(){return(AgeMin);}

39/40

}

public short get_AgeMax(){return(AgeMax);}
public String get_Domaine(){return(Domaine);}

g. Usager.java
package com.example.e_periscol_backup;
import java.text.ParseException;
import java.util.ArrayList;
public class Usager {
private String Nom;
private short NbEnfant;
private String AdrPostale;
private ArrayList<Enfant> Enfants; // tableau
public Usager(){
Nom="";
NbEnfant=1;
AdrPostale="";
Enfants=new ArrayList<Enfant>();
}
public String get_Nom(){return(Nom);}
public int get_NbEnfant(){return(NbEnfant);}
public String get_AdrPostale(){return(AdrPostale);}
public Enfant get_Enfant(int pos){return(Enfants.get(pos));}
//public Enfant[] get_AllEnfants(){return(Enfants);} // PAS MISE EN OEUVRE POUR LE MOMENT.
public void Ajouter_Enfant(int idEnf,String nom,String prenom,boolean sexe,String
date,ArrayList<String> activite,String photo){
Enfant temp;
temp=new Enfant();
temp.Ajouter(idEnf,nom,prenom,sexe,date,activite,photo);
Enfants.add(temp);
}
public void Creer(String nom,short nb,String adr){
Nom=nom;
NbEnfant=nb;
AdrPostale=adr;
}
}

40/40


Aperçu du document AnnexesAndroid.pdf - page 1/40
 
AnnexesAndroid.pdf - page 2/40
AnnexesAndroid.pdf - page 3/40
AnnexesAndroid.pdf - page 4/40
AnnexesAndroid.pdf - page 5/40
AnnexesAndroid.pdf - page 6/40
 




Télécharger le fichier (PDF)


AnnexesAndroid.pdf (PDF, 438 Ko)

Télécharger
Formats alternatifs: ZIP



Documents similaires


programmationavancee java gui
elecodes page map
eleextrait classe json java html xml codesource android
elecodes models existants
elecodes page informations
elecodes page preparer

Sur le même sujet..