ajout des avatars a partir de la vcard, faudra pofiner.
authorNikita Kozlov <nikita@beem-project.com>
Fri, 02 Oct 2009 17:45:24 +0200
changeset 438 051fa95b54f7
parent 437 fbac93bba310
child 439 bd4ab0cd1a34
child 440 1b04c885f87d
ajout des avatars a partir de la vcard, faudra pofiner.
src/com/beem/project/beem/service/XmppFacade.java
src/com/beem/project/beem/service/aidl/IXmppFacade.aidl
src/com/beem/project/beem/ui/ContactList.java
--- a/src/com/beem/project/beem/service/XmppFacade.java	Fri Oct 02 15:05:23 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppFacade.java	Fri Oct 02 17:45:24 2009 +0200
@@ -1,6 +1,8 @@
 package com.beem.project.beem.service;
 
+import org.jivesoftware.smack.XMPPException;
 import org.jivesoftware.smack.packet.Presence;
+import org.jivesoftware.smackx.packet.VCard;
 
 import android.app.Notification;
 import android.app.PendingIntent;
@@ -130,4 +132,17 @@
     public void call(String jid) throws RemoteException {
 	mJingle.call(jid);
     }
+
+    @Override
+    public byte[] getVcardAvater(String jid) throws RemoteException {
+	VCard vcard = new VCard();
+
+	try {
+	    vcard.load(mConnexion.getAdaptee(),jid);
+	    return vcard.getAvatar();
+	} catch (XMPPException e) {
+	    e.printStackTrace();
+	}
+	return null;
+    }
 }
--- a/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl	Fri Oct 02 15:05:23 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl	Fri Oct 02 17:45:24 2009 +0200
@@ -53,4 +53,10 @@
      * @param jid the receiver id
      */
      void call(in String jid);
+     
+     /**
+      * get the user vcard avatar
+      * @param jid the user jid
+      */
+      byte[] getVcardAvater(in String jid);
 }
--- a/src/com/beem/project/beem/ui/ContactList.java	Fri Oct 02 15:05:23 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Fri Oct 02 17:45:24 2009 +0200
@@ -15,6 +15,7 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.ServiceConnection;
+import android.graphics.BitmapFactory;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.Handler;
@@ -528,7 +529,7 @@
 			break;
 		    default:
 			imageDrawable = getResources().getDrawable(R.drawable.error);
-			break;
+		    break;
 		}
 		imgV.setImageDrawable(imageDrawable);
 
@@ -551,6 +552,20 @@
 		 * view.findViewById(R.id.contactlistavatar); if (imgV != null) { imageDrawable =
 		 * getResources().getDrawable(R.drawable.avatar); imgV.setImageDrawable(imageDrawable); }
 		 */
+
+		if (false){
+		    imgV = (ImageView) view.findViewById(R.id.contactlistavatar);
+
+		    byte[] rawImg;
+		    try {
+			//TODO: le faire en asynchrone, car la ca bloque tout.
+			rawImg = mXmppFacade.getVcardAvater(curContact.getJID());
+			if (rawImg != null)
+			    imgV.setImageBitmap(BitmapFactory.decodeByteArray(rawImg, 0, rawImg.length));
+		    } catch (RemoteException e) {
+			e.printStackTrace();
+		    }
+		}
 	    }
 	}
     }