BeemLike suppression d'entry !!
authorMarseille
Wed, 24 Jun 2009 18:03:32 +0200
changeset 289 a841ea9fba02
parent 288 b4112a39526c
child 292 1ba29ab8e122
child 293 597ee98a6477
BeemLike suppression d'entry !! Correction bug contactlist quand msg status hyper long.
res/layout/contactlistcontact.xml
res/values/strings.xml
src/com/beem/project/beem/ui/AddContact.java
src/com/beem/project/beem/ui/ContactList.java
--- a/res/layout/contactlistcontact.xml	Wed Jun 24 13:04:52 2009 +0200
+++ b/res/layout/contactlistcontact.xml	Wed Jun 24 18:03:32 2009 +0200
@@ -17,7 +17,8 @@
 			android:paddingLeft="20sp" />
 		<TextView android:id="@+id/contactlistmsgperso"
 			android:layout_width="fill_parent" android:layout_height="wrap_content"
-			android:paddingLeft="20sp" />
+			android:paddingLeft="20sp" android:singleLine="true"
+			android:maxLines="1" android:autoLink="all" />
 	</LinearLayout>
 
 	<ImageView android:id="@+id/contactlistavatar"
--- a/res/values/strings.xml	Wed Jun 24 13:04:52 2009 +0200
+++ b/res/values/strings.xml	Wed Jun 24 18:03:32 2009 +0200
@@ -81,6 +81,7 @@
 	<string name="AddCOkButton">Ok</string>
 	<string name="AddCContactAdded">Contact added</string>
 	<string name="AddCContactAddedError">Error Contact not added</string>
+	<string name="AddCContactAddedLoginError">Error Login</string>
 	<string name="AddCBadForm">Bad form</string>
 
 	<!--  SendIM class -->
--- a/src/com/beem/project/beem/ui/AddContact.java	Wed Jun 24 13:04:52 2009 +0200
+++ b/src/com/beem/project/beem/ui/AddContact.java	Wed Jun 24 18:03:32 2009 +0200
@@ -5,6 +5,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.regex.Pattern;
 
 import android.app.Activity;
 import android.content.ComponentName;
@@ -74,6 +75,12 @@
 	public void onClick(View v) {
 	    boolean valid = true;
 	    mLogin = getWidgetText(R.id.addc_login);
+	    boolean isEmail = Pattern.matches("[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,4}", mLogin);
+	    if (!isEmail) {
+		Toast.makeText(AddContact.this, getString(R.string.AddCContactAddedLoginError), Toast.LENGTH_SHORT)
+		    .show();
+		return;
+	    }
 	    mAlias = getWidgetText(R.id.addc_alias);
 	    if (mLogin.length() == 0)
 		valid = false;
@@ -84,6 +91,7 @@
 		    if (xmppFacade.getRoster().addContact(mLogin, mAlias, mGroup.toArray(new String[mGroup.size()])) == null) {
 			Toast.makeText(AddContact.this, getString(R.string.AddCContactAddedError), Toast.LENGTH_SHORT)
 			    .show();
+			return;
 		    } else {
 			Toast.makeText(AddContact.this, getString(R.string.AddCContactAdded), Toast.LENGTH_SHORT)
 			    .show();
--- a/src/com/beem/project/beem/ui/ContactList.java	Wed Jun 24 13:04:52 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Wed Jun 24 18:03:32 2009 +0200
@@ -4,6 +4,7 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -193,19 +194,17 @@
 	@Override
 	public void onEntriesDeleted(List<String> addresses) throws RemoteException {
 	    Log.d("CONTACTLIST", "DEBUG - ONENTRIESDELETED() " + addresses.get(0));
-	    for (List<Contact> cList : groupMap.values()) {
-		for (Contact curContact : cList) {
-		    for (String addr : addresses) {
-			if (addr.equals(curContact.getJID())) {
-			    cList.remove(curContact);
-			    if (cList.isEmpty()) {
-				groupMap.values().remove(cList);
-				groupName.remove(DEFAULT_GROUP);
-			    }
-			}
-		    }
+	    for (String user : addresses) {
+		List<Contact> tmpListContact = groupMap.get(DEFAULT_GROUP);
+		for (Contact contact : tmpListContact) {
+		    if (contact.getJID().equals(user))
+			tmpListContact.remove(contact);
 		}
 	    }
+	    if (groupMap.get(DEFAULT_GROUP).isEmpty()) {
+		groupMap.remove(DEFAULT_GROUP);
+		groupName.remove(DEFAULT_GROUP);
+	    }
 	    mHandler.post(new RunnableChange());
 	}
 
@@ -370,7 +369,6 @@
 		v = (TextView) view.findViewById(R.id.contactlistmsgperso);
 		if (v != null) {
 		    v.setText(curContact.getMsgState());
-		    Linkify.addLinks(v, Linkify.WEB_URLS);
 		}
 
 		// TODO: Rajouter l'avatar du contact getAvatar() dans la classe
@@ -383,6 +381,7 @@
 	}
 
 	public void changed() {
+	    Collections.sort(groupName);
 	    for (String name : groupName) {
 		Collections.sort(groupMap.get(name), new ComparatorContactListByStatusAndName<Contact>());
 	    }