--- a/res/layout/contactdialogaliasdialog.xml Wed Jun 24 19:23:00 2009 +0200
+++ b/res/layout/contactdialogaliasdialog.xml Wed Jun 24 19:24:58 2009 +0200
@@ -4,7 +4,8 @@
android:layout_height="fill_parent">
<EditText android:id="@+id/CDAliasDialogName"
- android:layout_width="fill_parent" android:layout_height="wrap_content" />
+ android:layout_width="fill_parent" android:layout_height="wrap_content"
+ android:singleLine="true" android:maxLines="1" />
<Button android:id="@+id/CDAliasDialogOk" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/OkButton" />
--- a/res/layout/contactlistcontact.xml Wed Jun 24 19:23:00 2009 +0200
+++ b/res/layout/contactlistcontact.xml Wed Jun 24 19:24:58 2009 +0200
@@ -14,10 +14,12 @@
android:layout_height="wrap_content">
<TextView android:id="@+id/contactlistpseudo"
android:layout_width="fill_parent" android:layout_height="wrap_content"
- android:paddingLeft="20sp" />
+ android:paddingLeft="20sp" android:singleLine="true"
+ android:maxLines="1" />
<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 19:23:00 2009 +0200
+++ b/res/values/strings.xml Wed Jun 24 19:24:58 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/service/PrivacyListManagerAdapter.java Wed Jun 24 19:23:00 2009 +0200
+++ b/src/com/beem/project/beem/service/PrivacyListManagerAdapter.java Wed Jun 24 19:24:58 2009 +0200
@@ -11,6 +11,7 @@
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.PrivacyItem;
+import org.jivesoftware.smack.packet.PrivacyItem.PrivacyRule;
import android.os.RemoteException;
import android.util.Log;
@@ -19,57 +20,78 @@
/**
* @author nikita
- *
+ * A finir
*/
public class PrivacyListManagerAdapter extends IPrivacyListManager.Stub {
public static final String TAG = "PrivacyListManagerAdapter";
private PrivacyListManager mAdaptee = null;
private List<String> mBlockedUser = new ArrayList<String>();
private XMPPConnection mConnection;
-
+ private MyPrivacyListListener privacyPacketListener = new MyPrivacyListListener();
+
public PrivacyListManagerAdapter(XMPPConnection connection) {
mConnection = connection;
+ mAdaptee = PrivacyListManager.getInstanceFor(mConnection);
+ mAdaptee.addListener(privacyPacketListener);
}
-
+
public List<String> getBlockedUsers() {
return mBlockedUser;
}
-
- public void addBlockedUser(String jid) {
+
+ public synchronized void addBlockedUser(String jid) {
if (mAdaptee == null) {
- PrivacyListManager.getInstanceFor(mConnection);
- if (mAdaptee == null) {
- Log.e(TAG, "pas bon");
- }
- mAdaptee.addListener(new MyPrivacyListListener());
+ mAdaptee = PrivacyListManager.getInstanceFor(mConnection);
+ mAdaptee.addListener(privacyPacketListener);
}
-
- Log.d(TAG, "addBlockedUser");
- PrivacyItem pItem = new PrivacyItem("jid", false, 0);
- pItem.setValue(jid);
- pItem.setFilterPresence_out(false);
List<PrivacyItem> pItemList = new ArrayList<PrivacyItem>();
+ PrivacyItem pItem = new PrivacyItem("jid", true, 1);
+ pItem.setFilterMessage(true);
+ pItem.setValue(jid);
pItemList.add(pItem);
+
+ pItem = new PrivacyItem("subscription", true, 2);
+ pItem.setValue(PrivacyRule.SUBSCRIPTION_BOTH);
+ pItemList.add(pItem);
+
try {
- mAdaptee.createPrivacyList(jid, pItemList);
+ if (mAdaptee.getPrivacyList("default") == null) {
+
+ }
+
+ } catch (XMPPException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ClassCastException e) {
+ e.printStackTrace();
+ try {
+ mAdaptee.createPrivacyList("default", pItemList);
+ } catch (XMPPException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+ try {
+ mAdaptee.setActiveListName("default");
+ mAdaptee.setDefaultListName("default");
} catch (XMPPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
+
+ Log.d(TAG, "addBlockedUser");
}
-
+
class MyPrivacyListListener implements PrivacyListListener {
@Override
public void setPrivacyList(String listName, List<PrivacyItem> listItem) {
Log.d(TAG,"setPrivacyList");
-
}
@Override
public void updatedPrivacyList(String listName) {
Log.d(TAG,"updatedPrivacyList");
-
}
}
--- a/src/com/beem/project/beem/service/RosterAdapter.java Wed Jun 24 19:23:00 2009 +0200
+++ b/src/com/beem/project/beem/service/RosterAdapter.java Wed Jun 24 19:24:58 2009 +0200
@@ -71,51 +71,31 @@
RosterEntry contact = mAdaptee.getEntry(user);
if (contact != null) {
res = mContacts.get(user);
- if (groups != null) {
- for (String groupStr : groups) {
- boolean found = false;
- for (RosterGroup group : mAdaptee.getGroups()) {
- if (group.getName().equals(groupStr) && !group.contains(contact)) {
- try {
- group.addEntry(contact);
- res.addGroup(groupStr);
- found = true;
- } catch (XMPPException e) {
- Log.e(TAG, "add new contact", e);
- }
- }
- }
- if (!found) {
- try {
- mAdaptee.createGroup(groupStr).addEntry(contact);
- } catch (XMPPException e) {
- e.printStackTrace();
- } catch (IllegalArgumentException e) {
- }
- res.addGroup(groupStr);
- }
- }
- }
} else {
try {
mAdaptee.createEntry(user, name, groups);
+ contact = mAdaptee.getEntry(user);
res = new Contact(user);
mContacts.put(user, res);
- if (groups != null) {
- for (String groupStr : groups) {
- try {
- mAdaptee.createGroup(groupStr);
- } catch (IllegalArgumentException e) {
- // e.printStackTrace();
- }
- res.addGroup(groupStr);
- }
- }
} catch (XMPPException e) {
Log.e(TAG, "Error while adding new contact", e);
return null;
}
}
+ if (groups != null) {
+ for (String groupStr : groups) {
+ RosterGroup group = mAdaptee.getGroup(groupStr);
+ if (group == null) {
+ group = mAdaptee.createGroup(groupStr);
+ }
+ try {
+ group.addEntry(contact);
+ } catch (XMPPException e) {
+ e.printStackTrace();
+ }
+ res.addGroup(groupStr);
+ }
+ }
return res;
}
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Wed Jun 24 19:23:00 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Wed Jun 24 19:24:58 2009 +0200
@@ -72,6 +72,7 @@
public XmppConnectionAdapter(final XMPPConnection con, final String login, final String password,
BeemService service) {
mAdaptee = con;
+ PrivacyListManager.getInstanceFor(mAdaptee);
mLogin = login;
mPassword = password;
mService = service;
@@ -111,11 +112,6 @@
@Override
public boolean connectSync() throws RemoteException {
try {
- try {
- PrivacyListManager.getInstanceFor(mAdaptee);
- } catch (NullPointerException e) {
- Log.e(TAG, "pas normal", e);
- }
mAdaptee.connect();
mAdaptee.addConnectionListener(mConListener);
mAdaptee.login(mLogin, mPassword, "BEEM");
@@ -187,7 +183,7 @@
sdm = new ServiceDiscoveryManager(mAdaptee);
sdm.addFeature("http://jabber.org/protocol/disco#info");
JingleManager.setJingleServiceEnabled();
- // sdm.addFeature("http://jabber.org/protocol/nick");
+ sdm.addFeature("jabber:iq:privacy");
}
/**
--- a/src/com/beem/project/beem/ui/AddContact.java Wed Jun 24 19:23:00 2009 +0200
+++ b/src/com/beem/project/beem/ui/AddContact.java Wed Jun 24 19:24:58 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/ContactDialog.java Wed Jun 24 19:23:00 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactDialog.java Wed Jun 24 19:24:58 2009 +0200
@@ -81,11 +81,11 @@
@Override
public void onClick(View v) {
try {
- xmppFacade.blockUser("beem.test@gmail.com");
+ xmppFacade.blockUser(mContact.getJID());
} catch (RemoteException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
+ dismiss();
}
}
--- a/src/com/beem/project/beem/ui/ContactList.java Wed Jun 24 19:23:00 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Wed Jun 24 19:24:58 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,26 +194,20 @@
@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());
}
- /**
- * TODO: sur la suppression de contact, on passe tt le temps dans entries updated ... probleme comment
- * reconnaitre si on supprime ou ajoute un contact ....
- */
@Override
public void onEntriesUpdated(List<String> addresses) throws RemoteException {
Log.d("CONTACTLIST", "DEBUG - ONENTRIESUPDATED()");
@@ -370,19 +365,18 @@
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
- imgV = (ImageView) view.findViewById(R.id.contactlistavatar);
- if (imgV != null) {
- imageDrawable = getResources().getDrawable(R.drawable.avatar);
- imgV.setImageDrawable(imageDrawable);
- }
+ /*
+ * TODO: Rajouter l'avatar du contact getAvatar() dans la classe imgV = (ImageView)
+ * view.findViewById(R.id.contactlistavatar); if (imgV != null) { imageDrawable =
+ * getResources().getDrawable(R.drawable.avatar); imgV.setImageDrawable(imageDrawable); }
+ */
}
}
public void changed() {
+ Collections.sort(groupName);
for (String name : groupName) {
Collections.sort(groupMap.get(name), new ComparatorContactListByStatusAndName<Contact>());
}