Ajout de nombreux icones pour la gestion des status.
authormarseille@KungFuh
Sat, 04 Apr 2009 01:22:36 +0200
changeset 60 aa70a805da17
parent 59 ff98ffba21f4
child 62 ec87eec66d56
child 65 fcafa1e28942
Ajout de nombreux icones pour la gestion des status.
res/drawable/away.png
res/drawable/chat.png
res/drawable/closed.png
res/drawable/connecting.png
res/drawable/dnd.png
res/drawable/error.png
res/drawable/invisible.png
res/drawable/message.png
res/drawable/not_in_the_roster.png
res/drawable/offline.png
res/drawable/online.png
res/drawable/requested.png
res/layout/contactlistcontact.xml
src/com/beem/project/beem/ui/ContactList.java
Binary file res/drawable/away.png has changed
Binary file res/drawable/chat.png has changed
Binary file res/drawable/closed.png has changed
Binary file res/drawable/connecting.png has changed
Binary file res/drawable/dnd.png has changed
Binary file res/drawable/error.png has changed
Binary file res/drawable/invisible.png has changed
Binary file res/drawable/message.png has changed
Binary file res/drawable/not_in_the_roster.png has changed
Binary file res/drawable/offline.png has changed
Binary file res/drawable/online.png has changed
Binary file res/drawable/requested.png has changed
--- a/res/layout/contactlistcontact.xml	Fri Apr 03 01:26:42 2009 +0200
+++ b/res/layout/contactlistcontact.xml	Sat Apr 04 01:22:36 2009 +0200
@@ -2,25 +2,34 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:orientation="horizontal"
         android:layout_width="fill_parent"
-        android:layout_height="50sp" 
+        android:layout_height="wrap_content" 
         android:gravity="center_vertical" >
 
-        <ImageView android:id="@+id/avatar"
-        	android:layout_width="70px"
-            android:layout_height="40sp" />
+        <ImageView android:id="@+id/contactliststatus"
+        android:layout_weight="5"
+        	android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center_vertical" />
+
 		<LinearLayout
 			android:orientation="vertical"
+			android:layout_weight="1"
         	android:layout_width="fill_parent"
-        	android:layout_height="40sp">
-        		
-        	<TextView android:id="@+id/textchild1"
+        	android:layout_height="wrap_content" >
+        	<TextView android:id="@+id/contactlistpseudo"
+				android:layout_width="fill_parent"
+            	android:layout_height="wrap_content"            	
+            	android:paddingLeft="20sp" />
+			<TextView android:id="@+id/contactlistmsgperso"
 				android:layout_width="fill_parent"
             	android:layout_height="wrap_content"
             	android:paddingLeft="20sp" />
-
-        	<TextView android:id="@+id/textchild2"
-				android:layout_width="fill_parent"
-            	android:layout_height="wrap_content" />
 		</LinearLayout>
 
+        <ImageView android:id="@+id/contactlistavatar"
+        	android:layout_weight="5"
+        	android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center_vertical" />
+            
 </LinearLayout> 
\ No newline at end of file
--- a/src/com/beem/project/beem/ui/ContactList.java	Fri Apr 03 01:26:42 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Sat Apr 04 01:22:36 2009 +0200
@@ -10,6 +10,7 @@
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
+import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.RemoteException;
@@ -21,6 +22,7 @@
 import android.view.ViewGroup;
 import android.widget.ExpandableListAdapter;
 import android.widget.ExpandableListView;
+import android.widget.ImageView;
 import android.widget.SimpleExpandableListAdapter;
 import android.widget.TextView;
 
@@ -39,6 +41,7 @@
     private BeemApplication mBeemApplication;
     private ContactListDialogSettings mDialog;
 
+    @SuppressWarnings("unchecked")
     @Override
     public boolean onChildClick(ExpandableListView parent, View v,
 	    int groupPosition, int childPosition, long id) {
@@ -46,7 +49,7 @@
 	Map<String, Contact> child = (HashMap<String, Contact>) parent
 		.getExpandableListAdapter().getChild(groupPosition,
 			childPosition);
-	i.putExtra("contact", child.get("CHILD"));
+	i.putExtra("contact", child.values().toArray());
 	startActivity(i);
 	return true;
     }
