Gros menage dans les views.
authormarseille@KungFuh
Fri, 03 Apr 2009 00:49:23 +0200
changeset 52 375194dc3bca
parent 51 85705bdb77ab
child 59 ff98ffba21f4
Gros menage dans les views. -Suppression de la vu beem avec le logo qui servait a rien ... les infos sont maintenant dans la classe contactlist. -Fix de la classe contactlist.
AndroidManifest.xml
res/layout/beem.xml
res/layout/beemdialogsettings.xml
res/layout/contactlistdialogsettings.xml
res/menu/beemmenu.xml
res/menu/contactlistmenu.xml
res/values/strings.xml
src/com/beem/project/beem/BeemApplication.java
src/com/beem/project/beem/service/XMPPConnectionAdapter.java
src/com/beem/project/beem/service/XMPPFacade.java
src/com/beem/project/beem/service/aidl/IXMPPConnection.aidl
src/com/beem/project/beem/ui/Beem.java
src/com/beem/project/beem/ui/BeemDialogSettings.java
src/com/beem/project/beem/ui/ContactList.java
src/com/beem/project/beem/ui/SendIM.java
--- a/AndroidManifest.xml	Thu Apr 02 14:32:07 2009 +0200
+++ b/AndroidManifest.xml	Fri Apr 03 00:49:23 2009 +0200
@@ -3,13 +3,12 @@
 	package="com.beem.project.beem" android:versionCode="1"
 	android:versionName="1.0">
 	<application android:label="@string/app_name" android:name="BeemApplication">
-		<activity android:name=".ui.Beem" android:label="@string/app_name">
+		<activity android:name=".ui.ContactList" android:label="@string/app_name">
 			<intent-filter>
 				<action android:name="android.intent.action.MAIN" />
 				<category android:name="android.intent.category.LAUNCHER" />
 			</intent-filter>
 		</activity>
-		<activity android:name=".ui.ContactList" android:label="@string/app_name" />
 		<activity android:name=".ui.SendIM" android:label="@string/app_name" />
 		<service android:name="BeemService" android:enabled="true"
 			android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_SERVICE">
@@ -24,5 +23,5 @@
 	<uses-permission android:name="android.permission.INTERNET"></uses-permission>
 	<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
 	<uses-permission android:name="com.beem.project.beem.BEEM_SERVICE"></uses-permission>
-<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission>
+	<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"></uses-permission>
 </manifest> 
