From 41c88a5ce93c50e56f5f8c283d37ad368580a0bd Mon Sep 17 00:00:00 2001 From: John Charron Date: Thu, 27 Jan 2011 11:38:34 +0100 Subject: [PATCH 1/2] Premier jet a la fenetre 'score' avec modifs dans main pour basculer de fenetre a fenetre --- code/PtiClic/AndroidManifest.xml | 2 + code/PtiClic/res/layout/main.xml | 13 ++++-- code/PtiClic/res/layout/score.xml | 40 +++++++++++++++++ code/PtiClic/src/model/GamePlayed.java | 62 ++++++++++++++++++++++++++ code/PtiClic/src/org/pticlic/Main.java | 21 ++++++++- 5 files changed, 134 insertions(+), 4 deletions(-) create mode 100644 code/PtiClic/res/layout/score.xml create mode 100644 code/PtiClic/src/model/GamePlayed.java diff --git a/code/PtiClic/AndroidManifest.xml b/code/PtiClic/AndroidManifest.xml index 8af6454..fafbc48 100644 --- a/code/PtiClic/AndroidManifest.xml +++ b/code/PtiClic/AndroidManifest.xml @@ -12,6 +12,8 @@ + + diff --git a/code/PtiClic/res/layout/main.xml b/code/PtiClic/res/layout/main.xml index 8cbaf31..a7c0116 100644 --- a/code/PtiClic/res/layout/main.xml +++ b/code/PtiClic/res/layout/main.xml @@ -20,7 +20,14 @@ android:layout_width="wrap_content" android:id="@+id/prefs" android:text="@string/prefs_name" android:layout_below="@+id/games" android:layout_alignLeft="@+id/games" android:layout_alignRight="@+id/games" /> - + + + + + + + + + + + + + + diff --git a/code/PtiClic/src/model/GamePlayed.java b/code/PtiClic/src/model/GamePlayed.java new file mode 100644 index 0000000..6d83c81 --- /dev/null +++ b/code/PtiClic/src/model/GamePlayed.java @@ -0,0 +1,62 @@ +package model; + +import java.util.Arrays; + +public class GamePlayed { + + private int id; + private String centre; + private String[] cloud; + private String[] category; + private static GamePlayed instance = null; + + private GamePlayed(){ + this.id = -1; + this.centre = ""; + this.cloud = null; + this.category = null; + } + + private GamePlayed(int id, String centre, String[] cloud, String[] category) { + this.id = id; + this.centre = centre; + this.cloud = cloud; + this.category = category; + } + + public final static GamePlayed getInstance(){ + if(instance == null) instance = new GamePlayed(); + return instance; + } + + public int getId() { + return id; + } + public void setId(int id) { + this.id = id; + } + public String getCentre() { + return centre; + } + public void setCentre(String centre) { + this.centre = centre; + } + public String[] getCloud() { + return cloud; + } + public void setCloud(String[] cloud) { + this.cloud = cloud; + } + public String[] getCategory() { + return category; + } + public void setCategory(String[] category) { + this.category = category; + } + + @Override + public String toString() { + return "GamePlayed [id=" + id + ", centre=" + centre + ", cloud=" + + Arrays.toString(cloud) + ", category=" + category + "]"; + } +} diff --git a/code/PtiClic/src/org/pticlic/Main.java b/code/PtiClic/src/org/pticlic/Main.java index 2cc0f62..3d32c8c 100644 --- a/code/PtiClic/src/org/pticlic/Main.java +++ b/code/PtiClic/src/org/pticlic/Main.java @@ -1,6 +1,9 @@ package org.pticlic; import android.app.Activity; +import android.app.AlertDialog; +import android.app.AlertDialog.Builder; +import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; @@ -8,6 +11,7 @@ import android.preference.PreferenceManager; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; +import android.widget.ImageButton; import android.widget.TextView; public class Main extends Activity implements OnClickListener { @@ -18,18 +22,33 @@ public class Main extends Activity implements OnClickListener { super.onCreate(savedInstanceState); setContentView(R.layout.main); ((Button)findViewById(R.id.prefs)).setOnClickListener(this); + ((Button)findViewById(R.id.voirscore)).setOnClickListener(this); + ((ImageButton)findViewById(R.id.infoButton)).setOnClickListener(this); + // On récupère le nom du joueur des préférences. SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); String loginPref = sp.getString("login", "joueur"); // On l'ajoute dans le TextView prévu à cet effet ((TextView)findViewById(R.id.login)).setText("Login : " + loginPref); - } + } + @Override public void onClick(View v) { if (v.getId()==R.id.prefs) { startActivity(new Intent(this, Preference.class)); } + if (v.getId()==R.id.voirscore){ + // TODO: à supprimer + Intent intent = new Intent(this, Score.class); + intent.putExtra("corrects", 10); + intent.putExtra("mauvais", 2); + intent.putExtra("manquants", 1.5); + intent.putExtra("total", 10); // WHERE?? + startActivity(intent); + } } + + } \ No newline at end of file From 984d28890cf2cba1cc05def7b7744745b3296a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Thu, 27 Jan 2011 19:07:40 +0100 Subject: [PATCH 2/2] =?UTF-8?q?D=C3=A9but=20de=20l'interface=20du=20Jeu.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/PtiClic/AndroidManifest.xml | 1 + code/PtiClic/res/layout/game.xml | 12 ++++++++ code/PtiClic/res/layout/main.xml | 9 +++--- code/PtiClic/res/values/strings.xml | 2 +- code/PtiClic/src/org/pticlic/Game.java | 42 ++++++++++++++++++++++++++ code/PtiClic/src/org/pticlic/Main.java | 38 +++++++++++++---------- 6 files changed, 82 insertions(+), 22 deletions(-) create mode 100644 code/PtiClic/res/layout/game.xml create mode 100644 code/PtiClic/src/org/pticlic/Game.java diff --git a/code/PtiClic/AndroidManifest.xml b/code/PtiClic/AndroidManifest.xml index 8af6454..66bf644 100644 --- a/code/PtiClic/AndroidManifest.xml +++ b/code/PtiClic/AndroidManifest.xml @@ -12,6 +12,7 @@ + diff --git a/code/PtiClic/res/layout/game.xml b/code/PtiClic/res/layout/game.xml new file mode 100644 index 0000000..1789d2c --- /dev/null +++ b/code/PtiClic/res/layout/game.xml @@ -0,0 +1,12 @@ + + + + + + + + + diff --git a/code/PtiClic/res/layout/main.xml b/code/PtiClic/res/layout/main.xml index 8cbaf31..80208e0 100644 --- a/code/PtiClic/res/layout/main.xml +++ b/code/PtiClic/res/layout/main.xml @@ -11,15 +11,14 @@ android:id="@+id/RelativeLayout01" android:layout_width="wrap_content" android:layout_gravity="bottom|center_horizontal"> -