--- a/res/layout/preferences.xml Fri Nov 06 17:51:22 2009 +0100
+++ b/res/layout/preferences.xml Fri Nov 06 18:00:49 2009 +0100
@@ -3,7 +3,8 @@
android:shouldDisableView="true" android:selectable="true">
<EditTextPreference android:singleLine="true"
android:summary="@string/SettingsText"
- android:title="@string/settings_account_username" android:key="settings_key_account_username" />
+ android:title="@string/settings_account_username" android:key="settings_key_account_username"
+ />
<EditTextPreference android:name="password"
android:singleLine="true" android:password="true"
android:summary="@string/SettingsPassword"
@@ -27,7 +28,8 @@
android:title="@string/settings_proxy_server" android:key="settings_key_proxy_server" />
<EditTextPreference android:singleLine="true" android:dependency="settings_key_proxy_use"
android:name="port" android:summary="@string/SettingsProxyPort"
- android:title="@string/settings_proxy_port" android:key="settings_key_proxy_port" />
+ android:title="@string/settings_proxy_port" android:key="settings_key_proxy_port"
+ android:numeric="integer" />
<EditTextPreference android:singleLine="true" android:dependency="settings_key_proxy_use"
android:name="Utilisateur"
android:summary="@string/SettingsProxyUser"
@@ -50,6 +52,7 @@
android:name="Reconnect delay"
android:summary="@string/SettingsAdvancedRecoDelay"
android:key="settings_key_reco_delay"
+ android:numeric="integer"
android:defaultValue="10" />
<CheckBoxPreference android:title="@string/SettingsAdvancedOptions"
@@ -63,6 +66,7 @@
<EditTextPreference android:singleLine="true" android:dependency="settings_key_specific_server"
android:name="port" android:summary="@string/SettingsAdvancedPortOpt"
android:title="@string/settings_xmpp_port" android:defaultValue="5222"
+ android:numeric="integer"
android:key="settings_key_xmpp_port" />
</PreferenceScreen>
</PreferenceScreen>
\ No newline at end of file
--- a/res/values/strings.xml Fri Nov 06 17:51:22 2009 +0100
+++ b/res/values/strings.xml Fri Nov 06 18:00:49 2009 +0100
@@ -162,6 +162,7 @@
<string name="login_settings_button">Settings</string>
<string name="login_login_button">Log in</string>
<string name="login_login_progress">Connecting. Please wait...</string>
+ <string name="login_max_retry">Max retry</string>
<string name="login_error_msg">Unfortunately, an error occured.\n\nError detail:\n%s</string>
<!--
--- a/src/com/beem/project/beem/BeemService.java Fri Nov 06 17:51:22 2009 +0100
+++ b/src/com/beem/project/beem/BeemService.java Fri Nov 06 18:00:49 2009 +0100
@@ -103,6 +103,7 @@
public boolean onUnbind(Intent intent) {
Log.d("BEEMSERVICE", "ONUNBIND()");
if (!mConnection.getAdaptee().isConnected()) {
+ Log.d("BEEMSERVICE","DESTROYED");
this.stopSelf();
}
return true;
@@ -160,6 +161,7 @@
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
+ Log.d("BEEMSERVICE","onStart");
try {
mConnection.connectAsync();
} catch (RemoteException e) {
--- a/src/com/beem/project/beem/jingle/PCMTransmitter.java Fri Nov 06 17:51:22 2009 +0100
+++ b/src/com/beem/project/beem/jingle/PCMTransmitter.java Fri Nov 06 18:00:49 2009 +0100
@@ -26,8 +26,8 @@
@Override
void start() {
AudioRecord audRec = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, RATE_IN_HZ,
- AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_8BIT, AudioRecord.getMinBufferSize(
- RATE_IN_HZ, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_8BIT));
+ AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, AudioRecord.getMinBufferSize(
+ RATE_IN_HZ, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT) * 4);
byte[] audioData = new byte[BUFF_SIZE];
int byteReaded = 0;
while (!isKillme()) {
--- a/src/com/beem/project/beem/ui/Login.java Fri Nov 06 17:51:22 2009 +0100
+++ b/src/com/beem/project/beem/ui/Login.java Fri Nov 06 18:00:49 2009 +0100
@@ -6,6 +6,7 @@
import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.os.Bundle;
@@ -25,6 +26,7 @@
import com.beem.project.beem.service.aidl.IBeemConnectionListener;
import com.beem.project.beem.service.aidl.IXmppConnection;
import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.utils.BeemBroadcastReceiver;
import com.beem.project.beem.utils.Status;
/**
@@ -51,6 +53,8 @@
private SharedPreferences mSettings;
private boolean mIsConfigured;
private int mRetry;
+ private BeemBroadcastReceiver mReceiver;
+
/**
* Constructor.
@@ -80,9 +84,11 @@
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ Log.d(TAG,"onCreate");
mSettings = PreferenceManager.getDefaultSharedPreferences(this);
setContentView(R.layout.login);
mProgressDialog = new ProgressDialog(this);
+ mReceiver = new BeemBroadcastReceiver(mServConn);
}
/**
@@ -91,8 +97,11 @@
@Override
protected void onStop() {
super.onStop();
+ Log.d(TAG,"onStop");
if (mIsConfigured && (mIsConnected || mXmppFacade != null)) {
+ mReceiver.setBinded(false);
unbindService(mServConn);
+ mXmppFacade = null;
}
}
@@ -101,7 +110,18 @@
*/
protected void onPause() {
super.onPause();
+ Log.d(TAG,"onPause");
+ this.unregisterReceiver(mReceiver);
mConnectionHandler.removeCallbacks(mConnectionRunnable);
+ mProgressDialog.dismiss();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void onResume() {
+ super.onResume();
+ this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED));
}
/**
@@ -110,9 +130,17 @@
@Override
public void onStart() {
super.onStart();
+ Log.d(TAG,"onStart");
mIsConfigured = mSettings.getBoolean("PreferenceIsConfigured", false);
- if (mIsConfigured)
+ if (mIsConfigured && !mIsConnected) {
+ try {
+ Thread.sleep(1000); //HACK: Pour éviter de rebinder un service pas encore arreter.
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
bindService(Login.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
+ mReceiver.setBinded(true);
+ }
}
/**
@@ -163,11 +191,14 @@
@Override
public void run() {
if (mRetry++ > 3) {
- Toast.makeText(Login.this, "Max retry", Toast.LENGTH_LONG).show();
+ Toast.makeText(Login.this, R.string.login_max_retry, Toast.LENGTH_LONG).show();
+ mConnectionHandler.removeCallbacks(mConnectionRunnable);
} else {
mIsConfigured = mSettings.getBoolean("PreferenceIsConfigured", false);
- if (mIsConfigured)
+ if (mIsConfigured) {
bindService(Login.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
+ mReceiver.setBinded(true);
+ }
}
}
@@ -208,6 +239,7 @@
Log.d(TAG, "CONNECTIONFAILLED");
mIsConnected = false;
if (mXmppFacade != null) {
+ mReceiver.setBinded(false);
Login.this.unbindService(mServConn);
Login.this.stopService(SERVICE_INTENT);
mXmppFacade = null;
@@ -294,7 +326,6 @@
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
Log.d(TAG, "service connected");
- mIsConnected = true;
mXmppFacade = IXmppFacade.Stub.asInterface(service);
try {
mXmppConnection = mXmppFacade.createConnection();
@@ -308,6 +339,7 @@
mProgressDialog.show();
}
});
+
Login.this.startService(Login.SERVICE_INTENT);
} else {
startActivity(new Intent(Login.this, ContactList.class));