--- a/res/layout/beem.xml	Thu Apr 02 14:32:07 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-	android:orientation="vertical"
-	android:layout_width="fill_parent"
-	android:layout_height="fill_parent">
-
-	<ImageView android:id="@+id/logo"
-		android:src="@drawable/logo"
-		android:adjustViewBounds="true"
-		android:layout_width="wrap_content"
-		android:layout_height="wrap_content"/>
-		
-	<TextView android:text="@string/BeemJabberID"
-		android:textSize="25sp"
-		android:paddingLeft="100sp"
-		android:paddingTop="50sp"
-		android:paddingBottom="15sp"
-		android:layout_width="fill_parent"
-		android:layout_height="wrap_content" />
-		
-	<ImageView android:id="@+id/avatar"
-		android:src="@drawable/bart"
-		android:paddingTop="10sp"
-		android:paddingBottom="10sp"		
-		android:adjustViewBounds="true"
-		android:layout_width="fill_parent"
-		android:layout_height="wrap_content"/>
-		
-	<Button android:id="@+id/connection"
-		android:textSize="20sp"
-		android:singleLine="true"
-		android:layout_width="fill_parent"
-		android:layout_height="wrap_content"/>
-
-</LinearLayout>
--- a/res/layout/beemdialogsettings.xml	Thu Apr 02 14:32:07 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-              android:orientation="vertical"
-              android:layout_width="fill_parent"
-              android:layout_height="fill_parent"
-        >
-    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                  android:orientation="horizontal"
-                  android:layout_width="fill_parent"
-                  android:layout_height="wrap_content"
-            >
-        <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="Host/Port:"
-                android:minWidth="70dp"
-                />
-                
-        <EditText android:id="@+id/host"
-                  android:layout_width="wrap_content"
-                  android:layout_height="wrap_content"
-                  android:singleLine="true"
-                  android:textSize="16sp"
-                  android:autoText="false"
-                  android:capitalize="none"
-                  android:minWidth="150dp"
-                  android:scrollHorizontally="true"/>
-        <EditText android:id="@+id/port"
-                  android:layout_width="wrap_content"
-                  android:layout_height="wrap_content"
-                  android:singleLine="true"
-                  android:textSize="16sp"
-                  android:autoText="false"
-                  android:minWidth="80dp"
-                  android:capitalize="none"
-                  android:scrollHorizontally="true"/>
-    </LinearLayout>
-
-    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                  android:orientation="horizontal"
-                  android:layout_width="fill_parent"
-                  android:layout_height="wrap_content"
-            >
-        <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="Userid:"
-                android:minWidth="70dp"
-                />
-        <EditText android:id="@+id/userid"
-                  android:layout_width="wrap_content"
-                  android:layout_height="wrap_content"
-                  android:singleLine="true"
-                  android:textSize="16sp"
-                  android:autoText="false"
-                  android:minWidth="250dp"
-                  android:capitalize="none"
-                  android:scrollHorizontally="true"/>
-    </LinearLayout>
-    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                  android:orientation="horizontal"
-                  android:layout_width="fill_parent"
-                  android:layout_height="wrap_content"
-            >
-        <TextView
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="Password:"
-                android:minWidth="70dp"
-                />
-        <EditText android:id="@+id/password"
-                  android:layout_width="wrap_content"
-                  android:layout_height="wrap_content"
-                  android:singleLine="true"
-                  android:password="true"
-                  android:textSize="16sp"
-                  android:autoText="false"
-                  android:minWidth="250dp"
-                  android:capitalize="none"
-                  android:scrollHorizontally="true"/>
-    </LinearLayout>
-
-    <Button android:id="@+id/ok"
-            android:layout_width="fill_parent"
-            android:layout_height="fill_parent"
-            android:text="OK">
-        <requestFocus/>
-    </Button>
-</LinearLayout>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/contactlistdialogsettings.xml	Fri Apr 03 00:49:23 2009 +0200
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:orientation="vertical"
+              android:layout_width="fill_parent"
+              android:layout_height="fill_parent"
+        >
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="horizontal"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+            >
+        <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="Host/Port:"
+                android:minWidth="70dp"
+                />
+                
+        <EditText android:id="@+id/host"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:singleLine="true"
+                  android:textSize="16sp"
+                  android:autoText="false"
+                  android:capitalize="none"
+                  android:minWidth="150dp"
+                  android:scrollHorizontally="true"/>
+        <EditText android:id="@+id/port"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:singleLine="true"
+                  android:textSize="16sp"
+                  android:autoText="false"
+                  android:minWidth="80dp"
+                  android:capitalize="none"
+                  android:scrollHorizontally="true"/>
+    </LinearLayout>
+
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="horizontal"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+            >
+        <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="Userid:"
+                android:minWidth="70dp"
+                />
+        <EditText android:id="@+id/userid"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:singleLine="true"
+                  android:textSize="16sp"
+                  android:autoText="false"
+                  android:minWidth="250dp"
+                  android:capitalize="none"
+                  android:scrollHorizontally="true"/>
+    </LinearLayout>
+    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:orientation="horizontal"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+            >
+        <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="Password:"
+                android:minWidth="70dp"
+                />
+        <EditText android:id="@+id/password"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:singleLine="true"
+                  android:password="true"
+                  android:textSize="16sp"
+                  android:autoText="false"
+                  android:minWidth="250dp"
+                  android:capitalize="none"
+                  android:scrollHorizontally="true"/>
+    </LinearLayout>
+
+    <Button android:id="@+id/ok"
+            android:layout_width="fill_parent"
+            android:layout_height="fill_parent"
+            android:text="OK">
+        <requestFocus/>
+    </Button>
+</LinearLayout>
\ No newline at end of file
--- a/res/menu/beemmenu.xml	Thu Apr 02 14:32:07 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
-	<item android:title="Creer ou Editer un compte" android:id="@+id/account_edit"/>
-	<item android:title="L'equipe Beem" android:id="@+id/account_about"/>
-</menu>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/menu/contactlistmenu.xml	Fri Apr 03 00:49:23 2009 +0200
@@ -0,0 +1,4 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+	<item android:title="Creer ou Editer un compte" android:id="@+id/account_edit"/>
+	<item android:title="L'equipe Beem" android:id="@+id/account_about"/>
+</menu>
--- a/res/values/strings.xml	Thu Apr 02 14:32:07 2009 +0200
+++ b/res/values/strings.xml	Fri Apr 03 00:49:23 2009 +0200
@@ -3,7 +3,7 @@
 	<string name="app_name">Beem</string>
 
 	<!--  Beem class -->
-	<string name="BeemCreateAccount">Creer un compte</string>
+	
 	<string name="BeemJabberID">Jabber ID</string>
 	
 	<!--  BeemService class -->
@@ -13,9 +13,9 @@
 
 	<!--  Preferences informations -->
 	<string name="PreferenceFileName">Beem</string>
-	<string name="PreferenceLoginKey">login</string>
+	
 	<string name="PreferenceHostKey">host</string>
