--- a/AndroidManifest.xml Fri Sep 25 15:22:26 2009 +0200
+++ b/AndroidManifest.xml Fri Sep 25 17:57:55 2009 +0200
@@ -10,18 +10,38 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ <intent-filter android:label="Beem Connection">
+ <action
+ android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+ </intent-filter>
</activity>
<activity android:name=".ui.SendIM" android:label="@string/SendIMActTitle"
- android:launchMode="singleTop" />
- <activity android:name=".ui.ChangeStatus" android:label="@string/ChangeStatusActTitle" />
- <activity android:name=".ui.AddContact" android:label="@string/AddCActTitle" />
+ android:launchMode="singleTop">
+ <intent-filter android:label="Beem Connection">
+ <action
+ android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+ </intent-filter>
+ </activity>
+ <activity android:name=".ui.ChangeStatus" android:label="@string/ChangeStatusActTitle">
+ <intent-filter android:label="Beem Connection">
+ <action
+ android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+ </intent-filter>
+ </activity>
+ <activity android:name=".ui.AddContact" android:label="@string/AddCActTitle">
+ <intent-filter android:label="Beem Connection">
+ <action
+ android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+ </intent-filter>
+ </activity>
<activity android:name=".ui.Subscription" android:label="@string/app_name" />
<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">
<intent-filter android:label="Beem Connection">
- <action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+ <action
+ android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
</intent-filter>
</activity>
<activity android:name=".jingle.demo.JingleCallActivity" android:label="JingleDemoCall">
--- a/src/com/beem/project/beem/jingle/JingleService.java Fri Sep 25 15:22:26 2009 +0200
+++ b/src/com/beem/project/beem/jingle/JingleService.java Fri Sep 25 17:57:55 2009 +0200
@@ -40,9 +40,6 @@
mMediaManagers = new ArrayList<JingleMediaManager>();
mMediaManagers.add(new MicrophoneRTPManager(bt));
- mJingleManager = new JingleManager(xmppConnection, mMediaManagers);
- mJingleManager.addJingleSessionRequestListener(new BeemJingleSessionRequestListener());
-
}
/**
--- a/src/com/beem/project/beem/ui/AddContact.java Fri Sep 25 15:22:26 2009 +0200
+++ b/src/com/beem/project/beem/ui/AddContact.java Fri Sep 25 17:57:55 2009 +0200
@@ -4,8 +4,11 @@
import java.util.List;
import java.util.regex.Pattern;
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.os.Bundle;
import android.os.IBinder;
@@ -18,8 +21,8 @@
import android.widget.Toast;
import com.beem.project.beem.BeemService;
import com.beem.project.beem.R;
+import com.beem.project.beem.service.XmppConnectionAdapter;
import com.beem.project.beem.service.aidl.IXmppFacade;
-
/**
* This activity is used to add a contact.
* @author nikita
@@ -30,6 +33,12 @@
private final List<String> mGroup = new ArrayList<String>();
private IXmppFacade mXmppFacade;
private final ServiceConnection mServConn = new BeemServiceConnection();
+ private BroadcastReceiver mReceiver;
+
+ private static final Intent SERVICE_INTENT = new Intent();
+ static {
+ SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
+ }
/**
* Constructor.
@@ -45,7 +54,7 @@
setContentView(R.layout.addcontact);
Button ok = (Button) findViewById(R.id.addc_ok);
ok.setOnClickListener(mOkListener);
- bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
+ mReceiver = new BeemBroadcastReceiver();
}
/**
@@ -56,6 +65,25 @@
super.onStop();
unbindService(mServConn);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void onResume() {
+ super.onResume();
+ this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED));
+ bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void onPause() {
+ super.onPause();
+ this.unregisterReceiver(mReceiver);
+ }
/**
* The ServiceConnection used to connect to the Beem service.
@@ -101,7 +129,7 @@
boolean isEmail = Pattern.matches("[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,4}", login);
if (!isEmail) {
Toast.makeText(AddContact.this, getString(R.string.AddCContactAddedLoginError), Toast.LENGTH_SHORT)
- .show();
+ .show();
return;
}
String alias;
@@ -113,13 +141,13 @@
if (mXmppFacade.getRoster().getContact(login) != null)
mGroup.addAll(mXmppFacade.getRoster().getContact(login).getGroups());
if (mXmppFacade.getRoster().addContact(login, alias,
- mGroup.toArray(new String[mGroup.size()])) == null) {
+ mGroup.toArray(new String[mGroup.size()])) == null) {
Toast.makeText(AddContact.this, getString(R.string.AddCContactAddedError), Toast.LENGTH_SHORT)
- .show();
+ .show();
return;
} else {
Toast.makeText(AddContact.this, getString(R.string.AddCContactAdded), Toast.LENGTH_SHORT)
- .show();
+ .show();
finish();
}
}
@@ -130,4 +158,14 @@
}
};
+
+ private class BeemBroadcastReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.d(TAG, "broadcast received");
+ stopService(SERVICE_INTENT);
+ startActivity(new Intent(AddContact.this, Login.class));
+ finish();
+ }
+ }
}
--- a/src/com/beem/project/beem/ui/ContactList.java Fri Sep 25 15:22:26 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Fri Sep 25 17:57:55 2009 +0200
@@ -66,6 +66,11 @@
private final ServiceConnection mServConn = new BeemServiceConnection();
private BroadcastReceiver mReceiver;
+ private static final Intent SERVICE_INTENT = new Intent();
+ static {
+ SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
+ }
+
/**
* Constructor.
*/
@@ -152,7 +157,6 @@
*/
@Override
protected void onStop() {
- Log.e(TAG, "UNBINSERVICE");
super.onStop();
unbindService(mServConn);
}
@@ -499,7 +503,7 @@
break;
default:
imageDrawable = getResources().getDrawable(R.drawable.error);
- break;
+ break;
}
imgV.setImageDrawable(imageDrawable);
@@ -640,12 +644,12 @@
}
private class BeemBroadcastReceiver extends BroadcastReceiver {
-
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "broadcast received");
-
+ stopService(SERVICE_INTENT);
+ startActivity(new Intent(ContactList.this, Login.class));
+ finish();
}
-
}
}
--- a/src/com/beem/project/beem/ui/Login.java Fri Sep 25 15:22:26 2009 +0200
+++ b/src/com/beem/project/beem/ui/Login.java Fri Sep 25 17:57:55 2009 +0200
@@ -3,7 +3,9 @@
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
+import android.content.BroadcastReceiver;
import android.content.ComponentName;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
@@ -46,6 +48,7 @@
private SharedPreferences mSettings;
private boolean mIsConfigured;
+ private BroadcastReceiver mReceiver;
/**
* Constructor.
@@ -78,6 +81,7 @@
mSettings = getSharedPreferences(getString(R.string.settings_filename), MODE_PRIVATE);
setContentView(R.layout.login);
mProgressDialog = new ProgressDialog(this);
+ mReceiver = new BeemBroadcastReceiver();
}
@Override
@@ -172,12 +176,12 @@
*/
@Override
public void connectionClosed() throws RemoteException {
- mIsConnected = false;
+ /*mIsConnected = false;
if (mXmppFacade != null) {
Login.this.unbindService(mServConn);
Login.this.stopService(SERVICE_INTENT);
mXmppFacade = null;
- }
+ }*/
}
@Override
@@ -303,5 +307,15 @@
mXmppFacade = null;
}
}
+
+ private class BeemBroadcastReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ unbindService(mServConn);
+ stopService(SERVICE_INTENT);
+ mIsConnected = false;
+ mXmppFacade = null;
+ }
+ }
}
--- a/src/com/beem/project/beem/ui/SendIM.java Fri Sep 25 15:22:26 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java Fri Sep 25 17:57:55 2009 +0200
@@ -5,8 +5,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.content.SharedPreferences;
import android.graphics.drawable.Drawable;
@@ -33,6 +36,7 @@
import com.beem.project.beem.service.Contact;
import com.beem.project.beem.service.Message;
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.IChat;
import com.beem.project.beem.service.aidl.IChatManager;
@@ -69,6 +73,12 @@
private final ServiceConnection mServConn = new BeemServiceConnection();
private IXmppFacade mXmppFacade;
private TextView mStatusText;
+ private BroadcastReceiver mReceiver;
+
+ private static final Intent SERVICE_INTENT = new Intent();
+ static {
+ SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
+ }
/**
* Constructor.
@@ -115,6 +125,7 @@
mScrolling = (ScrollView) findViewById(R.id.sendimscroll);
mStatusText = (TextView) findViewById(R.id.sendimstatus);
setViewHeader();
+ mReceiver = new BeemBroadcastReceiver();
}
/**
@@ -211,11 +222,11 @@
// TODO start the jingle call
// Bug a besoin du jid complet (resource compris)
try {
- mXmppFacade.call(mContact.getJID());
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ mXmppFacade.call(mContact.getJID());
+ } catch (RemoteException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
return true;
default:
return false;
@@ -228,6 +239,7 @@
@Override
protected void onPause() {
super.onPause();
+ this.unregisterReceiver(mReceiver);
try {
if (mChat != null)
mChat.setOpen(false);
@@ -243,6 +255,7 @@
@Override
protected void onResume() {
super.onResume();
+ this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED));
bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
mScrolling.fullScroll(ScrollView.FOCUS_DOWN);
}
@@ -262,7 +275,6 @@
e.printStackTrace();
}
setViewHeader();
-
}
/**
@@ -429,10 +441,10 @@
}
@Override
- public void onEntryDeleteFromGroup(String group, String jid) throws RemoteException {
+ public void onEntryDeleteFromGroup(String group, String jid) throws RemoteException {
// TODO Auto-generated method stub
- }
+ }
@Override
public void onPresenceChanged(PresenceAdapter presence) throws RemoteException {
@@ -523,4 +535,13 @@
}
}
+ private class BeemBroadcastReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.d(TAG, "broadcast received");
+ stopService(SERVICE_INTENT);
+ startActivity(new Intent(SendIM.this, Login.class));
+ finish();
+ }
+ }
}