diff --git a/code/PtiClic/AndroidManifest.xml b/code/PtiClic/AndroidManifest.xml index 8af6454..62efc1d 100644 --- a/code/PtiClic/AndroidManifest.xml +++ b/code/PtiClic/AndroidManifest.xml @@ -12,7 +12,10 @@ + + + - \ No newline at end of file + 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..bb5b30a 100644 --- a/code/PtiClic/res/layout/main.xml +++ b/code/PtiClic/res/layout/main.xml @@ -11,17 +11,21 @@ android:id="@+id/RelativeLayout01" android:layout_width="wrap_content" android:layout_gravity="bottom|center_horizontal"> - + + + + + + + + + + + diff --git a/code/PtiClic/res/values/strings.xml b/code/PtiClic/res/values/strings.xml index cd38a71..cdda3fb 100644 --- a/code/PtiClic/res/values/strings.xml +++ b/code/PtiClic/res/values/strings.xml @@ -1,8 +1,6 @@ - - PtiClic - Préférences - Jouer - + PtiClic + Préférences + Jouer 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/Game.java b/code/PtiClic/src/org/pticlic/Game.java new file mode 100644 index 0000000..7f59fa9 --- /dev/null +++ b/code/PtiClic/src/org/pticlic/Game.java @@ -0,0 +1,42 @@ +package org.pticlic; + +import android.app.Activity; +import android.os.Bundle; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.Button; + +public class Game extends Activity implements OnClickListener { + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + int nbrel = 2; + setContentView(R.layout.game); + + // Boutons des relations + Button r1 = ((Button)findViewById(R.id.relation1)); + Button r2 = ((Button)findViewById(R.id.relation2)); + Button r3 = ((Button)findViewById(R.id.relation3)); + Button r4 = ((Button)findViewById(R.id.relation4)); + + // Écoute des clics sur les relations + r1.setOnClickListener(this); + r2.setOnClickListener(this); + r3.setOnClickListener(this); + r4.setOnClickListener(this); + } + + /* (non-Javadoc) + * @see android.view.View.OnClickListener#onClick(android.view.View) + */ + @Override + public void onClick(View v) { + switch (v.getId()) { + case (R.id.relation1) : break; + case (R.id.relation2) : break; + case (R.id.relation3) : break; + case (R.id.relation4) : break; + } + } +} \ No newline at end of file diff --git a/code/PtiClic/src/org/pticlic/Main.java b/code/PtiClic/src/org/pticlic/Main.java index 2cc0f62..2f6422f 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,28 +11,46 @@ 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 { - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - ((Button)findViewById(R.id.prefs)).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); - } + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + // Écoute des clics sur les différents boutons + ((Button)findViewById(R.id.prefs)).setOnClickListener(this); + ((Button)findViewById(R.id.play)).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); + } + + /* (non-Javadoc) + * @see android.view.View.OnClickListener#onClick(android.view.View) + */ @Override public void onClick(View v) { - if (v.getId()==R.id.prefs) { - startActivity(new Intent(this, Preference.class)); + switch (v.getId()) { + case (R.id.prefs) : startActivity(new Intent(this, Preference.class)); break; + case (R.id.play) : startActivity(new Intent(this, Game.class)); break; + } + 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