-	<string name="PreferencePasswordKey">password</string>
+	<string name="PreferenceJID">Jabber ID</string><string name="PreferenceLoginKey">login</string><string name="PreferencePasswordKey">password</string>
 	<string name="PreferencePortKey">port</string>
 
 	<!--  SendIM class -->
@@ -24,4 +24,5 @@
 	<string name="SendIMState">Is : </string>
 	<string name="SendIMFrom">and is speaking from : </string>
 	<string name="SendIMSmiley">Insert a smiley</string>
+
 </resources>
--- a/src/com/beem/project/beem/BeemApplication.java	Thu Apr 02 14:32:07 2009 +0200
+++ b/src/com/beem/project/beem/BeemApplication.java	Fri Apr 03 00:49:23 2009 +0200
@@ -26,13 +26,13 @@
 public class BeemApplication extends Application {
 
     private IXMPPFacade mFacade;
-  
+
     private Context mApplicationContext;
     private Resources mPrivateResources;
     private static BeemApplication mBeemApp;
     private List<Message> mQueue = new LinkedList<Message>();
     private boolean mIsConnected;
-    
+
     public static BeemApplication getApplication(Activity activity) {
 	if (mBeemApp == null) {
 	    mBeemApp = new BeemApplication();
@@ -42,7 +42,7 @@
 	}
 	return mBeemApp;
     }
-    
+
     @Override
     public void onConfigurationChanged(Configuration newConfig) {
 	// TODO Auto-generated method stub
@@ -70,11 +70,12 @@
 
     public synchronized void startBeemService() {
 	if (!mIsConnected) {
-	    // Intent intent = new Intent(this, BeemService.class);
 	    Intent intent = new Intent();
-	    intent.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
+	    intent.setComponent(new ComponentName("com.beem.project.beem",
+		    "com.beem.project.beem.BeemService"));
 	    mApplicationContext.startService(intent);
-	    mApplicationContext.bindService(intent, mServConn, BIND_AUTO_CREATE);
+	    mApplicationContext
+		    .bindService(intent, mServConn, BIND_AUTO_CREATE);
 	    mIsConnected = true;
 	}
     }
@@ -101,15 +102,20 @@
     };
 
     public synchronized void stopBeemService() {
-	Intent intent = new Intent(this, BeemService.class);
-	mApplicationContext.unbindService(mServConn);
-	mApplicationContext.stopService(intent);
+	if (mIsConnected) {
+	    Intent intent = new Intent();
+	    intent.setComponent(new ComponentName("com.beem.project.beem",
+		    "com.beem.project.beem.BeemService"));
+	    mApplicationContext.unbindService(mServConn);
+	    mApplicationContext.stopService(intent);
+	    mIsConnected = false;
+	}
     }
 
     public IXMPPFacade getXmppFacade() {
 	return mFacade;
     }
-    
+
     public void callWhenServiceConnected(Handler target, Runnable callback) {
 	Message msg = Message.obtain(target, callback);
 	if (!mIsConnected) {
@@ -121,4 +127,12 @@
 	    }
 	}
     }
+
+    /**
+     * Indique si on est connecte au service.
+     */
+    public boolean isConnected() {
+	return mIsConnected;
+    }
+
 }
--- a/src/com/beem/project/beem/service/XMPPConnectionAdapter.java	Thu Apr 02 14:32:07 2009 +0200
+++ b/src/com/beem/project/beem/service/XMPPConnectionAdapter.java	Fri Apr 03 00:49:23 2009 +0200
@@ -320,4 +320,9 @@
 
     }
 
+    @Override
+    public boolean isAuthentificated() throws RemoteException {
+	return mAdaptee.isAuthenticated();
+    }
+
 }
--- a/src/com/beem/project/beem/service/XMPPFacade.java	Thu Apr 02 14:32:07 2009 +0200
+++ b/src/com/beem/project/beem/service/XMPPFacade.java	Fri Apr 03 00:49:23 2009 +0200
@@ -37,7 +37,6 @@
 
     @Override
     public IXMPPConnection createConnection() throws RemoteException {
-	// TODO Auto-generated method stub
 	return mConnexion;
     }
 
--- a/src/com/beem/project/beem/service/aidl/IXMPPConnection.aidl	Thu Apr 02 14:32:07 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IXMPPConnection.aidl	Fri Apr 03 00:49:23 2009 +0200
@@ -15,4 +15,6 @@
 
     void addConnectionListener(in IBeemConnectionListener listen);
     void removeConnectionListener(in IBeemConnectionListener listen);
+    
+    boolean isAuthentificated();
 }
