# HG changeset patch # User dasilvj # Date 1255008382 -7200 # Node ID eb1ce472a1a5788fef304cb76868082d10526fc6 # Parent 63cffd88721d1fc5f8b3f86823cadef95a6b17e5# Parent aa654c8efd1b4ba70bb6ea2d2407408dd238342d Merge diff -r 63cffd88721d -r eb1ce472a1a5 src/com/beem/project/beem/ui/ContactDialog.java --- a/src/com/beem/project/beem/ui/ContactDialog.java Thu Oct 08 14:38:09 2009 +0200 +++ b/src/com/beem/project/beem/ui/ContactDialog.java Thu Oct 08 15:26:22 2009 +0200 @@ -120,7 +120,7 @@ public void onClick(View v) { Activity a = ContactDialog.this.getOwnerActivity(); Intent i = new Intent(mContext, UserInfo.class); - i.putExtra("contact", mContact); + i.putExtra("contact_contactdialog", mContact.getJID()); a.startActivity(i); dismiss(); } diff -r 63cffd88721d -r eb1ce472a1a5 src/com/beem/project/beem/ui/GroupList.java --- a/src/com/beem/project/beem/ui/GroupList.java Thu Oct 08 14:38:09 2009 +0200 +++ b/src/com/beem/project/beem/ui/GroupList.java Thu Oct 08 15:26:22 2009 +0200 @@ -10,14 +10,15 @@ import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; -import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.view.View.OnKeyListener; +import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.CheckedTextView; import android.widget.ListView; import android.widget.TextView; +import android.widget.AdapterView.OnItemClickListener; import com.beem.project.beem.BeemService; import com.beem.project.beem.R; @@ -65,6 +66,7 @@ listView.setItemsCanFocus(false); listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); + listView.setOnItemClickListener(new GroupOnItemClickListener()); mText = (TextView) findViewById(R.id.GroupListText); mText.setOnKeyListener(new GroupListOnKeyListener()); @@ -93,33 +95,7 @@ } /** - * On group click listener. - * @param l The ListView where the click happened - * @param v The view that was clicked within the ListView - * @param position The position of the view in the list - * @param id The row id of the item that was clicked - */ - @Override - protected void onListItemClick(ListView l, View v, int position, long id) { - Log.d("GROUPLIST", "CLICK"); - CheckedTextView textView = (CheckedTextView) v; - if (textView.isChecked()) { - try { - mRoster.addContactToGroup(textView.getText().toString(), mJID); - } catch (RemoteException e) { - e.printStackTrace(); - } - } else { - try { - mRoster.removeContactFromGroup(textView.getText().toString(), mJID); - } catch (RemoteException e) { - e.printStackTrace(); - } - } - } - - /** - * init activity lsit adapter. + * init activity list adapter. */ private void setAdapter() { try { @@ -138,10 +114,16 @@ } /** - * GroupListOnKeyListener class. + * Event when group is added. */ private class GroupListOnKeyListener implements OnKeyListener { + /** + * Constructor. + */ + public GroupListOnKeyListener() { + } + @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { @@ -153,11 +135,6 @@ String groupname = mText.getText().toString(); mGroups.add(groupname); mText.setText(null); - try { - mRoster.createGroup(groupname); - } catch (RemoteException e) { - e.printStackTrace(); - } return true; default: return false; @@ -169,6 +146,39 @@ } /** + * Event click on list group contact. + */ + private class GroupOnItemClickListener implements OnItemClickListener { + + /** + * Constructor. + */ + public GroupOnItemClickListener() { + } + + @Override + public void onItemClick(AdapterView arg0, View v, int arg2, long arg3) { + CheckedTextView textView = (CheckedTextView) v; + if (!textView.isChecked()) { + try { + mRoster.createGroup(textView.getText().toString()); + mRoster.addContactToGroup(textView.getText().toString(), mJID); + } catch (RemoteException e) { + e.printStackTrace(); + } + } else { + try { + mRoster.removeContactFromGroup(textView.getText().toString(), mJID); + } catch (RemoteException e) { + e.printStackTrace(); + } + } + + } + + } + + /** * The ServiceConnection used to connect to the Beem service. */ private class BeemServiceConnection implements ServiceConnection { diff -r 63cffd88721d -r eb1ce472a1a5 src/com/beem/project/beem/ui/UserInfo.java --- a/src/com/beem/project/beem/ui/UserInfo.java Thu Oct 08 14:38:09 2009 +0200 +++ b/src/com/beem/project/beem/ui/UserInfo.java Thu Oct 08 15:26:22 2009 +0200 @@ -77,12 +77,6 @@ mTextAlias = (TextView) findViewById(R.id.userinfo_alias); mGalleryGroups = (Gallery) findViewById(R.id.userinfo_groups); mReceiver = new BeemBroadcastReceiver(mServConn); - - mContact = getIntent().getParcelableExtra("contact"); - mJID = mContact.getJID(); - mTextAlias.setText(mContact.getName()); - mGalleryGroups.setAdapter(new BeemGroups(UserInfo.this, mContact.getGroups())); - setTitle(mJID); } /** @@ -209,7 +203,7 @@ public BeemGroups(final Context c, final List listGroup) { mContext = c; if (listGroup.size() == 0) - listGroup.add("No Group"); + listGroup.add(getString(R.string.contact_list_no_group)); mListGroup = listGroup; } @@ -344,6 +338,11 @@ mXmppFacade = IXmppFacade.Stub.asInterface(service); try { mRoster = mXmppFacade.getRoster(); + mJID = getIntent().getStringExtra("contact_contactdialog"); + mContact = mRoster.getContact(mJID); + mTextAlias.setText(mContact.getName()); + mGalleryGroups.setAdapter(new BeemGroups(UserInfo.this, mContact.getGroups())); + setTitle(mJID); } catch (RemoteException e) { e.printStackTrace(); }