Ajout de la layout vcard
authorVincent Veronis <veroni_v@epitech.net>
Thu, 01 Oct 2009 16:50:12 +0200
changeset 423 32d2c5840a8c
parent 422 1385ea631852
child 424 489d3728f7b7
Ajout de la layout vcard Ajout de la layout manage group avec une banner defilante qui affiche tous les groups d'un user.
res/layout/contactlist.xml
res/layout/userinfo.xml
res/values-en/strings.xml
res/values-fr/strings.xml
src/com/beem/project/beem/ui/ContactList.java
src/com/beem/project/beem/ui/UserInfo.java
--- a/res/layout/contactlist.xml	Thu Oct 01 15:48:06 2009 +0200
+++ b/res/layout/contactlist.xml	Thu Oct 01 16:50:12 2009 +0200
@@ -4,7 +4,7 @@
 	android:orientation="vertical">
 
 	<Gallery xmlns:android="http://schemas.android.com/apk/res/android"
-		android:id="@+id/gallery" android:layout_width="fill_parent"
+		android:id="@+id/contactlist_banner" android:layout_width="fill_parent"
 		android:layout_height="wrap_content" android:spacing="50px" />
 
 	<LinearLayout android:layout_width="fill_parent"
--- a/res/layout/userinfo.xml	Thu Oct 01 15:48:06 2009 +0200
+++ b/res/layout/userinfo.xml	Thu Oct 01 16:50:12 2009 +0200
@@ -1,7 +1,47 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
 	android:orientation="vertical" android:layout_width="fill_parent"
 	android:layout_height="fill_parent">
-	<ListView android:id="@+id/userinfo" android:layout_width="fill_parent"
-		android:layout_height="fill_parent" />
-</LinearLayout>
\ No newline at end of file
+	<LinearLayout android:orientation="vertical"
+		android:layout_width="fill_parent" android:layout_height="wrap_content">
+		<LinearLayout android:id="@+id/userinfo_layout_alias"
+			android:orientation="vertical" android:layout_width="fill_parent"
+			android:layout_height="wrap_content">
+			<TextView android:layout_width="fill_parent"
+				android:layout_height="wrap_content" android:paddingLeft="20sp"
+				android:singleLine="true" android:maxLines="1" android:textSize="30px"
+				android:text="@string/userinfo_label_alias" />
+			<TextView android:id="@+id/userinfo_alias"
+				android:layout_width="fill_parent" android:layout_height="wrap_content"
+				android:paddingLeft="20sp" android:singleLine="true" />
+		</LinearLayout>
+		<View android:layout_height="1px" android:layout_width="fill_parent"
+			android:background="#FFFFFF" />
+		<LinearLayout android:id="@+id/userinfo_layout_vcard"
+			android:orientation="vertical" android:layout_width="fill_parent"
+			android:layout_height="wrap_content">
+			<TextView android:layout_width="fill_parent"
+				android:layout_height="wrap_content" android:paddingLeft="20sp"
+				android:singleLine="true" android:maxLines="1" android:textSize="30px"
+				android:text="@string/userinfo_label_vcard" />
+			<TextView android:layout_width="fill_parent"
+				android:layout_height="wrap_content" android:paddingLeft="20sp"
+				android:singleLine="true" android:text="@string/userinfo_def_vcard" />
+		</LinearLayout>
+		<View android:layout_height="1px" android:layout_width="fill_parent"
+			android:background="#FFFFFF" />
+		<LinearLayout android:id="@+id/userinfo_layout_chg_group"
+			android:orientation="vertical" android:layout_width="fill_parent"
+			android:layout_height="wrap_content">
+			<TextView android:layout_width="fill_parent"
+				android:layout_height="wrap_content" android:paddingLeft="20sp"
+				android:singleLine="true" android:maxLines="1" android:textSize="30px"
+				android:text="@string/userinfo_label_chg_group" />
+			<Gallery android:id="@+id/userinfo_groups"
+				android:layout_width="fill_parent" android:layout_height="wrap_content"
+				android:spacing="10px" />
+		</LinearLayout>
+		<View android:layout_height="1px" android:layout_width="fill_parent"
+			android:background="#FFFFFF" />
+	</LinearLayout>
+</ScrollView>
\ No newline at end of file
--- a/res/values-en/strings.xml	Thu Oct 01 15:48:06 2009 +0200
+++ b/res/values-en/strings.xml	Thu Oct 01 16:50:12 2009 +0200
@@ -38,7 +38,7 @@
 	<string name="CDCall">Call</string>
 	<string name="CDAlias">Alias</string>
 	<string name="CDResend">Resend suscription</string>