\ No newline at end of file
--- a/src/com/beem/project/beem/ui/Beem.java	Thu Apr 02 14:32:07 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-package com.beem.project.beem.ui;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.os.Handler;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.Button;
-
-import com.beem.project.beem.BeemApplication;
-import com.beem.project.beem.R;
-
-/**
- * La principale activite to be continuous.
- */
-public class Beem extends Activity {
-
-    private SharedPreferences mSettings;
-    private BeemDialogSettings mDialog;
-    private Button mButton;
-    private Handler mHandler;
-    private BeemApplication mBeemApplication;
-
-    /**
-     * Default constructor.
-     */
-    public Beem() {
-	super();
-	mHandler = new Handler();
-    }
-
-    /**
-     * Called when the activity is first created.
-     * @param savedInstanceState
-     *            previous state.
-     */
-    @Override
-    public final void onCreate(Bundle savedInstanceState) {
-	super.onCreate(savedInstanceState);
-	mBeemApplication = BeemApplication.getApplication(this);
-	setContentView(R.layout.beem);
-	mSettings = getSharedPreferences(
-		getString(R.string.PreferenceFileName), MODE_PRIVATE);
-	mDialog = new BeemDialogSettings(this, mSettings);
-
-	mButton = (Button) findViewById(R.id.connection);
-	mButton.setOnClickListener(new OnClickListener() {
-	    @Override
-	    public void onClick(View v) {
-		if (mButton.getText() == getString(R.string.BeemCreateAccount))
-		    mDialog.show();
-		else
-		    startActivity(new Intent(Beem.this, ContactList.class));	    
-	    }
-	});
-	showJID();
-    }
-
-    /**
-     * Callback for menu creation.
-     * @param menu
-     *            the menu created
-     * @return true on success, false otherwise
-     */
-    @Override
-    public final boolean onCreateOptionsMenu(Menu menu) {
-	super.onCreateOptionsMenu(menu);
-	MenuInflater inflater = getMenuInflater();
-	inflater.inflate(R.menu.beemmenu, menu);
-	return true;
-    }
-
-    /**
-     * Callback for menu item selected.
-     * @param item
-     *            the item selected
-     * @return true on success, false otherwise
-     */
-    @Override
-    public final boolean onOptionsItemSelected(MenuItem item) {
-	switch (item.getItemId()) {
-	    case R.id.account_edit:
-		mDialog.show();
-		return true;
-	    case R.id.account_about:
-		return true;
-	    default:
-		return false;
-	}
-    }
-
-    /**
-     * Show jabber id in button.
-     */
-    public final void showJID() {
-	String jid = mSettings.getString(
-		getString(R.string.PreferenceLoginKey), "")
-		+ "@"
-		+ mSettings
-			.getString(getString(R.string.PreferenceHostKey), "");
-	if (jid.length() == 1)
-	    jid = getString(R.string.BeemCreateAccount);
-	mButton.setText(jid);
-    }
-
-}
--- a/src/com/beem/project/beem/ui/BeemDialogSettings.java	Thu Apr 02 14:32:07 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-package com.beem.project.beem.ui;
-
-import android.app.Dialog;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.view.View;
-import android.widget.Button;
-import android.widget.EditText;
-
-import com.beem.project.beem.R;
-
-/**
- *
- */
-public class BeemDialogSettings extends Dialog implements
-        android.view.View.OnClickListener {
-
-    private Beem mbeem;
-
-    private SharedPreferences mSettings;
-
-    public BeemDialogSettings(Beem beem, SharedPreferences settings) {
-        super(beem);
-        this.mbeem = beem;
-        this.mSettings = settings;
-    }
-
-    @Override
-    protected void onStart() {
-        super.onStart();
-        setContentView(R.layout.beemdialogsettings);
-        getWindow().setFlags(4, 4);
-        setTitle("Jabber Account Settings");
-        showSettings();
-        Button ok = (Button) findViewById(R.id.ok);
-        ok.setOnClickListener(this);
-    }
-
-    @Override
-    public void onClick(View v) {
-        SharedPreferences.Editor editor = mSettings.edit();
-        Context ctx = getContext();
-        editor.putString(ctx.getString(R.string.PreferenceHostKey),
-                getWidgetText(R.id.host));
-        editor.putString(ctx.getString(R.string.PreferencePortKey),
-                getWidgetText(R.id.port));
-        editor.putString(ctx.getString(R.string.PreferenceLoginKey),
-                getWidgetText(R.id.userid));
-        editor.putString(ctx.getString(R.string.PreferencePasswordKey),
-                getWidgetText(R.id.password));
-        editor.commit();
-        this.mbeem.showJID();
-        dismiss();
-    }
-
-    private void showSettings() {
-        String tmp;
-        EditText eHost = (EditText) findViewById(R.id.host);
-        if ((tmp = mSettings.getString("host", "")) != "")
-            eHost.setText(tmp);
-        EditText ePort = (EditText) findViewById(R.id.port);
-        if ((tmp = mSettings.getString("port", "")) != "")
-            ePort.setText(tmp);
-        EditText eLogin = (EditText) findViewById(R.id.userid);
-        if ((tmp = mSettings.getString("login", "")) != "")
-            eLogin.setText(tmp);
-        EditText ePwd = (EditText) findViewById(R.id.password);
-        if ((tmp = mSettings.getString("password", "")) != "")
-            ePwd.setText(tmp);
-    }
-
-    private String getWidgetText(int id) {
-        EditText widget = (EditText) this.findViewById(id);
-        return widget.getText().toString();
-    }
-}
--- a/src/com/beem/project/beem/ui/ContactList.java	Thu Apr 02 14:32:07 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Fri Apr 03 00:49:23 2009 +0200
@@ -4,110 +4,213 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+
+import com.beem.project.beem.R;
 import android.app.ExpandableListActivity;
 import android.content.Context;
 import android.content.Intent;
