Correction d'un petit bug pour recuperer les infos du contact dans le
authormarseille@KungFuh
Sat, 04 Apr 2009 09:50:59 +0200
changeset 62 ec87eec66d56
parent 60 aa70a805da17 (current diff)
parent 61 08cfba11099a (diff)
child 66 661aa8634e98
Correction d'un petit bug pour recuperer les infos du contact dans le SendIM.java
src/com/beem/project/beem/ui/ContactList.java
src/com/beem/project/beem/ui/SendIM.java
--- a/project.aidl	Sat Apr 04 01:22:36 2009 +0200
+++ b/project.aidl	Sat Apr 04 09:50:59 2009 +0200
@@ -3,5 +3,6 @@
 // action. Do not modify!
 
 parcelable com.beem.project.beem.BeemException
+parcelable com.beem.project.beem.service.Message
 parcelable com.beem.project.beem.service.Contact
-parcelable com.beem.project.beem.service.Message
+parcelable com.beem.project.beem.service.PresenceAdapter
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/service/aidl/IBeemRosterListener.aidl	Sat Apr 04 09:50:59 2009 +0200
@@ -0,0 +1,10 @@
+package com.beem.project.beem.service.aidl;
+
+import com.beem.project.beem.service.PresenceAdapter;
+
+interface IBeemRosterListener {
+    void onEntriesAdded(in List<String> addresses);
+    void onEntriesUpdated(in List<String> addresses);
+    void onEntriesDeleted(in List<String> addresses);
+    void onPresenceChanged(in PresenceAdapter presence);
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/service/aidl/IContact.aidl	Sat Apr 04 09:50:59 2009 +0200
@@ -0,0 +1,9 @@
+package com.beem.project.beem.service.aidl;
+
+interface IContact {
+
+	String getJID();
+	
+	void setJID(String mjid);
+
+}
\ No newline at end of file
--- a/src/com/beem/project/beem/service/aidl/IRoster.aidl	Sat Apr 04 01:22:36 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IRoster.aidl	Sat Apr 04 09:50:59 2009 +0200
@@ -1,5 +1,6 @@
 package com.beem.project.beem.service.aidl;
 
+import com.beem.project.beem.service.aidl.IBeemRosterListener;
 import com.beem.project.beem.service.Contact;
 
 interface IRoster {
@@ -15,5 +16,8 @@
     List<Contact> getContactList(); 
     
     List<String> getGroupsNames();
+    
+    void addConnectionListener(in IBeemRosterListener listen);
+    void removeConnectionListener(in IBeemRosterListener listen);
 
 }
\ No newline at end of file
--- a/src/com/beem/project/beem/ui/ContactList.java	Sat Apr 04 01:22:36 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Sat Apr 04 09:50:59 2009 +0200
@@ -49,7 +49,7 @@
 	Map<String, Contact> child = (HashMap<String, Contact>) parent
 		.getExpandableListAdapter().getChild(groupPosition,
 			childPosition);
-	i.putExtra("contact", child.values().toArray());
+	i.putExtra("contact", child.get("CHILD"));
 	startActivity(i);
 	return true;
     }
@@ -181,6 +181,7 @@
 		Map<String, Contact> curChildMap = new HashMap<String, Contact>();
 		children.add(curChildMap);
 		Contact c = listContact.get(j);
+		Log.i(TAG, c.getID() + " " +c.getJID());
 		curChildMap.put("CHILD", c);
 	    }
 	    childData.add(children);
--- a/src/com/beem/project/beem/ui/SendIM.java	Sat Apr 04 01:22:36 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java	Sat Apr 04 09:50:59 2009 +0200
@@ -25,112 +25,118 @@
  */
 
 public class SendIM extends ListActivity implements OnClickListener,
