merge
authorNikita Kozlov <nikita@beem-project.com>
Thu, 01 Oct 2009 18:20:15 +0200
changeset 431 7c0dcffaf20a
parent 430 ebadf7ab35ee (current diff)
parent 427 ac5021ad2ac1 (diff)
child 432 d8e79c0014f1
merge
res/layout/userinfo_alias.xml
src/com/beem/project/beem/ui/ContactDialog.java
src/com/beem/project/beem/ui/ContactDialogAliasDialog.java
src/com/beem/project/beem/ui/UserInfo.java
--- a/res/layout/contactdialog.xml	Thu Oct 01 18:03:32 2009 +0200
+++ b/res/layout/contactdialog.xml	Thu Oct 01 18:20:15 2009 +0200
@@ -9,19 +9,7 @@
 	<Button android:id="@+id/CDCall" android:layout_width="fill_parent"
 		android:layout_height="wrap_content" android:text="@string/CDCall" />
 
-	<Button android:id="@+id/CDAlias" android:layout_width="fill_parent"
-		android:layout_height="wrap_content" android:text="@string/CDAlias" />
-
-	<Button android:id="@+id/CDDelete" android:layout_width="fill_parent"
-		android:layout_height="wrap_content" android:text="@string/CDDelete" />
-
-	<Button android:id="@+id/CDResend" android:layout_width="fill_parent"
-		android:layout_height="wrap_content" android:text="@string/CDResend" />
-
 	<Button android:id="@+id/CDInfos" android:layout_width="fill_parent"
 		android:layout_height="wrap_content" android:text="@string/CDInfos" />
 
-	<Button android:id="@+id/CDBlock" android:layout_width="fill_parent"
-		android:layout_height="wrap_content" android:text="@string/CDBlock" />
-
 </LinearLayout>
\ No newline at end of file
--- a/res/layout/contactlist.xml	Thu Oct 01 18:03:32 2009 +0200
+++ b/res/layout/contactlist.xml	Thu Oct 01 18:20:15 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 18:03:32 2009 +0200
+++ b/res/layout/userinfo.xml	Thu Oct 01 18:20:15 2009 +0200
@@ -1,7 +1,75 @@
 <?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="70px">
+			<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="70px">
+			<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="70px">
+			<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 android:id="@+id/userinfo_layout_re_suscription"
+			android:orientation="vertical" android:layout_width="fill_parent"
+			android:layout_height="70px">
+			<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_re_suscription" />
+		</LinearLayout>
+		<View android:layout_height="1px" android:layout_width="fill_parent"
+			android:background="#FFFFFF" />
+		<LinearLayout android:id="@+id/userinfo_layout_block"
+			android:orientation="vertical" android:layout_width="fill_parent"
+			android:layout_height="70px">
+			<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_block" />
+		</LinearLayout>
+		<View android:layout_height="1px" android:layout_width="fill_parent"
+			android:background="#FFFFFF" />
+		<LinearLayout android:id="@+id/userinfo_layout_delete"
+			android:orientation="vertical" android:layout_width="fill_parent"
+			android:layout_height="70px">
+			<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_delete" />
+		</LinearLayout>
+	</LinearLayout>
+</ScrollView>
\ No newline at end of file
--- a/res/layout/userinfo_alias.xml	Thu Oct 01 18:03:32 2009 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-	android:orientation="vertical" android:layout_width="fill_parent"
-	android:layout_height="wrap_content">
-	<TextView android:id="@+id/userinfo_alias_label"
-		android:layout_width="fill_parent" android:layout_height="wrap_content"
-		android:paddingLeft="20sp" android:singleLine="true" android:maxLines="1"
-		android:textSize="30px" android:text="Alias" />
-	<TextView android:id="@+id/userinfo_alias_def"
-		android:layout_width="fill_parent" android:layout_height="wrap_content"
-		android:paddingLeft="20sp" android:singleLine="true"
-		android:text="Modifier le nom affiche de votre contact" />
-</LinearLayout>
\ No newline at end of file
--- a/res/values-en/strings.xml	Thu Oct 01 18:03:32 2009 +0200
+++ b/res/values-en/strings.xml	Thu Oct 01 18:20:15 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?
@@ -214,5 +214,17 @@
 	 <string name="contact_list_menu_settings">Settings</string>
 	 <string name="contact_list_all_contact">All contacts</string>
 	 <string name="contact_list_no_group">No group</string>
+	 
+	 <!-- 
+		UserInfo Activity
+	 -->
+	 <string name="userinfo_label_alias">Alias</string>
+	 <string name="userinfo_label_vcard">VCard</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>
+	 <string name="userinfo_resend">Suscription resend</string>
 
 </resources>
