commit 8dd95762fa4add5e776c884480f77d3d2dc5fd53
parent 30fdf12bb445bcf831c4541ec1712dd20e0223b8
Author: Bertrand BRUN <bertrand0brun@gmail.com>
Date: Fri, 4 Feb 2011 13:37:39 +0100
Merge branch 'master' of https://github.com/jsmaniac/2011-m1s2-ter
Diffstat:
3 files changed, 98 insertions(+), 21 deletions(-)
diff --git a/code/PtiClic/res/layout/game.xml b/code/PtiClic/res/layout/game.xml
@@ -4,37 +4,69 @@
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:layout_width="fill_parent"
- android:layout_height="fill_parent" android:orientation="vertical" android:layout_weight="2">
+ android:layout_height="fill_parent" android:orientation="vertical"
+ android:layout_weight="2">
+
+
+ <AbsoluteLayout android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:paddingTop="10px">
+
+ <TextView android:id="@+id/mainWord" android:text="mainWord"
+ android:textStyle="bold" android:textSize="30dip"
+ android:layout_weight="1" android:gravity="center"
+ android:paddingTop="10px" android:layout_height="fill_parent"
+ android:layout_width="fill_parent">
+ </TextView>
+
+
+
+
+
+
+ <LinearLayout android:layout_width="fill_parent"
+ android:layout_height="fill_parent" android:gravity="right">
+
+ <ImageView android:src="@drawable/aide"
+ android:id="@+id/aideBaseGame" android:paddingRight="10px"
+ android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
+
+ </LinearLayout>
+
+
+ </AbsoluteLayout>
- <TextView android:id="@+id/mainWord" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="mainWord"
- android:textStyle="bold" android:gravity="center" android:textSize="30dip">
- </TextView>
<TextView android:id="@+id/currentWord" android:layout_width="fill_parent"
- android:text="currentWord"
- android:textStyle="bold" android:textSize="20dip" android:layout_height="fill_parent" android:gravity="top|center">
+ android:text="currentWord" android:textStyle="bold" android:textSize="20dip"
+ android:layout_height="fill_parent" android:gravity="top|center">
</TextView>
- </LinearLayout>
+
+</LinearLayout>
<LinearLayout android:orientation="horizontal"
- android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="10">
+ android:layout_height="fill_parent" android:layout_width="fill_parent"
+ android:layout_weight="10">
- <ImageView android:id="@+id/relation1"
- android:src="@drawable/contenant" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center">
+ <ImageView android:id="@+id/relation1" android:src="@drawable/contenant"
+ android:layout_weight="1" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:layout_gravity="center">
</ImageView>
- <ImageView android:id="@+id/relation2"
- android:src="@drawable/contenu" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center">
+ <ImageView android:id="@+id/relation2" android:src="@drawable/contenu"
+ android:layout_weight="1" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:layout_gravity="center">
</ImageView>
- <ImageView android:id="@+id/trash"
- android:src="@android:drawable/ic_menu_delete" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center">
+ <ImageView android:id="@+id/relation3" android:src="@drawable/contraire"
+ android:layout_weight="1" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:layout_gravity="center">
</ImageView>
- <ImageView android:id="@+id/relation3"
- android:src="@drawable/contraire" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center">
+ <ImageView android:id="@+id/relation4" android:src="@drawable/synonyme"
+ android:layout_weight="1" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:layout_gravity="center">
</ImageView>
- <ImageView android:id="@+id/relation4"
- android:src="@drawable/synonyme" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center">
+ <ImageView android:id="@+id/trash" android:src="@android:drawable/ic_menu_delete"
+ android:layout_weight="1" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:layout_gravity="center">
</ImageView>
</LinearLayout>
diff --git a/code/PtiClic/src/org/pticlic/Preference.java b/code/PtiClic/src/org/pticlic/Preference.java
@@ -1,9 +1,15 @@
package org.pticlic;
+import org.pticlic.model.Constant;
+import org.pticlic.model.Network;
+
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.PreferenceActivity;
+import android.widget.Toast;
-public class Preference extends PreferenceActivity {
+public class Preference extends PreferenceActivity implements OnSharedPreferenceChangeListener {
/* (non-Javadoc)
* @see android.preference.PreferenceActivity#onCreate(android.os.Bundle)
@@ -12,6 +18,43 @@ public class Preference extends PreferenceActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.prefs);
+
+ SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
+ prefs.registerOnSharedPreferenceChangeListener(this);
+
}
-
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ if (key.equals("passwd")) {
+ if (Network.isConnected(this)) {
+ String id = sharedPreferences.getString("login", "");
+ String passwd = sharedPreferences.getString("passwd", "");
+ if (Network.isLoginCorrect(this, id, passwd)) {
+ Toast.makeText(this,
+ "Couple login/mdp valide.",
+ Toast.LENGTH_LONG).show();
+
+ SharedPreferences.Editor editor = sharedPreferences.edit();
+ editor.putBoolean(Constant.SERVER_AUTH, true);
+ editor.commit();
+ } else {
+ Toast.makeText(this,
+ "Couple login/mdp non valide.",
+ Toast.LENGTH_LONG).show();
+
+ SharedPreferences.Editor editor = sharedPreferences.edit();
+ editor.putBoolean(Constant.SERVER_AUTH, false);
+ editor.commit();
+ }
+ } else {
+ Toast.makeText(this,
+ "Pas connecter au reseau, verification du login/mdp impossible",
+ Toast.LENGTH_LONG).show();
+ }
+ }
+
+ }
+
+
}
diff --git a/code/PtiClic/src/org/pticlic/model/Constant.java b/code/PtiClic/src/org/pticlic/model/Constant.java
@@ -3,6 +3,8 @@ package org.pticlic.model;
public class Constant {
public static final String SERVER_URL = "SERVER_URL";
+ public static final String SERVER_AUTH = "SERVER_AUTH";
+
// Constant pour les information de l'utilisateur.
public static final String USER_ID = "login";
public static final String USER_PASSWD = "passwd";