Merge.
--- a/AndroidManifest.xml Tue Jun 23 18:36:28 2009 +0200
+++ b/AndroidManifest.xml Tue Jun 23 19:22:46 2009 +0200
@@ -2,8 +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"
- android:icon="@drawable/signal" android:theme="@style/Theme.BEEM.Default">
+ <application android:label="@string/app_name" android:icon="@drawable/signal" android:theme="@style/Theme.BEEM.Default">
<activity android:name=".ui.Login" android:label="@string/app_name"
android:launchMode="singleTask">
<intent-filter>
--- a/res/layout/login.xml Tue Jun 23 18:36:28 2009 +0200
+++ b/res/layout/login.xml Tue Jun 23 19:22:46 2009 +0200
@@ -3,7 +3,10 @@
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:id="@+id/log_as_logo" android:src="@drawable/logo"
- android:layout_width="fill_parent" android:layout_height="wrap_content" />
+ android:layout_width="fill_parent" android:layout_height="wrap_content"
+ android:layout_marginBottom="25px" android:layout_marginTop="15px" />
+ <TextView android:id="@+id/log_as_msg" android:layout_width="fill_parent"
+ android:layout_height="wrap_content" android:gravity="center" />
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:gravity="bottom">
@@ -12,4 +15,5 @@
<Button android:id="@+id/log_as_login" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="Login" />
</LinearLayout>
+
</LinearLayout>
\ No newline at end of file
--- a/src/com/beem/project/beem/BeemService.java Tue Jun 23 18:36:28 2009 +0200
+++ b/src/com/beem/project/beem/BeemService.java Tue Jun 23 19:22:46 2009 +0200
@@ -245,7 +245,6 @@
@Override
public void onDestroy() {
super.onDestroy();
- Log.e("BEEEMSERVICE", "ONDESTROY");
closeConnection();
mNotificationManager.cancel(NOTIFICATION_STATUS_ID);
Log.e("BEEEMSERVICE", "ONDESTROY");
--- a/src/com/beem/project/beem/service/RosterAdapter.java Tue Jun 23 18:36:28 2009 +0200
+++ b/src/com/beem/project/beem/service/RosterAdapter.java Tue Jun 23 19:22:46 2009 +0200
@@ -27,8 +27,7 @@
* This class implement a Roster adapter for BEEM.
* @author darisk
*/
-public class RosterAdapter extends
- com.beem.project.beem.service.aidl.IRoster.Stub {
+public class RosterAdapter extends com.beem.project.beem.service.aidl.IRoster.Stub {
private static final String TAG = "RosterAdapter";
private Roster mAdaptee;
@@ -40,8 +39,7 @@
/**
* Constructor.
- * @param roster
- * the roster to adapt
+ * @param roster the roster to adapt
*/
public RosterAdapter(final Roster roster) {
mAdaptee = roster;
@@ -59,8 +57,7 @@
* {@inheritDoc}
*/
@Override
- public void addRosterListener(IBeemRosterListener listen)
- throws RemoteException {
+ public void addRosterListener(IBeemRosterListener listen) throws RemoteException {
if (listen != null)
mRemoteRosListeners.register(listen);
}
@@ -69,8 +66,7 @@
* {@inheritDoc}
*/
@Override
- public Contact addContact(String user, String name, String[] groups)
- throws RemoteException {
+ public Contact addContact(String user, String name, String[] groups) throws RemoteException {
Contact res = null;
RosterEntry contact = mAdaptee.getEntry(user);
if (contact != null) {
@@ -79,8 +75,7 @@
for (String groupStr : groups) {
boolean found = false;
for (RosterGroup group : mAdaptee.getGroups()) {
- if (group.getName().equals(groupStr)
- && !group.contains(contact)) {
+ if (group.getName().equals(groupStr) && !group.contains(contact)) {
try {
group.addEntry(contact);
res.addGroup(groupStr);
@@ -128,12 +123,14 @@
* {@inheritDoc}
*/
@Override
- public void deleteContact(Contact contact, String group)
- throws RemoteException {
+ public void deleteContact(Contact contact, String group) throws RemoteException {
mContacts.get(contact.getJID()).delGroup(group);
try {
- mAdaptee.getGroup(group).removeEntry(
- mAdaptee.getEntry(contact.getJID()));
+ if (mAdaptee != null) {
+ RosterEntry entry = mAdaptee.getEntry(contact.getJID());
+ if (entry != null)
+ mAdaptee.getGroup(group).removeEntry(entry);
+ }
} catch (XMPPException e) {
e.printStackTrace();
}
@@ -182,8 +179,7 @@
* {@inheritDoc}
*/
@Override
- public void removeRosterListener(IBeemRosterListener listen)
- throws RemoteException {
+ public void removeRosterListener(IBeemRosterListener listen) throws RemoteException {
if (listen != null)
mRemoteRosListeners.unregister(listen);
}
@@ -202,7 +198,7 @@
return new PresenceAdapter(mAdaptee.getPresence(jid));
}
- private Contact getContactFromRosterEntry(RosterEntry entry) {
+ private Contact getContactFromRosterEntry(RosterEntry entry) {
String user = StringUtils.parseBareAddress(entry.getUser());
Contact c = new Contact(user);
c.setStatus(mAdaptee.getPresence(user));
@@ -211,9 +207,9 @@
return c;
}
+
/**
- * Listener for the roster events. It will call the remote listeners
- * registered.
+ * Listener for the roster events. It will call the remote listeners registered.
* @author darisk
*/
private class RosterListenerAdapter implements RosterListener {
@@ -235,8 +231,7 @@
List<String> tab = new ArrayList<String>();
tab.addAll(addresses);
for (int i = 0; i < n; i++) {
- IBeemRosterListener listener = mRemoteRosListeners
- .getBroadcastItem(i);
+ IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
try {
listener.onEntriesAdded(tab);
} catch (RemoteException e) {
@@ -257,8 +252,7 @@
List<String> tab = new ArrayList<String>();
tab.addAll(addresses);
for (int i = 0; i < n; i++) {
- IBeemRosterListener listener = mRemoteRosListeners
- .getBroadcastItem(i);
+ IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
try {
listener.onEntriesDeleted(tab);
} catch (RemoteException e) {
@@ -279,8 +273,7 @@
List<String> tab = new ArrayList<String>();
tab.addAll(addresses);
for (int i = 0; i < n; i++) {
- IBeemRosterListener listener = mRemoteRosListeners
- .getBroadcastItem(i);
+ IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
try {
listener.onEntriesUpdated(tab);
} catch (RemoteException e) {
@@ -309,8 +302,7 @@
final int n = mRemoteRosListeners.beginBroadcast();
for (int i = 0; i < n; i++) {
- IBeemRosterListener listener = mRemoteRosListeners
- .getBroadcastItem(i);
+ IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
try {
listener.onPresenceChanged(new PresenceAdapter(presence));
} catch (RemoteException e) {
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Tue Jun 23 18:36:28 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Tue Jun 23 19:22:46 2009 +0200
@@ -113,7 +113,7 @@
try {
try {
PrivacyListManager.getInstanceFor(mAdaptee);
- } catch (NullPointerException e){
+ } catch (NullPointerException e) {
Log.e(TAG, "pas normal", e);
}
mAdaptee.connect();
@@ -130,7 +130,10 @@
return true;
} catch (XMPPException e) {
Log.e(TAG, "Error while connecting", e);
- mConListener.connectionFailed("Error On Connection");
+ if (e.getXMPPError() != null && e.getXMPPError().getMessage() != null)
+ mConListener.connectionFailed(e.getXMPPError().getMessage());
+ else
+ mConListener.connectionFailed("Error On Connection");
}
return false;
}
@@ -171,7 +174,7 @@
Roster adap = mAdaptee.getRoster();
if (adap == null)
return null;
- mRoster = new RosterAdapter(adap);
+ mRoster = new RosterAdapter(adap);
return mRoster;
}
@@ -210,6 +213,7 @@
private void triggerAsynchronousConnectEvent() {
mConListener.onConnect();
}
+
/**
* @param mPrivacyList the mPrivacyList to set
*/
@@ -223,6 +227,7 @@
public PrivacyListManagerAdapter getPrivacyList() {
return mPrivacyList;
}
+
/**
* Listener for XMPP connection events. It will calls the remote listeners for connexion events.
* @author darisk
--- a/src/com/beem/project/beem/ui/ContactList.java Tue Jun 23 18:36:28 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Tue Jun 23 19:22:46 2009 +0200
@@ -94,6 +94,7 @@
if (requestCode == REQUEST_CODE) {
if (resultCode == 69) {
stopService(new Intent(this, BeemService.class));
+ Log.e("CONTACTLIST", "STOPSERVICE");
finish();
startActivity(new Intent(this, Login.class));
}
@@ -117,6 +118,7 @@
@Override
protected void onStop() {
super.onStop();
+ Log.e("CONTACTLIST", "UNBINDSERVICE");
unbindService(mServConn);
groupName.clear();
groupMap.clear();
@@ -208,10 +210,9 @@
mHandler.post(new RunnableChange());
}
-
/**
- * TODO: sur la suppression de contact, on passe tt le temps dans entries updated ...
- * probleme comment reconnaitre si on supprime ou ajoute un contact ....
+ * TODO: sur la suppression de contact, on passe tt le temps dans entries updated ... probleme comment
+ * reconnaitre si on supprime ou ajoute un contact ....
*/
@Override
public void onEntriesUpdated(List<String> addresses) throws RemoteException {
--- a/src/com/beem/project/beem/ui/Login.java Tue Jun 23 18:36:28 2009 +0200
+++ b/src/com/beem/project/beem/ui/Login.java Tue Jun 23 19:22:46 2009 +0200
@@ -15,8 +15,10 @@
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
+import android.widget.TextView;
import android.widget.Toast;
+import com.beem.project.beem.BeemService;
import com.beem.project.beem.R;
import com.beem.project.beem.service.aidl.IBeemConnectionListener;
import com.beem.project.beem.service.aidl.IXmppConnection;
@@ -59,7 +61,7 @@
}
/**
- * {@inheritDoc}
+ * Create Login activity
*/
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -80,7 +82,6 @@
@Override
public void onClick(View v) {
bindService(Login.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
- Log.e("LOGIN", "bindService()");
}
});
@@ -90,8 +91,7 @@
@Override
protected void onDestroy() {
super.onDestroy();
- if (mIsConnected) {
- Log.e("LOGIN", "unbindService()");
+ if (mIsConnected || xmppFacade == null) {
unbindService(mServConn);
}
}
@@ -102,7 +102,7 @@
@Override
public void onStart() {
super.onStart();
- Log.e("Login", "bindService");
+ Log.e("LOGIN", "BINDSERVICE");
bindService(Login.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
}
@@ -125,24 +125,21 @@
@Override
public void connectionClosed() throws RemoteException {
- mIsConnected = false;
Log.e("Login", "CONNECTIONCLOSED");
- Login.this.unbindService(mServConn);
- Login.this.stopService(SERVICE_INTENT);
}
@Override
public void connectionClosedOnError() throws RemoteException {
- if (mIsConnected) {
- mIsConnected = false;
- Login.this.unbindService(mServConn);
- Login.this.stopService(SERVICE_INTENT);
- }
+ Log.e("Login", "CONNECTIONCLOSEONERROR");
}
@Override
public void connectionFailed(String errorMsg) throws RemoteException {
mIsConnected = false;
+ if (xmppFacade != null) {
+ Login.this.unbindService(mServConn);
+ Login.this.stopService(SERVICE_INTENT);
+ }
connectionHandler.post(new ErrorRunnable(errorMsg));
dismissProgressDialog();
showToast(errorMsg);
@@ -152,7 +149,9 @@
connectionHandler.post(new Runnable() {
@Override
public void run() {
- Toast.makeText(Login.this, errorMsg, Toast.LENGTH_SHORT).show();
+ Toast.makeText(Login.this, errorMsg, Toast.LENGTH_LONG).show();
+ TextView labelError = (TextView) findViewById(R.id.log_as_msg);
+ labelError.setText(errorMsg);
}
});
}
@@ -179,6 +178,7 @@
@Override
public void reconnectingIn(int seconds) throws RemoteException {
+ mIsConnected = true;
}
@@ -198,6 +198,7 @@
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
+ mIsConnected = true;
xmppFacade = IXmppFacade.Stub.asInterface(service);
try {
xmppConnection = xmppFacade.createConnection();
@@ -213,7 +214,6 @@
});
Login.this.startService(Login.SERVICE_INTENT);
} else {
- mIsConnected = true;
startActivity(new Intent(Login.this, ContactList.class));
finish();
}
@@ -224,8 +224,8 @@
@Override
public void onServiceDisconnected(ComponentName name) {
+ mIsConnected = false;
xmppFacade = null;
- mIsConnected = false;
}
}