-import android.graphics.drawable.Drawable;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.RemoteException;
 import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ExpandableListAdapter;
 import android.widget.ExpandableListView;
-import android.widget.ImageView;
 import android.widget.SimpleExpandableListAdapter;
 import android.widget.TextView;
+
 import com.beem.project.beem.BeemApplication;
-import com.beem.project.beem.R;
 import com.beem.project.beem.service.Contact;
+import com.beem.project.beem.service.aidl.IRoster;
 import com.beem.project.beem.service.aidl.IXMPPFacade;
 
 public class ContactList extends ExpandableListActivity {
 
     private static final String TAG = "CONTACTLIST_ACT";
+    private SharedPreferences mSettings;
     private IXMPPFacade mService = null;
     private Handler mHandler;
     private BeemApplication mBeemApplication;
+    private ContactListDialogSettings mDialog;
 
     @Override
-    public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
-	startActivity(new Intent(this, SendIM.class));
+    public boolean onChildClick(ExpandableListView parent, View v,
+	    int groupPosition, int childPosition, long id) {
+	Intent i = new Intent(this, SendIM.class);
+	Map<String, Contact> child = (HashMap<String, Contact>) parent
+		.getExpandableListAdapter().getChild(groupPosition,
+			childPosition);
+	i.putExtra("contact", child.get("CHILD"));
+	startActivity(i);
 	return true;
-
-    };
+    }
 
     @Override
-    public void onCreate(Bundle saveBundle) {
+    protected void onCreate(Bundle saveBundle) {
 	super.onCreate(saveBundle);
 	mHandler = new Handler();
 	mBeemApplication = BeemApplication.getApplication(this);
+	mSettings = getSharedPreferences(
+		getString(R.string.PreferenceFileName), MODE_PRIVATE);
+	mDialog = new ContactListDialogSettings(this, mSettings);
+
+	mSettings
+		.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() {
+		    @Override
+		    public void onSharedPreferenceChanged(
+			    SharedPreferences sharedPreferences, String key) {
+			/*
+			 * TODO : A faire apres listener nikita
+			 *
+			mBeemApplication.stopBeemService();
+			mBeemApplication.startBeemService();
+			mBeemApplication.callWhenServiceConnected(mHandler,
+				new Runnable() {
+				    @Override
+				    public void run() {
+					callbackShowContactList();
+				    }
+				});
+				*/
+		    }
+		});
 
     }
 
     @Override
