diff --git a/code/PtiClic/AndroidManifest.xml b/code/PtiClic/AndroidManifest.xml
index 33fc440..c1b936c 100644
--- a/code/PtiClic/AndroidManifest.xml
+++ b/code/PtiClic/AndroidManifest.xml
@@ -1,24 +1,28 @@
-
-
-
-
-
-
-
+ package="org.pticlic" android:versionCode="1" android:versionName="@string/version">
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
+
-
+
diff --git a/code/PtiClic/res/layout/basegame.xml b/code/PtiClic/res/layout/basegame.xml
deleted file mode 100644
index 9e5a90e..0000000
--- a/code/PtiClic/res/layout/basegame.xml
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/code/PtiClic/res/layout/frontpage.xml b/code/PtiClic/res/layout/frontpage.xml
index fbcef16..3b80fb5 100644
--- a/code/PtiClic/res/layout/frontpage.xml
+++ b/code/PtiClic/res/layout/frontpage.xml
@@ -1,41 +1,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/code/PtiClic/res/layout/score.xml b/code/PtiClic/res/layout/score.xml
deleted file mode 100644
index 312a0d8..0000000
--- a/code/PtiClic/res/layout/score.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/code/PtiClic/src/org/pticlic/BaseScore.java b/code/PtiClic/src/org/pticlic/BaseScore.java
deleted file mode 100644
index 97ffbdf..0000000
--- a/code/PtiClic/src/org/pticlic/BaseScore.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package org.pticlic;
-
-import org.pticlic.R.string;
-import org.pticlic.exception.PtiClicException;
-import org.pticlic.model.Constant;
-import org.pticlic.model.DownloadedBaseGame;
-import org.pticlic.model.Match;
-import org.pticlic.model.Network;
-import org.pticlic.model.Network.Mode;
-import org.pticlic.model.Network.ScoreResponse;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.DialogInterface;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.Button;
-import android.widget.TextView;
-
-/**
- * @author John CHARRON
- *
- * Permet l'affichage du score obtenu par le joueur lors de sa partie.
- */
-public class BaseScore extends Activity implements OnClickListener{
-
- private Match gamePlayed;
- private ScoreResponse sr = null;
-
- private void networkStuff() {
- SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
- String id = sp.getString(Constant.USER_ID, "joueur");
- String passwd = sp.getString(Constant.USER_PASSWD, "");
- String serverURL = sp.getString(Constant.SERVER_URL, Constant.SERVER);
- Mode mode = null;
-
- if (getIntent().getExtras() != null) {
- // GamePlayed contient toutes les infos sur la partie jouee
- this.gamePlayed = (Match) getIntent().getExtras().get(Constant.SCORE_GAMEPLAYED);
- mode = (Mode) getIntent().getExtras().get(Constant.SCORE_MODE);
- }
-
- // TODO : factoriser le serverUrl dans Network
- sp.edit().remove(Constant.NEW_BASE_GAME).commit();
- Network network = new Network(serverURL, mode, id, passwd);
- try {
- sr = network.sendBaseGame(gamePlayed);
- sp.edit().putString(Constant.NEW_BASE_GAME, sr.getNewGame()).commit();
- } catch (PtiClicException e) {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(getString(R.string.app_name))
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setMessage(e.getMessage())
- .setCancelable(false)
- .setNegativeButton("Ok", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- finish();
- }
- });
- AlertDialog alert = builder.create();
- alert.show();
- } catch (Exception e) {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(getString(R.string.app_name))
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setMessage(R.string.server_down)
- .setCancelable(false)
- .setNegativeButton("Ok", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- finish();
- }
- });
- AlertDialog alert = builder.create();
- alert.show();
- }
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.score);
-
- this.networkStuff();
- this.networkStuff();
-
- // TODO : Attention, le cast en (BaseGame) n'est pas sûr !
- DownloadedBaseGame bg = (DownloadedBaseGame)gamePlayed.getGame();
- ((TextView)findViewById(R.id.total)).setText(String.valueOf(sr.getScoreTotal()));
- ((TextView)findViewById(R.id.scoreRel1)).setText(bg.getCatString(1));
- ((TextView)findViewById(R.id.scoreRel2)).setText(bg.getCatString(2));
- ((TextView)findViewById(R.id.scoreRel3)).setText(bg.getCatString(3));
- ((TextView)findViewById(R.id.scoreRel4)).setText(bg.getCatString(4));
-
- String res;
- String noAnswers = getString(string.score_no_answers);
- res = "";
- for (int i : gamePlayed.getRelation1()) {
- res += bg.getWordInCloud(i).getName();
- res += " (" + String.valueOf(sr.getScoreOfWord(i)) + "), ";
- }
- ((TextView)findViewById(R.id.scoreWords1)).setText(res.length() < 1 ? noAnswers : res);
-
- res = "";
- for (int i : gamePlayed.getRelation2()) {
- res += bg.getWordInCloud(i).getName();
- res += " (" + String.valueOf(sr.getScoreOfWord(i)) + "), ";
- }
- ((TextView)findViewById(R.id.scoreWords2)).setText(res.length() < 1 ? noAnswers : res);
-
- res = "";
- for (int i : gamePlayed.getRelation3()) {
- res += bg.getWordInCloud(i).getName();
- res += " (" + String.valueOf(sr.getScoreOfWord(i)) + "), ";
- }
- ((TextView)findViewById(R.id.scoreWords3)).setText(res.length() < 1 ? noAnswers : res);
-
- res = "";
- for (int i : gamePlayed.getRelation4()) {
- res += bg.getWordInCloud(i).getName();
- res += " (" + String.valueOf(sr.getScoreOfWord(i)) + "), ";
- }
- ((TextView)findViewById(R.id.scoreWords4)).setText(res.length() < 1 ? noAnswers : res);
-
- ((Button)findViewById(R.id.saw)).setOnClickListener(this);
- }
-
- @Override
- public void onBackPressed() {
- super.onBackPressed();
-
- finish();
- }
-
- protected double calculateTotal(){
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void onClick(View v) {
- if (v.getId()==R.id.saw) {
- finish();
- }
- }
-}
diff --git a/code/PtiClic/src/org/pticlic/FrontPage.java b/code/PtiClic/src/org/pticlic/FrontPage.java
index 42dd995..b397d51 100644
--- a/code/PtiClic/src/org/pticlic/FrontPage.java
+++ b/code/PtiClic/src/org/pticlic/FrontPage.java
@@ -1,25 +1,15 @@
package org.pticlic;
-import org.pticlic.games.BaseGame;
import org.pticlic.model.Constant;
-import org.pticlic.model.Network;
import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.net.Uri;
import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.ImageView;
-import android.widget.TextView;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
-public class FrontPage extends Activity implements OnClickListener{
+public class FrontPage extends Activity {
- private Uri uri = null;
+ private WebView webView;
/** Called when the activity is first created. */
@Override
@@ -27,83 +17,11 @@ public class FrontPage extends Activity implements OnClickListener{
super.onCreate(savedInstanceState);
setContentView(R.layout.frontpage);
- // Écoute des clics sur les différents boutons
- ((ImageView)findViewById(R.id.prefs)).setOnClickListener(this);
- ((ImageView)findViewById(R.id.play)).setOnClickListener(this);
- ((ImageView)findViewById(R.id.infoButton)).setOnClickListener(this);
-
- SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
- String serverURL = sp.getString(Constant.SERVER_URL, Constant.SERVER);
- Uri.parse(serverURL + "/signup.php");
- }
-
- @Override
- protected void onStart() {
- super.onStart();
-
- // On récupère le nom du joueur des préférences.
- SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
- Boolean connected = sp.getBoolean(Constant.SERVER_AUTH, false);
- if (connected) {
- ((TextView)findViewById(R.id.login)).setText(R.string.frontpage_user_connected);
- } else {
- ((TextView)findViewById(R.id.login)).setText(R.string.frontpage_user_notconnected);
- }
- }
-
- /* (non-Javadoc)
- * @see android.view.View.OnClickListener#onClick(android.view.View)
- */
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case (R.id.prefs) : startActivity(new Intent(this, Preference.class)); break;
- case (R.id.play) : checkAllIsOk(BaseGame.class); break;
- case (R.id.infoButton) : startActivity(new Intent(this, Information.class)); break;
- }
- }
-
- @SuppressWarnings("rawtypes")
- private void checkAllIsOk(Class c) {
- if (Network.isConnected(this)) {
- if (Network.isLoginCorrect(this)) {
- startActivity(new Intent(this, c));
- } else {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(getString(R.string.app_name))
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setMessage(getString(R.string.frontpage_bad_loginmdp))
- .setCancelable(false)
- .setNeutralButton(getString(R.string.frontpage_inscription_button), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.dismiss();
- // TODO : Essayer de trouver comment mettre l'url qui est dans les preferences.
- startActivity(new Intent(Intent.ACTION_VIEW, uri));
- }
- })
- .setPositiveButton(getString(R.string.frontpage_preference_button), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.dismiss();
- startActivity(new Intent(getApplicationContext(), Preference.class));
- }
- });
- AlertDialog alert = builder.create();
- alert.show();
- }
- } else {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(getString(R.string.app_name))
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setMessage(getString(R.string.frontpage_no_connection))
- .setCancelable(false)
- .setNegativeButton("Ok", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- }
- });
- AlertDialog alert = builder.create();
- alert.show();
- }
+ webView = (WebView) findViewById(R.id.webview);
+ WebSettings webSettings = webView.getSettings();
+ webSettings.setJavaScriptEnabled(true);
+
+ webView.loadUrl(Constant.SERVER + Constant.SERVER_URL);
}
@Override
diff --git a/code/PtiClic/src/org/pticlic/Information.java b/code/PtiClic/src/org/pticlic/Information.java
index d106f83..015ce2c 100644
--- a/code/PtiClic/src/org/pticlic/Information.java
+++ b/code/PtiClic/src/org/pticlic/Information.java
@@ -40,7 +40,7 @@ public class Information extends Activity {
}
in.close();
- webview.loadUrl("http://www.pticlic.fr/html5/code/html5/");
+ webview.loadData(html, "text/html", "UTF-8");
} catch (IOException e) {
//TODO : Ajouter un boite de dialog indiquant qu'une erreur est arrivee.
diff --git a/code/PtiClic/src/org/pticlic/games/BaseGame.java b/code/PtiClic/src/org/pticlic/games/BaseGame.java
deleted file mode 100644
index ee966ed..0000000
--- a/code/PtiClic/src/org/pticlic/games/BaseGame.java
+++ /dev/null
@@ -1,433 +0,0 @@
-package org.pticlic.games;
-
-import org.pticlic.R;
-import org.pticlic.BaseScore;
-import org.pticlic.exception.PtiClicException;
-import org.pticlic.model.Constant;
-import org.pticlic.model.DownloadedBaseGame;
-import org.pticlic.model.Match;
-import org.pticlic.model.Network;
-import org.pticlic.model.Network.Mode;
-import org.pticlic.model.Relation;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.view.Display;
-import android.view.Gravity;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.animation.AlphaAnimation;
-import android.view.animation.AnimationSet;
-import android.view.animation.TranslateAnimation;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.LinearLayout.LayoutParams;
-import android.widget.TextView;
-
-import com.google.gson.Gson;
-
-/**
- * @author Bertrand BRUN et Georges DUPÉRON
- *
- * Cette classe est le controlleur du premier jeu.
- *
- * Ce premier jeu appeler "Jeux de Base", permet de creer des relations en selectionnant
- * le type de relation d'un mot du nuage de mot par rapport au mot central.
- *
- * La vue de ce jeu se presente sous la forme d'un fenetre presentant en haut le mot central,
- * et les mots du nuage descende en partant du mot central vers le centre du mobile.
- * Une fois le mot du nuage afficher, l'utilisateur peut selectionner, parmis les relations
- * proposer celle qui lui semble le mieux approprier.
- *
- */
-
-public class BaseGame extends Activity implements OnClickListener {
- private int currentWord = 0;
- private TextView currentWordTextView;
- private TextView wordRemaining;
- private int nbWord = 0;
- private DownloadedBaseGame game;
- private Match match;
- private Network network;
- private boolean help = false;
- private String gameJson;
-
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.basegame);
-
- // On recupere du PreferenceManager les differentes information dont on a besoin
- SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
- String serverURL = sp.getString(Constant.SERVER_URL, Constant.SERVER);
- String id = sp.getString(Constant.USER_ID, "joueur");
- String passwd = sp.getString(Constant.USER_PASSWD, "");
- gameJson = sp.getString(Constant.NEW_BASE_GAME, null);
-
- // On initialise la classe permettant la communication avec le serveur.
- network = new Network(serverURL, Mode.SIMPLE_GAME, id, passwd);
- }
-
-
-
- /* (non-Javadoc)
- * @see android.app.Activity#onStart()
- */
- @Override
- protected void onStart() {
- super.onStart();
- try {
- Gson gson = new Gson();
- if (gameJson == null) game = (DownloadedBaseGame)network.getGames(1);
- else game = gson.fromJson(gameJson, DownloadedBaseGame.class);
- SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
- Boolean first = sp.getBoolean(Constant.FIRST_TIME, true);
- if (first) {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(getString(R.string.basegame_title))
- .setIcon(android.R.drawable.ic_dialog_info)
- .setMessage(getString(R.string.basegame_explication))
- .setCancelable(false)
- .setNegativeButton("Fermez", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- runMatch();
- start();
- }
- })
- .setPositiveButton("Ne plus afficher", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
- sp.edit().putBoolean(Constant.FIRST_TIME, false).commit();
- dialog.cancel();
- runMatch();
- start();
- }
- });
- AlertDialog alert = builder.create();
- alert.show();
- } else {
- runMatch();
- start();
- }
- } catch (PtiClicException e) {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(getString(R.string.app_name))
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setMessage(e.getMessage())
- .setCancelable(false)
- .setNegativeButton("Ok", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- finish();
- }
- });
- AlertDialog alert = builder.create();
- alert.show();
- } catch (Exception e) {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(getString(R.string.app_name))
- .setIcon(android.R.drawable.ic_dialog_alert)
- .setMessage(getString(R.string.server_down))
- .setCancelable(false)
- .setNegativeButton("Ok", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- finish();
- }
- });
- AlertDialog alert = builder.create();
- alert.show();
- }
-
- }
-
- private void runMatch() {
- nbWord = game.getNbWord();
-
- wordRemaining = (TextView)findViewById(R.id.wordRemaining);
- wordRemaining.setText((currentWord + 1) + "/" + nbWord);
-
- // On initialise la partie.
- match = new Match();
- match.setGame(game);
-
- // Boutons des relations
- ImageView r1 = ((ImageView)findViewById(R.id.relation1));
- ImageView r2 = ((ImageView)findViewById(R.id.relation2));
- ImageView r3 = ((ImageView)findViewById(R.id.relation3));
- ImageView r4 = ((ImageView)findViewById(R.id.relation4));
-
-
- // TextView des relations
- TextView rn1 = ((TextView)findViewById(R.id.relation1Name));
- TextView rn2 = ((TextView)findViewById(R.id.relation2Name));
- TextView rn3 = ((TextView)findViewById(R.id.relation3Name));
- TextView rn4 = ((TextView)findViewById(R.id.relation4Name));
-
- // Bouton d'aide
- ImageView aide = ((ImageView)findViewById(R.id.aideBaseGame));
- aide.setOnClickListener(this);
-
- // On met set le nom du mot central
- ((TextView)findViewById(R.id.mainWord)).setText(DownloadedBaseGame.getName(game.getCentre()));
-
- Relation r = Relation.getInstance();
-
- // Écoute des clics sur les relations
- // TODO : A enlever lorsque l'on aura toutes les images des relations.
- try {
- r1.setOnClickListener(this);
- rn1.setText(String.format(r.getRelationName(game.getCat1()), ((TextView)findViewById(R.id.mainWord)).getText()));
- r1.setImageResource(r.getRelationImage(game.getCat1()));
- } catch (Exception e) {
- r1.setImageResource(R.drawable.icon);
- }
- // TODO : A enlever lorsque l'on aura toutes les images des relations.
- try {
- r2.setOnClickListener(this);
- rn2.setText(String.format(r.getRelationName(game.getCat2()), ((TextView)findViewById(R.id.mainWord)).getText()));
- r2.setImageResource(r.getRelationImage(game.getCat2()));
- } catch (Exception e) {
- r2.setImageResource(R.drawable.icon);
- }
- // TODO : A enlever lorsque l'on aura toutes les images des relations.
- try {
- r3.setOnClickListener(this);
- rn3.setText(String.format(r.getRelationName(game.getCat3()), ((TextView)findViewById(R.id.mainWord)).getText()));
- r3.setImageResource(r.getRelationImage(game.getCat3()));
- } catch (Exception e) {
- r3.setImageResource(R.drawable.icon);
- }
- // TODO : A enlever lorsque l'on aura toutes les images des relations.
- try {
- r4.setOnClickListener(this);
- rn4.setText(String.format(r.getRelationName(game.getCat4()), ((TextView)findViewById(R.id.mainWord)).getText()));
- r4.setImageResource(r.getRelationImage(game.getCat4()));
- } catch (Exception e) {
- r4.setImageResource(R.drawable.icon);
- }
-
- this.helpMode();
- }
-
- /* (non-Javadoc)
- * @see android.app.Activity#onActivityResult(int, int, android.content.Intent)
- */
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- finish();
- }
-
- /**
- * Cette methode permet au mot courant de partir du mot central vers le centre de l'appareil.
- */
- private void arrivalView() {
- //On recupere la largueur de l'ecran.
- Display display = getWindowManager().getDefaultDisplay();
- int width = display.getWidth();
-
- // On recupere le centre de mainWord pour l'animation de translation.
- TextView mainWord = (TextView)findViewById(R.id.mainWord);
- currentWordTextView = (TextView)findViewById(R.id.currentWord);
-
- // On defini un ensemble d'animation
- AnimationSet set = new AnimationSet(true);
- set.setDuration(1000);
- set.setFillAfter(true);
-
- TranslateAnimation translate;
- if (isInHelpMode())
- translate = new TranslateAnimation(mainWord.getScrollX() / 2, mainWord.getScrollX() / 2, mainWord.getScrollY() / 2, width / 8);
- else
- translate = new TranslateAnimation(mainWord.getScrollX() / 2, mainWord.getScrollX() / 2, mainWord.getScrollY() / 2, width / 4);
- translate.setDuration(500);
- set.addAnimation(translate);
-
- AlphaAnimation alpha = new AlphaAnimation(0, 1);
- alpha.setDuration(1000);
- set.addAnimation(alpha);
-
- // Que l'on rajoute a notre vue.
- currentWordTextView.startAnimation(set);
- }
-
- /**
- *
- */
- private void leaveView() {
- currentWordTextView.clearAnimation();
- }
-
- /**
- * Cette methode permet de passer au mot courant suivant et de lancer l'animation.
- */
- private void start() {
- ((TextView)findViewById(R.id.currentWord)).setText(DownloadedBaseGame.getName(game.getWordInCloud(currentWord)));
- arrivalView();
- }
-
- /**
- * Permet de verifier si la partie est fini auquel cas on lance l'activite Score, sinon on passe au mot suivant.
- */
- private void next() {
- if (++currentWord < nbWord) {
- wordRemaining.setText((currentWord + 1) + "/" + nbWord);
- leaveView();
- start();
- } else {
- Intent intent = new Intent(this, BaseScore.class);
- intent.putExtra(Constant.SCORE_GAMEPLAYED, match);
- intent.putExtra(Constant.SCORE_MODE, Mode.SIMPLE_GAME);
-
- startActivityForResult(intent, 0x100);
- }
- }
-
- /**
- * Cette methode est appeler lorsque l'utilisateur appuie sur le bouton d'aide.
- * Elle change la disposition des elements de maniere a afficher la description
- * de l'icone a cote de l'icone.
- */
- private void helpMode() {
- if (!isInHelpMode()) {
- help = true;
-
- LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 2);
-
- // On modifie l'affichage du layout
- LinearLayout menuLayout = ((LinearLayout)findViewById(R.id.menuLayout));
- menuLayout.setOrientation(LinearLayout.VERTICAL);
- menuLayout.setLayoutParams(layoutParams);
-
- // Puis on modifie l'affichage des relations
- //relation1
- LinearLayout relationLayout = ((LinearLayout)findViewById(R.id.relation1Layout));
- relationLayout.setGravity(Gravity.LEFT);
-
- TextView relationName = ((TextView)findViewById(R.id.relation1Name));
- relationName.setVisibility(View.VISIBLE);
-
- //relation2
- relationLayout = ((LinearLayout)findViewById(R.id.relation2Layout));
- relationLayout.setGravity(Gravity.LEFT);
-
- relationName = ((TextView)findViewById(R.id.relation2Name));
- relationName.setVisibility(View.VISIBLE);
-
- //relation3
- relationLayout = ((LinearLayout)findViewById(R.id.relation3Layout));
- relationLayout.setGravity(Gravity.LEFT);
-
- relationName = ((TextView)findViewById(R.id.relation3Name));
- relationName.setVisibility(View.VISIBLE);
-
- //relation4
- relationLayout = ((LinearLayout)findViewById(R.id.relation4Layout));
- relationLayout.setGravity(Gravity.LEFT);
-
- relationName = ((TextView)findViewById(R.id.relation4Name));
- relationName.setVisibility(View.VISIBLE);
-
-
- // On met le mot courant au bon endroit dans la fenetre
- // On recupere la largueur de l'ecran.
- Display display = getWindowManager().getDefaultDisplay();
- int width = display.getWidth();
-
- //On recupere le centre de mainWord pour l'animation de translation.
- TextView mainWord = (TextView)findViewById(R.id.mainWord);
- currentWordTextView = (TextView)findViewById(R.id.currentWord);
-
- TranslateAnimation translate = new TranslateAnimation(mainWord.getScrollX() / 2, mainWord.getScrollX() / 2, mainWord.getScrollY() / 2, width / 8);
- translate.setDuration(0);
- translate.setFillAfter(true);
-
- currentWordTextView.setAnimation(translate);
-
- } else {
- help = false;
-
- LayoutParams layoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 10);
-
- // On modifie l'affichage du layout
- LinearLayout menuLayout = ((LinearLayout)findViewById(R.id.menuLayout));
- menuLayout.setOrientation(LinearLayout.HORIZONTAL);
- menuLayout.setLayoutParams(layoutParams);
-
- // Puis on modifie l'affichage des relations
- //relation1
- LinearLayout relationLayout = ((LinearLayout)findViewById(R.id.relation1Layout));
- relationLayout.setGravity(Gravity.CENTER);
-
- TextView relationName = ((TextView)findViewById(R.id.relation1Name));
- relationName.setVisibility(View.GONE);
-
- //relation2
- relationLayout = ((LinearLayout)findViewById(R.id.relation2Layout));
- relationLayout.setGravity(Gravity.CENTER);
-
- relationName = ((TextView)findViewById(R.id.relation2Name));
- relationName.setVisibility(View.GONE);
-
- //relation3
- relationLayout = ((LinearLayout)findViewById(R.id.relation3Layout));
- relationLayout.setGravity(Gravity.CENTER);
-
- relationName = ((TextView)findViewById(R.id.relation3Name));
- relationName.setVisibility(View.GONE);
-
- //relation4
- relationLayout = ((LinearLayout)findViewById(R.id.relation4Layout));
- relationLayout.setGravity(Gravity.CENTER);
-
- relationName = ((TextView)findViewById(R.id.relation4Name));
- relationName.setVisibility(View.GONE);
-
- // On met le mot courant au bon endroit dans la fenetre
- // On recupere la largueur de l'ecran.
- Display display = getWindowManager().getDefaultDisplay();
- int width = display.getWidth();
-
- //On recupere le centre de mainWord pour l'animation de translation.
- TextView mainWord = (TextView)findViewById(R.id.mainWord);
- currentWordTextView = (TextView)findViewById(R.id.currentWord);
-
- TranslateAnimation translate = new TranslateAnimation(mainWord.getScrollX() / 2, mainWord.getScrollX() / 2, mainWord.getScrollY() / 2, width / 4);
- translate.setDuration(0);
- translate.setFillAfter(true);
-
- currentWordTextView.setAnimation(translate);
- }
- }
-
- /**
- * Permet de savoir si l'on se trouve ou non dans le mode d'aide
- *
- * @return true
si l'on ce trouve dans le mode d'aide false
sinon
- */
- private boolean isInHelpMode() {
- return help;
- }
-
- /* (non-Javadoc)
- * @see android.view.View.OnClickListener#onClick(android.view.View)
- */
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case (R.id.relation1) : match.add(1, currentWord); next(); break;
- case (R.id.relation2) : match.add(2, currentWord); next(); break;
- case (R.id.relation3) : match.add(3, currentWord); next(); break;
- case (R.id.relation4) : match.add(4, currentWord); next(); break;
- case (R.id.aideBaseGame) : helpMode(); break;
- }
- }
-}
\ No newline at end of file
diff --git a/code/PtiClic/src/org/pticlic/model/Constant.java b/code/PtiClic/src/org/pticlic/model/Constant.java
index d4a3b54..27481ce 100644
--- a/code/PtiClic/src/org/pticlic/model/Constant.java
+++ b/code/PtiClic/src/org/pticlic/model/Constant.java
@@ -1,7 +1,7 @@
package org.pticlic.model;
public class Constant {
- public static final String SERVER_URL = "server";
+ public static final String SERVER_URL = "html5/code/html5/";
public static final String SERVER_AUTH = "SERVER_AUTH";
public static final String SERVER = "http://www.pticlic.fr/";
diff --git a/code/PtiClic/src/org/pticlic/model/DownloadedBaseGame.java b/code/PtiClic/src/org/pticlic/model/DownloadedBaseGame.java
deleted file mode 100644
index 9c3b048..0000000
--- a/code/PtiClic/src/org/pticlic/model/DownloadedBaseGame.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package org.pticlic.model;
-
-import java.io.Serializable;
-import java.util.Arrays;
-
-/**
- * @author Bertrand BRUN
- *
- * Classe metier reprensentant une parti "Normal" telecharge.
- */
-public class DownloadedBaseGame extends DownloadedGame {
-
- private static final long serialVersionUID = 1L;
-
- public static class Word implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private int id;
- private String name;
-
- public Word() {}
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
- }
-
- private int cat1;
- private int cat2;
- private int cat3;
- private int cat4;
- private Word center;
- private Word[] cloud;
-
- public DownloadedBaseGame() {
- super();
- this.cat1 = -1;
- this.cat2 = -1;
- this.cat3 = -1;
- this.cat4 = -1;
- this.center = null;
- this.cloud = null;
- }
-
- public DownloadedBaseGame(int id, int gid, int pgid, int cat1, int cat2,
- int cat3, int cat4, Word center, Word[] cloud) {
- super(id, gid, pgid);
- this.cat1 = cat1;
- this.cat2 = cat2;
- this.cat3 = cat3;
- this.cat4 = cat4;
- this.center = center;
- this.cloud = cloud;
- }
-
- public static String getName(Word word) {
- return word.getName();
- }
-
- public int getCat(int numCat) {
- switch (numCat) {
- case 1: return getCat1();
- case 2: return getCat2();
- case 3: return getCat3();
- default: return getCat4();
- }
- }
-
- public String getCatString(int numCat) {
- return String.format(
- Relation.getInstance().getRelationName(this.getCat(numCat)),
- center.getName());
- }
-
- public int getCat1() {
- return cat1;
- }
-
- public void setCat1(int cat1) {
- this.cat1 = cat1;
- }
-
- public int getCat2() {
- return cat2;
- }
-
- public void setCat2(int cat2) {
- this.cat2 = cat2;
- }
-
- public int getCat3() {
- return cat3;
- }
-
- public void setCat3(int cat3) {
- this.cat3 = cat3;
- }
-
- public int getCat4() {
- return cat4;
- }
-
- public void setCat4(int cat4) {
- this.cat4 = cat4;
- }
-
- public Word getCentre() {
- return center;
- }
-
- public void setCentre(Word center) {
- this.center = center;
- }
-
- public int getNbWord() {
- return cloud.length;
- }
-
- public Word getWordInCloud(int index) {
- return cloud[index];
- }
-
-
- @Override
- public String toString() {
- return "DownloadedBaseGame [gid=" + gid + ", pgid=" + pgid + ", id=" + id
- + ", cat1=" + cat1 + ", cat2=" + cat2 + ", cat3=" + cat3
- + ", cat4=" + cat4 + ", center=" + center + ", cloud="
- + Arrays.toString(cloud) + "]";
- }
-
-}
diff --git a/code/PtiClic/src/org/pticlic/model/DownloadedGame.java b/code/PtiClic/src/org/pticlic/model/DownloadedGame.java
deleted file mode 100644
index 1b21133..0000000
--- a/code/PtiClic/src/org/pticlic/model/DownloadedGame.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.pticlic.model;
-
-import java.io.Serializable;
-
-
-/**
- * @author Bertrand BRUN
- *
- * Classe metier reprensentant n'importe quel le jeu telecharger du serveur.
- *
- */
-public abstract class DownloadedGame implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- protected int gid;
- protected int pgid;
- protected int id;
-
- public DownloadedGame() {
- this.id = -1;
- this.gid = -1;
- this.pgid = -1;
- }
-
- public DownloadedGame(int id, int gid, int pgid) {
- super();
- this.id = id;
- this.gid = gid;
- this.pgid = pgid;
- }
-
- public int getGid() {
- return gid;
- }
-
- public void setGid(int gid) {
- this.gid = gid;
- }
-
- public int getPgid() {
- return pgid;
- }
-
- public void setPgid(int pgid) {
- this.pgid = pgid;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
-}
diff --git a/code/PtiClic/src/org/pticlic/model/Match.java b/code/PtiClic/src/org/pticlic/model/Match.java
deleted file mode 100644
index 5aaba36..0000000
--- a/code/PtiClic/src/org/pticlic/model/Match.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.pticlic.model;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-
-/**
- * @author Bertrand BRUN
- *
- * Cette classe represente une partie joue.
- * Elle sera envoyer au serveur pour que celui-ci
- * puisse calculer le score obtenue.
- *
- */
-public class Match implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private ArrayList relation1;
- private ArrayList relation2;
- private ArrayList relation3;
- private ArrayList relation4;
- private DownloadedGame game;
-
- public Match() {
- relation1 = new ArrayList();
- relation2 = new ArrayList();
- relation3 = new ArrayList();
- relation4 = new ArrayList();
- }
-
- public void setGame(DownloadedGame game) {
- this.game = game;
- }
-
- public DownloadedGame getGame() {
- return game;
- }
-
- public void add(int relation, int word) {
- switch (relation) {
- case 1: relation1.add(word); break;
- case 2: relation2.add(word); break;
- case 3: relation3.add(word); break;
- case 4: relation4.add(word); break;
- }
- }
-
- /**
- * @return the relation1
- */
- public ArrayList getRelation1() {
- return relation1;
- }
-
- /**
- * @return the relation2
- */
- public ArrayList getRelation2() {
- return relation2;
- }
-
- /**
- * @return the relation3
- */
- public ArrayList getRelation3() {
- return relation3;
- }
-
- /**
- * @return the relation4
- */
- public ArrayList getRelation4() {
- return relation4;
- }
-}
diff --git a/code/PtiClic/src/org/pticlic/model/Network.java b/code/PtiClic/src/org/pticlic/model/Network.java
index 9fdbd73..c04377a 100644
--- a/code/PtiClic/src/org/pticlic/model/Network.java
+++ b/code/PtiClic/src/org/pticlic/model/Network.java
@@ -1,13 +1,6 @@
package org.pticlic.model;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
-
-import org.pticlic.exception.PtiClicException;
import android.content.Context;
import android.content.SharedPreferences;
@@ -15,7 +8,6 @@ import android.net.ConnectivityManager;
import android.preference.PreferenceManager;
import com.google.gson.Gson;
-import com.google.gson.stream.JsonReader;
/**
@@ -175,179 +167,4 @@ public class Network {
return res;
}
-
- /**
- * Cette méthode permet de récupérer du serveur un certain nombre de parties.
- * @param nbGames Le nombre de parties que l'on veut récupérer.
- * @return
- */
- public DownloadedGame getGames(int nbGames) throws PtiClicException, Exception {
- switch (mode) {
- case SIMPLE_GAME:
- return DownloadBaseGame(nbGames);
- default:
- return null;
- }
- }
-
- private DownloadedBaseGame DownloadBaseGame(int nbGames) throws PtiClicException, Exception {
- Gson gson = null;
- String json = null;
- DownloadedBaseGame game = null;
-
- // URLConnection connection = url.openConnection();
- // connection.addRequestProperty("action", Action.GET_GAMES.value());
- // connection.addRequestProperty("user", this.id);
- // connection.addRequestProperty("passwd", this.passwd);
- // connection.addRequestProperty("nb", String.valueOf(nbGames));
- // connection.addRequestProperty("mode", mode.value());
-
- String urlS = this.serverURL
- + "?action=" + Action.GET_GAMES.value()
- + "&user=" + this.id
- + "&passwd=" + this.passwd
- + "&nb=" + String.valueOf(nbGames)
- + "&mode="+mode.value();
-
- gson = new Gson();
- json = HttpClient.SendHttpPost(urlS);
-
- try {
-
- //JsonReader reader = new JsonReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
- InputStream in = new ByteArrayInputStream(json.getBytes("UTF-8"));
- JsonReader jsonReader = new JsonReader(new InputStreamReader(in));
-
- // FIXME : Attention lorsque l'on pourra vraiment recupere plusieur partie, il faudra changer ce qui suit.
- jsonReader.beginArray();
- while (jsonReader.hasNext()) {
- game = makeBaseGame(jsonReader, gson);
- }
- jsonReader.endArray();
- jsonReader.close();
- } catch (UnsupportedEncodingException e1) {
- throw new PtiClicException(0, "Impossible de recuperer l'erreur, nous avons pris note de cette erreur.\n Merci");
- } catch (IOException e1) {
- throw new PtiClicException(0, "Impossible de recuperer l'erreur, nous avons pris note de cette erreur.\n Merci");
- } catch (Exception e) {
- throw new PtiClicException(json);
- }
-
- return game;
- }
-
- /**
- * Permet la transformation du Json en une instance de Game.
- *
- * @param reader Le Json sous forme d'un flux.
- * @param gson Une instance de Gson.
- * @return Une nouvelle instance de Game.
- * @throws IOException
- */
- private DownloadedBaseGame makeBaseGame(JsonReader reader, Gson gson) throws IOException {
- int gid = -1;
- int pgid = -1;
- int id = -1;
- int cat1 = -1;
- int cat2 = -1;
- int cat3 = -1;
- int cat4 = -1;
- DownloadedBaseGame.Word center = null;
- DownloadedBaseGame.Word[] cloud = null;
-
- reader.beginObject();
- while (reader.hasNext()) {
- String name = reader.nextName();
- if (name.equals("id")) {
- id = reader.nextInt();
- } else if (name.equals("gid")) {
- gid = reader.nextInt();
- } else if (name.equals("pgid")) {
- pgid = reader.nextInt();
- } else if (name.equals("cat1")) {
- cat1 = reader.nextInt();
- } else if (name.equals("cat2")) {
- cat2 = reader.nextInt();
- } else if (name.equals("cat3")) {
- cat3 = reader.nextInt();
- } else if (name.equals("cat4")) {
- cat4 = reader.nextInt();
- } else if (name.equals("center")) {
- center = gson.fromJson(reader, DownloadedBaseGame.Word.class);
- } else if (name.equals("cloud")) {
- cloud = gson.fromJson(reader, DownloadedBaseGame.Word[].class);
- } else {
- reader.skipValue();
- }
- }
- reader.endObject();
- return new DownloadedBaseGame(id, gid, pgid, cat1, cat2, cat3, cat4, center, cloud);
- }
-
- /**
- * Cette méthode permet d'envoyer les parties au serveur pour qu'il puisse les
- * rajouter à la base de données, et calculer le score.
- * @param game La partie jouee par l'utilisateur
- * @return Le score sous forme JSON.
- */
- public ScoreResponse sendGame(Match game) throws PtiClicException, Exception {
- switch (mode) {
- case SIMPLE_GAME:
- return sendBaseGame(game);
- default:
- return null;
- }
- }
-
- public ScoreResponse sendBaseGame(Match game) throws PtiClicException, Exception {
- Gson gson = null;
- String json = null;
-
- // TODO : ne restera le temps que les requete du serveur passe du GET au POST
- String urlS = this.serverURL
- + "?action=" + Action.SEND_GAME.value()
- + "&user=" + this.id
- + "&passwd=" + this.passwd
- + "&pgid=" + game.getGame().getPgid()
- + "&gid=" + game.getGame().getGid()
- + "&mode="+mode.value()
- + "&nb="+((DownloadedBaseGame)(game.getGame())).getNbWord();
-
- // TODO : faut gere le mode
- for (Integer i : game.getRelation1()) {
- urlS += "&" + i + "=" + ((DownloadedBaseGame)game.getGame()).getCat1() ;
- }
- for (Integer i : game.getRelation2()) {
- urlS += "&" + i + "=" + ((DownloadedBaseGame)game.getGame()).getCat2();
- }
- for (Integer i : game.getRelation3()) {
- urlS += "&" + i + "=" + ((DownloadedBaseGame)game.getGame()).getCat3();
- }
- for (Integer i : game.getRelation4()) {
- urlS += "&" + i + "=" + ((DownloadedBaseGame)game.getGame()).getCat4();
- }
-
- // URL url = new URL(this.serverURL); // Attention ! this.serverURL contient "/server.php"
- // URLConnection connection = url.openConnection();
- // connection.addRequestProperty("action", Action.SEND_GAME.value());
- // connection.addRequestProperty("user", this.id);
- // connection.addRequestProperty("passwd", this.passwd);
- // connection.addRequestProperty("mode", mode.value());
- // connection.addRequestProperty("pgid", String.valueOf(game.getGame().getId()));
-
- gson = new Gson();
- json = HttpClient.SendHttpPost(urlS);
-
- // Comme gson ne renvoie pas une erreur si l'objet qui recupere ne correspond pas a la classe qu'il attends.
- // On creer tout d'abord une objet error et si celui-ci est vide on creer l'objet score, sinon on lance
- // une exception.
- int foo = 42;
- ScoreResponse sr = gson.fromJson(json, ScoreResponse.class);
- foo = foo + 1;
- if (sr.getNewGame() == null) {
- throw new PtiClicException(gson.fromJson(json, PtiClicException.Error.class));
- } else {
- return sr;
- }
- }
}
diff --git a/code/PtiClic/src/org/pticlic/model/Relation.java b/code/PtiClic/src/org/pticlic/model/Relation.java
deleted file mode 100644
index a06bf7f..0000000
--- a/code/PtiClic/src/org/pticlic/model/Relation.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package org.pticlic.model;
-
-import java.util.HashMap;
-
-import org.pticlic.R;
-
-/**
- * @author Bertrand BRUN
- *
- * Cette classe permet de recuperer le noms ou l'image d'un relation en fonction du numero de son id.
- *
- */
-public class Relation {
- // TODO : Penser a peut etre remplacer les HashMap par une BDD.
-
- private static Relation instance = null;
-
- HashMap stringRelations;
- HashMap imageRelations;
-
- private Relation() {
- imageRelations = new HashMap();
- imageRelations.put(-1, R.drawable.corbeille);
- imageRelations.put(0, R.drawable.rapport);
- imageRelations.put(5, R.drawable.synonyme);
- imageRelations.put(7, R.drawable.contraire);
- imageRelations.put(9, R.drawable.contenu);
- imageRelations.put(10, R.drawable.contenant);
-
- // ATTENTION ! Tout ce qui est ci-dessous est en double dans relations.php .
- stringRelations = new HashMap();
- stringRelations.put(-1, "Mot non lié à '%s'");
- stringRelations.put(0, "'%s' est en rapport avec...");
- stringRelations.put(1, "raffinement sémantique"); // pas utilisé
- stringRelations.put(2, "raffinement morphologique"); // pas utilisé
- stringRelations.put(3, "domaine"); // pas utilisé
- stringRelations.put(4, "r_pos"); // pas utilisé
- stringRelations.put(5, "'%s' est un synonyme de...");
- stringRelations.put(6, "'%s' est une sorte de...");
- stringRelations.put(7, "Un contraire de '%s' est...");
- stringRelations.put(8, "Un spécifique de '%s' est...");
- stringRelations.put(9, "... est une partie de '%s'");
- stringRelations.put(10, "'%s' fait partie de...");
- stringRelations.put(11, "locution"); // pas utilisé
- stringRelations.put(12, "potentiel de FL"); // pas utilisé
- stringRelations.put(13, "Quoi/Qui pourrait '%s'");
- stringRelations.put(14, "action>patient"); // pas utilisé
- stringRelations.put(15, "Le lieu pour '%s' est...");
- stringRelations.put(16, "Un instrument pour '%s' est...");
- stringRelations.put(17, "Un caractéristique de '%s' est...");
- stringRelations.put(18, "r_data"); // pas utilisé
- stringRelations.put(19, "r_lemma"); // pas utilisé
- stringRelations.put(20, "magn"); // pas utilisé
- stringRelations.put(21, "antimagn"); // pas utilisé
- stringRelations.put(22, "'%s' est de la même famille que...");
- stringRelations.put(29, "predicat"); // pas utilisé
- stringRelations.put(30, "lieu>action"); // pas utilisé
- stringRelations.put(31, "action>lieu"); // pas utilisé
- stringRelations.put(32, "sentiment"); // pas utilisé
- stringRelations.put(33, "erreur"); // pas utilisé
- stringRelations.put(34, "manière"); // pas utilisé
- stringRelations.put(35, "sens/signification"); // pas utilisé
- stringRelations.put(36, "information potentielle"); // pas utilisé
- stringRelations.put(37, "rôle télique"); // pas utilisé
- stringRelations.put(38, "rôle agentif"); // pas utilisé
- stringRelations.put(41, "conséquence"); // pas utilisé
- stringRelations.put(42, "cause"); // pas utilisé
- stringRelations.put(52, "succession"); // pas utilisé
- stringRelations.put(53, "produit"); // pas utilisé
- stringRelations.put(54, "est le produit de"); // pas utilisé
- stringRelations.put(55, "s'oppose à"); // pas utilisé
- }
-
- public synchronized static Relation getInstance() {
- if (instance == null) {
- instance = new Relation();
- }
- return instance;
- }
-
- public String getRelationName(int id) {
- return stringRelations.get(id);
- }
-
- public Integer getRelationImage(int id) {
- return imageRelations.get(id);
- }
-}