Ajout de la partie de barbu. Mais c'est en dur.
authormarseille@KungFuh
Thu, 26 Mar 2009 20:29:35 +0100
changeset 42 a0baf41c24a1
parent 41 c537c1ea3636
child 43 4e7c6918b092
Ajout de la partie de barbu. Mais c'est en dur.
AndroidManifest.xml
res/layout/contactlist.xml
src/com/beem/project/beem/BeemService.java
src/com/beem/project/beem/ui/ContactList.java
--- a/AndroidManifest.xml	Thu Mar 26 18:26:13 2009 +0100
+++ b/AndroidManifest.xml	Thu Mar 26 20:29:35 2009 +0100
@@ -10,6 +10,7 @@
 			</intent-filter>
 		</activity>
 		<activity android:name=".ui.ContactList" android:label="@string/app_name" />
+		<activity android:name=".ui.SendIM" android:label="@string/app_name" />
 		<service android:name="BeemService" android:enabled="true"
 			android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_SERVICE">
 			<intent-filter>
--- a/res/layout/contactlist.xml	Thu Mar 26 18:26:13 2009 +0100
+++ b/res/layout/contactlist.xml	Thu Mar 26 20:29:35 2009 +0100
@@ -10,10 +10,15 @@
 		android:layout_width="wrap_content"
 		android:layout_height="wrap_content"/>
  
-     <TextView android:id="@+id/textchild"
+     <TextView android:id="@+id/textchild1"
          android:textSize="16sp"         
          android:paddingLeft="100sp"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"/>
-		
+         
+	<TextView android:id="@+id/textchild2"
+         android:textSize="16sp"         
+         android:paddingLeft="100sp"
+         android:layout_width="fill_parent"
+         android:layout_height="wrap_content"/>
  </LinearLayout>
--- a/src/com/beem/project/beem/BeemService.java	Thu Mar 26 18:26:13 2009 +0100
+++ b/src/com/beem/project/beem/BeemService.java	Thu Mar 26 20:29:35 2009 +0100
@@ -1,3 +1,4 @@
+
 /**
  * 
  */
--- a/src/com/beem/project/beem/ui/ContactList.java	Thu Mar 26 18:26:13 2009 +0100
+++ b/src/com/beem/project/beem/ui/ContactList.java	Thu Mar 26 20:29:35 2009 +0100
@@ -11,133 +11,84 @@
 import android.content.ServiceConnection;
 import android.os.Bundle;
 import android.os.IBinder;
-import android.os.RemoteException;
-import android.util.Log;
+import android.view.View;
 import android.widget.ExpandableListAdapter;
+import android.widget.ExpandableListView;
 import android.widget.SimpleExpandableListAdapter;
 
 import com.beem.project.beem.BeemService;
 import com.beem.project.beem.R;
