--- a/res/values-en/strings.xml Fri Sep 25 19:00:34 2009 +0200
+++ b/res/values-en/strings.xml Fri Sep 25 19:01:30 2009 +0200
@@ -92,6 +92,9 @@
<!-- BeemChatManager -->
<string name="BeemChatManagerNewMessage">You have got a new message</string>
+ <!-- BeemBroadcastReceiver class -->
+ <string name="BeemBroadcastReceiverDisconnect">You have been disconnected</string>
+
<!--
Services
-->
--- a/res/values-fr/strings.xml Fri Sep 25 19:00:34 2009 +0200
+++ b/res/values-fr/strings.xml Fri Sep 25 19:01:30 2009 +0200
@@ -87,9 +87,12 @@
<!-- ContactList class -->
<string name="ConListNotConnected">Non connecté</string>
- <!-- BeemChatManager -->
+ <!-- BeemChatManager class -->
<string name="BeemChatManagerNewMessage">Vous avez reçu un nouveau message</string>
+ <!-- BeemBroadcastReceiver class -->
+ <string name="BeemBroadcastReceiverDisconnect">Vous avez été déconnecté</string>
+
<!--
Services
-->
--- a/src/com/beem/project/beem/BeemService.java Fri Sep 25 19:00:34 2009 +0200
+++ b/src/com/beem/project/beem/BeemService.java Fri Sep 25 19:01:30 2009 +0200
@@ -107,7 +107,7 @@
Log.e("BEEMSERVICE", "ONBIND()");
return mBind;
}
-
+
/**
* {@inheritDoc}
*/
@@ -182,8 +182,6 @@
}
public void initJingle(XMPPConnection adaptee) {
- mJingle.initWhenConntected(adaptee);
-
+ mJingle.initWhenConntected(adaptee);
}
-
}
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Fri Sep 25 19:00:34 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Fri Sep 25 19:01:30 2009 +0200
@@ -269,7 +269,7 @@
public void connectionClosed() {
mRoster = null;
- final int n = mRemoteConnListeners.beginBroadcast();
+ /*final int n = mRemoteConnListeners.beginBroadcast();
for (int i = 0; i < n; i++) {
IBeemConnectionListener listener = mRemoteConnListeners.getBroadcastItem(i);
@@ -282,9 +282,10 @@
Log.w(TAG, "Error while triggering remote connection listeners", e);
}
}
- mRemoteConnListeners.finishBroadcast();
+ mRemoteConnListeners.finishBroadcast();*/
Intent closedIntent = new Intent(BEEM_CONNECTION_CLOSED);
mService.sendBroadcast(closedIntent);
+ mService.stopSelf();
}
/**
--- a/src/com/beem/project/beem/ui/AddContact.java Fri Sep 25 19:00:34 2009 +0200
+++ b/src/com/beem/project/beem/ui/AddContact.java Fri Sep 25 19:01:30 2009 +0200
@@ -3,10 +3,10 @@
import java.util.ArrayList;
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;
@@ -19,10 +19,12 @@
import android.widget.Button;
import android.widget.EditText;
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;
+import com.beem.project.beem.utils.BeemBroadcastReceiver;
/**
* This activity is used to add a contact.
* @author nikita
@@ -158,14 +160,4 @@
}
};
-
- 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/ChangeStatus.java Fri Sep 25 19:00:34 2009 +0200
+++ b/src/com/beem/project/beem/ui/ChangeStatus.java Fri Sep 25 19:01:30 2009 +0200
@@ -3,7 +3,6 @@
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;
@@ -24,6 +23,7 @@
import com.beem.project.beem.R;
import com.beem.project.beem.service.XmppConnectionAdapter;
import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.utils.BeemBroadcastReceiver;
import com.beem.project.beem.utils.Status;
public class ChangeStatus extends Activity {
@@ -199,13 +199,4 @@
return (!mStatusText.getText().toString().equals(getPreferenceString(R.string.PreferenceStatusText)));
}
}
-
- private class BeemBroadcastReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- stopService(SERVICE_INTENT);
- finish();
- }
- }
-
}
--- a/src/com/beem/project/beem/ui/ContactList.java Fri Sep 25 19:00:34 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Fri Sep 25 19:01:30 2009 +0200
@@ -1,6 +1,5 @@
package com.beem.project.beem.ui;
-import java.security.spec.MGF1ParameterSpec;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -46,6 +45,7 @@
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.BeemBroadcastReceiver;
import com.beem.project.beem.utils.Status;
/**
@@ -53,12 +53,13 @@
*/
public class ContactList extends Activity {
- private static final String TAG = "CONTACTLIST_ACT";
+ //private static final String TAG = "CONTACTLIST_ACT";
private static final int REQUEST_CODE = 1;
- private BeemContactList mAdapter;
+ private BeemContactList mAdapterContactList;
+ private BeemBanner mAdapterBanner;
private IRoster mRoster;
private List<Contact> mListContact = new ArrayList<Contact>();
- private List<String> mListGroup;
+ private List<String> mListGroup = new ArrayList<String>();
private Map<String, List<Contact>> mContactOnGroup = new HashMap<String, List<Contact>>();
private String mCurGroup;
private Handler mHandler;
@@ -85,7 +86,8 @@
protected void onCreate(Bundle saveBundle) {
super.onCreate(saveBundle);
setContentView(R.layout.contactlist);
- mAdapter = new BeemContactList(this);
+ mAdapterContactList = new BeemContactList(this);
+ mAdapterBanner = new BeemBanner(this);
mHandler = new Handler();
mReceiver = new BeemBroadcastReceiver();
}
@@ -146,7 +148,6 @@
if (requestCode == REQUEST_CODE) {
if (resultCode == 69) {
finish();
- stopService(new Intent(this, BeemService.class));
startActivity(new Intent(this, Login.class));
}
}
@@ -170,12 +171,6 @@
unbindService(mServConn);
}
- @Override
- public void onContentChanged() {
- super.onContentChanged();
- Log.i("OO", "CHANGED");
- }
-
/**
* Comparator Contact by Name.
*/
@@ -234,13 +229,13 @@
ListView listView = (ListView) findViewById(R.id.contactlist);
listView.setOnItemClickListener(new BeemContactListOnClick());
listView.setOnItemLongClickListener(new BeemContactListOnLongClick());
- listView.setAdapter(mAdapter);
+ listView.setAdapter(mAdapterContactList);
}
private void buildBanner() {
Gallery g = (Gallery) findViewById(R.id.gallery);
g.setOnItemClickListener(new OnItemClickGroupName());
- g.setAdapter(new BeemBanner(this));
+ g.setAdapter(mAdapterBanner);
}
/**
@@ -337,7 +332,8 @@
@Override
public void run() {
sortBeemContactList();
- mAdapter.notifyDataSetChanged();
+ mAdapterContactList.notifyDataSetChanged();
+ mAdapterBanner.notifyDataSetChanged();
}
}
@@ -378,7 +374,7 @@
}
@Override
- public void onEntryDeleteFromGroup(String group, String jid) throws RemoteException {
+ public void onEntryDeleteFromGroup(String group, String jid) throws RemoteException {
List<Contact> tmpContactList = mContactOnGroup.get(group);
Contact curContact = null;
for (Contact c : tmpContactList) {
@@ -386,6 +382,11 @@
curContact = c;
tmpContactList.remove(c);
c.getGroups().remove(group);
+ if (mContactOnGroup.get(group).size() == 0) {
+ mContactOnGroup.remove(group);
+ mListGroup.remove(group);
+ mListContact = mContactOnGroup.get(getString(R.string.contact_list_all_contact));
+ }
break;
}
}
@@ -611,7 +612,10 @@
List<Contact> tmpContactList = mRoster.getContactList();
List<String> tmpGroupList = mRoster.getGroupsNames();
Collections.sort(tmpGroupList);
- mListGroup = tmpGroupList;
+ if (mListGroup.size() > 0)
+ mListGroup.clear();
+ mListGroup.add(getString(R.string.contact_list_all_contact));
+ mListGroup.addAll(tmpGroupList);
mListGroup.add(getString(R.string.contact_list_no_group));
if (tmpGroupList.size() > 0) {
List<Contact> tmpNoGroup = new ArrayList<Contact>();
@@ -626,11 +630,11 @@
mContactOnGroup.put(s, tmpList);
}
mContactOnGroup.put(getString(R.string.contact_list_no_group), tmpNoGroup);
- mCurGroup = tmpGroupList.get(0);
} else {
- mCurGroup = null;
- mListContact = tmpContactList;
+ mContactOnGroup.put(getString(R.string.contact_list_no_group), tmpContactList);
}
+ mContactOnGroup.put(getString(R.string.contact_list_all_contact), tmpContactList);
+ mCurGroup = getString(R.string.contact_list_all_contact);
buildBanner();
buildContactList();
}
@@ -651,14 +655,4 @@
mRoster = null;
}
}
-
- 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/EditSettings.java Fri Sep 25 19:00:34 2009 +0200
+++ b/src/com/beem/project/beem/ui/EditSettings.java Fri Sep 25 19:01:30 2009 +0200
@@ -551,7 +551,7 @@
private class BeemBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
- stopService(SERVICE_INTENT);
+ EditSettings.this.setResult(69);
}
}
}
--- a/src/com/beem/project/beem/ui/Login.java Fri Sep 25 19:00:34 2009 +0200
+++ b/src/com/beem/project/beem/ui/Login.java Fri Sep 25 19:01:30 2009 +0200
@@ -3,9 +3,7 @@
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;
@@ -33,7 +31,7 @@
*/
public class Login extends Activity {
- // private static final String TAG = "LOG_AS";
+ private static final String TAG = "LOG_AS";
private static final Intent SERVICE_INTENT = new Intent();
static {
SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
@@ -48,7 +46,6 @@
private SharedPreferences mSettings;
private boolean mIsConfigured;
- private BroadcastReceiver mReceiver;
/**
* Constructor.
@@ -81,13 +78,12 @@
mSettings = getSharedPreferences(getString(R.string.settings_filename), MODE_PRIVATE);
setContentView(R.layout.login);
mProgressDialog = new ProgressDialog(this);
- mReceiver = new BeemBroadcastReceiver();
}
@Override
protected void onDestroy() {
super.onDestroy();
- if (mIsConfigured && (mIsConnected || mXmppFacade == null)) {
+ if (mIsConfigured && (mIsConnected || mXmppFacade != null)) {
unbindService(mServConn);
}
}
@@ -176,12 +172,10 @@
*/
@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
@@ -277,6 +271,7 @@
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
+ Log.d(TAG, "service connected");
mIsConnected = true;
mXmppFacade = IXmppFacade.Stub.asInterface(service);
try {
@@ -306,16 +301,5 @@
mIsConnected = false;
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 19:00:34 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java Fri Sep 25 19:01:30 2009 +0200
@@ -7,7 +7,6 @@
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;
@@ -44,6 +43,7 @@
import com.beem.project.beem.service.aidl.IMessageListener;
import com.beem.project.beem.service.aidl.IRoster;
import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.utils.BeemBroadcastReceiver;
/**
* This activity class provides the view for instant messaging after selecting a correspondant.
@@ -534,14 +534,4 @@
});
}
}
-
- 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();
- }
- }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/utils/BeemBroadcastReceiver.java Fri Sep 25 19:01:30 2009 +0200
@@ -0,0 +1,25 @@
+package com.beem.project.beem.utils;
+
+import com.beem.project.beem.R;
+import com.beem.project.beem.ui.Login;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.widget.Toast;
+
+/**
+ * @author nikita
+ *
+ */
+public class BeemBroadcastReceiver extends BroadcastReceiver {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ context.startActivity(new Intent(context, Login.class));
+ Toast.makeText(context, context.getString(R.string.BeemBroadcastReceiverDisconnect), Toast.LENGTH_LONG).show();
+ }
+}