diff --git a/code/PtiClic/res/values/strings.xml b/code/PtiClic/res/values/strings.xml
index 6049f74..1ce20fe 100644
--- a/code/PtiClic/res/values/strings.xml
+++ b/code/PtiClic/res/values/strings.xml
@@ -5,4 +5,5 @@
Jouer
0.1
+Il y a actuellement un probleme avec le serveur. Veuillez re-essayer dans quelque minutes.
diff --git a/code/PtiClic/src/org/pticlic/FrontPage.java b/code/PtiClic/src/org/pticlic/FrontPage.java
index 6710b1d..037f891 100644
--- a/code/PtiClic/src/org/pticlic/FrontPage.java
+++ b/code/PtiClic/src/org/pticlic/FrontPage.java
@@ -1,6 +1,7 @@
package org.pticlic;
import org.pticlic.games.BaseGame;
+import org.pticlic.model.Constant;
import org.pticlic.model.Network;
import android.app.Activity;
@@ -18,6 +19,8 @@ import android.widget.TextView;
public class FrontPage extends Activity implements OnClickListener{
+ private Uri uri = null;
+
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -29,6 +32,9 @@ public class FrontPage extends Activity implements OnClickListener{
((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
@@ -74,7 +80,6 @@ public class FrontPage extends Activity implements OnClickListener{
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
// TODO : Essayer de trouver comment mettre l'url qui est dans les preferences.
- Uri uri = Uri.parse("http://dumbs.fr/~bbrun/pticlic/signup.php");
startActivity(new Intent(Intent.ACTION_VIEW, uri));
}
})
diff --git a/code/PtiClic/src/org/pticlic/Score.java b/code/PtiClic/src/org/pticlic/Score.java
index e7a3a90..d29da70 100644
--- a/code/PtiClic/src/org/pticlic/Score.java
+++ b/code/PtiClic/src/org/pticlic/Score.java
@@ -32,7 +32,7 @@ public class Score extends Activity implements OnClickListener{
setContentView(R.layout.score);
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
- String serverURL = sp.getString(Constant.SERVER_URL, "http://dumbs.fr/~bbrun/pticlic/pticlic.php"); // TODO : Mettre comme valeur par defaut l'adresse reel du serveur
+ String serverURL = sp.getString(Constant.SERVER_URL, Constant.SERVER);
String id = sp.getString(Constant.USER_ID, "joueur");
String passwd = sp.getString(Constant.USER_PASSWD, "");
Mode mode = null;
@@ -64,6 +64,20 @@ public class Score extends Activity implements OnClickListener{
});
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();
}
((Button)findViewById(R.id.saw)).setOnClickListener(this);
diff --git a/code/PtiClic/src/org/pticlic/games/BaseGame.java b/code/PtiClic/src/org/pticlic/games/BaseGame.java
index a7a3274..72e9241 100644
--- a/code/PtiClic/src/org/pticlic/games/BaseGame.java
+++ b/code/PtiClic/src/org/pticlic/games/BaseGame.java
@@ -102,6 +102,20 @@ public class BaseGame extends Activity implements OnClickListener {
});
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();
}
}
diff --git a/code/PtiClic/src/org/pticlic/model/Network.java b/code/PtiClic/src/org/pticlic/model/Network.java
index af84747..03c6da0 100644
--- a/code/PtiClic/src/org/pticlic/model/Network.java
+++ b/code/PtiClic/src/org/pticlic/model/Network.java
@@ -155,7 +155,7 @@ public class Network {
* @param nbGames Le nombre de parties que l'on veut récupérer.
* @return
*/
- public DownloadedGame getGames(int nbGames) throws PtiClicException {
+ public DownloadedGame getGames(int nbGames) throws PtiClicException, Exception {
switch (mode) {
case SIMPLE_GAME:
return DownloadBaseGame(nbGames);
@@ -164,7 +164,7 @@ public class Network {
}
}
- private DownloadedBaseGame DownloadBaseGame(int nbGames) throws PtiClicException {
+ private DownloadedBaseGame DownloadBaseGame(int nbGames) throws PtiClicException, Exception {
DownloadedBaseGame game = null;
URL url = null;
Gson gson = null;
@@ -267,7 +267,7 @@ public class Network {
* @param game La partie jouee par l'utilisateur
* @return Le score sous forme JSON.
*/
- public double sendGame(Match game) throws PtiClicException {
+ public double sendGame(Match game) throws PtiClicException, Exception {
switch (mode) {
case SIMPLE_GAME:
return sendBaseGame(game);
@@ -277,7 +277,7 @@ public class Network {
}
- public double sendBaseGame(Match game) throws PtiClicException {
+ public double sendBaseGame(Match game) throws PtiClicException, Exception {
double score = -1;
URL url = null;
Gson gson = null;