# HG changeset patch # User Da Risk # Date 1259369726 -3600 # Node ID f25639696d5c6e1b6778a6c16f88070473560d65 # Parent 97ae7bcc219ab3fcfdb5c5a53fdec94efcb949ff Utilisation de vrai menu pour le longclick sur la contactlist diff -r 97ae7bcc219a -r f25639696d5c .classpath --- a/.classpath Fri Nov 27 22:21:27 2009 +0100 +++ b/.classpath Sat Nov 28 01:55:26 2009 +0100 @@ -1,24 +1,24 @@ - - - + + + - - + + - + - + diff -r 97ae7bcc219a -r f25639696d5c src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Fri Nov 27 22:21:27 2009 +0100 +++ b/src/com/beem/project/beem/ui/ContactList.java Sat Nov 28 01:55:26 2009 +0100 @@ -29,6 +29,7 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.view.ContextMenu; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.Gallery; @@ -131,6 +132,55 @@ } } + /** + * {@inheritDoc} + */ + @Override + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { + super.onCreateContextMenu(menu, v, menuInfo); + // TODO gere les info du context menu pour afficher que pour le bon long click + MenuInflater inflater = getMenuInflater(); + inflater.inflate(R.menu.contactlist_context, menu); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean onContextItemSelected(MenuItem item) { + ContextMenu.ContextMenuInfo i = item.getMenuInfo(); + if (i != null && i instanceof AdapterView.AdapterContextMenuInfo) { + AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) i; + Contact c = mListContact.get(info.position); + Intent in; + if (c != null) { + switch (item.getItemId()) { + case R.id.contact_list_context_menu_chat_item: + in = new Intent(this, Chat.class); + in.setData(c.toUri()); + startActivity(in); + return true; + case R.id.contact_list_context_menu_call_item: + try { + mXmppFacade.call(c.getJID() + "/psi"); + return true; + } catch (RemoteException e) { + e.printStackTrace(); + } + case R.id.contact_list_context_menu_manage_user_item: + in = new Intent(this, UserInfo.class); + //TODO use in.setData(c.toUri()); a la place + in.putExtra("contact_contactdialog", c.getJID()); + startActivity(in); + return true; + default: + return super.onContextItemSelected(item); + } + } + } + return super.onContextItemSelected(item); + } + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); @@ -174,7 +224,7 @@ /** * Comparator Contact by Name. */ - class ComparatorContactListByName implements Comparator { + private class ComparatorContactListByName implements Comparator { /** * Constructor. */ @@ -194,7 +244,7 @@ /** * Comparator Contact by status and name. */ - class ComparatorContactListByStatusAndName implements Comparator { + private class ComparatorContactListByStatusAndName implements Comparator { /** * Constructor. */ @@ -226,7 +276,7 @@ sortBeemContactList(); ListView listView = (ListView) findViewById(R.id.contactlist); listView.setOnItemClickListener(new BeemContactListOnClick()); - listView.setOnItemLongClickListener(new BeemContactListOnLongClick()); + registerForContextMenu(listView); listView.setAdapter(mAdapterContactList); } @@ -242,7 +292,7 @@ /** * Event simple click on item of the contact list. */ - public class BeemContactListOnClick implements OnItemClickListener { + private class BeemContactListOnClick implements OnItemClickListener { /** * Constructor. */ @@ -263,30 +313,6 @@ } /** - * Event long click on item of the contact list. - */ - public class BeemContactListOnLongClick implements OnItemLongClickListener { - /** - * Constructor. - */ - public BeemContactListOnLongClick() { - - } - - /** - * {@inheritDoc} - */ - @Override - public boolean onItemLongClick(AdapterView arg0, View v, int pos, long lpos) { - Contact c = mListContact.get(pos); - mContactDialog = new ContactDialog(ContactList.this, c); - mContactDialog.setOwnerActivity(ContactList.this); - mContactDialog.show(); - return true; - } - } - - /** * Event simple click on middle groupe name. */ private class OnItemClickGroupName implements OnItemClickListener { @@ -512,7 +538,20 @@ */ @Override public Object getItem(int position) { - return position; + Contact c = null; + if (mSettings.getBoolean("settings_key_hidden_contact", false)) { + int res = 0; + for (Contact cur : mListContact) { + if (res == position) { + c = cur; + break; + } + if (Status.statusOnline(cur.getStatus())) + res++; + } + } else + c = mListContact.get(position); + return c; } /** @@ -523,6 +562,7 @@ return position; } + /** * {@inheritDoc} */ @@ -581,7 +621,7 @@ /** * Adapter banner list. */ - public class BeemBanner extends BaseAdapter { + private class BeemBanner extends BaseAdapter { /** * Constructor. * @param c context activity. diff -r 97ae7bcc219a -r f25639696d5c src/com/beem/project/beem/ui/UserInfo.java --- a/src/com/beem/project/beem/ui/UserInfo.java Fri Nov 27 22:21:27 2009 +0100 +++ b/src/com/beem/project/beem/ui/UserInfo.java Sat Nov 28 01:55:26 2009 +0100 @@ -16,6 +16,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; +import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; @@ -252,7 +253,7 @@ /** * Event simple click on layout resend suscription. */ - class ResendListener implements View.OnClickListener { + private class ResendListener implements View.OnClickListener { /** * Constructor. @@ -293,12 +294,13 @@ /** * Event simple click on layout delete. */ - class DeleteListener implements View.OnClickListener { + private class DeleteListener implements View.OnClickListener { /** * Constructor. */ public DeleteListener() { + } @Override