@@ -67,17 +70,15 @@
 			    SharedPreferences sharedPreferences, String key) {
 			/*
 			 * TODO : A faire apres listener nikita
-			 *
-			mBeemApplication.stopBeemService();
-			mBeemApplication.startBeemService();
-			mBeemApplication.callWhenServiceConnected(mHandler,
-				new Runnable() {
-				    @Override
-				    public void run() {
-					callbackShowContactList();
-				    }
-				});
-				*/
+			 * 
+			 * mBeemApplication.stopBeemService();
+			 * mBeemApplication.startBeemService();
+			 * mBeemApplication.callWhenServiceConnected(mHandler,
+			 * new Runnable() {
+			 * 
+			 * @Override public void run() {
+			 * callbackShowContactList(); } });
+			 */
 		    }
 		});
 
@@ -179,7 +180,8 @@
 	    for (int j = 0; j < listContact.size(); ++j) {
 		Map<String, Contact> curChildMap = new HashMap<String, Contact>();
 		children.add(curChildMap);
-		curChildMap.put("CHILD", listContact.get(j));
+		Contact c = listContact.get(j);
+		curChildMap.put("CHILD", c);
 	    }
 	    childData.add(children);
 	}
@@ -188,7 +190,8 @@
 		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 });
+		new int[] { R.id.contactliststatus, R.id.contactlistpseudo,
+			R.id.contactlistmsgperso, R.id.contactlistavatar });
 	setListAdapter(Adapter);
     }
 
@@ -197,7 +200,7 @@
      * within the layout of an Expandable Lists children (Implement
      * getGroupView() to define the layout of parents)
      */
-    public class ContactExpandableListAdapter extends
+    private class ContactExpandableListAdapter extends
 	    SimpleExpandableListAdapter {
 
 	private List<? extends List<? extends Map<String, ?>>> mChildData;
@@ -235,25 +238,60 @@
 
 	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());
+
+	    if (c != null) {
+
+		ImageView imgV = (ImageView) view.findViewById(to[0]);
+		Drawable imageDrawable = null;
+		switch (c.getStatus()) {
+		    case Contact.CONTACT_STATUS_AVAILABLE:
+			imageDrawable = (Drawable) getResources().getDrawable(
+				R.drawable.avatar);
+		    case Contact.CONTACT_STATUS_AVAILABLE_FOR_CHAT:
+			imageDrawable = (Drawable) getResources().getDrawable(
+				R.drawable.chat);
+		    case Contact.CONTACT_STATUS_AWAY:
+			imageDrawable = (Drawable) getResources().getDrawable(
+				R.drawable.away);
+		    case Contact.CONTACT_STATUS_BUSY:
+			imageDrawable = (Drawable) getResources().getDrawable(
+				R.drawable.dnd);
+		    case Contact.CONTACT_STATUS_DISCONNECT:
+			imageDrawable = (Drawable) getResources().getDrawable(
+				R.drawable.offline);
+		    case Contact.CONTACT_STATUS_UNAVAILABLE:
+			imageDrawable = (Drawable) getResources().getDrawable(
+				R.drawable.requested);
+		    default:
+			imageDrawable = (Drawable) getResources().getDrawable(
+				R.drawable.error);
+		}
+		imgV.setImageDrawable(imageDrawable);
+
+		TextView v = (TextView) view.findViewById(to[1]);
+		if (v != null) {
+		    v.setText(c.getJID());
+		}
+		/*
+		 * @TODO: Rajouter le message perso du contact v = (TextView)
+		 */
+		v = (TextView) view.findViewById(to[2]);
+		if (v != null) {
+		    v.setText(c.getMMsgState());
+		}
+
+		/*
+		 * @TODO: Rajouter l'avatar du contact getAvatar() dans la
+		 * classe
+		 */
+		imgV = (ImageView) view.findViewById(to[3]);
+		if (imgV != null) {
+		    imageDrawable = (Drawable) getResources().getDrawable(
+			    R.drawable.avatar);
+		    imgV.setImageDrawable(imageDrawable);
+		}
 	    }
-	    /*
-	     * @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); }
-	     */
 	}
     }
-
-}
+}
\ No newline at end of file