merge.
authormarseille@KungFuh
Tue, 07 Apr 2009 20:14:42 +0200
changeset 87 84cad8522aa6
parent 86 23a0dfdff589 (diff)
parent 80 29f0d6a23321 (current diff)
child 88 7b2a869e9ef8
merge.
src/com/beem/project/beem/BeemService.java
src/com/beem/project/beem/ui/ContactList.java
--- a/AndroidManifest.xml	Tue Apr 07 10:25:40 2009 +0200
+++ b/AndroidManifest.xml	Tue Apr 07 20:14:42 2009 +0200
@@ -2,7 +2,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 	package="com.beem.project.beem" android:versionCode="1"
 	android:versionName="1.0">
-	<application android:label="@string/app_name" android:name="BeemApplication">
+	<application android:label="@string/app_name" android:name="BeemApplication" android:theme="@style/customtheme">
 		<activity android:name=".ui.ContactList" android:label="@string/app_name">
 			<intent-filter>
 				<action android:name="android.intent.action.MAIN" />
Binary file res/drawable/background.png has changed
Binary file res/drawable/xmpp.jpg has changed
--- a/res/layout/contactlistcontact.xml	Tue Apr 07 10:25:40 2009 +0200
+++ b/res/layout/contactlistcontact.xml	Tue Apr 07 20:14:42 2009 +0200
@@ -6,7 +6,7 @@
         android:gravity="center_vertical" >
 
         <ImageView android:id="@+id/contactliststatus"
-        android:layout_weight="5"
+        	android:layout_weight="5"
         	android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:gravity="center_vertical" />
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/values/style.xml	Tue Apr 07 20:14:42 2009 +0200
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+  <style name="customtheme" parent="android:Theme">
+ </style>
+ 
+  	<style name="customtheme.login"> 
+    <item name="android:windowBackground">@drawable/background</item>
+    <item name="android:windowNoTitle">true</item>
+
+ 
+  </style>        
+</resources>
\ No newline at end of file
--- a/src/com/beem/project/beem/BeemService.java	Tue Apr 07 10:25:40 2009 +0200
+++ b/src/com/beem/project/beem/BeemService.java	Tue Apr 07 20:14:42 2009 +0200
@@ -91,7 +91,7 @@
 	} else {
 	    mConnectionConfiguration = new ConnectionConfiguration(mHost);
 	}