--- a/res/values-fr/strings.xml	Thu Oct 01 18:03:32 2009 +0200
+++ b/res/values-fr/strings.xml	Thu Oct 01 18:20:15 2009 +0200
@@ -34,12 +34,8 @@
 
 	<!--  ContactDialog class -->
 	<string name="CDChat">Chat</string>
-	<string name="CDAlias">Alias</string>
 	<string name="CDCall">Appeller</string>
-	<string name="CDResend">Réenvoyer la demande</string>
-	<string name="CDInfos">Informations utilisateur</string>
-	<string name="CDBlock">Bloquer l\'utilisateur</string>
-	<string name="CDDelete">Supprimer l\'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>
@@ -211,4 +207,15 @@
 	 <string name="contact_list_all_contact">Tous les contacts</string>
 	 <string name="contact_list_no_group">Aucun groupe</string>
 
+	<!-- 
+		UserInfo Activity
+	 -->
+	 <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_def_vcard">Informations utilisateur</string>
+	 <string name="userinfo_resend">Souscription réenvoyée</string>
 </resources>
--- a/src/com/beem/project/beem/service/RosterAdapter.java	Thu Oct 01 18:03:32 2009 +0200
+++ b/src/com/beem/project/beem/service/RosterAdapter.java	Thu Oct 01 18:20:15 2009 +0200
@@ -3,7 +3,6 @@
  */
 package com.beem.project.beem.service;
 
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -85,15 +84,10 @@
      * {@inheritDoc}
      */
     @Override
