# HG changeset patch # User Philippe Lago # Date 1245774988 -7200 # Node ID 3178dcbd170a43439f2e8e34188da8cbe1a48e1f # Parent f34b1da1c6688addcdec32ddef0fdfbb076e87a1# Parent 5a07bf00b2f842f0ab5ee1444d8058edebe85c0b merge avec marseille diff -r f34b1da1c668 -r 3178dcbd170a src/com/beem/project/beem/BeemApplication.java --- a/src/com/beem/project/beem/BeemApplication.java Tue Jun 23 18:35:10 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,287 +0,0 @@ -/** - * - */ -package com.beem.project.beem; - -import java.util.LinkedList; -import java.util.List; - -import android.app.Activity; -import android.app.Application; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; -import android.os.Handler; -import android.os.IBinder; -import android.os.Message; -import android.os.RemoteException; -import android.util.Log; - -import com.beem.project.beem.service.aidl.IBeemConnectionListener; -import com.beem.project.beem.service.aidl.IXmppConnection; -import com.beem.project.beem.service.aidl.IXmppFacade; -import com.beem.project.beem.utils.Status; - -/** - * The Beem application. This class has some methods utiliy needs by the activities. - * - * @author darisk - */ -public class BeemApplication extends Application { - - - private static final Intent SERVICE_INTENT = new Intent(); - private static BeemApplication mBeemApp; - static { - SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); - } - - /** - * Get the Beem application for an activity. - * - * @param activity - * the activity which want the Beem application - * @return the Beem application - */ - public static BeemApplication getApplication(Activity activity) { - if (mBeemApp == null) { - mBeemApp = new BeemApplication(); - } - mBeemApp.mActivity = activity; - - mBeemApp.mApplicationContext = activity.getApplication(); - activity.getResources(); - mBeemApp.onCreate(); - return mBeemApp; - } - - private Activity mActivity; - public static final String TAG = "BeemApplication"; - private IXmppFacade mFacade; - private Context mApplicationContext; - private final List mQueue = new LinkedList(); - - private boolean mIsConnected; - - private IXmppConnection mConnection; - - private final ConnectionListener mConnectionListener = new ConnectionListener(); - - private final ServiceConnection mServConn = new ServiceConnection() { - - @Override - public void onServiceConnected(ComponentName name, - IBinder service) { - mIsConnected = true; - mFacade = IXmppFacade.Stub.asInterface(service); - try { - mConnection = mFacade.createConnection(); - if (!mConnection.isAuthentificated()) { - mConnection - .addConnectionListener(mConnectionListener); - mApplicationContext - .startService(BeemApplication.SERVICE_INTENT); - } else { - synchronized (mQueue) { - for (Message msg : mQueue) { - msg.sendToTarget(); - } - mQueue.clear(); - } - } - } catch (RemoteException e) { - Log.e(TAG, "service connection exception", e); - } - } - - @Override - public void onServiceDisconnected(ComponentName name) { - mFacade = null; - mIsConnected = false; - } - }; - - /** - * Constructor. - */ - public BeemApplication() { - } - - /** - * Add a methode to execute when the application is connected to the server. - * - * @param target - * the handler which will execute the callback - * @param callback - * the callback to execute - */ - public void callWhenConnectedToServer(Handler target, Runnable callback) { - Message msg = Message.obtain(target, callback); - if (mIsConnected) { - msg.sendToTarget(); - } else { - startBeemService(); - synchronized (mQueue) { - mQueue.add(msg); - } - } - } - - /** - * Get the facade to use to access the Beem service. - * - * @return the facade or null if the application is not connected to the beem service. - */ - public IXmppFacade getXmppFacade() { - return mFacade; - } - - /** - * Tell if we are connected with the Beem Service. - * - * @return true if connected false otherwise - */ - public boolean isConnected() { - return mIsConnected; - } - - /** - * Start the beem service. - */ - public synchronized void startBeemService() { - if (!mIsConnected) { - ConnectionRunnable cRun = new ConnectionRunnable("Connecting..."); - mBeemApp.mActivity.runOnUiThread(cRun); - // the connection will be made on service connect - mApplicationContext.bindService(BeemApplication.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE); - } - } - - /** - * Stop the Beem service. - */ - public synchronized void stopBeemService() { - if (mIsConnected) { - Intent intent = new Intent(); - intent.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); - mApplicationContext.unbindService(mServConn); - mApplicationContext.stopService(intent); - mIsConnected = false; - } - } - - public synchronized void unbindBeemService() { - if (mIsConnected) { - mApplicationContext.unbindService(mServConn); - mIsConnected = false; - } - } - - /** - * Connection listener use to hide the progress dialog. - * - * @author darisk - */ - private class ConnectionListener extends IBeemConnectionListener.Stub { - - /** - * Constructor. - */ - public ConnectionListener() { - } - - /** - * {@inheritDoc} - */ - @Override - public void connectionClosed() throws RemoteException { - Log.e(TAG, "Connection Close"); - } - - /** - * {@inheritDoc} - */ - @Override - public void connectionClosedOnError() throws RemoteException { - Log.e(TAG, "ConnectionClosedOnError"); - // TODO afficher une notification et reafficher le progress dialog - } - - @Override - public void connectionFailed(String errorMsg) throws RemoteException { - Log.i(TAG, "Connection Failed"); - ConnectionRunnable cRun = new ConnectionRunnable(errorMsg); - mBeemApp.mActivity.runOnUiThread(cRun); - } - - /** - * {@inheritDoc} - */ - @Override - public void onConnect() throws RemoteException { - // TODO Auto-generated method stub - // TODO recuperer les informations de status dans les preferences - mFacade.changeStatus(Status.CONTACT_STATUS_AVAILABLE, null); - synchronized (mQueue) { - for (Message msg : mQueue) { - msg.sendToTarget(); - } - mQueue.clear(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void reconnectingIn(int seconds) throws RemoteException { - } - - /** - * {@inheritDoc} - */ - @Override - public void reconnectionFailed() throws RemoteException { - } - - /** - * {@inheritDoc} - */ - @Override - public void reconnectionSuccessful() throws RemoteException { - } - - } - - private class ConnectionRunnable implements Runnable { - - private String mErrorMsg; - - public ConnectionRunnable(String string) { - this.mErrorMsg = string; - } - - /** - * @return the mErrorMsg - */ - public String getMErrorMsg() { - return mErrorMsg; - } - - @Override - public void run() { - } - - /** - * @param mErrorMsg - * the mErrorMsg to set - */ - public void setMErrorMsg(String mErrorMsg) { - this.mErrorMsg = mErrorMsg; - } - - } - - -} diff -r f34b1da1c668 -r 3178dcbd170a src/com/beem/project/beem/BeemService.java --- a/src/com/beem/project/beem/BeemService.java Tue Jun 23 18:35:10 2009 +0200 +++ b/src/com/beem/project/beem/BeemService.java Tue Jun 23 18:36:28 2009 +0200 @@ -2,7 +2,6 @@ import org.jivesoftware.smack.ConnectionConfiguration; import org.jivesoftware.smack.PacketListener; -import org.jivesoftware.smack.PrivacyListManager; import org.jivesoftware.smack.Roster; import org.jivesoftware.smack.XMPPConnection; import org.jivesoftware.smack.Roster.SubscriptionMode; @@ -17,7 +16,6 @@ import android.app.PendingIntent; import android.app.Service; import android.content.Intent; -import android.content.ServiceConnection; import android.content.SharedPreferences; import android.os.IBinder; import android.os.RemoteException; diff -r f34b1da1c668 -r 3178dcbd170a src/com/beem/project/beem/service/RosterAdapter.java --- a/src/com/beem/project/beem/service/RosterAdapter.java Tue Jun 23 18:35:10 2009 +0200 +++ b/src/com/beem/project/beem/service/RosterAdapter.java Tue Jun 23 18:36:28 2009 +0200 @@ -222,7 +222,6 @@ * Constructor. */ public RosterListenerAdapter() { - // TODO Auto-generated constructor stub } /** diff -r f34b1da1c668 -r 3178dcbd170a src/com/beem/project/beem/ui/ContactDialog.java --- a/src/com/beem/project/beem/ui/ContactDialog.java Tue Jun 23 18:35:10 2009 +0200 +++ b/src/com/beem/project/beem/ui/ContactDialog.java Tue Jun 23 18:36:28 2009 +0200 @@ -46,7 +46,7 @@ button = (Button) findViewById(R.id.CDAlias); button.setOnClickListener(new aliasListener()); button = (Button) findViewById(R.id.CDDelete); - button.setOnClickListener(new groupListener()); + button.setOnClickListener(new deleteListener()); button = (Button) findViewById(R.id.CDResend); button.setOnClickListener(new resendListener()); button = (Button) findViewById(R.id.CDInfos); @@ -102,7 +102,7 @@ } - class groupListener implements View.OnClickListener { + class deleteListener implements View.OnClickListener { @Override public void onClick(View v) { diff -r f34b1da1c668 -r 3178dcbd170a src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Tue Jun 23 18:35:10 2009 +0200 +++ b/src/com/beem/project/beem/ui/ContactList.java Tue Jun 23 18:36:28 2009 +0200 @@ -52,7 +52,7 @@ private List groupName; private List mListContact; private Handler mHandler; - public IXmppFacade xmppFacade = null; + private IXmppFacade xmppFacade = null; private final ServiceConnection mServConn = new BeemServiceConnection(); private int REQUEST_CODE = 1; @@ -118,6 +118,8 @@ protected void onStop() { super.onStop(); unbindService(mServConn); + groupName.clear(); + groupMap.clear(); } class ComparatorContactListByName implements Comparator { @@ -146,7 +148,6 @@ for (String group : contact.getGroups()) { if (!groupMap.containsKey(group)) { groupMap.put(group, new ArrayList()); - Collections.sort(groupMap.get(group), new ComparatorContactListByStatusAndName()); groupName.add(group); } try { diff -r f34b1da1c668 -r 3178dcbd170a src/com/beem/project/beem/ui/Login.java --- a/src/com/beem/project/beem/ui/Login.java Tue Jun 23 18:35:10 2009 +0200 +++ b/src/com/beem/project/beem/ui/Login.java Tue Jun 23 18:36:28 2009 +0200 @@ -42,8 +42,6 @@ private final ServiceConnection mServConn = new BeemServiceConnection(); private IXmppFacade xmppFacade = null; - private int REQUEST_CODE = 1; - /** * Create an about "BEEM" dialog */