navigation: added back user photo and name
diff --git a/res/layout/frag_menu.xml b/res/layout/frag_menu.xml
index 0133723..6ebfd93 100644
--- a/res/layout/frag_menu.xml
+++ b/res/layout/frag_menu.xml
@@ -6,6 +6,32 @@
android:orientation="vertical"
android:paddingTop="?android:attr/actionBarSize" >
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="@color/lighter_gray"
+ android:padding="5dp" >
+
+ <ImageView
+ android:id="@+id/user_photo"
+ android:layout_width="70dp"
+ android:layout_height="70dp"
+ android:layout_alignParentLeft="true"
+ android:layout_centerVertical="true" />
+
+ <TextView
+ android:id="@+id/user_name"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerVertical="true"
+ android:layout_toRightOf="@+id/user_photo"
+ android:layout_marginLeft="15dp"
+ android:singleLine="true"
+ android:textStyle="bold"
+ android:textColor="@color/black"
+ android:textSize="20sp" />
+ </RelativeLayout>
+
<TextView
android:id="@+id/list_header_title"
style="?android:attr/listSeparatorTextViewStyle"
diff --git a/src/org/sflphone/fragments/MenuFragment.java b/src/org/sflphone/fragments/MenuFragment.java
index 3b9b936..6dfbba3 100644
--- a/src/org/sflphone/fragments/MenuFragment.java
+++ b/src/org/sflphone/fragments/MenuFragment.java
@@ -34,6 +34,7 @@
import org.sflphone.R;
import org.sflphone.adapters.AccountSelectionAdapter;
+import org.sflphone.adapters.ContactPictureTask;
import org.sflphone.adapters.MenuAdapter;
import org.sflphone.client.ActivityHolder;
import org.sflphone.client.SFLPhoneHomeActivity;
@@ -52,10 +53,11 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.Loader;
+import android.database.Cursor;
+import android.net.Uri;
import android.os.Bundle;
import android.os.RemoteException;
import android.provider.ContactsContract.Profile;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -63,9 +65,11 @@
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
+import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.Spinner;
+import android.widget.TextView;
public class MenuFragment extends Fragment implements LoaderCallbacks<Bundle>, AccountsInterface {
@@ -73,7 +77,7 @@
public static final String ARG_SECTION_NUMBER = "section_number";
MenuAdapter mAdapter;
- String[] mProjection = new String[] { Profile._ID, Profile.DISPLAY_NAME_PRIMARY, Profile.LOOKUP_KEY, Profile.PHOTO_THUMBNAIL_URI };
+ String[] mProjection = new String[] { Profile._ID, Profile.DISPLAY_NAME_PRIMARY, Profile.LOOKUP_KEY, Profile.PHOTO_URI };
AccountSelectionAdapter mAccountAdapter;
private Spinner spinnerAccounts;
AccountsReceiver accountReceiver;
@@ -164,11 +168,6 @@
in.setClass(getActivity(), SFLPhonePreferenceActivity.class);
getActivity().startActivityForResult(in, SFLPhoneHomeActivity.REQUEST_CODE_PREFERENCES);
break;
- // case 3:
- // in.putExtra("ActivityHolder.args", ActivityHolder.args.FRAG_GESTURES);
- // in.setClass(getActivity(), ActivityHolder.class);
- // getActivity().startActivity(in);
- // break;
case 1:
in.putExtra("ActivityHolder.args", ActivityHolder.args.FRAG_ABOUT);
in.setClass(getActivity(), ActivityHolder.class);
@@ -202,18 +201,19 @@
}
});
- // Cursor mProfileCursor = getActivity().getContentResolver().query(Profile.CONTENT_URI, mProjection, null, null, null);
- //
- // if (mProfileCursor.getCount() > 0) {
- // mProfileCursor.moveToFirst();
- // String photo_uri = mProfileCursor.getString(mProfileCursor.getColumnIndex(Profile.PHOTO_THUMBNAIL_URI));
- // if (photo_uri != null) {
- // ((ImageView) inflatedView.findViewById(R.id.user_photo)).setImageURI(Uri.parse(photo_uri));
- // }
- // ((TextView) inflatedView.findViewById(R.id.user_name)).setText(mProfileCursor.getString(mProfileCursor
- // .getColumnIndex(Profile.DISPLAY_NAME_PRIMARY)));
- // mProfileCursor.close();
- // }
+ Cursor mProfileCursor = getActivity().getContentResolver().query(Profile.CONTENT_URI, mProjection, null, null, null);
+
+ if (mProfileCursor.getCount() > 0) {
+ mProfileCursor.moveToFirst();
+ long contact_id = mProfileCursor.getLong(mProfileCursor.getColumnIndex(Profile._ID));
+
+ 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;
}