-	<string name="CDInfos">User infos</string>
+	<string name="CDInfos">Manage User</string>
 	<string name="CDBlock">Block user</string>
 	<string name="CDDelete">Delete user</string>
 	<string name="CDSure2Delete">Are you sure you want to delete this contact?
@@ -220,9 +220,10 @@
 	 -->
 	 <string name="userinfo_label_alias">Alias</string>
 	 <string name="userinfo_label_vcard">VCard</string>
-	 <string name="userinfo_label_chg_group">Modifier groupe</string>
-	 <string name="userinfo_label_re_suscription">Renvoyer souscription</string>
-	 <string name="userinfo_label_block">Bloquer</string>
-	 <string name="userinfo_label_delete">Supprimer</string>
+	 <string name="userinfo_label_chg_group">Manage groups</string>
+	 <string name="userinfo_label_re_suscription">Resend suscription</string>
+	 <string name="userinfo_label_block">Block</string>
+	 <string name="userinfo_label_delete">Delete</string>
+	 <string name="userinfo_def_vcard">User informations</string>
 
 </resources>
--- a/res/values-fr/strings.xml	Thu Oct 01 15:48:06 2009 +0200
+++ b/res/values-fr/strings.xml	Thu Oct 01 16:50:12 2009 +0200
@@ -35,7 +35,7 @@
 	<!--  ContactDialog class -->
 	<string name="CDChat">Chat</string>
 	<string name="CDCall">Appeller</string>
-	<string name="CDInfos">Informations utilisateur</string>
+	<string name="CDInfos">Gestion utilisateur</string>
 	<string name="CDSure2Delete">Êtes-vous sûr de vouloir supprimer ce contact ?</string>
 	<string name="CDSure2DeleteYes">Oui</string>
 	<string name="CDSure2DeleteNo">Non</string>
@@ -216,4 +216,5 @@
 	 <string name="userinfo_label_re_suscription">Renvoyer souscription</string>
 	 <string name="userinfo_label_block">Bloquer</string>
 	 <string name="userinfo_label_delete">Supprimer</string>
+	 <string name="userinfo_def_vcard">Informations utilisateur</string>
 </resources>
--- a/src/com/beem/project/beem/ui/ContactList.java	Thu Oct 01 15:48:06 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Thu Oct 01 16:50:12 2009 +0200
@@ -235,7 +235,7 @@
      * buildBanner.
      */
     private void buildBanner() {
-	Gallery g = (Gallery) findViewById(R.id.gallery);
+	Gallery g = (Gallery) findViewById(R.id.contactlist_banner);
 	g.setOnItemClickListener(new OnItemClickGroupName());
 	g.setAdapter(mAdapterBanner);
     }
@@ -288,7 +288,7 @@
     }
 
     /**
-     * Event on middle groupe name.
+     * Event simple click on middle groupe name.
      */
     private class OnItemClickGroupName implements OnItemClickListener {
 
--- a/src/com/beem/project/beem/ui/UserInfo.java	Thu Oct 01 15:48:06 2009 +0200
+++ b/src/com/beem/project/beem/ui/UserInfo.java	Thu Oct 01 16:50:12 2009 +0200
@@ -1,18 +1,23 @@
 package com.beem.project.beem.ui;
 
+import java.util.List;
+
 import android.app.Activity;
 import android.app.Dialog;
 import android.content.ComponentName;
+import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.ServiceConnection;
-import android.net.Uri;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.os.RemoteException;
 import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
 import android.widget.Button;
 import android.widget.EditText;
+import android.widget.Gallery;
 import android.widget.TextView;
 
 import com.beem.project.beem.BeemService;
@@ -30,7 +35,8 @@
 
     private static final Intent SERVICE_INTENT = new Intent();
     private final ServiceConnection mServConn = new BeemServiceConnection();
-    private String mJID;
+    private TextView mTextAlias;
+    private Gallery mGalleryGroups;
     private Contact mContact;
     private IXmppFacade mXmppFacade;
     private BeemBroadcastReceiver mReceiver;
@@ -54,7 +60,8 @@
 	setContentView(R.layout.userinfo);
 	View v = (View) findViewById(R.id.userinfo_layout_alias);
 	v.setOnClickListener(new AliasListener());
-
+	mTextAlias = (TextView) findViewById(R.id.userinfo_alias);
+	mGalleryGroups = (Gallery) findViewById(R.id.userinfo_groups);
 	mReceiver = new BeemBroadcastReceiver(mServConn);
     }
 
