petit commit pour bundle
authorNikita Kozlov <nikita@beem-project.com>
Thu, 24 Sep 2009 19:38:56 +0200
changeset 380 9416b5711edd
parent 377 5f60caa9f85c
child 381 166db9c93335
petit commit pour bundle
AndroidManifest.xml
default.properties
src/com/beem/project/beem/service/XmppConnectionAdapter.java
src/com/beem/project/beem/ui/ContactList.java
--- a/AndroidManifest.xml	Thu Sep 24 17:35:59 2009 +0200
+++ b/AndroidManifest.xml	Thu Sep 24 19:38:56 2009 +0200
@@ -2,7 +2,8 @@
 <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:icon="@drawable/signal" android:theme="@style/Theme.BEEM.Default" android:debuggable="true">
+	<application android:label="@string/app_name" android:icon="@drawable/signal"
+		android:theme="@style/Theme.BEEM.Default" android:debuggable="true">
 		<activity android:name=".ui.Login" android:label="@string/app_name"
 			android:launchMode="singleTask">
 			<intent-filter>
@@ -18,7 +19,11 @@
 		<activity android:name=".ui.EditSettings" android:label="@string/edit_settings_name" />
 		<activity android:name=".ui.CreateAccount" android:label="@string/create_account_name" />
 		<activity android:name=".ui.ContactList" android:label="@string/contact_list_name"
-			android:launchMode="singleTask" />
+			android:launchMode="singleTask">
+			<intent-filter android:label="Beem Connection">
+				<action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+			</intent-filter>
+		</activity>
 		<service android:name="BeemService" android:enabled="true"
 			android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_SERVICE">
 			<intent-filter>
--- a/default.properties	Thu Sep 24 17:35:59 2009 +0200
+++ b/default.properties	Thu Sep 24 19:38:56 2009 +0200
@@ -8,7 +8,7 @@
 # project structure.
 
 # Project target.
-target=android-3
+target=android-4
 # apk configurations. This property allows creation of APK files with limited
 # resources. For example, if your application contains many locales and
 # you wish to release multiple smaller apks instead of a large one, you can
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Thu Sep 24 17:35:59 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Thu Sep 24 19:38:56 2009 +0200
@@ -35,6 +35,7 @@
 public class XmppConnectionAdapter extends IXmppConnection.Stub {
 
     private static final String TAG = "XMPPConnectionAdapter";
+    public static final String BEEM_CONNECTION_CLOSED = "BeemConnectionClosed";
     private XMPPConnection mAdaptee;
     private IChatManager mChatManager;
     private String mLogin;
@@ -253,6 +254,8 @@
      */
     private class ConnexionListenerAdapter implements ConnectionListener {
 
+	
+
 	/**
 	 * Defaut constructor.
 	 */
@@ -280,6 +283,8 @@
 		}
 	    }
 	    mRemoteConnListeners.finishBroadcast();
+	    Intent closedIntent = new Intent(BEEM_CONNECTION_CLOSED);
+	    mService.sendBroadcast(closedIntent);
 	}
 
 	/**
--- a/src/com/beem/project/beem/ui/ContactList.java	Thu Sep 24 17:35:59 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Thu Sep 24 19:38:56 2009 +0200
@@ -7,9 +7,11 @@
 import org.jivesoftware.smack.util.StringUtils;
 
 import android.app.Activity;
+import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
+import android.content.IntentFilter;
 import android.content.ServiceConnection;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
@@ -25,7 +27,6 @@
 import android.view.ViewGroup;
 import android.widget.AdapterView;
 import android.widget.BaseAdapter;
-import android.widget.Button;
 import android.widget.Gallery;
 import android.widget.ImageView;
 import android.widget.ListView;
@@ -37,10 +38,10 @@
 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.XmppConnectionAdapter;
 import com.beem.project.beem.service.aidl.IBeemRosterListener;
 import com.beem.project.beem.service.aidl.IRoster;
 import com.beem.project.beem.service.aidl.IXmppFacade;
-import com.beem.project.beem.utils.PresenceType;
 import com.beem.project.beem.utils.Status;
 
 /**
@@ -72,6 +73,7 @@
 	setContentView(R.layout.contactlist);
 	mAdapter = new BeemContactList(this);
 	mHandler = new Handler();
+	this.registerReceiver(new BeemBroadcastReceiver(), new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED));
 
     }
 
@@ -426,13 +428,13 @@
 	public void onEntriesUpdated(List<String> addresses) throws RemoteException {
 	    mHandler.post(new RunnableChange());
 	}
-	
+
 	@Override
-        public void onEntryDeleteFromGroup(String group, String jid)
-                throws RemoteException {
+	public void onEntryDeleteFromGroup(String group, String jid)
+	throws RemoteException {
 	    // TODO Auto-generated method stub
-	    
-        }
+
+	}
 	/**
 	 * {@inheritDoc}
 	 */
@@ -445,11 +447,11 @@
 		if (curContact.getJID().equals(StringUtils.parseBareAddress(from))) {
 		    String pres = StringUtils.parseResource(from);
 		    for (String res : curContact.getMRes()) {
-	                if (res.equals(pres)) {
-	                    resfound = true;
-	                    break;
-	                }
-                    }
+			if (res.equals(pres)) {
+			    resfound = true;
+			    break;
+			}
+		    }
 		    curContact.setStatus(mRoster.getPresence(StringUtils.parseBareAddress(presence.getFrom())));
 		    int status = presence.getStatus();
 		    if (!resfound &&  (status != Status.CONTACT_STATUS_DISCONNECT && status != Status.CONTACT_STATUS_UNAVAILABLE))
@@ -462,7 +464,7 @@
 	    }
 	}
 
-	
+
     }
 
     /**
@@ -652,6 +654,7 @@
 	    } catch (RemoteException e) {
 		e.printStackTrace();
 	    }
+
 	}
 
 	@Override
@@ -665,4 +668,14 @@
 	    mRoster = null;
 	}
     }
+
+    private class BeemBroadcastReceiver extends BroadcastReceiver {
+
+	@Override
+	public void onReceive(Context context, Intent intent) {
+	    Log.d(TAG, "broadcast received");
+
+	}
+
+    }
 }