# HG changeset patch
# User marseille@marseille-desktop
# Date 1242997050 -7200
# Node ID 052599f4e64668b6da0f8d4d8f49b51eb56973b6
# Parent 54e1e3f0bd4b16e8f82870ff68dff5e9265be64a
oulala le dialog ...
diff -r 54e1e3f0bd4b -r 052599f4e646 res/layout/contactdialog.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/contactdialog.xml Fri May 22 14:57:30 2009 +0200
@@ -0,0 +1,9 @@
+
+
+
+
+
+
\ No newline at end of file
diff -r 54e1e3f0bd4b -r 052599f4e646 src/com/beem/project/beem/ui/ContactDialog.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/ui/ContactDialog.java Fri May 22 14:57:30 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();
+ }
+
+ });
+ }
+}
diff -r 54e1e3f0bd4b -r 052599f4e646 src/com/beem/project/beem/ui/ContactList.java
--- a/src/com/beem/project/beem/ui/ContactList.java Thu May 21 16:33:11 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Fri May 22 14:57:30 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,7 +72,7 @@
@Override
protected void onResume() {
super.onResume();
-
+
mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
@Override
public void run() {
@@ -93,7 +98,7 @@
@Override
protected void onDestroy() {
mBeemApplication.unbindBeemService();
- super.onDestroy();
+ super.onDestroy();
}
private void callbackShowContactList() {
@@ -147,19 +152,10 @@
}
}
- @Override
- public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
- Intent i = new Intent(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;
- }
- }
-
+ /*
+ * @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) {
if (requestCode == PREFERENCECHANGED) {
if (resultCode == RESULT_OK) {
@@ -175,7 +171,7 @@
groupMap = new HashMap>();
groupName = new ArrayList();
for (Contact contact : listContact) {
- for (String group: contact.getGroups()) {
+ for (String group : contact.getGroups()) {
if (!groupMap.containsKey(group)) {
groupMap.put(group, new ArrayList());
groupName.add(group);
@@ -200,19 +196,18 @@
private class MyExpandableListAdapter implements ExpandableListAdapter {
- private List observers;
-
+ private List observers;
+
public MyExpandableListAdapter() {
observers = new ArrayList();
}
-
+
public void changed() {
for (DataSetObserver obs : observers) {
obs.onChanged();
}
}
-
-
+
@Override
public boolean areAllItemsEnabled() {
return true;
@@ -239,17 +234,58 @@
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);
Log.d(TAG, "Convert view est vide sur un getChildView");
} else {
v = convertView;
}
bindView(v, groupMap.get(groupName.get(groupPosition)).get(childPosition));
+
+ v.setOnLongClickListener(new MyOnLongClickListener());
+ v.setOnClickListener(new MyOnClickListener());
return v;
}
@@ -321,13 +357,10 @@
@Override
public void onGroupCollapsed(int groupPosition) {
- // TODO A voir
}
@Override
public void onGroupExpanded(int groupPosition) {
- // TODO A voir
-
}
@Override
@@ -368,7 +401,7 @@
break;
default:
imageDrawable = (Drawable) getResources().getDrawable(R.drawable.error);
- break;
+ break;
}
imgV.setImageDrawable(imageDrawable);
@@ -382,7 +415,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);
@@ -390,7 +423,6 @@
}
}
}
-
}
private class BeemRosterListener extends IBeemRosterListener.Stub {
@@ -415,7 +447,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() {
@@ -424,7 +456,7 @@
mAdapter.changed();
}
});
- return ;
+ return;
}
}
}
diff -r 54e1e3f0bd4b -r 052599f4e646 src/com/beem/project/beem/ui/SendIMDialogSmiley.java
--- a/src/com/beem/project/beem/ui/SendIMDialogSmiley.java Thu May 21 16:33:11 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIMDialogSmiley.java Fri May 22 14:57:30 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");
}
}