-    public void deleteContact(Contact contact, String group) throws RemoteException {
+    public void deleteContact(Contact contact) throws RemoteException {
 	try {
 	    RosterEntry entry = mAdaptee.getEntry(contact.getJID());
-	    if (entry.getGroups().size() == 0) {
-		mAdaptee.removeEntry(entry);
-	    } else {
-		mAdaptee.getGroup(group).removeEntry(entry);
-		mRosterListener.onEntryDeleteFromGroup(group, contact.getJID());
-	    }
+	    mAdaptee.removeEntry(entry);
 	} catch (XMPPException e) {
 	    e.printStackTrace();
 	}
@@ -107,7 +101,7 @@
 	try {
 	    mAdaptee.createGroup(groupname);
 	} catch (IllegalArgumentException e) {
-	    //pas grave, plus simple a gerer comme ca.
+	    // pas grave, plus simple a gerer comme ca.
 	    Log.e(TAG, "Error while creating group", e);
 	}
     }
@@ -201,7 +195,7 @@
 	 * @param jid the jid of the entry which is deleted.
 	 */
 	public void onEntryDeleteFromGroup(String group, String jid) {
-	    //Log.i(TAG, "entry delete listener");
+	    // Log.i(TAG, "entry delete listener");
 	    final int n = mRemoteRosListeners.beginBroadcast();
 	    for (int i = 0; i < n; i++) {
 		IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
@@ -220,7 +214,7 @@
 	 */
 	@Override
 	public void entriesAdded(Collection<String> addresses) {
-	    //Log.i(TAG, "Ajout de l'entry " + addresses.size() + " " + addresses.toArray()[0]);
+	    // Log.i(TAG, "Ajout de l'entry " + addresses.size() + " " + addresses.toArray()[0]);
 	    final int n = mRemoteRosListeners.beginBroadcast();
 
 	    List<String> tab = new ArrayList<String>();
@@ -241,7 +235,7 @@
 	 */
 	@Override
 	public void entriesDeleted(Collection<String> addresses) {
-	    //Log.i(TAG, "Suppression de l'entry");
+	    // Log.i(TAG, "Suppression de l'entry");
 	    final int n = mRemoteRosListeners.beginBroadcast();
 
 	    List<String> tab = new ArrayList<String>();
@@ -262,7 +256,7 @@
 	 */
 	@Override
 	public void entriesUpdated(Collection<String> addresses) {
-	    //Log.i(TAG, "Update de l'entry " + addresses.size() + " " + addresses.toArray()[0]);
+	    // Log.i(TAG, "Update de l'entry " + addresses.size() + " " + addresses.toArray()[0]);
 	    final int n = mRemoteRosListeners.beginBroadcast();
 
 	    List<String> tab = new ArrayList<String>();
@@ -283,7 +277,7 @@
 	 */
 	@Override
 	public void presenceChanged(Presence presence) {
-	    //Log.i(TAG, "presence Changed");
+	    // Log.i(TAG, "presence Changed");
 	    /* redispatch vers les IBeemRosterListener */
 	    final int n = mRemoteRosListeners.beginBroadcast();
 
--- a/src/com/beem/project/beem/service/aidl/IRoster.aidl	Thu Oct 01 18:03:32 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IRoster.aidl	Thu Oct 01 18:20:15 2009 +0200
@@ -8,7 +8,7 @@
     
     Contact addContact(in String user, in String name, in String[] groups);
     
-    void deleteContact(in Contact contact, in String group);
+    void deleteContact(in Contact contact);
     
     Contact getContact(in String jid);
     void setContactName(in String jid, in String name);
--- a/src/com/beem/project/beem/ui/AddContact.java	Thu Oct 01 18:03:32 2009 +0200
+++ b/src/com/beem/project/beem/ui/AddContact.java	Thu Oct 01 18:20:15 2009 +0200
@@ -23,6 +23,7 @@
 import com.beem.project.beem.R;
 import com.beem.project.beem.service.aidl.IXmppFacade;
 import com.beem.project.beem.utils.BeemBroadcastReceiver;
+
 /**
  * This activity is used to add a contact.
  * @author nikita
@@ -43,7 +44,8 @@
     /**
      * Constructor.
      */
-    public AddContact() { }
+    public AddContact() {
+    }
 
     /**
      * {@inheritDoc}
@@ -87,7 +89,8 @@
 	/**
 	 * Constructor.
 	 */
-	public BeemServiceConnection() { }
+	public BeemServiceConnection() {
+	}
 
 	@Override
 	public void onServiceConnected(ComponentName name, IBinder service) {
@@ -123,7 +126,7 @@
 	    boolean isEmail = Pattern.matches("[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,4}", login);
 	    if (!isEmail) {
 		Toast.makeText(AddContact.this, getString(R.string.AddCContactAddedLoginError), Toast.LENGTH_SHORT)
-		.show();
+		    .show();
 		return;
 	    }
 	    String alias;
@@ -134,14 +137,13 @@
 		if (mXmppFacade != null) {
 		    if (mXmppFacade.getRoster().getContact(login) != null)
 			mGroup.addAll(mXmppFacade.getRoster().getContact(login).getGroups());
-		    if (mXmppFacade.getRoster().addContact(login, alias,
-			mGroup.toArray(new String[mGroup.size()])) == null) {
+		    if (mXmppFacade.getRoster().addContact(login, alias, mGroup.toArray(new String[mGroup.size()])) == null) {
 			Toast.makeText(AddContact.this, getString(R.string.AddCContactAddedError), Toast.LENGTH_SHORT)
-			.show();
+			    .show();
 			return;
 		    } else {
 			Toast.makeText(AddContact.this, getString(R.string.AddCContactAdded), Toast.LENGTH_SHORT)
-			.show();
+			    .show();
 			finish();
 		    }
 		}
--- a/src/com/beem/project/beem/ui/ContactDialog.java	Thu Oct 01 18:03:32 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactDialog.java	Thu Oct 01 18:20:15 2009 +0200
@@ -1,58 +1,50 @@
 package com.beem.project.beem.ui;
 
-import org.jivesoftware.smack.packet.Presence;
-
 import android.app.Activity;
-import android.app.AlertDialog;
 import android.app.Dialog;
 import android.app.Service;
 import android.content.ComponentName;
 import android.content.Context;
-import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.ServiceConnection;
 import android.os.IBinder;
 import android.os.RemoteException;
-import android.util.Log;
 import android.view.View;
 import android.widget.Button;
 
 import com.beem.project.beem.BeemService;
 import com.beem.project.beem.R;
 import com.beem.project.beem.service.Contact;
-import com.beem.project.beem.service.PresenceAdapter;
 import com.beem.project.beem.service.aidl.IXmppFacade;
 
+/**
+ * This activity class provides the view to show dialog when long click on contact list.
+ * @author marseille
+ */
 public class ContactDialog extends Dialog {
 
-    public static final String TAG = "Option Dialog";
     private final Contact mContact;
-    private final String mGroup;
     private final Context mContext;
-    private IXmppFacade mXmppFacade = null;
+    private IXmppFacade mXmppFacade;
     private final ServiceConnection mServConn = new BeemServiceConnection();
 
-    public ContactDialog(final Context context, Contact curContact, String group) {
+    /**
+     * Constructor.
+     * @param context context where is call the dialog.
+     * @param curContact current contact.
+     */
+    public ContactDialog(final Context context, final Contact curContact) {
 	super(context);
 	mContext = context;
 
 	setContentView(R.layout.contactdialog);
 	mContact = curContact;
-	mGroup = group;
 	setTitle(curContact.getJID());
 
 	Button button = (Button) findViewById(R.id.CDChat);
-	button.setOnClickListener(new chatListener());
-	button = (Button) findViewById(R.id.CDAlias);
-	button.setOnClickListener(new aliasListener());
-	button = (Button) findViewById(R.id.CDDelete);
-	button.setOnClickListener(new deleteListener());
-	button = (Button) findViewById(R.id.CDResend);
-	button.setOnClickListener(new resendListener());
-	button = (Button) findViewById(R.id.CDBlock);
-	button.setOnClickListener(new blockListener());
+	button.setOnClickListener(new ChatListener());
 	button = (Button) findViewById(R.id.CDInfos);
-	button.setOnClickListener(new infosListener());
+	button.setOnClickListener(new InfosListener());
 	button = (Button) findViewById(R.id.CDCall);
 	button.setOnClickListener(new CallListener());
 
@@ -65,49 +57,38 @@
 	mContext.unbindService(mServConn);
     }
 
+    /**
+     * Event simple click on call button.
+     */
     class CallListener implements View.OnClickListener {
 
+	/**
+	 * Constructor.
+	 */
+	public CallListener() {
+	}
+
 	@Override
 	public void onClick(View v) {
 	    try {
-		//TODO: permettre a l'user de choisir a quel ressource il veut faire le call.
+		//TODO permettre a l'user de choisir a quel ressource il veut faire le call.
 		mXmppFacade.call(mContact.getJID() + "/BEEM");
 	    } catch (RemoteException e) {
-		// TODO Auto-generated catch block
-		e.printStackTrace();
-	    }
-	    
-	}
-	
-    }
-    
-    class aliasListener implements View.OnClickListener {
-
-	@Override
-	public void onClick(View v) {
-
-	    ContactDialogAliasDialog dialog = new ContactDialogAliasDialog(mContext, mContact);
-	    dialog.setOwnerActivity(ContactDialog.this.getOwnerActivity());
-	    dialog.initService(mXmppFacade);
-	    dialog.show();
-	}
-
-    }
-
-    class blockListener implements View.OnClickListener {
-
-	@Override
-	public void onClick(View v) {
-	    try {
-		mXmppFacade.blockUser(mContact.getJID());
-	    } catch (RemoteException e) {
 		e.printStackTrace();
 	    }
-	    dismiss();
-	}	
+	}
     }
 
-    class chatListener implements View.OnClickListener {
+    /**
+     * Event simple click on chat button.
+     */
+    class ChatListener implements View.OnClickListener {
+
+	/**
+	 * Constructor.
+	 */
+	public ChatListener() {
+	}
 
 	@Override
 	public void onClick(View v) {
@@ -120,64 +101,39 @@
 
     }
 
-    class deleteListener implements View.OnClickListener {
+    /**
+     * Event simple click on info button.
+     */
+    class InfosListener implements View.OnClickListener {
 
-	@Override
-	public void onClick(View v) {
-	    final Activity a = ContactDialog.this.getOwnerActivity();
-	    AlertDialog.Builder builder = new AlertDialog.Builder(a);
-	    builder.setMessage(a.getString(R.string.CDDelete)).setCancelable(false).setPositiveButton(
-		a.getString(R.string.CDSure2DeleteYes), new DialogInterface.OnClickListener() {
-		    public void onClick(DialogInterface dialog, int id) {
-			try {
-			    mXmppFacade.getRoster().deleteContact(mContact, mGroup);
-			} catch (RemoteException e) {
-			    e.printStackTrace();
-			}
-			dismiss();
-		    }
-		}).setNegativeButton(a.getString(R.string.CDSure2DeleteNo), new DialogInterface.OnClickListener() {
-		    public void onClick(DialogInterface dialog, int id) {
-			dialog.cancel();
-		    }
-		});
-	    AlertDialog alert = builder.create();
-	    alert.show();
+	/**
+	 * Constructor.
+	 */
+	public InfosListener() {
 	}
-    }
-
-    class infosListener implements View.OnClickListener {
 
 	@Override
 	public void onClick(View v) {
 	    Activity a = ContactDialog.this.getOwnerActivity();
-	    Intent i = new Intent(mContext, GroupList.class);
-	    //i.setData(mContact.toUri());
-	    i.putExtra("JID", mContact.getJID());
+	    Intent i = new Intent(mContext, UserInfo.class);
+	    i.setData(mContact.toUri());
 	    a.startActivity(i);
 	    dismiss();
 	}
 
     }
 
-    class resendListener implements View.OnClickListener {
+    /**
+     * The service connection used to connect to the Beem service.
+     */
+    private class BeemServiceConnection implements ServiceConnection {
 
-	@Override
-	public void onClick(View v) {
-	    Presence presencePacket = new Presence(Presence.Type.subscribe);
-	    presencePacket.setTo(mContact.getJID());
-	    try {
-		mXmppFacade.sendPresencePacket(new PresenceAdapter(presencePacket));
-	    } catch (RemoteException e) {
-		Log.e(TAG, "resend subscription error", e);
-	    }
-	    dismiss();
+	/**
+	 * Constructor.
+	 */
+	public BeemServiceConnection() {
 	}