Toujours de la mise en place du user infos dans le longclick.
Menage.
--- a/AndroidManifest.xml Sun Sep 27 19:09:18 2009 +0200
+++ b/AndroidManifest.xml Sun Sep 27 20:02:15 2009 +0200
@@ -40,8 +40,7 @@
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.Subscription" android:label="@string/app_name">
<intent-filter android:label="Beem Connection">
<action
android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
--- a/res/layout/contactlistgroup.xml Sun Sep 27 19:09:18 2009 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="50sp"
- android:paddingTop="5sp"
- android:gravity="center_vertical">
-
- <TextView android:id="@+id/textgroup"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:minHeight="30sp"
- android:paddingLeft="40sp" />
-
-</LinearLayout>
\ No newline at end of file
--- a/res/layout/contactlistsettings.xml Sun Sep 27 19:09:18 2009 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <LinearLayout android:orientation="vertical"
- android:layout_width="fill_parent" android:layout_height="fill_parent">
-
- <TextView android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="@string/CLSServerConnection"
- android:textSize="18sp" />
- <LinearLayout android:orientation="horizontal"
- android:layout_width="fill_parent" android:layout_height="wrap_content">
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:text="@string/CLSUserid"
- android:minWidth="90dp" android:textSize="14sp" />
- <EditText android:id="@+id/userid" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:singleLine="true"
- android:textSize="14sp" android:autoText="false" android:capitalize="none"
- android:scrollHorizontally="true" />
- </LinearLayout>
-
- <LinearLayout android:orientation="horizontal"
- android:layout_width="fill_parent" android:layout_height="wrap_content">
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:text="@string/CLSHostPort"
- android:minWidth="90dp" android:textSize="14sp" />
- <EditText android:id="@+id/host" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:singleLine="true"
- android:textSize="14sp" android:autoText="false" android:capitalize="none"
- android:layout_weight="2" android:scrollHorizontally="true" />
- <EditText android:id="@+id/port" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:singleLine="true"
- android:textSize="14sp" android:autoText="false" android:capitalize="none"
- android:layout_weight="3" android:scrollHorizontally="true" />
- </LinearLayout>
-
- <LinearLayout android:orientation="horizontal"
- android:layout_width="fill_parent" android:layout_height="wrap_content">
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:text="@string/CLSPassword"
- android:minWidth="90dp" android:textSize="14sp" />
- <EditText android:id="@+id/password" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:singleLine="true"
- android:password="true" android:textSize="14sp" android:autoText="false"
- android:capitalize="none" android:scrollHorizontally="true" />
- </LinearLayout>
-
- <TextView android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text=""
- android:textSize="18sp" />
-
- <Spinner android:id="@+id/proxy_type" android:layout_width="fill_parent"
- android:layout_height="wrap_content" />
-
- <LinearLayout android:id="@+id/proxy_layout"
- android:orientation="vertical" android:layout_width="fill_parent"
- android:layout_height="0sp">
-
- <TextView android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:text="@string/CLSProxyInfo"
- android:textSize="18sp" />
-
- <LinearLayout android:orientation="horizontal"
- android:layout_width="fill_parent" android:layout_height="wrap_content">
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:text="@string/CLSHostPort"
- android:minWidth="90dp" android:textSize="14sp" />
- <EditText android:id="@+id/proxy_host"
- android:layout_width="fill_parent" android:layout_height="wrap_content"
- android:singleLine="true" android:textSize="14sp" android:autoText="false"
- android:capitalize="none" android:layout_weight="2"
- android:scrollHorizontally="true" />
- <EditText android:id="@+id/proxy_port"
- android:layout_width="fill_parent" android:layout_height="wrap_content"
- android:singleLine="true" android:textSize="14sp" android:autoText="false"
- android:capitalize="none" android:layout_weight="3"
- android:scrollHorizontally="true" />
- </LinearLayout>
-
- <LinearLayout android:orientation="horizontal"
- android:layout_width="fill_parent" android:layout_height="wrap_content">
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:text="@string/CLSLogin"
- android:minWidth="90dp" android:textSize="14sp" />
- <EditText android:id="@+id/proxy_login"
- android:layout_width="fill_parent" android:layout_height="wrap_content"
- android:singleLine="true" android:textSize="14sp" android:autoText="false"
- android:capitalize="none" android:scrollHorizontally="true" />
- </LinearLayout>
-
- <LinearLayout android:orientation="horizontal"
- android:layout_width="fill_parent" android:layout_height="wrap_content">
- <TextView android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:text="@string/CLSPassword"
- android:minWidth="90dp" android:textSize="14sp" />
- <EditText android:id="@+id/proxy_pwd" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:singleLine="true"
- android:password="true" android:textSize="14sp" android:autoText="false"
- android:capitalize="none" android:scrollHorizontally="true" />
- </LinearLayout>
- </LinearLayout>
- <Button android:id="@+id/ok" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
- android:text="@string/CLSOkButton">
- <requestFocus />
- </Button>
- </LinearLayout>
-</ScrollView>
\ No newline at end of file
--- a/res/layout/edit_settings.xml Sun Sep 27 19:09:18 2009 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,212 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<TabHost android:id="@+id/settings_tab_host" xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <LinearLayout
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <TabWidget android:id="@android:id/tabs"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" />
- <FrameLayout android:id="@android:id/tabcontent"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
-
- <!--
- Account Tab
- -->
- <ScrollView
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <RelativeLayout android:id="@+id/settings_account"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:padding="10dip">
- <TextView android:id="@+id/settings_account_label_username"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/settings_account_username"
- style="@style/Label" />
- <EditText android:id="@+id/settings_account_username"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/settings_account_label_username"
- android:singleLine="true" />
- <TextView android:id="@+id/settings_account_label_password"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/settings_account_username"
- android:text="@string/settings_account_password"
- style="@style/Label" />
- <EditText android:id="@+id/settings_account_password"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/settings_account_label_password"
- android:password="true"
- android:singleLine="true" />
- <Button android:id="@+id/settings_account_button_save"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/settings_account_password"
- android:layout_alignParentRight="true"
- android:text="@string/button_save" />
- </RelativeLayout>
- </ScrollView>
-
- <!--
- XMPP Tab
- -->
- <ScrollView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical">
- <RelativeLayout android:id="@+id/settings_xmpp"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:padding="10dip">
- <TableLayout android:id="@+id/settings_xmpp_table_sp"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:stretchColumns="1">
- <TableRow>
- <TextView android:id="@+id/settings_xmpp_label_server"
- android:layout_column="1"
- android:layout_width="223dp"
- android:layout_height="wrap_content"
- android:text="@string/settings_xmpp_server"
- style="@style/Label" />
- <TextView android:id="@+id/settings_xmpp_label_port"
- android:layout_column="2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/settings_xmpp_port"
- style="@style/Label" />
- </TableRow>
- <TableRow>
- <EditText android:id="@+id/settings_xmpp_server"
- android:layout_column="1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:maxWidth="223dp"
- android:singleLine="true" />
- <EditText android:id="@+id/settings_xmpp_port"
- android:layout_column="2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:minWidth="77dp"
- android:numeric="integer"
- android:maxLength="5"
- android:singleLine="true" />
- </TableRow>
- </TableLayout>
- <CheckBox android:id="@+id/settings_xmpp_use_tls"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/settings_xmpp_use_tls"
- android:layout_below="@id/settings_xmpp_table_sp"
- android:focusable="true"
- style="@style/CheckBoxLabel" />
- <Button android:id="@+id/settings_xmpp_button_save"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_below="@id/settings_xmpp_use_tls"
- android:text="@string/button_save" />
- </RelativeLayout>
- </ScrollView>
-
- <!--
- Proxy Tab
- -->
- <ScrollView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical">
- <RelativeLayout android:id="@+id/settings_proxy"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:padding="10dip">
- <CheckBox android:id="@+id/settings_proxy_use"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/settings_proxy_use"
- android:focusable="true"
- style="@style/CheckBoxLabel" />
- <LinearLayout android:id="@+id/settings_proxy_parameters"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_below="@id/settings_proxy_use"
- android:orientation="vertical">
- <Spinner android:id="@+id/settings_proxy_type"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" />
- <TableLayout android:id="@+id/settings_proxy_table_sp"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:stretchColumns="1">
- <TableRow>
- <TextView android:id="@+id/settings_proxy_label_server"
- android:layout_column="1"
- android:layout_width="223dp"
- android:layout_height="wrap_content"
- android:text="@string/settings_proxy_server"
- style="@style/Label" />
- <TextView android:id="@+id/settings_proxy_label_port"
- android:layout_column="2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/settings_proxy_port"
- style="@style/Label" />
- </TableRow>
- <TableRow>
- <EditText android:id="@+id/settings_proxy_server"
- android:layout_column="1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:maxWidth="223dp"
- android:singleLine="true" />
- <EditText android:id="@+id/settings_proxy_port"
- android:layout_column="2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:minWidth="77dp"
- android:numeric="integer"
- android:maxLength="5"
- android:singleLine="true" />
- </TableRow>
- </TableLayout>
- <TextView android:id="@+id/settings_proxy_label_username"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/settings_proxy_username"
- style="@style/Label" />
- <EditText android:id="@+id/settings_proxy_username"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:singleLine="true" />
- <TextView android:id="@+id/settings_proxy_label_password"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/settings_proxy_password"
- style="@style/Label" />
- <EditText android:id="@+id/settings_proxy_password"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:password="true"
- android:singleLine="true" />
- </LinearLayout>
- <Button android:id="@+id/settings_proxy_button_save"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:text="@string/button_save" />
- </RelativeLayout>
- </ScrollView>
- </FrameLayout>
- </LinearLayout>
-</TabHost>
--- a/res/layout/userinfo.xml Sun Sep 27 19:09:18 2009 +0200
+++ b/res/layout/userinfo.xml Sun Sep 27 20:02:15 2009 +0200
@@ -4,34 +4,4 @@
android:layout_height="fill_parent">
<ListView android:id="@+id/userinfo" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
- <LinearLayout android:id="@+id/userinfo_alias"
- android:orientation="horizontal" android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:paddingLeft="10px"
- android:paddingRight="10px" android:gravity="center_vertical">
-
- <ImageView android:id="@+id/contactliststatus"
- android:adjustViewBounds="true" android:maxWidth="15dip"
- android:maxHeight="15dip" android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:gravity="center_vertical" />
-
- <LinearLayout android:orientation="vertical"
- android:layout_weight="1" android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- <TextView android:id="@+id/contactlistpseudo"
- android:layout_width="fill_parent" android:layout_height="wrap_content"
- android:paddingLeft="20sp" android:singleLine="true"
- android:maxLines="1" />
- <TextView android:id="@+id/contactlistmsgperso"
- android:layout_width="fill_parent" android:layout_height="wrap_content"
- android:paddingLeft="20sp" android:singleLine="true"
- android:maxLines="1" android:autoLink="all" />
- </LinearLayout>
-
- <ImageView android:id="@+id/contactlistavatar"
- android:adjustViewBounds="true" android:maxWidth="50dip"
- android:maxHeight="50dip" android:padding="1dip"
- android:layout_width="wrap_content" android:layout_height="wrap_content"
- android:gravity="center_vertical" />
-
- </LinearLayout>
</LinearLayout>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/userinfo_alias.xml Sun Sep 27 20:02:15 2009 +0200
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+ <TextView android:id="@+id/userinfo_alias_label"
+ android:layout_width="fill_parent" android:layout_height="wrap_content"
+ android:paddingLeft="20sp" android:singleLine="true" android:maxLines="1"
+ android:textSize="30px" android:text="Alias" />
+ <TextView android:id="@+id/userinfo_alias_def"
+ android:layout_width="fill_parent" android:layout_height="wrap_content"
+ android:paddingLeft="20sp" android:singleLine="true" android:textSize="10px"
+ android:text="Modifier le nom affiche de votre contact" />
+</LinearLayout>
\ No newline at end of file
--- a/src/com/beem/project/beem/BeemService.java Sun Sep 27 19:09:18 2009 +0200
+++ b/src/com/beem/project/beem/BeemService.java Sun Sep 27 20:02:15 2009 +0200
@@ -98,6 +98,15 @@
Log.e("BEEMSERVICE", "ONBIND()");
return mBind;
}
+
+ @Override
+ public boolean onUnbind(Intent intent) {
+ Log.e("BEEMSERVICE", "ONUNBIND()");
+ if (!mConnection.getAdaptee().isConnected()) {
+ this.stopSelf();
+ }
+ return true;
+ }
/**
* {@inheritDoc}
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Sun Sep 27 19:09:18 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Sun Sep 27 20:02:15 2009 +0200
@@ -21,13 +21,14 @@
import android.os.RemoteException;
import android.util.Log;
+import com.beem.project.beem.BeemService;
import com.beem.project.beem.R;
-import com.beem.project.beem.BeemService;
import com.beem.project.beem.service.aidl.IBeemConnectionListener;
import com.beem.project.beem.service.aidl.IChatManager;
import com.beem.project.beem.service.aidl.IRoster;
import com.beem.project.beem.service.aidl.IXmppConnection;
import com.beem.project.beem.ui.Subscription;
+import com.beem.project.beem.utils.BeemBroadcastReceiver;
/**
* This class implements an adapter for XMPPConnection.
@@ -38,7 +39,7 @@
/**
* Beem connection closed Intent name.
*/
- public static final String BEEM_CONNECTION_CLOSED = "BeemConnectionClosed";
+
private static final String TAG = "XMPPConnectionAdapter";
private XMPPConnection mAdaptee;
private IChatManager mChatManager;
@@ -273,7 +274,9 @@
public void connectionClosed() {
Log.d(TAG, "closing connection");
mRoster = null;
- mService.sendBroadcast(new Intent(BEEM_CONNECTION_CLOSED));
+ Intent intent = new Intent(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED);
+ intent.putExtra("message", mService.getString(R.string.BeemBroadcastReceiverDisconnect));
+ mService.sendBroadcast(intent);
mService.stopSelf();
}
@@ -281,23 +284,13 @@
* {@inheritDoc}
*/
@Override
- public void connectionClosedOnError(Exception arg0) {
+ public void connectionClosedOnError(Exception exception) {
Log.d(TAG, "connectionClosedOnError");
mRoster = null;
- final int n = mRemoteConnListeners.beginBroadcast();
-
- for (int i = 0; i < n; i++) {
- IBeemConnectionListener listener = mRemoteConnListeners.getBroadcastItem(i);
- try {
- if (listener != null)
- listener.connectionClosedOnError();
- } catch (RemoteException e) {
- // The RemoteCallbackList will take care of removing the
- // dead listeners.
- Log.w(TAG, "Error while triggering remote connection listeners", e);
- }
- }
- mRemoteConnListeners.finishBroadcast();
+ Intent intent = new Intent(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED);
+ intent.putExtra("message", exception.getMessage());
+ mService.sendBroadcast(intent);
+ mService.stopSelf();
}
/**
@@ -320,7 +313,7 @@
}
}
mRemoteConnListeners.finishBroadcast();
- //mService.stopSelf();
+ mService.stopSelf();
}
/**
--- a/src/com/beem/project/beem/ui/AddContact.java Sun Sep 27 19:09:18 2009 +0200
+++ b/src/com/beem/project/beem/ui/AddContact.java Sun Sep 27 20:02:15 2009 +0200
@@ -5,7 +5,6 @@
import java.util.regex.Pattern;
import android.app.Activity;
-import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
@@ -22,7 +21,6 @@
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;
/**
@@ -36,7 +34,7 @@
private final List<String> mGroup = new ArrayList<String>();
private IXmppFacade mXmppFacade;
private final ServiceConnection mServConn = new BeemServiceConnection();
- private BroadcastReceiver mReceiver;
+ private BeemBroadcastReceiver mReceiver;
static {
SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
@@ -56,16 +54,7 @@
setContentView(R.layout.addcontact);
Button ok = (Button) findViewById(R.id.addc_ok);
ok.setOnClickListener(mOkListener);
- mReceiver = new BeemBroadcastReceiver();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onStop() {
- super.onStop();
- unbindService(mServConn);
+ mReceiver = new BeemBroadcastReceiver(mServConn);
}
/**
@@ -74,8 +63,9 @@
@Override
protected void onResume() {
super.onResume();
- this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED));
+ this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED));
bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
+ mReceiver.setBinded();
}
/**
@@ -85,6 +75,8 @@
protected void onPause() {
super.onPause();
this.unregisterReceiver(mReceiver);
+ if (mReceiver.isBinded())
+ unbindService(mServConn);
}
/**
--- a/src/com/beem/project/beem/ui/ChangeStatus.java Sun Sep 27 19:09:18 2009 +0200
+++ b/src/com/beem/project/beem/ui/ChangeStatus.java Sun Sep 27 20:02:15 2009 +0200
@@ -1,7 +1,6 @@
package com.beem.project.beem.ui;
import android.app.Activity;
-import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
@@ -21,7 +20,6 @@
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;
import com.beem.project.beem.utils.Status;
@@ -54,7 +52,7 @@
private IXmppFacade mXmppFacade;
private final ServiceConnection mServConn = new BeemServiceConnection();
private final OnClickListener mOnClickOk = new MyOnClickListener();
- private BroadcastReceiver mReceiver;
+ private BeemBroadcastReceiver mReceiver;
/**
* constructor.
@@ -123,7 +121,7 @@
mAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSpinner.setAdapter(mAdapter);
mToast = Toast.makeText(this, R.string.ChangeStatusOk, Toast.LENGTH_LONG);
- mReceiver = new BeemBroadcastReceiver();
+ mReceiver = new BeemBroadcastReceiver(mServConn);
mStatusText.setText(getPreferenceString(R.string.PreferenceStatusText));
mSpinner.setSelection(getPreferenceStatusIndex());
}
@@ -132,19 +130,11 @@
* {@inheritDoc}
*/
@Override
- protected void onDestroy() {
- super.onDestroy();
- unbindService(mServConn);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
protected void onResume() {
super.onResume();
bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
- this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED));
+ mReceiver.setBinded();
+ this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED));
}
/**
@@ -154,6 +144,8 @@
protected void onPause() {
super.onPause();
this.unregisterReceiver(mReceiver);
+ if (mReceiver.isBinded())
+ unbindService(mServConn);
}
/**
--- a/src/com/beem/project/beem/ui/ContactList.java Sun Sep 27 19:09:18 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Sun Sep 27 20:02:15 2009 +0200
@@ -10,7 +10,6 @@
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;
@@ -21,6 +20,7 @@
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -39,7 +39,6 @@
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;
@@ -64,7 +63,7 @@
private Handler mHandler;
private IXmppFacade mXmppFacade;
private final ServiceConnection mServConn = new BeemServiceConnection();
- private BroadcastReceiver mReceiver;
+ private BeemBroadcastReceiver mReceiver;
static {
SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
@@ -87,7 +86,7 @@
mAdapterContactList = new BeemContactList(this);
mAdapterBanner = new BeemBanner(this);
mHandler = new Handler();
- mReceiver = new BeemBroadcastReceiver();
+ mReceiver = new BeemBroadcastReceiver(mServConn);
}
/**
@@ -96,7 +95,7 @@
@Override
protected void onResume() {
super.onResume();
- this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED));
+ this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED));
}
/**
@@ -159,6 +158,7 @@
protected void onStart() {
super.onStart();
bindService(SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
+ mReceiver.setBinded();
}
/**
@@ -166,8 +166,10 @@
*/
@Override
protected void onStop() {
+ Log.d("CONTACTLIST","onStop");
super.onStop();
- unbindService(mServConn);
+ if (mReceiver.isBinded())
+ unbindService(mServConn);
}
/**
@@ -519,7 +521,7 @@
break;
default:
imageDrawable = getResources().getDrawable(R.drawable.error);
- break;
+ break;
}
imgV.setImageDrawable(imageDrawable);
--- a/src/com/beem/project/beem/ui/EditSettings.java Sun Sep 27 19:09:18 2009 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,558 +0,0 @@
-package com.beem.project.beem.ui;
-
-import java.util.ArrayList;
-
-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.SharedPreferences;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.ArrayAdapter;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.EditText;
-import android.widget.Spinner;
-import android.widget.TabHost;
-import android.widget.Toast;
-
-import com.beem.project.beem.R;
-import com.beem.project.beem.service.XmppConnectionAdapter;
-
-/**
- * This class represents an activity which allows the user to change his account or proxy parameters.
- * @author dasilvj
- */
-public class EditSettings extends Activity {
-
- private static final String LOG_MSG_SETTINGS_SAVED = "Settings saved successfully.";
- private static final String LOG_MSG_XMPP_SETTINGS_REGISTERED = "XMPP Settings has been registered.";
- private static final String LOG_MSG_ACCOUNT_SETTINGS_REGISTERED = "Account Settings has been registered.";
- private static final String LOG_MSG_PROXY_SETTINGS_REGISTERED = "Proxy Settings has been registered.";
-
- private static final boolean DEFAULT_BOOLEAN_VALUE = false;
- private static final String DEFAULT_STRING_VALUE = "";
- private static final int DEFAULT_INT_VALUE = 0;
-
- private static final String DEFAULT_XMPP_PORT = "5222";
-
- private static final int NOTIFICATION_DURATION = Toast.LENGTH_SHORT;
-
- private SharedPreferences mSettings;
-
- private EditText mAccUsernameField;
- private EditText mAccPasswordField;
-
- private EditText mXmppServerField;
- private EditText mXmppPortField;
- private CheckBox mXmppUseTlsCheckBox;
-
- private CheckBox mProxyUseCheckBox;
- private Spinner mProxyTypeSpinner;
- private EditText mProxyServerField;
- private EditText mProxyPortField;
- private EditText mProxyUsernameField;
- private EditText mProxyPasswordField;
- 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.
- */
- public EditSettings() { }
-
- /**
- * Add a labeled "Account" tab on the tabbed window view passed by parameter.
- * @param tHost a tabbed window view
- */
- private void addAccountTab(TabHost tHost) {
- TabHost.TabSpec accountTab = tHost.newTabSpec(getString(R.string.settings_tab_tag_account));
- accountTab.setIndicator(getString(R.string.settings_tab_label_account));
- accountTab.setContent(R.id.settings_account);
- tHost.addTab(accountTab);
- }
-
- /**
- * Add a labeled "Proxy" tab on the tabbed window view passed by parameter.
- * @param tHost a tabbed window view
- */
- private void addProxyTab(TabHost tHost) {
- TabHost.TabSpec proxyTab = tHost.newTabSpec(getString(R.string.settings_tab_tag_proxy));
- proxyTab.setIndicator(getString(R.string.settings_tab_label_proxy));
- proxyTab.setContent(R.id.settings_proxy);
- tHost.addTab(proxyTab);
- }
-
- /**
- * Add a labeled "XMPP" tab on the tabbed window view passed by parameter.
- * @param tHost a tabbed window view
- */
- private void addXMPPTab(TabHost tHost) {
- TabHost.TabSpec personalTab = tHost.newTabSpec(getString(R.string.settings_tab_tag_xmpp));
- personalTab.setIndicator(getString(R.string.settings_tab_label_xmpp));
- personalTab.setContent(R.id.settings_xmpp);
- tHost.addTab(personalTab);
- }
-
- /**
- * Disable proxy parameters fields.
- */
- private void disableProxyParameters() {
- mProxyTypeSpinner.setEnabled(false);
- mProxyServerField.setEnabled(false);
- mProxyPortField.setEnabled(false);
- mProxyUsernameField.setEnabled(false);
- mProxyPasswordField.setEnabled(false);
- mProxyTypeSpinner.setFocusable(false);
- mProxyServerField.setFocusable(false);
- mProxyPortField.setFocusable(false);
- mProxyUsernameField.setFocusable(false);
- mProxyPasswordField.setFocusable(false);
- mProxyTypeSpinner.setFocusableInTouchMode(false);
- mProxyServerField.setFocusableInTouchMode(false);
- mProxyPortField.setFocusableInTouchMode(false);
- mProxyUsernameField.setFocusableInTouchMode(false);
- mProxyPasswordField.setFocusableInTouchMode(false);
- }
-
- /**
- * Display a brief notification.
- * @param msg the message to display.
- */
- private void displayNotification(CharSequence msg) {
- Toast toast = Toast.makeText(getApplicationContext(), msg, NOTIFICATION_DURATION);
- toast.show();
- }
-
- /**
- * Enable proxy parameters fields.
- */
- private void enableProxyParameters() {
- mProxyTypeSpinner.setEnabled(true);
- mProxyServerField.setEnabled(true);
- mProxyPortField.setEnabled(true);
- mProxyUsernameField.setEnabled(true);
- mProxyPasswordField.setEnabled(true);
- mProxyTypeSpinner.setFocusable(true);
- mProxyServerField.setFocusable(true);
- mProxyPortField.setFocusable(true);
- mProxyUsernameField.setFocusable(true);
- mProxyPasswordField.setFocusable(true);
- mProxyTypeSpinner.setFocusableInTouchMode(true);
- mProxyServerField.setFocusableInTouchMode(true);
- mProxyPortField.setFocusableInTouchMode(true);
- mProxyUsernameField.setFocusableInTouchMode(true);
- mProxyPasswordField.setFocusableInTouchMode(true);
- }
-
- /**
- * Retrieve the value of a CheckBox.
- * @param viewId identifier of the checkbox
- * @return true if the CheckBox is checked, else false
- */
- private boolean getCheckBoxValue(int viewId) {
- final CheckBox checkBox = (CheckBox) findViewById(viewId);
- if (checkBox.isChecked())
- return true;
- return false;
- }
-
- /**
- * Retrieve account password from the preferences.
- * @return Registered account password
- */
- private String getRegisteredAccountPassword() {
- return mSettings.getString(getString(R.string.settings_key_account_password), DEFAULT_STRING_VALUE);
- }
-
- /**
- * Retrieve account username from the preferences.
- * @return Registered account username
- */
- private String getRegisteredAccountUsername() {
- return mSettings.getString(getString(R.string.settings_key_account_username), DEFAULT_STRING_VALUE);
- }
-
- /**
- * Retrieve proxy password from the preferences.
- * @return Registered proxy password
- */
- private String getRegisteredProxyPassword() {
- return mSettings.getString(getString(R.string.settings_key_proxy_password), DEFAULT_STRING_VALUE);
- }
-
- /**
- * Retrieve proxy port from the preferences.
- * @return Registered proxy port
- */
- private String getRegisteredProxyPort() {
- return mSettings.getString(getString(R.string.settings_key_proxy_port), DEFAULT_STRING_VALUE);
- }
-
- /**
- * Retrieve proxy server from the preferences.
- * @return Registered proxy server
- */
- private String getRegisteredProxyServer() {
- return mSettings.getString(getString(R.string.settings_key_proxy_server), DEFAULT_STRING_VALUE);
- }
-
- /**
- * Retrieve proxy type from the preferences.
- * @return Registered proxy type
- */
- private int getRegisteredProxyType() {
- return mSettings.getInt(getString(R.string.settings_key_proxy_type), DEFAULT_INT_VALUE);
- }
-
- /**
- * Retrieve proxy use from the preferences.
- * @return Registered proxy use
- */
- private boolean getRegisteredProxyUse() {
- return mSettings.getBoolean(getString(R.string.settings_key_proxy_use), DEFAULT_BOOLEAN_VALUE);
- }
-
- /**
- * Retrieve proxy username from the preferences.
- * @return Registered proxy username
- */
- private String getRegisteredProxyUsername() {
- return mSettings.getString(getString(R.string.settings_key_proxy_username), DEFAULT_STRING_VALUE);
- }
-
- /**
- * Retrieve xmpp port from the preferences.
- * @return Registered xmpp port
- */
- private String getRegisteredXMPPPort() {
- return mSettings.getString(getString(R.string.settings_key_xmpp_port), DEFAULT_XMPP_PORT);
- }
-
- /**
- * Retrieve xmpp server from the preferences.
- * @return Registered xmpp server
- */
- private String getRegisteredXMPPServer() {
- return mSettings.getString(getString(R.string.settings_key_xmpp_server), DEFAULT_STRING_VALUE);
- }
-
- /**
- * Retrieve TLS use from the preferences.
- * @return Registered TLS use
- */
- private boolean getRegisteredXMPPTLSUse() {
- return mSettings.getBoolean(getString(R.string.settings_key_xmpp_tls_use), DEFAULT_BOOLEAN_VALUE);
- }
-
- /**
- * Initialize Account tab fields.
- */
- private void initAccountFields() {
- mAccUsernameField = (EditText) findViewById(R.id.settings_account_username);
- mAccPasswordField = (EditText) findViewById(R.id.settings_account_password);
- }
-
- /**
- * Initialize all of the components displayed in tabs (EditText fields, CheckBoxes, Spinners...).
- */
- private void initFields() {
- initAccountFields();
- initXMPPFields();
- initProxyFields();
- }
-
- /**
- * Initialize Proxy tab fields.
- */
- private void initProxyFields() {
- mProxyUseCheckBox = (CheckBox) findViewById(R.id.settings_proxy_use);
- mProxyTypeSpinner = (Spinner) findViewById(R.id.settings_proxy_type);
- mProxyServerField = (EditText) findViewById(R.id.settings_proxy_server);
- mProxyPortField = (EditText) findViewById(R.id.settings_proxy_port);
- mProxyUsernameField = (EditText) findViewById(R.id.settings_proxy_username);
- mProxyPasswordField = (EditText) findViewById(R.id.settings_proxy_password);
- }
-
- /**
- * Initialize proxy's types spinner of the proxy tab.
- */
- private void initProxyTypesSpinner() {
- ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.proxy_types,
- android.R.layout.simple_spinner_item);
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- mProxyTypeSpinner.setAdapter(adapter);
- }
-
- /**
- * Initialize the checkbox allowing user to use a proxy.
- */
- private void initProxyUseCheckBox() {
- mProxyUseCheckBox.setOnClickListener(new OnClickListener() {
-
- public void onClick(View v) {
- if (mProxyUseCheckBox.isChecked()) {
- enableProxyParameters();
- } else {
- disableProxyParameters();
- }
- }
- });
- }
-
- /**
- * Initialize "save" buttons allowing user to save settings.
- */
- private void initSaveButtons() {
- final ArrayList<Integer> views = new ArrayList<Integer>();
- Button saveButton = null;
-
- views.add(R.id.settings_account_button_save);
- views.add(R.id.settings_proxy_button_save);
- views.add(R.id.settings_xmpp_button_save);
-
- for (int i = 0; i < views.size(); i++) {
- saveButton = (Button) findViewById(views.get(i));
- saveButton.setFocusable(true);
- saveButton.setOnClickListener(new View.OnClickListener() {
-
- public void onClick(View v) {
- saveSettings();
- setResult(69);
- }
- });
- }
- }
-
- /**
- * Initialize tabbed window view by adding tabs and setting the default tab.
- */
- private void initTabbedWindow() {
- TabHost tHost = (TabHost) this.findViewById(R.id.settings_tab_host);
- tHost.setup();
- addAccountTab(tHost);
- addXMPPTab(tHost);
- addProxyTab(tHost);
- tHost.setCurrentTab(0);
- }
-
- /**
- * Initialize XMPP tab fields.
- */
- private void initXMPPFields() {
- mXmppServerField = (EditText) findViewById(R.id.settings_xmpp_server);
- mXmppPortField = (EditText) findViewById(R.id.settings_xmpp_port);
- mXmppUseTlsCheckBox = (CheckBox) findViewById(R.id.settings_xmpp_use_tls);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.edit_settings);
- initTabbedWindow();
- initFields();
- mSettings = getSharedPreferences(getString(R.string.settings_filename), MODE_PRIVATE);
- mReceiver = new BeemBroadcastReceiver();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater mInflater = getMenuInflater();
- mInflater.inflate(R.menu.edit_settings, menu);
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- Intent i = null;
- switch (item.getItemId()) {
- case R.id.settings_menu_create_account:
- i = new Intent(this, CreateAccount.class);
- startActivity(i);
- return true;
- case R.id.settings_menu_login:
- setResult(69);
- this.stopService(SERVICE_INTENT);
- finish();
- return true;
- default:
- return false;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onResume() {
- super.onResume();
- this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED));
- refreshAccountTabFields();
- refreshXMPPTabFields();
- refreshProxyTabFields();
-
- if (!mProxyUseCheckBox.isChecked())
- disableProxyParameters();
- }
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onPause() {
- super.onPause();
- this.unregisterReceiver(mReceiver);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onStart() {
- super.onStart();
- initProxyTypesSpinner();
- initProxyUseCheckBox();
- initSaveButtons();
- }
-
- /**
- * Refresh values of "Account" tab fields.
- */
- private void refreshAccountTabFields() {
- mAccUsernameField.setText(getRegisteredAccountUsername());
- mAccPasswordField.setText(getRegisteredAccountPassword());
- }
-
- /**
- * Refresh values of "Account" tab fields.
- */
- private void refreshProxyTabFields() {
- mProxyUseCheckBox.setChecked(getRegisteredProxyUse());
- mProxyTypeSpinner.setSelection(getRegisteredProxyType());
- mProxyServerField.setText(getRegisteredProxyServer());
- mProxyPortField.setText(getRegisteredProxyPort());
- mProxyUsernameField.setText(getRegisteredProxyUsername());
- mProxyPasswordField.setText(getRegisteredProxyPassword());
- }
-
- /**
- * Refresh values of "Account" tab fields.
- */
- private void refreshXMPPTabFields() {
- mXmppServerField.setText(getRegisteredXMPPServer());
- mXmppPortField.setText(getRegisteredXMPPPort());
- mXmppUseTlsCheckBox.setChecked(getRegisteredXMPPTLSUse());
- }
-
- /**
- * Register account settings changes in SharedPreferences.Editor object passed by parameter.
- * @param settingsEditor the editor to use.
- */
- private void registerAccountSettingsChanges(SharedPreferences.Editor settingsEditor) {
- final String usernameFieldValue = mAccUsernameField.getText().toString();
- final String passwordFieldValue = mAccPasswordField.getText().toString();
-
- if (!getRegisteredAccountUsername().equals(usernameFieldValue))
- settingsEditor.putString(getString(R.string.settings_key_account_username), usernameFieldValue);
- if (!getRegisteredAccountPassword().equals(passwordFieldValue))
- settingsEditor.putString(getString(R.string.settings_key_account_password), passwordFieldValue);
- Log.i(getString(R.string.edit_settings_tag), LOG_MSG_ACCOUNT_SETTINGS_REGISTERED);
- }
-
- /**
- * Register proxy settings changes in SharedPreferences.Editor object passed by parameter.
- * @param settingsEditor the editor to use.
- */
- private void registerProxySettingsChanges(SharedPreferences.Editor settingsEditor) {
- final int proxyTypeFieldValue = mProxyTypeSpinner.getSelectedItemPosition();
- final String serverFieldValue = mProxyServerField.getText().toString();
- final String portFieldValue = mProxyPortField.getText().toString();
- final String usernameFieldValue = mProxyUsernameField.getText().toString();
- final String passwordFieldValue = mProxyPasswordField.getText().toString();
-
- if (getRegisteredProxyType() != proxyTypeFieldValue)
- settingsEditor.putInt(getString(R.string.settings_key_proxy_type), proxyTypeFieldValue);
- if (!getRegisteredProxyServer().equals(serverFieldValue))
- settingsEditor.putString(getString(R.string.settings_key_proxy_server), serverFieldValue);
- if (!getRegisteredProxyPort().equals(portFieldValue))
- settingsEditor.putString(getString(R.string.settings_key_proxy_port), portFieldValue);
- if (!getRegisteredProxyUsername().equals(usernameFieldValue))
- settingsEditor.putString(getString(R.string.settings_key_proxy_username), usernameFieldValue);
- if (!getRegisteredProxyPassword().equals(passwordFieldValue))
- settingsEditor.putString(getString(R.string.settings_key_proxy_password), passwordFieldValue);
- Log.i(getString(R.string.edit_settings_tag), LOG_MSG_PROXY_SETTINGS_REGISTERED);
- }
-
- /**
- * Register XMPP settings changes in SharedPreferences.Editor object passed by parameter.
- * @param settingsEditor the editor to use.
- */
- private void registerXMPPSettingsChanges(SharedPreferences.Editor settingsEditor) {
- final boolean tlsUseCheckBoxValue = getCheckBoxValue(R.id.settings_xmpp_use_tls);
- final String serverFieldValue = mXmppServerField.getText().toString();
- final String portFieldValue = mXmppPortField.getText().toString();
-
- if (getRegisteredXMPPTLSUse() != tlsUseCheckBoxValue)
- settingsEditor.putBoolean(getString(R.string.settings_key_xmpp_tls_use), tlsUseCheckBoxValue);
- if (!getRegisteredXMPPServer().equals(serverFieldValue))
- settingsEditor.putString(getString(R.string.settings_key_xmpp_server), serverFieldValue);
- if (!getRegisteredXMPPPort().equals(portFieldValue))
- settingsEditor.putString(getString(R.string.settings_key_xmpp_port), portFieldValue);
- Log.i(getString(R.string.edit_settings_tag), LOG_MSG_XMPP_SETTINGS_REGISTERED);
- }
-
- /**
- * Save settings in shared preferences.
- */
- private void saveSettings() {
- final SharedPreferences.Editor settingsEditor = mSettings.edit();
- final boolean proxyUseCheckBoxValue = getCheckBoxValue(R.id.settings_proxy_use);
-
- if (getRegisteredProxyUse() != proxyUseCheckBoxValue)
- settingsEditor.putBoolean(getString(R.string.settings_key_proxy_use), proxyUseCheckBoxValue);
- if (proxyUseCheckBoxValue)
- registerProxySettingsChanges(settingsEditor);
- registerAccountSettingsChanges(settingsEditor);
- registerXMPPSettingsChanges(settingsEditor);
- String password = mAccPasswordField.getText().toString();
- String username = mAccUsernameField.getText().toString();
- String port = mXmppPortField.getText().toString();
- if ("".equals(password) || "".equals(username)
- || "".equals(port))
- settingsEditor.putBoolean(getString(R.string.PreferenceIsConfigured), false);
- else
- settingsEditor.putBoolean(getString(R.string.PreferenceIsConfigured), true);
-
- if (settingsEditor.commit()) {
- displayNotification(getText(R.string.settings_saved_ok));
- Log.i(getString(R.string.edit_settings_tag), LOG_MSG_SETTINGS_SAVED);
- }
- }
-
- private class BeemBroadcastReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- EditSettings.this.setResult(69);
- }
- }
-}
--- a/src/com/beem/project/beem/ui/Login.java Sun Sep 27 19:09:18 2009 +0200
+++ b/src/com/beem/project/beem/ui/Login.java Sun Sep 27 20:02:15 2009 +0200
@@ -81,23 +81,13 @@
setContentView(R.layout.login);
mProgressDialog = new ProgressDialog(this);
}
-
+
/**
* {@inheritDoc}
*/
@Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (requestCode == REQUEST_CODE) {
- if (resultCode == 69) {
- stopService(SERVICE_INTENT);
- }
- }
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
+ protected void onStop() {
+ super.onStop();
if (mIsConfigured && (mIsConnected || mXmppFacade != null)) {
unbindService(mServConn);
}
@@ -118,6 +108,19 @@
* {@inheritDoc}
*/
@Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == REQUEST_CODE) {
+ if (resultCode == 69) {
+ stopService(SERVICE_INTENT);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
@@ -168,6 +171,10 @@
@Override
public void connectionClosedOnError() throws RemoteException {
+ mIsConnected = false;
+ if (mXmppFacade != null) {
+ mXmppFacade = null;
+ }
}
@Override
--- a/src/com/beem/project/beem/ui/SendIM.java Sun Sep 27 19:09:18 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java Sun Sep 27 20:02:15 2009 +0200
@@ -5,7 +5,6 @@
import org.jivesoftware.smack.util.StringUtils;
import android.app.Activity;
-import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
@@ -35,7 +34,6 @@
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;
@@ -73,7 +71,7 @@
private final ServiceConnection mServConn = new BeemServiceConnection();
private IXmppFacade mXmppFacade;
private TextView mStatusText;
- private BroadcastReceiver mReceiver;
+ private BeemBroadcastReceiver mReceiver;
private static final Intent SERVICE_INTENT = new Intent();
static {
@@ -125,7 +123,7 @@
mScrolling = (ScrollView) findViewById(R.id.sendimscroll);
mStatusText = (TextView) findViewById(R.id.sendimstatus);
setViewHeader();
- mReceiver = new BeemBroadcastReceiver();
+ mReceiver = new BeemBroadcastReceiver(mServConn);
}
/**
@@ -246,7 +244,8 @@
} catch (RemoteException e) {
Log.d(TAG, "Error while closing chat", e);
}
- unbindService(mServConn);
+ if (mReceiver.isBinded())
+ unbindService(mServConn);
}
/**
@@ -255,8 +254,9 @@
@Override
protected void onResume() {
super.onResume();
- this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED));
+ this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED));
bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
+ mReceiver.setBinded();
mScrolling.fullScroll(ScrollView.FOCUS_DOWN);
}
--- a/src/com/beem/project/beem/ui/Settings.java Sun Sep 27 19:09:18 2009 +0200
+++ b/src/com/beem/project/beem/ui/Settings.java Sun Sep 27 20:02:15 2009 +0200
@@ -13,7 +13,7 @@
import android.view.MenuItem;
import com.beem.project.beem.R;
-import com.beem.project.beem.service.XmppConnectionAdapter;
+import com.beem.project.beem.utils.BeemBroadcastReceiver;
/**
* This class represents an activity which allows the user to change his account or proxy parameters.
@@ -22,7 +22,7 @@
public class Settings extends PreferenceActivity {
private static final Intent SERVICE_INTENT = new Intent();
- private BeemBroadcastReceiver mReceiver;
+ private SettingsBroadcastReceiver mReceiver;
static {
SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
@@ -38,7 +38,7 @@
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.layout.preferences);
- mReceiver = new BeemBroadcastReceiver();
+ mReceiver = new SettingsBroadcastReceiver();
}
/**
@@ -56,7 +56,7 @@
@Override
public void onResume() {
super.onResume();
- this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED));
+ this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED));
}
/**
@@ -111,12 +111,11 @@
/**
* disconnect Broadcast receiver.
*/
- private class BeemBroadcastReceiver extends BroadcastReceiver {
-
+ private class SettingsBroadcastReceiver extends BroadcastReceiver {
/**
* Constructor.
*/
- public BeemBroadcastReceiver() {
+ public SettingsBroadcastReceiver() {
}
@Override
--- a/src/com/beem/project/beem/ui/UserInfo.java Sun Sep 27 19:09:18 2009 +0200
+++ b/src/com/beem/project/beem/ui/UserInfo.java Sun Sep 27 20:02:15 2009 +0200
@@ -1,14 +1,19 @@
package com.beem.project.beem.ui;
+import java.util.ArrayList;
+import java.util.List;
+
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;
-import android.widget.TextView;
+import android.widget.AdapterView.OnItemClickListener;
import com.beem.project.beem.R;
import com.beem.project.beem.service.Contact;
@@ -20,6 +25,11 @@
public class UserInfo extends Activity {
private Contact mContact;
+ private static final List<String> mInfo = new ArrayList<String>();
+
+ static {
+ mInfo.add("alias");
+ }
/**
* Constructor.
@@ -38,10 +48,18 @@
setTitle(mContact.getName());
ListView listview = (ListView) findViewById(R.id.userinfo);
listview.setAdapter(new BeemUserInfo(this));
+ listview.setOnItemClickListener(new BeemUserInfoClick());
+ }
+
+ public class BeemUserInfoClick implements OnItemClickListener {
+ @Override
+ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
+ Log.i("OOO", mInfo.get(arg2));
+ }
}
/**
- * Adapter banner list.
+ * Adapter user info list.
*/
public class BeemUserInfo extends BaseAdapter {
private LayoutInflater mInflater;
@@ -59,7 +77,7 @@
*/
@Override
public int getCount() {
- return 1;
+ return mInfo.size();
}
/**
@@ -85,11 +103,11 @@
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (convertView == null) {
- v = mInflater.inflate(R.id.userinfo_alias, null);
+ if (position == 0)
+ v = mInflater.inflate(R.layout.userinfo_alias, null);
}
return v;
}
-
}
}
--- a/src/com/beem/project/beem/utils/BeemBroadcastReceiver.java Sun Sep 27 19:09:18 2009 +0200
+++ b/src/com/beem/project/beem/utils/BeemBroadcastReceiver.java Sun Sep 27 20:02:15 2009 +0200
@@ -3,9 +3,9 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.ServiceConnection;
import android.widget.Toast;
-import com.beem.project.beem.R;
import com.beem.project.beem.ui.Login;
/**
@@ -14,10 +14,16 @@
*/
public class BeemBroadcastReceiver extends BroadcastReceiver {
+ public static final String BEEM_CONNECTION_CLOSED = "BeemConnectionClosed";
+ private ServiceConnection mService;
+ private boolean mIsBinded;
+
/**
* constructor.
*/
- public BeemBroadcastReceiver() {
+ public BeemBroadcastReceiver(ServiceConnection service) {
+ mService = service;
+ mIsBinded = false;
}
/**
@@ -25,7 +31,18 @@
*/
@Override
public void onReceive(Context context, Intent intent) {
+ context.unbindService(mService);
+ mIsBinded = false;
context.startActivity(new Intent(context, Login.class));
- Toast.makeText(context, context.getString(R.string.BeemBroadcastReceiverDisconnect), Toast.LENGTH_LONG).show();
+ CharSequence message = intent.getCharSequenceExtra("message");
+ Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
+ }
+
+ public void setBinded() {
+ mIsBinded = true;
+ }
+
+ public boolean isBinded() {
+ return mIsBinded;
}
}