merged
authornikita@nikita-lab
Fri, 22 May 2009 15:43:31 +0200
changeset 198 088857b09c7d
parent 195 fb0591e482d8 (current diff)
parent 197 73b3c7576722 (diff)
child 199 32104eafe784
merged
src/com/beem/project/beem/ui/ContactDialog.java
src/com/beem/project/beem/ui/ContactList.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/contactdialog.xml	Fri May 22 15:43:31 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:43:31 2009 +0200
@@ -0,0 +1,42 @@
+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 android.widget.TextView;
+
+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 curContact, Intent curIntent) {
+	super(context);
+	mContext = context;
+	setContentView(R.layout.contactdialog);
+	mContact = curContact;
+	setTitle(curContact.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);*/
+		String type = ((TextView) v).getText();
+		dismiss();
+	    }
+	    
+	});
+    }
+}
--- a/src/com/beem/project/beem/ui/ContactList.java	Thu May 21 23:50:57 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Fri May 22 15:43:31 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;
@@ -60,6 +65,7 @@
 	mRosterListener = new BeemRosterListener();
 	mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
 	mBeemApplication = BeemApplication.getApplication(this);
+<<<<<<< local
 	groupMap = new HashMap<String, List<Contact>>();
 	groupName = new ArrayList<String>();
 	mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
@@ -70,14 +76,26 @@
 		    mRoster = mService.getRoster();
 		} catch (RemoteException e1) {
 		    Log.e(TAG, "Get roster failed", e1);
+=======
+
+	//TODO: a refaire
+	/*if (mSettings.getString(getString(R.string.PreferenceHostKey), "").equals(""))
+	    startActivityForResult(new Intent(this, ContactListSettings.class), PREFERENCECHANGED);*/
+    }
+
+    @Override
+		protected void onResume() {	
+			super.onResume();
+
+>>>>>>> other
 		}
-		if (mRoster != null) {
-		    try {
-			mRoster.addConnectionListener(mRosterListener);
-		    } catch (RemoteException e) {
-			e.printStackTrace();
-		    }
+
+	@Override
+		protected void onDestroy() {
+			mBeemApplication.unbindBeemService();
+			super.onDestroy();
 		}
+<<<<<<< local
 		callbackShowContactList();
 	    }
 	});
@@ -91,6 +109,8 @@
 	mBeemApplication.unbindBeemService();
 	super.onDestroy();	
     }
+=======
+>>>>>>> other
 
     private void callbackShowContactList() {
 	if (mRoster != null) {
@@ -141,15 +161,19 @@
 	}
     }
 
+    /*
+     * @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) {
-	    Log.d(TAG, "onPREFERENCECHANGED");
 	    if (resultCode == RESULT_OK) {
 		if (!groupMap.isEmpty())
 		    groupMap.clear();
 		mBeemApplication.stopBeemService();
 	    }
 	}
+<<<<<<< local
     }
 
     @Override
@@ -163,12 +187,14 @@
 	    Log.e(TAG, "Child not found", e);
 	    return false;
 	}
+=======
+>>>>>>> other
     }
 
     private void buildContactList(List<Contact> listContact) {
 	mListContact = listContact;	
 	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);
@@ -194,7 +220,7 @@
 
     private class MyExpandableListAdapter implements ExpandableListAdapter {
 
-	private List<DataSetObserver> observers; 
+	private List<DataSetObserver> observers;
 
 	public MyExpandableListAdapter() {
 	    observers = new ArrayList<DataSetObserver>();
@@ -206,7 +232,6 @@
 	    }
 	}
 
-
 	@Override
 	public boolean areAllItemsEnabled() {
 	    return true;
@@ -233,16 +258,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;
 	}
 
@@ -313,13 +379,10 @@
 
 	@Override
 	public void onGroupCollapsed(int groupPosition) {
-	    // TODO A voir
 	}
 
 	@Override
 	public void onGroupExpanded(int groupPosition) {
-	    // TODO A voir
-
 	}
 
 	@Override
@@ -358,7 +421,7 @@
 			break;
 		    default:
 			imageDrawable = (Drawable) getResources().getDrawable(R.drawable.error);
-		    break;
+			break;
 		}
 		imgV.setImageDrawable(imageDrawable);
 
@@ -372,7 +435,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);
@@ -380,7 +443,6 @@
 		}
 	    }
 	}
-
     }
 
     private class BeemRosterListener extends IBeemRosterListener.Stub {
@@ -411,8 +473,6 @@
 
 	@Override
 	public void onEntriesDeleted(List<String> addresses) throws RemoteException {
-	    
-	    
 	    for (List<Contact> cList : groupMap.values()) {
 		for (Contact curContact:cList) {
 		    for (String addr:addresses) {
@@ -420,7 +480,7 @@
 			    cList.remove(curContact);
 			    if (cList.isEmpty()) {
 				groupMap.values().remove(cList);
-			    }				
+				}
 			}
 		    }
 		}
@@ -467,7 +527,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() {
@@ -476,7 +536,7 @@
 			    mAdapter.changed();
 			}
 		    });
-		    return ;
+		    return;
 		}
 	    }
 	}
--- a/src/com/beem/project/beem/ui/SendIMDialogSmiley.java	Thu May 21 23:50:57 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIMDialogSmiley.java	Fri May 22 15:43:31 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");
     }
 }