-		OnKeyListener {
-	private EditText mToSend;
-	private ArrayList<String> mMessages = new ArrayList<String>();
-	private ArrayAdapter<String> mAdapter;
-	private SendIMDialogSmiley mSmyDialog;
-	private SharedPreferences mSet;
-	private Contact mContact;
+	OnKeyListener {
+    private EditText mToSend;
+    private ArrayList<String> mMessages = new ArrayList<String>();
+    private ArrayAdapter<String> mAdapter;
+    private SendIMDialogSmiley mSmyDialog;
+    private SharedPreferences mSet;
+    private Contact mContact;
 
-	/**
-	 * Constructor.
-	 */
-	public SendIM() {
-		super();
-	}
+    /**
+     * Constructor.
+     */
+    public SendIM() {
+	super();
+    }
+
+    /**
+     * Overload of onCreate() Activity inherited function
+     */
+    @Override
+    public void onCreate(Bundle saveBundle) {
+	super.onCreate(saveBundle);
 
-	/**
-	 * Overload of onCreate() Activity inherited function
-	 */
-	@Override
-	public void onCreate(Bundle saveBundle) {
-		super.onCreate(saveBundle);
-		
-		setContentView(R.layout.sendim);
-		mToSend = (EditText) findViewById(R.id.userText);
-		mSet = getSharedPreferences("lol", MODE_PRIVATE);
-		mSmyDialog = new SendIMDialogSmiley(this, mSet);
+	setContentView(R.layout.sendim);
+	mToSend = (EditText) findViewById(R.id.userText);
+	mSet = getSharedPreferences("lol", MODE_PRIVATE);
+	mSmyDialog = new SendIMDialogSmiley(this, mSet);
+
+	mAdapter = new ArrayAdapter<String>(this, R.layout.messagelist,
+		mMessages);
+	setListAdapter(mAdapter);
+
+	mToSend.setOnClickListener(this);
+	mToSend.setOnKeyListener(this);
 
-		mAdapter = new ArrayAdapter<String>(this, R.layout.messagelist,
-				mMessages);
-		setListAdapter(mAdapter);
+	mContact = getIntent().getParcelableExtra("contact");
+    }
+
+    @Override
+    public void onStart() {
+	super.onStart();
 
-		mToSend.setOnClickListener(this);
-		mToSend.setOnKeyListener(this);
-		
-		mContact = getIntent().getParcelableExtra("contact");
-	}
+    }
+
+    /**
+     * Abstract method inherited from OnClickListener
+     */
+    public void onClick(View view) {
+	sendText();
+    }
 
-	@Override
-	public void onStart() {
-		super.onStart();
-
+    /**
+     * This method send a message to the server over the XMPP connection and
+     * display it on activity view TODO : Exception si la connexion se coupe
+     * pendant la conversation
+     */
+    private void sendText() {
+	String text = mToSend.getText().toString();
+	if (!text.equals("")) {
+	    /*
+	     * Prepare the message to be send
+	     */
+	    /* Message msg = new Message("barbu", Message.Type.chat); */
+	    /* msg.setBody(text); */
+	    /*
+	     * Rien a voir il faut changer le mContact.getJID() et remplacer
+	     * avec son pseudo cetait juste un test pour savoir qu'on recupere
+	     * bien le contact a qui envoyer les infos
+	     */
+	    mAdapter.add(mContact.getJID() + " "
+		    + getString(R.string.SendIMSays) + text);
+	    mToSend.setText(null);
 	}
-
-	/**
-	 * Abstract method inherited from OnClickListener
-	 */
-	public void onClick(View view) {
-		sendText();
-	}
+    }
 
-	/**
-	 * This method send a message to the server over the XMPP connection and
-	 * display it on activity view TODO : Exception si la connexion se coupe
-	 * pendant la conversation
-	 */
-	private void sendText() {
-		String text = mToSend.getText().toString();
-		if (!text.equals("")) {
-			/*
-			 * Prepare the message to be send
-			 */
-			/* Message msg = new Message("barbu", Message.Type.chat); */
-			/* msg.setBody(text); */
-			mAdapter.add(getString(R.string.PreferenceJID) + " " + getString(R.string.SendIMSays) + text);
-			mToSend.setText(null);
-		}
+    /**
+     * Abstract method inherited from OnKeyListener
+     */
+    public boolean onKey(View v, int keyCode, KeyEvent event) {
+	if (event.getAction() == KeyEvent.ACTION_DOWN) {
+	    switch (keyCode) {
+		case KeyEvent.KEYCODE_DPAD_CENTER:
+		case KeyEvent.KEYCODE_ENTER:
+		    sendText();
+		    return true;
+	    }
 	}
+	return false;
+    }
 
-	/**
-	 * Abstract method inherited from OnKeyListener
-	 */
-	public boolean onKey(View v, int keyCode, KeyEvent event) {
-		if (event.getAction() == KeyEvent.ACTION_DOWN) {
-			switch (keyCode) {
-			case KeyEvent.KEYCODE_DPAD_CENTER:
-			case KeyEvent.KEYCODE_ENTER:
-				sendText();
-				return true;
-			}
-		}
+    /**
+     * Callback for menu creation.
+     * 
+     * @param menu
+     *            the menu created
+     * @return true on success, false otherwise
+     */
+    @Override
+    public final boolean onCreateOptionsMenu(Menu menu) {
+	super.onCreateOptionsMenu(menu);
+	MenuInflater inflater = getMenuInflater();
+	inflater.inflate(R.menu.sendimmenu, menu);
+	return true;
+    }
+
+    @Override
+    public final boolean onOptionsItemSelected(MenuItem item) {
+	switch (item.getItemId()) {
+	    case R.id.sendim_smiley:
+		mSmyDialog.show();
+		return true;
+	    default:
 		return false;
 	}
-
-	/**
-	 * Callback for menu creation.
-	 * 
-	 * @param menu
-	 *            the menu created
-	 * @return true on success, false otherwise
-	 */
-	@Override
-	public final boolean onCreateOptionsMenu(Menu menu) {
-		super.onCreateOptionsMenu(menu);
-		MenuInflater inflater = getMenuInflater();
-		inflater.inflate(R.menu.sendimmenu, menu);
-		return true;
-	}
-
-	@Override
-	public final boolean onOptionsItemSelected(MenuItem item) {
-		switch (item.getItemId()) {
-		case R.id.sendim_smiley:
-			mSmyDialog.show();
-			return true;
-		default:
-			return false;
-		}
-	}
+    }
 }