@@ -80,11 +87,18 @@
 	    unbindService(mServConn);
     }
 
-    class AliasListener implements View.OnClickListener {
+    /**
+     * Event simple click on layout alias.
+     */
+    private class AliasListener implements View.OnClickListener {
+	/**
+	 * Constructor.
+	 */
+	public AliasListener() {
+	}
 
 	@Override
 	public void onClick(View v) {
-
 	    Dialog d = new ContactDialogAliasDialog();
 	    d.show();
 	}
@@ -93,6 +107,9 @@
 
     public class ContactDialogAliasDialog extends Dialog {
 
+	/**
+	 * Constructor.
+	 */
 	public ContactDialogAliasDialog() {
 	    super(UserInfo.this);
 	    setContentView(R.layout.contactdialogaliasdialog);
@@ -102,31 +119,84 @@
 		nameText.setText(mContact.getJID());
 	    else
 		nameText.setText(mContact.getName());
+	    Button ok = (Button) findViewById(R.id.CDAliasDialogOk);
+	    ok.setOnClickListener(new ContactDialogAliasDialogOK());
+	}
 
-	    Button ok = (Button) findViewById(R.id.CDAliasDialogOk);
-	    ok.setOnClickListener(new View.OnClickListener() {
+	private class ContactDialogAliasDialogOK implements View.OnClickListener {
+
+	    @Override
+	    public void onClick(View v) {
+		IRoster r;
+		try {
+		    r = mXmppFacade.getRoster();
+		    if (r != null) {
+			EditText nameText = (EditText) findViewById(R.id.CDAliasDialogName);
+			String name = nameText.getText().toString();
+			if (name.length() == 0)
+			    name = mContact.getJID();
+			r.setContactName(mContact.getJID(), name);
+			mContact.setName(name);
+			mTextAlias.setText(name);
+		    }
+		} catch (RemoteException e) {
+		    e.printStackTrace();
+		}
+		dismiss();
+	    }
+	}
+    }
+
+    /**
+     * Adapter group horizontal list.
+     */
+    public class BeemGroups extends BaseAdapter {
+	private Context mContext;
+	private List<String> mListGroup;
 
-		@Override
-		public void onClick(View v) {
-		    IRoster r;
-		    try {
-			r = mXmppFacade.getRoster();
-			if (r != null) {
-			    EditText nameText = (EditText) findViewById(R.id.CDAliasDialogName);
-			    String name = nameText.getText().toString();
-			    if (name.length() == 0)
-				name = mContact.getJID();
-			    r.setContactName(mContact.getJID(), name);
-			    mContact.setName(name);
+	/**
+	 * Constructor.
+	 * @param c context activity.
+	 */
+	public BeemGroups(final Context c, List<String> listGroup) {
+	    mContext = c;
+	    if (listGroup.size() == 0)
+		listGroup.add("No Group");
+	    mListGroup = listGroup;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public int getCount() {
+	    return mListGroup.size();
+	}
 
-			}
-		    } catch (RemoteException e) {
-			e.printStackTrace();
-		    }
-		    dismiss();
-		}
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public Object getItem(int position) {
+	    return position;
+	}
 
-	    });
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public long getItemId(int position) {
+	    return position;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public View getView(int position, View convertView, ViewGroup parent) {
+	    TextView textView = new TextView(mContext);
+	    textView.setText(mListGroup.get(position));
+	    return textView;
 	}
 
     }
@@ -142,6 +212,9 @@
 	public BeemServiceConnection() {
 	}
 
+	/**
+	 * {@inheritDoc}
+	 */
 	@Override
 	public void onServiceConnected(ComponentName name, IBinder service) {
 	    mXmppFacade = IXmppFacade.Stub.asInterface(service);
@@ -149,14 +222,19 @@
 		IRoster r = mXmppFacade.getRoster();
 		if (r != null) {
 		    String jidByUri = getIntent().getData().getEncodedSchemeSpecificPart();
+		    setTitle(jidByUri);
 		    mContact = r.getContact(jidByUri);
-		    setTitle(mContact.getJID());
+		    mTextAlias.setText(mContact.getName());
+		    mGalleryGroups.setAdapter(new BeemGroups(UserInfo.this, mContact.getGroups()));
 		}
 	    } catch (RemoteException e) {
 		e.printStackTrace();
 	    }
 	}
 
+	/**
+	 * {@inheritDoc}
+	 */
 	@Override
 	public void onServiceDisconnected(ComponentName name) {
 	    mXmppFacade = null;