# HG changeset patch # User Nikita Kozlov # Date 1254498324 -7200 # Node ID 051fa95b54f7d65739db66ce52c199f4b4655c1b # Parent fbac93bba31030868ad22096153c44b7de2c7447 ajout des avatars a partir de la vcard, faudra pofiner. diff -r fbac93bba310 -r 051fa95b54f7 src/com/beem/project/beem/service/XmppFacade.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; + } } diff -r fbac93bba310 -r 051fa95b54f7 src/com/beem/project/beem/service/aidl/IXmppFacade.aidl --- 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); } diff -r fbac93bba310 -r 051fa95b54f7 src/com/beem/project/beem/ui/ContactList.java --- 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(); + } + } } } }