--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/contactdialog.xml Fri May 22 15:07:35 2009 +0200
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+
+ <Button android:id="@+id/chat" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:text="Chat" />
+
+</LinearLayout>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/ui/ContactDialog.java Fri May 22 15:07:35 2009 +0200
@@ -0,0 +1,40 @@
+package com.beem.project.beem.ui;
+
+import android.app.Activity;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.Intent;
+import android.view.View;
+import android.widget.Button;
+
+import com.beem.project.beem.R;
+import com.beem.project.beem.service.Contact;
+
+public class ContactDialog extends Dialog {
+
+ // final private CharSequence[] items = { "Chat", "Resend suscription", "Alias", "Change group", "Infos" };
+ private Contact mContact;
+ private Context mContext;
+
+ public ContactDialog(final Context context, Contact c) {
+ super(context);
+ mContext = context;
+ setContentView(R.layout.contactdialog);
+ mContact = c;
+ setTitle(c.getJID());
+
+ Button chat = (Button) findViewById(R.id.chat);
+ chat.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Activity a = ContactDialog.this.getOwnerActivity();
+ Intent i = new Intent(mContext, SendIM.class);
+ i.putExtra("contact", mContact);
+ a.startActivity(i);
+ dismiss();
+ }
+
+ });
+ }
+}
--- a/src/com/beem/project/beem/ui/ContactList.java Thu May 21 22:18:14 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Fri May 22 15:07:35 2009 +0200
@@ -7,7 +7,10 @@
import org.jivesoftware.smack.util.StringUtils;
+import android.app.AlertDialog;
+import android.app.Dialog;
import android.app.ExpandableListActivity;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.DataSetObserver;
@@ -23,10 +26,12 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.view.View.OnClickListener;
+import android.view.View.OnLongClickListener;
import android.widget.ExpandableListAdapter;
-import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.TextView;
+import android.widget.Toast;
import com.beem.project.beem.BeemApplication;
import com.beem.project.beem.R;
@@ -67,34 +72,16 @@
}
@Override
- protected void onResume() {
- mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
- @Override
- public void run() {
- mService = mBeemApplication.getXmppFacade();
- try {
- mRoster = mService.getRoster();
- } catch (RemoteException e1) {
- Log.e(TAG, "Get roster failed", e1);
+ protected void onResume() {
+ super.onResume();
+
}
- if (mRoster != null) {
- try {
- mRoster.addConnectionListener(mRosterListener);
- } catch (RemoteException e) {
- e.printStackTrace();
- }
+
+ @Override
+ protected void onDestroy() {
+ mBeemApplication.unbindBeemService();
+ super.onDestroy();
}
- callbackShowContactList();
- }
- });
- super.onResume();
- }
-
- @Override
- protected void onDestroy() {
- mBeemApplication.unbindBeemService();
- super.onDestroy();
- }
private void callbackShowContactList() {
if (mRoster != null)
@@ -144,33 +131,18 @@
}
}
+ /*
+ * @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
+ * long id) { try { } catch (NullPointerException e) { Log.e(TAG, "Child not found", e); return false; } }
+ */
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- //TODO:marche pas
- Log.d(TAG, "onActivityResult" );
if (requestCode == PREFERENCECHANGED) {
- Log.d(TAG, "onPREFERENCECHANGED");
if (resultCode == RESULT_OK) {
if (!groupMap.isEmpty())
groupMap.clear();
mBeemApplication.stopBeemService();
}
}
- if (requestCode == 1) {
- Log.d(TAG, "onSENDIMRESULT");
- }
- }
-
- @Override
- public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
- Intent i = new Intent(ContactList.this, SendIM.class);
- try {
- i.putExtra("contact", groupMap.get(groupName.get(groupPosition)).get(childPosition));
- startActivity(i);
- return true;
- } catch (NullPointerException e) {
- Log.e(TAG, "Child not found", e);
- return false;
- }
}
private void buildContactList(List<Contact> listContact) {
@@ -178,7 +150,7 @@
groupMap = new HashMap<String, List<Contact>>();
groupName = new ArrayList<String>();
for (Contact contact : listContact) {
- for (String group: contact.getGroups()) {
+ for (String group : contact.getGroups()) {
if (!groupMap.containsKey(group)) {
groupMap.put(group, new ArrayList<Contact>());
groupName.add(group);
@@ -203,7 +175,7 @@
private class MyExpandableListAdapter implements ExpandableListAdapter {
- private List<DataSetObserver> observers;
+ private List<DataSetObserver> observers;
public MyExpandableListAdapter() {
observers = new ArrayList<DataSetObserver>();
@@ -215,7 +187,6 @@
}
}
-
@Override
public boolean areAllItemsEnabled() {
return true;
@@ -242,16 +213,57 @@
return childPosition;
}
+ void createDialog(Contact contact) {
+
+ Dialog dialogContact= new ContactDialog(ContactList.this, contact);
+ dialogContact.show();
+ }
+
+ class MyOnLongClickListener implements OnLongClickListener {
+ @Override
+ public boolean onLongClick(View v) {
+ TextView jidTextView = (TextView) v.findViewById(R.id.contactlistpseudo);
+ String jid = jidTextView.getText().toString();
+ for (Contact curContact : mListContact) {
+ if (jid.equals(curContact.getJID())) {
+ createDialog(curContact);
+ break;
+ }
+ }
+ return true;
+ }
+ }
+
+ class MyOnClickListener implements OnClickListener {
+ @Override
+ public void onClick(View v) {
+ TextView jidTextView = (TextView) v.findViewById(R.id.contactlistpseudo);
+ String jid = jidTextView.getText().toString();
+ for (Contact curContact : mListContact) {
+ if (jid.equals(curContact.getJID())) {
+ Intent i = new Intent(ContactList.this, SendIM.class);
+ i.putExtra("contact", curContact);
+ startActivity(i);
+ break;
+ }
+ }
+ }
+
+ }
+
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
ViewGroup parent) {
View v;
if (convertView == null) {
- v = LayoutInflater.from(ContactList.this).inflate(R.layout.contactlistcontact, null);
+ v = LayoutInflater.from(ContactList.this).inflate(R.layout.contactlistcontact, null);
} else {
v = convertView;
}
bindView(v, groupMap.get(groupName.get(groupPosition)).get(childPosition));
+
+ v.setOnLongClickListener(new MyOnLongClickListener());
+ v.setOnClickListener(new MyOnClickListener());
return v;
}
@@ -322,13 +334,10 @@
@Override
public void onGroupCollapsed(int groupPosition) {
- // TODO A voir
}
@Override
public void onGroupExpanded(int groupPosition) {
- // TODO A voir
-
}
@Override
@@ -367,7 +376,7 @@
break;
default:
imageDrawable = (Drawable) getResources().getDrawable(R.drawable.error);
- break;
+ break;
}
imgV.setImageDrawable(imageDrawable);
@@ -381,7 +390,7 @@
v.setText(curContact.getMsgState());
}
- //TODO: Rajouter l'avatar du contact getAvatar() dans la classe
+ // TODO: Rajouter l'avatar du contact getAvatar() dans la classe
imgV = (ImageView) view.findViewById(R.id.contactlistavatar);
if (imgV != null) {
imageDrawable = (Drawable) getResources().getDrawable(R.drawable.avatar);
@@ -389,7 +398,6 @@
}
}
}
-
}
private class BeemRosterListener extends IBeemRosterListener.Stub {
@@ -420,8 +428,6 @@
@Override
public void onEntriesDeleted(List<String> addresses) throws RemoteException {
-
-
for (List<Contact> cList : groupMap.values()) {
for (Contact curContact:cList) {
for (String addr:addresses) {
@@ -429,7 +435,7 @@
cList.remove(curContact);
if (cList.isEmpty()) {
groupMap.values().remove(cList);
- }
+ }
}
}
}
@@ -476,7 +482,7 @@
@Override
public void onPresenceChanged(PresenceAdapter presence) throws RemoteException {
- for (Contact curContact :mListContact) {
+ for (Contact curContact : mListContact) {
if (curContact.getJID().equals(StringUtils.parseBareAddress(presence.getFrom()))) {
curContact.setStatus(presence);
mHandler.post(new Runnable() {
@@ -485,7 +491,7 @@
mAdapter.changed();
}
});
- return ;
+ return;
}
}
}
--- a/src/com/beem/project/beem/ui/SendIMDialogSmiley.java Thu May 21 22:18:14 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIMDialogSmiley.java Fri May 22 15:07:35 2009 +0200
@@ -6,19 +6,19 @@
import android.content.SharedPreferences;
public class SendIMDialogSmiley extends Dialog {
- private SendIM mSendIM;
- private SharedPreferences mSet;
-
+ private SendIM mSendIM;
+ private SharedPreferences mSet;
+
public SendIMDialogSmiley(SendIM sendim, SharedPreferences settings) {
- super(sendim);
- this.mSendIM = sendim;
- this.mSet = settings;
+ super(sendim);
+ this.mSendIM = sendim;
+ this.mSet = settings;
}
-
+
@Override
protected void onStart() {
- super.onStart();
- setContentView(R.layout.sendimdialogsmiley);
- setTitle("Select a smiley");
+ super.onStart();
+ setContentView(R.layout.sendimdialogsmiley);
+ setTitle("Select a smiley");
}
}