-	mConnectionConfiguration.setSendPresence(false);
+	mConnectionConfiguration.setSendPresence(true);
     }
 
     /**
--- a/src/com/beem/project/beem/service/Contact.java	Tue Apr 07 10:25:40 2009 +0200
+++ b/src/com/beem/project/beem/service/Contact.java	Tue Apr 07 20:14:42 2009 +0200
@@ -20,36 +20,12 @@
  */
 public class Contact implements Parcelable {
 
-    /**
-     * Status of a disconnected contact.
-     */
     public static final int CONTACT_STATUS_DISCONNECT = 100;
-
-    /**
-     * Status of a unavailable (long away) contact.
-     */
     public static final int CONTACT_STATUS_UNAVAILABLE = 200;
-
-    /**
-     * Status of a away contact.
-     */
     public static final int CONTACT_STATUS_AWAY = 300;
-
-    /**
-     * Status of a busy contact.
-     */
     public static final int CONTACT_STATUS_BUSY = 400;
-
-    /**
-     * Status of a available contact.
-     */
     public static final int CONTACT_STATUS_AVAILABLE = 500;
-
-    /**
-     * Status of a available for chat contact.
-     */
     public static final int CONTACT_STATUS_AVAILABLE_FOR_CHAT = 600;
-
     private static final String TAG = "Contact";
 
     private int mID;
@@ -75,26 +51,9 @@
     };
 
     /**
-     * Constructor.
-     */
-    public Contact() {
-	// TODO Auto-generated constructor stub
-    }
-
-    /**
-     * Constructor.
-     * @param jid JID of the contact
-     */
-    public Contact(final String jid) {
-	mJID = jid;
-	mStatus = Contact.CONTACT_STATUS_DISCONNECT;
-	mRes = new ArrayList<String>();
-	mRes.add("none");
-    }
-
-    /**
      * Construct a contact from a parcel.
-     * @param in parcel to use for construction
+     * @param in
+     *            parcel to use for construction
      */
     private Contact(final Parcel in) {
 	mID = in.readInt();
@@ -127,7 +86,25 @@
     }
 
     /**
-     * Get the id of the contact on the phone contact list.
+     * Constructor.
+     */
+    public Contact() {
+	// TODO Auto-generated constructor stub
+    }
+
+    /**
+     * Constructor.
+     * @param jid
+     *            JID of the contact
+     */
+    public Contact(final String jid) {
+	mJID = jid;
+	mStatus = Contact.CONTACT_STATUS_DISCONNECT;
+	mRes = new ArrayList<String>();
+	mRes.add("none");
+    }
+
+    /**
      * @return the mID
      */
     public int getID() {
@@ -135,15 +112,14 @@
     }
 
     /**
-     * set the id of te contact on the phone contact list.
-     * @param mid the mID to set
+     * @param mid
+     *            the mID to set
      */
     public void setID(int mid) {
 	mID = mid;
     }
 
     /**
-     * Get the status of the contact.
      * @return the mStatus
      */
     public int getStatus() {
@@ -151,22 +127,22 @@
     }
 
     /**
-     * Set the status of the contact.
-     * @param status the mStatus to set
+     * @param status
+     *            the mStatus to set
      */
     public void setStatus(int status) {
 	mStatus = status;
     }
 
     /**
-     * Set the status of the contact using a presence packet.
-     * @param presence the presence containing status
+     * @param presence
+     *            the presence containing status
      */
     public void setStatus(Presence presence) {
-	if (presence.getType().equals(Presence.Type.unavailable)) {
-	    Log.d(TAG, "Presence pas dispo");
-	    mStatus = Contact.CONTACT_STATUS_DISCONNECT;
-	} else {
+	Log.i(TAG, "NIKITAAAA");
+	/* presence.isAvailable() !?!? */
+	if (presence.getType().equals(Presence.Type.available)) {
+	    mStatus = Contact.CONTACT_STATUS_AVAILABLE;
 	    Log.d(TAG, "Presence OK");
 	    Mode mode = presence.getMode();
 	    switch (mode) {
@@ -187,25 +163,27 @@
 		    break;
 		default:
 		    Log.e("RosterAdapter", "Status mode non gere");
-		    mStatus = Contact.CONTACT_STATUS_DISCONNECT;
+		    mStatus = Contact.CONTACT_STATUS_AVAILABLE;
 		    break;
 	    }
+	} else {
+	    Log.d(TAG, "Presence pas dispo");
+	    mStatus = Contact.CONTACT_STATUS_DISCONNECT;
 	}
     }
 
     /**
-     * Get the message status of the contact.
-     * @return the message status of the contact.
+     * @return the mMsgState
      */
-    public String getMsgState() {
+    public String getMMsgState() {
 	return mMsgState;
     }
 
     /**
-     * Set the message status of the contact.
-     * @param msgState the message status of the contact to set
+     * @param msgState
+     *            the mMsgState to set
      */
-    public void setMsgState(String msgState) {
+    public void setMMsgState(String msgState) {
 	mMsgState = msgState;
     }
 
@@ -219,31 +197,25 @@
 
     /**
      * Set the Jabber ID of the contact.
-     * @param mjid the jabber ID to set
+     * @param mjid
+     *            the jabber ID to set
      */
     public void setJID(String mjid) {
 	mJID = mjid;
     }
 
-    /**
-     * 
-     * @param res
-     */
     public void addRes(String res) {
 	if (!mRes.contains(res))
 	    mRes.add(res);
     }
 
-    /**
-     * 
-     * @param res
-     */
     public void delRes(String res) {
 	mRes.remove(res);
     }
 
     /**
-     * @param mRes the mRes to set
+     * @param mRes
+     *            the mRes to set
      */
     public void setMRes(List<String> mRes) {
 	this.mRes = mRes;
--- a/src/com/beem/project/beem/ui/ContactList.java	Tue Apr 07 10:25:40 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Tue Apr 07 20:14:42 2009 +0200
@@ -13,6 +13,7 @@
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.IBinder;
 import android.os.RemoteException;
 import android.util.Log;
 import android.view.Menu;
@@ -29,6 +30,8 @@
 import com.beem.project.beem.BeemApplication;
 import com.beem.project.beem.R;
 import com.beem.project.beem.service.Contact;
+import com.beem.project.beem.service.PresenceAdapter;
+import com.beem.project.beem.service.aidl.IBeemRosterListener;
 import com.beem.project.beem.service.aidl.IXmppFacade;
 import com.beem.project.beem.service.aidl.IRoster;
 
@@ -40,6 +43,8 @@
     private Handler mHandler;
     private BeemApplication mBeemApplication;
     private ContactListDialogSettings mDialog;
+    private BeemRosterListener mRosterListener;
+    private IRoster mRoster;
 
     @SuppressWarnings("unchecked")
     @Override
@@ -62,33 +67,22 @@
 	mSettings = getSharedPreferences(
 		getString(R.string.PreferenceFileName), MODE_PRIVATE);
 	mDialog = new ContactListDialogSettings(this, mSettings);
+	mRosterListener = new BeemRosterListener();
 
 	mSettings
 		.registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() {
 		    @Override
 		    public void onSharedPreferenceChanged(
 			    SharedPreferences sharedPreferences, String key) {
-			/*
-			 * TODO : A faire apres listener nikita
-			 * 
-			 * mBeemApplication.stopBeemService();
-			 * mBeemApplication.startBeemService();
-			 * mBeemApplication.callWhenServiceConnected(mHandler,
-			 * new Runnable() {
-			 * 
-			 * @Override public void run() {
-			 * callbackShowContactList(); } });
-			 */
+			Log.i(TAG, "On Preference Changed");
 		    }
 		});
-
     }
 
     @Override
     protected void onStart() {
 	super.onStart();
-	Log.i(TAG, "onStart");
-	mBeemApplication.startBeemService();
+
     }
 
     @Override
@@ -102,6 +96,15 @@
 	mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() {
 	    @Override
 	    public void run() {
+		mService = mBeemApplication.getXmppFacade();
+		try {
+		    if (mRoster != null) {
+			mRoster = mService.getRoster();
+			mRoster.addConnectionListener(mRosterListener);
+		    }
+		} catch (RemoteException e) {
+		    e.printStackTrace();
+		}
 		callbackShowContactList();
 	    }
 	});
@@ -111,17 +114,13 @@
 	/*
 	 * @TODO: A ameliorer apres listener de nikita
 	 */
-	mService = mBeemApplication.getXmppFacade();
-	if (mService != null) {
+	if (mRoster != null)
 	    try {
-		IRoster r = mService.getRoster();
-		if (r != null)
-		    showContactList(r.getGroupsNames(), r.getContactList());
+		showContactList(mRoster.getGroupsNames(), mRoster
+			.getContactList());
 	    } catch (RemoteException e) {
-		// TODO Auto-generated catch block
 		e.printStackTrace();
 	    }
-	}
     }
 
     /**
@@ -178,7 +177,7 @@
 		Map<String, Contact> curChildMap = new HashMap<String, Contact>();
 		children.add(curChildMap);
 		Contact c = listContact.get(j);
-		Log.i(TAG, c.getID() + " " +c.getJID());
+		Log.i(TAG, c.getID() + " " + c.getJID());
 		curChildMap.put("CHILD", c);
 	    }
 	    childData.add(children);
@@ -245,25 +244,32 @@
 		switch (c.getStatus()) {
 		    case Contact.CONTACT_STATUS_AVAILABLE:
 			imageDrawable = (Drawable) getResources().getDrawable(
-				R.drawable.avatar);
+				R.drawable.online);
+			break;
 		    case Contact.CONTACT_STATUS_AVAILABLE_FOR_CHAT:
 			imageDrawable = (Drawable) getResources().getDrawable(
 				R.drawable.chat);
+			break;
 		    case Contact.CONTACT_STATUS_AWAY:
 			imageDrawable = (Drawable) getResources().getDrawable(
 				R.drawable.away);
+			break;
 		    case Contact.CONTACT_STATUS_BUSY:
 			imageDrawable = (Drawable) getResources().getDrawable(
 				R.drawable.dnd);
+			break;
 		    case Contact.CONTACT_STATUS_DISCONNECT:
 			imageDrawable = (Drawable) getResources().getDrawable(
 				R.drawable.offline);
+			break;
 		    case Contact.CONTACT_STATUS_UNAVAILABLE:
 			imageDrawable = (Drawable) getResources().getDrawable(
 				R.drawable.requested);
+			break;
 		    default:
 			imageDrawable = (Drawable) getResources().getDrawable(
 				R.drawable.error);
+			break;
 		}
 		imgV.setImageDrawable(imageDrawable);
 
@@ -292,4 +298,36 @@
 	    }
 	}
     }
+
+    private class BeemRosterListener extends IBeemRosterListener.Stub {
+
+	@Override
+	public void onEntriesAdded(List<String> addresses)
+		throws RemoteException {
+	    Log.i(TAG, "ENTRIES ADDED");
+
+	}
+
+	@Override
+	public void onEntriesDeleted(List<String> addresses)
+		throws RemoteException {
+	    Log.i(TAG, "ENTRIES DEL");
+
+	}
+
+	@Override
+	public void onEntriesUpdated(List<String> addresses)
+		throws RemoteException {
+	    Log.i(TAG, "ENTRIES UPD");
+
+	}
+
+	@Override
+	public void onPresenceChanged(PresenceAdapter presence)
+		throws RemoteException {
+	    Log.i(TAG, "PRESENCE CHANGED");
+
+	}
+
+    }
 }
\ No newline at end of file