bitmap caching
diff --git a/src/org/sflphone/adapters/ContactPictureTask.java b/src/org/sflphone/adapters/ContactPictureTask.java
index 7b57a17..478d2de 100644
--- a/src/org/sflphone/adapters/ContactPictureTask.java
+++ b/src/org/sflphone/adapters/ContactPictureTask.java
@@ -34,6 +34,7 @@
 import java.io.InputStream;
 
 import org.sflphone.R;
+import org.sflphone.model.CallContact;
 
 import android.content.ContentResolver;
 import android.content.ContentUris;
@@ -52,13 +53,13 @@
 
 public class ContactPictureTask implements Runnable {
     private ImageView view;
-    private long cid;
+    private CallContact contact;
     private ContentResolver cr;
 
     // private final String TAG = ContactPictureTask.class.getSimpleName();
 
-    public ContactPictureTask(Context context, ImageView element, long contact_id) {
-        cid = contact_id;
+    public ContactPictureTask(Context context, ImageView element, CallContact item) {
+        contact = item;
         cr = context.getContentResolver();
         view = element;
     }
@@ -76,7 +77,7 @@
     public void run() {
         Bitmap photo_bmp;
         try {
-            photo_bmp = loadContactPhoto(cr, cid);
+            photo_bmp = loadContactPhoto(cr, contact.getId());
         } catch (IllegalArgumentException e) {
             photo_bmp = null;
         }
@@ -107,6 +108,7 @@
             @Override
             public void run() {
                 view.setImageBitmap(externalBMP);
+                contact.setPhoto(externalBMP);
                 view.invalidate();
             }
         });
diff --git a/src/org/sflphone/adapters/ContactsAdapter.java b/src/org/sflphone/adapters/ContactsAdapter.java
index 83492f9..1f70c05 100644
--- a/src/org/sflphone/adapters/ContactsAdapter.java
+++ b/src/org/sflphone/adapters/ContactsAdapter.java
@@ -98,8 +98,11 @@
 
         entryView.display_name.setText(item.getmDisplayName());
 
-
-        infos_fetcher.execute(new ContactPictureTask(mContext, entryView.photo, item.getId()));
+        if(item.hasPhoto()){
+            entryView.photo.setImageBitmap(item.getPhoto());
+        } else {
+            infos_fetcher.execute(new ContactPictureTask(mContext, entryView.photo, item));
+        }
 
         entryView.quick_call.setOnClickListener(new OnClickListener() {
 
diff --git a/src/org/sflphone/adapters/StarredContactsAdapter.java b/src/org/sflphone/adapters/StarredContactsAdapter.java
index 6a010bc..49989b8 100644
--- a/src/org/sflphone/adapters/StarredContactsAdapter.java
+++ b/src/org/sflphone/adapters/StarredContactsAdapter.java
@@ -100,8 +100,11 @@
         ((TextView) v.findViewById(R.id.display_name)).setText(item.getmDisplayName());
         ImageView photo_view = (ImageView) v.findViewById(R.id.photo);
 
-        infos_fetcher.execute(new ContactPictureTask(mContext, photo_view, item.getId()));
-
+        if(item.hasPhoto()){
+            photo_view.setImageBitmap(item.getPhoto());
+        } else {
+            infos_fetcher.execute(new ContactPictureTask(mContext, photo_view, item));
+        }
         return v;
     }
 }
\ No newline at end of file
diff --git a/src/org/sflphone/fragments/CallFragment.java b/src/org/sflphone/fragments/CallFragment.java
index beaf2ad..b14e189 100644
--- a/src/org/sflphone/fragments/CallFragment.java
+++ b/src/org/sflphone/fragments/CallFragment.java
@@ -364,8 +364,7 @@
             return contact_bubble;
         }
 
-        contact_bubble = new BubbleUser(getActivity(), CallContact.ContactBuilder.buildUserContact(getActivity().getContentResolver(), getResources()
-                .getString(R.string.me)), conf, x, y, BUBBLE_SIZE);
+        contact_bubble = new BubbleUser(getActivity(), CallContact.ContactBuilder.buildUserContact(getActivity().getContentResolver()), conf, x, y, BUBBLE_SIZE);
 
         model.addBubble(contact_bubble);
         return contact_bubble;
diff --git a/src/org/sflphone/fragments/HistoryFragment.java b/src/org/sflphone/fragments/HistoryFragment.java
index 30c1d92..29173ae 100644
--- a/src/org/sflphone/fragments/HistoryFragment.java
+++ b/src/org/sflphone/fragments/HistoryFragment.java
@@ -209,8 +209,7 @@
             // SipCall call = (SipCall) mCallList.values().toArray()[position];
             entryView.displayName.setText(dataset.get(pos).getContact().getmDisplayName());
 
-            infos_fetcher.execute(new ContactPictureTask(mContext.getActivity(), entryView.photo, dataset.get(pos).getContact().getId()));
-
+            infos_fetcher.execute(new ContactPictureTask(mContext, entryView.photo, dataset.get(pos).getContact()));
 
             entryView.missed.setText(getString(R.string.hist_missed_calls, dataset.get(pos).getMissed_sum()));
             entryView.incoming.setText(getString(R.string.hist_in_calls, dataset.get(pos).getIncoming_sum()));
