# HG changeset patch # User Vincent Veronis # Date 1253197998 -7200 # Node ID c7ee14b65f39e2fae38b8b88787401d08749007b # Parent 411222f0f758778ed0243896beddc327b8cb6a01 Gestion du changement de group. diff -r 411222f0f758 -r c7ee14b65f39 checkstyle.xml --- a/checkstyle.xml Wed Sep 16 22:45:41 2009 +0200 +++ b/checkstyle.xml Thu Sep 17 16:33:18 2009 +0200 @@ -1,264 +1,264 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 411222f0f758 -r c7ee14b65f39 res/layout/addcontact.xml diff -r 411222f0f758 -r c7ee14b65f39 res/layout/contactlist.xml --- a/res/layout/contactlist.xml Wed Sep 16 22:45:41 2009 +0200 +++ b/res/layout/contactlist.xml Thu Sep 17 16:33:18 2009 +0200 @@ -1,29 +1,29 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff -r 411222f0f758 -r c7ee14b65f39 res/values diff -r 411222f0f758 -r c7ee14b65f39 res/values-en/strings.xml --- a/res/values-en/strings.xml Wed Sep 16 22:45:41 2009 +0200 +++ b/res/values-en/strings.xml Thu Sep 17 16:33:18 2009 +0200 @@ -206,5 +206,6 @@ --> Add a contact Settings + All contacts diff -r 411222f0f758 -r c7ee14b65f39 res/values-fr/strings.xml --- a/res/values-fr/strings.xml Wed Sep 16 22:45:41 2009 +0200 +++ b/res/values-fr/strings.xml Thu Sep 17 16:33:18 2009 +0200 @@ -200,5 +200,6 @@ --> Ajouter un contact Paramètres + Tous les contacts diff -r 411222f0f758 -r c7ee14b65f39 src/com/beem/project/beem/service/RosterAdapter.java --- a/src/com/beem/project/beem/service/RosterAdapter.java Wed Sep 16 22:45:41 2009 +0200 +++ b/src/com/beem/project/beem/service/RosterAdapter.java Thu Sep 17 16:33:18 2009 +0200 @@ -90,7 +90,6 @@ mAdaptee.removeEntry(entry); } else { mAdaptee.getGroup(group).removeEntry(entry); - mRosterListener.onEntryDeleteFromGroup(group, contact.getJID()); } } catch (XMPPException e) { e.printStackTrace(); @@ -197,7 +196,7 @@ * Event which is fired when an entry is deleted for a group. * @param group the group the entry was. * @param jid the jid of the entry which is deleted. - */ + * / public void onEntryDeleteFromGroup(String group, String jid) { //Log.i(TAG, "entry delete listener"); final int n = mRemoteRosListeners.beginBroadcast(); @@ -211,7 +210,7 @@ } mRemoteRosListeners.finishBroadcast(); - } + } */ /** * {@inheritDoc} diff -r 411222f0f758 -r c7ee14b65f39 src/com/beem/project/beem/service/aidl/IBeemRosterListener.aidl --- a/src/com/beem/project/beem/service/aidl/IBeemRosterListener.aidl Wed Sep 16 22:45:41 2009 +0200 +++ b/src/com/beem/project/beem/service/aidl/IBeemRosterListener.aidl Thu Sep 17 16:33:18 2009 +0200 @@ -7,5 +7,4 @@ void onEntriesUpdated(in List addresses); void onEntriesDeleted(in List addresses); void onPresenceChanged(in PresenceAdapter presence); - void onEntryDeleteFromGroup(in String group, in String jid); } \ No newline at end of file diff -r 411222f0f758 -r c7ee14b65f39 src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Wed Sep 16 22:45:41 2009 +0200 +++ b/src/com/beem/project/beem/ui/ContactList.java Thu Sep 17 16:33:18 2009 +0200 @@ -25,6 +25,7 @@ import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.BaseAdapter; +import android.widget.Button; import android.widget.ImageView; import android.widget.ListView; import android.widget.TextView; @@ -50,7 +51,9 @@ private static final int REQUEST_CODE = 1; private BeemContactList mAdapter; private IRoster mRoster; - private List mListContact; + private List mListContact = null; + private List mListGroup; + private int mPosCurGroup = -1; private Handler mHandler; private IXmppFacade mXmppFacade; private final ServiceConnection mServConn = new BeemServiceConnection(); @@ -103,8 +106,63 @@ protected void onCreate(Bundle saveBundle) { super.onCreate(saveBundle); setContentView(R.layout.contactlist); + mAdapter = new BeemContactList(this); + Button b = (Button) findViewById(R.id.contactlist_group); + b.setOnClickListener(new OnClickGroupName()); + b = (Button) findViewById(R.id.contactlist_left); + b.setOnClickListener(new OnClickLeft()); + b = (Button) findViewById(R.id.contactlist_right); + b.setOnClickListener(new OnClickRight()); + mHandler = new Handler(); - mHandler = new Handler(); + } + + private class OnClickGroupName implements View.OnClickListener { + @Override + public void onClick(View arg0) { + + } + } + + private class OnClickLeft implements View.OnClickListener { + @Override + public void onClick(View arg0) { + mPosCurGroup--; + if (mPosCurGroup < -1) + mPosCurGroup = mListGroup.size() - 1; + Button b = (Button) findViewById(R.id.contactlist_group); + if (mPosCurGroup == -1) + b.setText(R.string.contact_list_all_contact); + else + b.setText(mListGroup.get(mPosCurGroup)); + try { + buildContactList(mRoster.getContactList(), mRoster.getGroupsNames()); + } catch (RemoteException e) { + e.printStackTrace(); + } + mAdapter.notifyDataSetChanged(); + mAdapter.notifyDataSetChanged(); + } + } + + private class OnClickRight implements View.OnClickListener { + @Override + public void onClick(View arg0) { + mPosCurGroup++; + if (mPosCurGroup == mListGroup.size()) + mPosCurGroup = -1; + Button b = (Button) findViewById(R.id.contactlist_group); + if (mPosCurGroup == -1) + b.setText(R.string.contact_list_all_contact); + else + b.setText(mListGroup.get(mPosCurGroup)); + try { + buildContactList(mRoster.getContactList(), mRoster.getGroupsNames()); + } catch (RemoteException e) { + e.printStackTrace(); + } + mAdapter.notifyDataSetChanged(); + } } @Override @@ -139,10 +197,30 @@ } } - private void buildContactList(List listContact) { - mListContact = listContact; - Collections.sort(mListContact, new ComparatorContactListByStatusAndName()); - mAdapter = new BeemContactList(this); + class ComparatorString implements Comparator { + @Override + public int compare(String g1, String g2) { + return (g1.compareToIgnoreCase(g2)); + } + } + + private void buildContactList(List listContact, List listGroup) { + mListGroup = listGroup; + Collections.sort(mListGroup);// , new ComparatorString()); + if (mListContact != null) + mListContact.clear(); + if (mPosCurGroup == -1) + mListContact = listContact; + else { + String curGroup = mListGroup.get(mPosCurGroup); + for (Contact c : listContact) { + if (c.getGroups().contains(curGroup)) { + mListContact.add(c); + } + } + } + + BeemContactListSort(); ListView listView = (ListView) findViewById(R.id.contactlist); listView.setOnItemClickListener(new BeemContactListOnClick()); @@ -172,28 +250,38 @@ } } + private void BeemContactListSort() { + Collections.sort(mListContact, new ComparatorContactListByStatusAndName()); + } + private class BeemRosterListener extends IBeemRosterListener.Stub { private class RunnableChange implements Runnable { @Override public void run() { + BeemContactListSort(); mAdapter.notifyDataSetChanged(); } } @Override public void onEntriesAdded(List addresses) throws RemoteException { - /* - * TODO: C'est OK. - */ + for (String newName : addresses) { + Contact c = new Contact(newName); + mListContact.add(c); + } mHandler.post(new RunnableChange()); } @Override public void onEntriesDeleted(List addresses) throws RemoteException { - mListContact.removeAll(addresses); - /* - * TODO: Raffrichir la liste. - */ + for (String cToDelete : addresses) { + for (Contact c : mListContact) { + if (c.getJID().equals(cToDelete)) { + mListContact.remove(c); + break; + } + } + } mHandler.post(new RunnableChange()); } @@ -215,14 +303,6 @@ } } } - - @Override - public void onEntryDeleteFromGroup(String group, String jid) throws RemoteException { - /* - * TODO: - */ - mHandler.post(new RunnableChange()); - } } private class BeemContactList extends BaseAdapter { @@ -255,7 +335,6 @@ Contact c = mListContact.get(position); bindView(convertView, c); - return convertView; } @@ -333,7 +412,7 @@ mRoster = mXmppFacade.getRoster(); if (mRoster != null) { mRoster.addRosterListener(mBeemRosterListener); - buildContactList(mRoster.getContactList()); + buildContactList(mRoster.getContactList(), mRoster.getGroupsNames()); } } catch (RemoteException e) { e.printStackTrace(); diff -r 411222f0f758 -r c7ee14b65f39 src/com/beem/project/beem/ui/Login.java --- a/src/com/beem/project/beem/ui/Login.java Wed Sep 16 22:45:41 2009 +0200 +++ b/src/com/beem/project/beem/ui/Login.java Thu Sep 17 16:33:18 2009 +0200 @@ -102,8 +102,6 @@ if (mIsConfigured) bindService(Login.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE); - else - mButtonLogin.setEnabled(false); } diff -r 411222f0f758 -r c7ee14b65f39 src/com/beem/project/beem/ui/SendIM.java --- a/src/com/beem/project/beem/ui/SendIM.java Wed Sep 16 22:45:41 2009 +0200 +++ b/src/com/beem/project/beem/ui/SendIM.java Thu Sep 17 16:33:18 2009 +0200 @@ -443,12 +443,6 @@ } } - @Override - public void onEntryDeleteFromGroup(String group, String jid) throws RemoteException { - // TODO Auto-generated method stub - - } - } /**