# HG changeset patch # User marseille@marseille-desktop # Date 1237498048 -3600 # Node ID b9f4a0ef574a998479bba4999cdb41625cd0282e # Parent 213b84d2e74315e02e15017d40c8c4c302046c7f Contact List OK. A faire jolie ... Je me comprend ! diff -r 213b84d2e743 -r b9f4a0ef574a AndroidManifest.xml --- a/AndroidManifest.xml Thu Mar 19 12:40:29 2009 +0100 +++ b/AndroidManifest.xml Thu Mar 19 22:27:28 2009 +0100 @@ -11,6 +11,8 @@ + + diff -r 213b84d2e743 -r b9f4a0ef574a res/drawable/avatar.png Binary file res/drawable/avatar.png has changed diff -r 213b84d2e743 -r b9f4a0ef574a res/layout/contactlist.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/res/layout/contactlist.xml Thu Mar 19 22:27:28 2009 +0100 @@ -0,0 +1,19 @@ + + + + + + + + diff -r 213b84d2e743 -r b9f4a0ef574a res/layout/contactlistgroup.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/res/layout/contactlistgroup.xml Thu Mar 19 22:27:28 2009 +0100 @@ -0,0 +1,16 @@ + + + + + + diff -r 213b84d2e743 -r b9f4a0ef574a src/com/beem/project/beem/Beem.java --- a/src/com/beem/project/beem/Beem.java Thu Mar 19 12:40:29 2009 +0100 +++ b/src/com/beem/project/beem/Beem.java Thu Mar 19 22:27:28 2009 +0100 @@ -4,6 +4,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; +import android.util.Log; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; @@ -25,13 +26,13 @@ setContentView(R.layout.main); mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE); showJID(); + Button btConnection = (Button) findViewById(R.id.connection); btConnection.setOnClickListener(new OnClickListener() { - +; @Override public void onClick(View v) { - // TODO Auto-generated method stub - startService(new Intent(Beem.this,BeemService.class)); + startActivity(new Intent(Beem.this, UIContactList.class)); } }); } diff -r 213b84d2e743 -r b9f4a0ef574a src/com/beem/project/beem/BeemService.java --- a/src/com/beem/project/beem/BeemService.java Thu Mar 19 12:40:29 2009 +0100 +++ b/src/com/beem/project/beem/BeemService.java Thu Mar 19 22:27:28 2009 +0100 @@ -8,96 +8,125 @@ import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.XMPPException; -import com.beem.project.beem.service.IXMPPFacade; - import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.Intent; import android.content.SharedPreferences; -import android.content.res.Resources; import android.os.IBinder; import android.os.RemoteException; -import android.widget.TextView; import android.widget.Toast; +import com.beem.project.beem.service.IXMPPFacade; + /** * @author darisk - * + * */ public class BeemService extends Service { private NotificationManager notificationManager; private XMPPConnection connection; + private SharedPreferences settings; + private String login; + private String password; + private String host; - + private IXMPPFacade.Stub bind = new IXMPPFacade.Stub() { - + @Override public List getContactList() throws RemoteException { - // TODO Auto-generated method stub - return null; + return null; + } + + @Override + public List getGroupList() throws RemoteException { + return null; } }; - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see android.app.Service#onBind(android.content.Intent) */ @Override public IBinder onBind(Intent arg0) { - // TODO Auto-generated method stub - return null; + try { + connection = new XMPPConnection("10.0.2.2"); // address du pc host + // de l'emulateur + connection.connect(); + connection.login(login, password); + notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + showBasicNotification(R.string.BeemServiceCreated); + } catch (XMPPException e) { + // TODO Auto-generated catch block + Toast toast = Toast.makeText(this, "ERREUR " + e.getMessage(), + Toast.LENGTH_LONG); + toast.show(); + notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + showBasicNotification(R.string.PreferenceFileName); + } + return bind; } - + private void showBasicNotification(int stringResource) { - String text = (String) getText(stringResource); - Notification notif = new Notification(R.drawable.logo, text, System.currentTimeMillis()); - notif.defaults = Notification.DEFAULT_ALL; - notif.setLatestEventInfo(this, text, text, PendingIntent.getActivity(this, 0, new Intent(),0)); - notificationManager.notify(stringResource, notif); - Toast toast = Toast.makeText(this, R.string.BeemServiceCreated, Toast.LENGTH_LONG); - toast.show(); + String text = (String) getText(stringResource); + Notification notif = new Notification(R.drawable.logo, text, System + .currentTimeMillis()); + notif.defaults = Notification.DEFAULT_ALL; + notif.setLatestEventInfo(this, text, text, PendingIntent.getActivity( + this, 0, new Intent(), 0)); + notificationManager.notify(stringResource, notif); + Toast toast = Toast.makeText(this, R.string.BeemServiceCreated, + Toast.LENGTH_LONG); + toast.show(); } - + @Override - public void onCreate(){ - super.onCreate(); - settings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE); - login = settings.getString(getString(R.string.PreferenceLoginKey), ""); - password = settings.getString(getString(R.string.PreferencePasswordKey), ""); - host = settings.getString(getString(R.string.PreferenceHostKey), ""); + public void onCreate() { + super.onCreate(); + settings = getSharedPreferences(getString(R.string.PreferenceFileName), + MODE_PRIVATE); + login = settings.getString(getString(R.string.PreferenceLoginKey), ""); + password = settings.getString( + getString(R.string.PreferencePasswordKey), ""); + host = settings.getString(getString(R.string.PreferenceHostKey), ""); } - + @Override public void onStart(Intent intent, int startId) { - try { - connection = new XMPPConnection("10.0.2.2"); // address du pc host de l'emulateur - connection.connect(); - connection.login(login, password); - notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - showBasicNotification(R.string.BeemServiceCreated); - } catch (XMPPException e) { - // TODO Auto-generated catch block - Toast toast = Toast.makeText(this, "ERREUR " + e.getMessage(), Toast.LENGTH_LONG); - toast.show(); - e.printStackTrace(); - } + try { + connection = new XMPPConnection("10.0.2.2"); // address du pc host + // de l'emulateur + connection.connect(); + connection.login(login, password); + notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + showBasicNotification(R.string.BeemServiceCreated); + } catch (XMPPException e) { + // TODO Auto-generated catch block + Toast toast = Toast.makeText(this, "ERREUR " + e.getMessage(), + Toast.LENGTH_LONG); + toast.show(); + notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + showBasicNotification(R.string.PreferenceFileName); + } } - + private void closeConnection() { - if (connection != null) - connection.disconnect(); + if (connection != null) + connection.disconnect(); } - + @Override public void onDestroy() { - closeConnection(); - showBasicNotification(R.string.BeemServiceDestroyed); - } + closeConnection(); + } } diff -r 213b84d2e743 -r b9f4a0ef574a src/com/beem/project/beem/UIContactList.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/UIContactList.java Thu Mar 19 22:27:28 2009 +0100 @@ -0,0 +1,81 @@ +package com.beem.project.beem; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.beem.project.beem.service.IXMPPFacade; + +import android.app.ExpandableListActivity; +import android.content.ComponentName; +import android.content.Intent; +import android.content.ServiceConnection; +import android.os.Bundle; +import android.os.IBinder; +import android.util.Log; +import android.widget.ExpandableListAdapter; +import android.widget.SimpleExpandableListAdapter; + +public class UIContactList extends ExpandableListActivity { + + 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); + showContactList(); + } + + private void showContactList() { + ExpandableListAdapter Adapter; + List> groupData = new ArrayList>(); + List>> childData = new ArrayList>>(); + + for (int i = 0; i < 2; i++) { + Map curGroupMap = new HashMap(); + groupData.add(curGroupMap); + curGroupMap.put("NAME", "Group " + i); + + List> children = new ArrayList>(); + for (int j = 0; j < 5; j++) { + Map curChildMap = new HashMap(); + children.add(curChildMap); + curChildMap.put("NAME CHILD", "Child " + j); + } + 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); + } + + private ServiceConnection mConnection = new ServiceConnection() { + @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 onDestroy() { + super.onDestroy(); + unbindService(mConnection); + } + +} diff -r 213b84d2e743 -r b9f4a0ef574a src/com/beem/project/beem/service/IXMPPFacade.aidl --- a/src/com/beem/project/beem/service/IXMPPFacade.aidl Thu Mar 19 12:40:29 2009 +0100 +++ b/src/com/beem/project/beem/service/IXMPPFacade.aidl Thu Mar 19 22:27:28 2009 +0100 @@ -7,5 +7,6 @@ // org.jivesoftware.smack.XMPPConnection getXMPPConnection(); List getContactList(); + List getGroupList(); }