@@ -227,11 +226,11 @@
                             if ((Boolean) v.getTag(R.id.replay)) {
                                 mCallbacks.getService().startRecordedFilePlayback(dataset.get(pos).getCalls().lastEntry().getValue().getRecordPath());
                                 v.setTag(R.id.replay, false);
-                                ((Button)v).setText(getString(R.string.hist_replay_button_stop));
+                                ((Button) v).setText(getString(R.string.hist_replay_button_stop));
                             } else {
                                 mCallbacks.getService().stopRecordedFilePlayback(dataset.get(pos).getCalls().lastEntry().getValue().getRecordPath());
                                 v.setTag(R.id.replay, true);
-                                ((Button)v).setText(getString(R.string.hist_replay_button));
+                                ((Button) v).setText(getString(R.string.hist_replay_button));
                             }
                         } catch (RemoteException e) {
                             // TODO Auto-generated catch block
diff --git a/src/org/sflphone/fragments/MenuFragment.java b/src/org/sflphone/fragments/MenuFragment.java
index e1234f5..83c2001 100644
--- a/src/org/sflphone/fragments/MenuFragment.java
+++ b/src/org/sflphone/fragments/MenuFragment.java
@@ -43,6 +43,7 @@
 import org.sflphone.loaders.AccountsLoader;
 import org.sflphone.loaders.LoaderConstants;
 import org.sflphone.model.Account;
+import org.sflphone.model.CallContact;
 import org.sflphone.receivers.AccountsReceiver;
 import org.sflphone.service.ConfigurationManagerCallback;
 import org.sflphone.service.ISipService;
@@ -201,19 +202,11 @@
             }
         });
 
-        Cursor mProfileCursor = getActivity().getContentResolver().query(Profile.CONTENT_URI, mProjection, null, null, null);
+        CallContact user = CallContact.ContactBuilder.buildUserContact(getActivity().getContentResolver());
+        new ContactPictureTask(getActivity(), (ImageView) inflatedView.findViewById(R.id.user_photo), user).run();
 
-        if (mProfileCursor.getCount() > 0) {
-            mProfileCursor.moveToFirst();
-            long contact_id = mProfileCursor.getLong(mProfileCursor.getColumnIndex(Profile._ID));
+        ((TextView) inflatedView.findViewById(R.id.user_name)).setText(user.getmDisplayName());
 
-            new ContactPictureTask(getActivity(), (ImageView) inflatedView.findViewById(R.id.user_photo), contact_id).run();
-            
-
-            ((TextView) inflatedView.findViewById(R.id.user_name)).setText(mProfileCursor.getString(mProfileCursor
-                    .getColumnIndex(Profile.DISPLAY_NAME_PRIMARY)));
-            mProfileCursor.close();
-        }
         return inflatedView;
     }
 
diff --git a/src/org/sflphone/model/CallContact.java b/src/org/sflphone/model/CallContact.java
index 757db40..168ea38 100644
--- a/src/org/sflphone/model/CallContact.java
+++ b/src/org/sflphone/model/CallContact.java
@@ -30,13 +30,16 @@
  */
 package org.sflphone.model;
 
+import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 
 import android.content.ContentResolver;
 import android.database.Cursor;
+import android.graphics.Bitmap;
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.provider.ContactsContract.Profile;
+import android.util.Log;
 
 public class CallContact implements Parcelable {
 
@@ -46,6 +49,7 @@
     private ArrayList<Phone> phones, sip_phones;
     private String mEmail;
     private boolean isUser;
+    private WeakReference<Bitmap> contact_photo = new WeakReference<Bitmap>(null);
 
     private CallContact(long cID, String displayName, long photoID, ArrayList<Phone> p, ArrayList<Phone> sip, String mail, boolean user) {
         id = cID;
@@ -161,17 +165,19 @@
             return new CallContact(-1, to, 0, phones, new ArrayList<CallContact.Phone>(), "", false);
         }
 
-        public static CallContact buildUserContact(ContentResolver cr, String displayName) {
-            String[] mProjection = new String[] { Profile._ID, Profile.PHOTO_ID };
+        public static CallContact buildUserContact(ContentResolver cr) {
+            String[] mProjection = new String[] { Profile._ID, Profile.DISPLAY_NAME_PRIMARY, Profile.PHOTO_ID };
             Cursor mProfileCursor = cr.query(Profile.CONTENT_URI, mProjection, null, null, null);
             CallContact result = null;
             if (mProfileCursor.getCount() > 0) {
                 mProfileCursor.moveToFirst();
+                String displayName = mProfileCursor.getString(mProfileCursor.getColumnIndex(Profile.DISPLAY_NAME_PRIMARY));
+
                 result = new CallContact(mProfileCursor.getLong(mProfileCursor.getColumnIndex(Profile._ID)), displayName,
                         mProfileCursor.getLong(mProfileCursor.getColumnIndex(Profile.PHOTO_ID)), new ArrayList<Phone>(),
                         new ArrayList<CallContact.Phone>(), "", true);
             } else {
-                result = new CallContact(-1, displayName, 0, new ArrayList<Phone>(), new ArrayList<CallContact.Phone>(), "", true);
+                result = new CallContact(-1, "Me", 0, new ArrayList<Phone>(), new ArrayList<CallContact.Phone>(), "", true);
             }
             mProfileCursor.close();
             return result;
@@ -297,4 +303,18 @@
         return isUser;
     }
 
+    public boolean hasPhoto() {
+        if (contact_photo.get() != null)
+            return true;
+        return false;
+    }
+
+    public Bitmap getPhoto() {
+        return contact_photo.get();
+    }
+
+    public void setPhoto(Bitmap externalBMP) {
+        contact_photo = new WeakReference<Bitmap>(externalBMP);
+    }
+
 }