-    public void onStart() {
+    protected void onStart() {
 	super.onStart();
-	mBeemApplication.startBeemService();
+	Log.i(TAG, "onStart");
+    }
+
+    @Override
+    protected void onResume() {
+	super.onResume();
+	/*
+	 * @TODO: A ameliorer apres listener de nikita
+	 */
+	Log.i(TAG, "onResume");
+	if (!mBeemApplication.isConnected())
+	    mBeemApplication.startBeemService();
+	else {
+	    callbackShowContactList();
+	}
 	mBeemApplication.callWhenServiceConnected(mHandler, new Runnable() {
 	    @Override
 	    public void run() {
-		mService = mBeemApplication.getXmppFacade();
-		try {
-		    showContactList(mService.getRoster().getContactList(), mService.getRoster().getContactList());
-		} catch (RemoteException e) {
-		    // TODO Auto-generated catch block
-		    e.printStackTrace();
-		}
-
+		callbackShowContactList();
 	    }
 	});
     }
 
-    private void showContactList(List<Contact> listGroup, List<Contact> listContact) {
+    private void callbackShowContactList() {
+	/*
+	 * @TODO: A ameliorer apres listener de nikita
+	 */
+	mService = mBeemApplication.getXmppFacade();
+	if (mService != null) {
+	    try {
+		IRoster r = mService.getRoster();
+		if (r != null)
+		    showContactList(r.getGroupsNames(), r.getContactList());
+	    } catch (RemoteException e) {
+		// TODO Auto-generated catch block
+		e.printStackTrace();
+	    }
+	}
+    }
+
+    /**
+     * Callback for menu creation.
+     * 
+     * @param menu
+     *            the menu created
+     * @return true on success, false otherwise
+     */
+    @Override
+    public final boolean onCreateOptionsMenu(Menu menu) {
+	super.onCreateOptionsMenu(menu);
+	MenuInflater inflater = getMenuInflater();
+	inflater.inflate(R.menu.contactlistmenu, menu);
+	return true;
+    }
+
+    /**
+     * Callback for menu item selected.
+     * 
+     * @param item
+     *            the item selected
+     * @return true on success, false otherwise
+     */
+    @Override
+    public final boolean onOptionsItemSelected(MenuItem item) {
+	switch (item.getItemId()) {
+	    case R.id.account_edit:
+		mDialog.show();
+		return true;
+	    case R.id.account_about:
+		return true;
+	    default:
+		return false;
+	}
+    }
+
+    private void showContactList(List<String> listGroup,
+	    List<Contact> listContact) {
 	ExpandableListAdapter Adapter;
 	List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
-	List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
+	List<List<Map<String, Contact>>> childData = new ArrayList<List<Map<String, Contact>>>();
 
 	if (listGroup.size() == 0)
-	    listGroup.add(new Contact());
+	    listGroup.add("Default");
 	for (int i = 0; i < listGroup.size(); i++) {
 	    Map<String, String> curGroupMap = new HashMap<String, String>();
 
 	    groupData.add(curGroupMap);
-	    curGroupMap.put("NAME", "Default");
+	    curGroupMap.put("GROUP", listGroup.get(i));
 
-	    List<Map<String, String>> children = new ArrayList<Map<String, String>>();
+	    List<Map<String, Contact>> children = new ArrayList<Map<String, Contact>>();
 	    for (int j = 0; j < listContact.size(); ++j) {
-		Map<String, String> curChildMap = new HashMap<String, String>();
+		Map<String, Contact> curChildMap = new HashMap<String, Contact>();
 		children.add(curChildMap);
-		curChildMap.put("NAME_CHILD", listContact.get(j).getJID());
-		curChildMap.put("MSG", "Taper votre message perso");
+		curChildMap.put("CHILD", listContact.get(j));
 	    }
 	    childData.add(children);
 	}
 
-	Adapter = new ContactExpandableListAdapter(this, groupData, R.layout.contactlistgroup, new String[] { "NAME" },
-	    new int[] { R.id.textgroup }, childData, R.layout.contactlistcontact, new String[] { "NAME_CHILD", "MSG" },
-	    new int[] { R.id.textchild1, R.id.textchild2, R.id.avatar });
+	Adapter = new ContactExpandableListAdapter(this, groupData,
+		R.layout.contactlistgroup, new String[] { "GROUP" },
+		new int[] { R.id.textgroup }, childData,
+		R.layout.contactlistcontact, new String[] { "CHILD" },
+		new int[] { R.id.textchild1, R.id.textchild2, R.id.avatar });
 	setListAdapter(Adapter);
     }
 
     /**
-     * A simple adapter which allows you to bind data to specific Views defined within the layout of an Expandable Lists
-     * children (Implement getGroupView() to define the layout of parents)
+     * A simple adapter which allows you to bind data to specific Views defined
+     * within the layout of an Expandable Lists children (Implement
+     * getGroupView() to define the layout of parents)
      */
-    public class ContactExpandableListAdapter extends SimpleExpandableListAdapter {
+    public class ContactExpandableListAdapter extends
+	    SimpleExpandableListAdapter {
 
 	private List<? extends List<? extends Map<String, ?>>> mChildData;
 	private String[] mChildFrom;
 	private int[] mChildTo;
 
-	public ContactExpandableListAdapter(Context context, List<? extends Map<String, ?>> groupData, int groupLayout,
-	    String[] groupFrom, int[] groupTo, List<? extends List<? extends Map<String, ?>>> childData,
-	    int childLayout, String[] childFrom, int[] childTo) {
-	    super(context, groupData, groupLayout, groupFrom, groupTo, childData, childLayout, childFrom, childTo);
+	public ContactExpandableListAdapter(Context context,
+		List<? extends Map<String, ?>> groupData, int groupLayout,
+		String[] groupFrom, int[] groupTo,
+		List<? extends List<? extends Map<String, ?>>> childData,
+		int childLayout, String[] childFrom, int[] childTo) {
+	    super(context, groupData, groupLayout, groupFrom, groupTo,
+		    childData, childLayout, childFrom, childTo);
 
 	    mChildData = childData;
 	    mChildFrom = childFrom;
@@ -116,8 +219,8 @@
 	}
 
 	@Override
-	public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
-	    ViewGroup parent) {
+	public View getChildView(int groupPosition, int childPosition,
+		boolean isLastChild, View convertView, ViewGroup parent) {
 
 	    View v;
 	    if (convertView == null) {
@@ -125,32 +228,31 @@
 	    } else {
 		v = convertView;
 	    }
-	    bindView(v, mChildData.get(groupPosition).get(childPosition), mChildFrom, mChildTo, groupPosition,
-		childPosition);
+	    bindView(v, mChildData.get(groupPosition).get(childPosition),
+		    mChildFrom, mChildTo, groupPosition, childPosition);
 	    return v;
 	}
 
-	// This method binds my data to the Views specified in the child
-	// xmllayout
-	private void bindView(View view, Map<String, ?> data, String[] from, int[] to, int groupPosition,
-	    int childPosition) {
-	    // Apply TextViews
-	    TextView v1 = (TextView) view.findViewById(to[0]);
-	    if (v1 != null) {
-		Log.i("CONTACT LIST 1", (String) data.get(from[0]) + " " + to[0]);
-		v1.setText((String) data.get(from[0]));
+	private void bindView(View view, Map<String, ?> data, String[] from,
+		int[] to, int groupPosition, int childPosition) {
+	    TextView v = (TextView) view.findViewById(to[0]);
+	    Contact c = (Contact) data.get(from[0]);
+	    if (v != null) {
+		Log.i(TAG, c.getJID());
+		v.setText(c.getJID());
 	    }
-	    TextView v2 = (TextView) view.findViewById(to[1]);
-	    if (v2 != null) {
-		Log.i("CONTACT LIST 2", (String) data.get(from[1]) + " " + to[1]);
-		v2.setText((String) data.get(from[1]));
-	    }
-	    // Apply ImageView
-	    ImageView imgV = (ImageView) view.findViewById(to[2]);
-	    if (imgV != null) {
-		Drawable avatar = (Drawable) getResources().getDrawable(R.drawable.avatar);
-		imgV.setImageDrawable(avatar);
-	    }
+	    /*
+	     * @TODO: Rajouter le message perso du contact v = (TextView)
+	     * view.findViewById(to[1]); if (v != null) { Log.i(TAG,
+	     * c.getJID()); v.setText(c.getJID()); }
+	     */
+	    /*
+	     * @TODO: Rajouter l'avatar du contact getAvatar() dans la classe
+	     * Contact ImageView imgV = (ImageView) view.findViewById(to[2]); if
+	     * (imgV != null) { Drawable avatar = (Drawable)
+	     * getResources().getDrawable( R.drawable.avatar);
+	     * imgV.setImageDrawable(avatar); }
+	     */
 	}
     }
 
--- a/src/com/beem/project/beem/ui/SendIM.java	Thu Apr 02 14:32:07 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java	Fri Apr 03 00:49:23 2009 +0200
@@ -5,6 +5,7 @@
 import android.app.ListActivity;
 import android.content.SharedPreferences;
 import android.os.Bundle;
+import android.util.Log;
 import android.view.KeyEvent;
 import android.view.Menu;
 import android.view.MenuInflater;
@@ -16,107 +17,120 @@
 import android.widget.EditText;
 
 import com.beem.project.beem.R;
+import com.beem.project.beem.service.Contact;
 
 /**
- * @author barbu
- * This activity class provide the view for instant messaging
- * after selecting a correspondant.
+ * @author barbu This activity class provide the view for instant messaging
+ *         after selecting a correspondant.
  */
 
-public class SendIM extends ListActivity implements OnClickListener, OnKeyListener {
-    private EditText			mToSend;
-    private ArrayList<String>		mMessages = new ArrayList<String>();
-    private ArrayAdapter<String>	mAdapter;
-    private SendIMDialogSmiley		mSmyDialog;
-    private SharedPreferences mSet;
+public class SendIM extends ListActivity implements OnClickListener,
+		OnKeyListener {
+	private EditText mToSend;
+	private ArrayList<String> mMessages = new ArrayList<String>();
+	private ArrayAdapter<String> mAdapter;
+	private SendIMDialogSmiley mSmyDialog;
+	private SharedPreferences mSet;
+	private Contact mContact;
 
-    /**
-     * Constructor.
-     */
-    public SendIM() {
-	super();
-    }
+	/**
+	 * Constructor.
+	 */
+	public SendIM() {
+		super();
+	}
 
-    /**
-     * Overload of onCreate() Activity inherited function
-     */
-    @Override
-    public void onCreate(Bundle saveBundle) {
-	super.onCreate(saveBundle);
-	setContentView(R.layout.sendim);
-	mToSend = (EditText) findViewById(R.id.userText);
-	mSet = getSharedPreferences("lol", MODE_PRIVATE);
-	mSmyDialog = new SendIMDialogSmiley(this, mSet);
+	/**
+	 * Overload of onCreate() Activity inherited function
+	 */
+	@Override
+	public void onCreate(Bundle saveBundle) {
+		super.onCreate(saveBundle);
+		
+		setContentView(R.layout.sendim);
+		mToSend = (EditText) findViewById(R.id.userText);
+		mSet = getSharedPreferences("lol", MODE_PRIVATE);
+		mSmyDialog = new SendIMDialogSmiley(this, mSet);
 
-	mAdapter = new ArrayAdapter<String>(this, R.layout.messagelist, mMessages);
-	setListAdapter(mAdapter);
-
-	mToSend.setOnClickListener(this);
-	mToSend.setOnKeyListener(this);
-    }
+		mAdapter = new ArrayAdapter<String>(this, R.layout.messagelist,
+				mMessages);
+		setListAdapter(mAdapter);
 
-    /**
-     * Abstract method inherited from OnClickListener
-     */
-    public void onClick(View view) {
-	sendText();
-    }
+		mToSend.setOnClickListener(this);
+		mToSend.setOnKeyListener(this);
+		
+		mContact = getIntent().getParcelableExtra("contact");
+	}
 
-    /**
-     * This method send a message to the server over the XMPP
-     * connection and display it on activity view
-     * TODO : Exception si la connexion se coupe pendant la conversation
-     */
-    private void sendText() {
-	String text = mToSend.getText().toString();
-	if (!text.equals("")) {
-	    /*
-	     * Prepare the message to be send 
-	     * */
-	    /*Message msg = new Message("barbu", Message.Type.chat);*/
-	    /*msg.setBody(text);*/
-	    mAdapter.add("Barbu " + getString(R.string.SendIMSays) + text);
-	    mToSend.setText(null);
+	@Override
+	public void onStart() {
+		super.onStart();
+
 	}
-    }
+
+	/**
+	 * Abstract method inherited from OnClickListener
+	 */
+	public void onClick(View view) {
+		sendText();
+	}
 
-    /**
-     * Abstract method inherited from OnKeyListener
-     */
-    public boolean onKey(View v, int keyCode, KeyEvent event) {
-	if (event.getAction() == KeyEvent.ACTION_DOWN) {
-	    switch (keyCode) {
-		case KeyEvent.KEYCODE_DPAD_CENTER:
-		case KeyEvent.KEYCODE_ENTER:
-		    sendText();
-		    return true;
-	    }
+	/**
+	 * This method send a message to the server over the XMPP connection and
+	 * display it on activity view TODO : Exception si la connexion se coupe
+	 * pendant la conversation
+	 */
+	private void sendText() {
+		String text = mToSend.getText().toString();
+		if (!text.equals("")) {
+			/*
+			 * Prepare the message to be send
+			 */
+			/* Message msg = new Message("barbu", Message.Type.chat); */
+			/* msg.setBody(text); */
+			mAdapter.add(getString(R.string.PreferenceJID) + " " + getString(R.string.SendIMSays) + text);
+			mToSend.setText(null);
+		}
 	}
-	return false;
-    }
-    
-    /**
-     * Callback for menu creation.
-     * @param menu
-     *            the menu created
-     * @return true on success, false otherwise
-     */
-    @Override
-    public final boolean onCreateOptionsMenu(Menu menu) {
-	super.onCreateOptionsMenu(menu);
-	MenuInflater inflater = getMenuInflater();
-	inflater.inflate(R.menu.sendimmenu, menu);
-	return true;
-    }
-    
-    @Override
-    public final boolean onOptionsItemSelected(MenuItem item) {
-	switch (item.getItemId()) {
-	    case R.id.sendim_smiley:
-		mSmyDialog.show();
-		return true;
-	    default:
+
+	/**
+	 * Abstract method inherited from OnKeyListener
+	 */
+	public boolean onKey(View v, int keyCode, KeyEvent event) {
+		if (event.getAction() == KeyEvent.ACTION_DOWN) {
+			switch (keyCode) {
+			case KeyEvent.KEYCODE_DPAD_CENTER:
+			case KeyEvent.KEYCODE_ENTER:
+				sendText();
+				return true;
+			}
+		}
 		return false;
 	}
-    }
+
+	/**
+	 * Callback for menu creation.
+	 * 
+	 * @param menu
+	 *            the menu created
+	 * @return true on success, false otherwise
+	 */
+	@Override
+	public final boolean onCreateOptionsMenu(Menu menu) {
+		super.onCreateOptionsMenu(menu);
+		MenuInflater inflater = getMenuInflater();
+		inflater.inflate(R.menu.sendimmenu, menu);
+		return true;
+	}
+
+	@Override
+	public final boolean onOptionsItemSelected(MenuItem item) {
+		switch (item.getItemId()) {
+		case R.id.sendim_smiley:
+			mSmyDialog.show();
+			return true;
+		default:
+			return false;
+		}
+	}
 }