-import com.beem.project.beem.service.Contact;
-import com.beem.project.beem.service.aidl.IBeemConnectionListener;
-import com.beem.project.beem.service.aidl.IRoster;
-import com.beem.project.beem.service.aidl.IXMPPConnection;
 import com.beem.project.beem.service.aidl.IXMPPFacade;
 
 public class ContactList extends ExpandableListActivity {
 
-    private static final String TAG = "CONTACTLIST_ACT";
-    
     private IXMPPFacade mService = null;
 
     @Override
     public void onCreate(Bundle saveBundle) {
-        super.onCreate(saveBundle);
-        bindService(new Intent(this, BeemService.class), mConnection,
-                BIND_AUTO_CREATE | BIND_DEBUG_UNBIND);
+	super.onCreate(saveBundle);
+	bindService(new Intent(this, BeemService.class), mConnection,
+		BIND_AUTO_CREATE | BIND_DEBUG_UNBIND);
+	showContactList();
     }
 
+    @Override
+    public boolean onChildClick(ExpandableListView parent,
+	    View v, int groupPosition, int childPosition, long id) {
+	startActivity(new Intent(this, SendIM.class));
+		return true;
+
+    };
+
     private void showContactList() {
-        ExpandableListAdapter Adapter;
-        
-        List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
-        List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
+	ExpandableListAdapter Adapter;
+
+	List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
+	List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
+
+	for (int i = 0; i < 2; i++) {
+	    Map<String, String> curGroupMap = new HashMap<String, String>();
+	    groupData.add(curGroupMap);
+	    curGroupMap.put("NAME", "Group " + i);
 
-        for (int i = 0; i < 2; i++) {
-            Map<String, String> curGroupMap = new HashMap<String, String>();
-            groupData.add(curGroupMap);
-            curGroupMap.put("NAME", "Group " + i);
-            
-            List<Map<String, String>> children = new ArrayList<Map<String, String>>();
-            for (int j = 0; j < 5; j++) {
-                Map<String, String> curChildMap = new HashMap<String, String>();
-                children.add(curChildMap);
-                curChildMap.put("NAOME CHILD", "Child " + j);                
-            }
-            childData.add(children);
-        }
+	    List<Map<String, String>> children = new ArrayList<Map<String, String>>();
+	    for (int j = 0; j < 5; j++) {
+		Map<String, String> curChildMap = new HashMap<String, String>();
+		children.add(curChildMap);
+		curChildMap.put("NAME CHILD", "Child " + j);
+		curChildMap.put("MSG", "Taper votre message perso");
+	    }
+	    childData.add(children);
+	}
 
-        Adapter = new SimpleExpandableListAdapter(this, 
-                groupData, R.layout.contactlistgroup,
-                new String[] {"NAME"}, new int[] {R.id.textgroup},
-                childData, R.layout.contactlist,
-                new String[] {"NAME CHILD"}, new int[] {R.id.textchild});
-        setListAdapter(Adapter);
+	Adapter = new SimpleExpandableListAdapter(this, groupData,
+		R.layout.contactlistgroup, new String[] { "NAME" },
+		new int[] { R.id.textgroup }, childData, R.layout.contactlist,
+		new String[] { "NAME CHILD", "MSG" }, new int[] {
+			R.id.textchild1, R.id.textchild2 });
+	setListAdapter(Adapter);
     }
 
     private ServiceConnection mConnection = new ServiceConnection() {
-        @Override
-        public void onServiceConnected(ComponentName name, IBinder service) {
-            mService = IXMPPFacade.Stub.asInterface(service);
-            try {
-		IXMPPConnection con = mService.createConnection();
-		con.addConnectionListener(new TestConnectionListener());
-		mService.connectSync();
-		Log.i("BEEM", "Connected !!!");
-	    } catch (RemoteException e) {
-		// TODO Auto-generated catch block
-		e.printStackTrace();
-	    }
-            
-            /*
-             * mService.getGroupList(); mService.getContactList();
-             */
-        }
+	@Override
+	public void onServiceConnected(ComponentName name, IBinder service) {
+	    mService = IXMPPFacade.Stub.asInterface(service);
+	    /*
+	     * mService.getGroupList(); mService.getContactList();
+	     */
+	    showContactList();
+	}
 
-        @Override
-        public void onServiceDisconnected(ComponentName name) {
-        }
+	@Override
+	public void onServiceDisconnected(ComponentName name) {
+	}
 
     };
 
     @Override
     public void onDestroy() {
-        super.onDestroy();
-        unbindService(mConnection);
+	super.onDestroy();
+	unbindService(mConnection);
     }
 
-    private class TestConnectionListener extends IBeemConnectionListener.Stub {
-
-	@Override
-	public void connectionClosed() throws RemoteException {
-	    // TODO Auto-generated method stub
-	    
-	}
-
-	@Override
-	public void connectionClosedOnError() throws RemoteException {
-	    // TODO Auto-generated method stub
-	    
-	}
-
-	@Override
-	public void onConnect() throws RemoteException {
-	    // TODO Auto-generated method stub
-	    IRoster roster = mService.getRoster();
-	    for (Contact contact : roster.getContactList()) {
-		Log.v(TAG,"Contact name " + contact.getJID() );
-	    }
-	    showContactList();
-	}
-
-	@Override
-	public void reconnectingIn(int seconds) throws RemoteException {
-	    // TODO Auto-generated method stub
-	    
-	}
-
-	@Override
-	public void reconnectionFailed() throws RemoteException {
-	    // TODO Auto-generated method stub
-	    
-	}
-
-	@Override
-	public void reconnectionSuccessful() throws RemoteException {
-	    // TODO Auto-generated method stub
-	    
-	}
-	
-    } 
-    
 }