--- a/res/values-fr/strings.xml Thu Dec 03 01:37:47 2009 +0100
+++ b/res/values-fr/strings.xml Thu Dec 03 10:49:44 2009 +0100
@@ -177,21 +177,7 @@
-->
<string name="settings_menu_create_account">Créer un compte</string>
<string name="settings_menu_privacy_lists">Gérer mes listes privées</string>
- <string name="settings_saved_ok">Les paramètres ont été enregistrés avec succès.
- </string>
-
- <string name="settings_key_account_username">beem_account_username</string>
- <string name="settings_key_account_password">beem_account_password</string>
- <string name="settings_key_xmpp_server">beem_xmpp_server</string>
- <string name="settings_key_xmpp_port">beem_xmpp_port</string>
- <string name="settings_key_xmpp_tls_use">beem_xmpp_tls_use</string>
- <string name="settings_key_proxy_use">beem_xmpp_proxy_use</string>
- <string name="settings_key_proxy_server">beem_xmpp_proxy_server</string>
- <string name="settings_key_proxy_port">beem_xmpp_proxy_port</string>
- <string name="settings_key_proxy_username">beem_xmpp_proxy_username</string>
- <string name="settings_key_proxy_password">beem_xmpp_proxy_password</string>
- <string name="settings_key_proxy_type">beem_xmpp_proxy_type</string>
- <string name="settings_key_hidden_contact">settings_key_hidden_contact</string>
+ <string name="settings_saved_ok">Les paramètres ont été enregistrés avec succès.</string>
<!-- EditSettings Activity Categories -->
<string name="general_preferences">Préférences de l\'application</string>
@@ -246,7 +232,7 @@
<string name="create_account_err_dialog_title">Créer un compte - Erreur</string>
<string name="create_account_err_dialog_settings_button">Changer mes paramètres</string>
<string name="create_account_close_dialog_button">Fermer</string>
- <string name="create_account_successfull_after">A été créé avec succès</string>
+ <string name="create_account_successfull_after">L\'utilisateur %s a été créé avec succès</string>
<string name="create_account_err_username">Mauvais JabberID</string>
<string name="create_account_err_passwords">Les mots de passe ne correspondent pas</string>
<string name="create_account_username">Nom d\'utilisateur</string>
--- a/res/values/strings.xml Thu Dec 03 01:37:47 2009 +0100
+++ b/res/values/strings.xml Thu Dec 03 10:49:44 2009 +0100
@@ -167,18 +167,7 @@
<string name="settings_menu_privacy_lists">Manage my privacy lists</string>
<string name="settings_saved_ok">The settings have been saved successfully.</string>
- <string name="settings_key_account_username">beem_account_username</string>
- <string name="settings_key_account_password">beem_account_password</string>
- <string name="settings_key_xmpp_server">beem_xmpp_server</string>
- <string name="settings_key_xmpp_port">beem_xmpp_port</string>
- <string name="settings_key_xmpp_tls_use">beem_xmpp_tls_use</string>
- <string name="settings_key_proxy_use">beem_xmpp_proxy_use</string>
- <string name="settings_key_proxy_server">beem_xmpp_proxy_server</string>
- <string name="settings_key_proxy_port">beem_xmpp_proxy_port</string>
- <string name="settings_key_proxy_username">beem_xmpp_proxy_username</string>
- <string name="settings_key_proxy_password">beem_xmpp_proxy_password</string>
- <string name="settings_key_proxy_type">beem_xmpp_proxy_type</string>
- <string name="settings_key_hidden_contact">settings_key_hidden_contact</string>
+
<!-- EditSettings Activity Categories -->
<string name="general_preferences">General preferences</string>
@@ -231,7 +220,7 @@
<string name="create_account_err_dialog_title">Create an account - Error</string>
<string name="create_account_err_dialog_settings_button">Change my settings</string>
<string name="create_account_close_dialog_button">Close</string>
- <string name="create_account_successfull_after">has been created successfully</string>
+ <string name="create_account_successfull_after">account %s has been created successfully</string>
<string name="create_account_err_username">Bad JabberID</string>
<string name="create_account_err_passwords">Passwords do not match.</string>
<string name="create_account_username">Username</string>
--- a/src/com/beem/project/beem/BeemService.java Thu Dec 03 01:37:47 2009 +0100
+++ b/src/com/beem/project/beem/BeemService.java Thu Dec 03 10:49:44 2009 +0100
@@ -79,7 +79,6 @@
private ProxyInfo mProxyInfo;
private boolean mUseProxy;
private IXmppFacade.Stub mBind;
- private ProviderManager mProviderManager;
/**
* Constructor.
--- a/src/com/beem/project/beem/ui/CreateAccount.java Thu Dec 03 01:37:47 2009 +0100
+++ b/src/com/beem/project/beem/ui/CreateAccount.java Thu Dec 03 10:49:44 2009 +0100
@@ -15,7 +15,6 @@
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
-import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
@@ -66,12 +65,12 @@
private boolean createAccount(String username, String password) {
XMPPConnection xmppConnection = null;
ConnectionConfiguration connectionConfiguration = null;
-
- if (getRegisteredProxy() != null) {
- connectionConfiguration = new ConnectionConfiguration(getXMPPServer(), DEFAULT_XMPP_PORT,
- getRegisteredProxy());
+ ProxyInfo pi = null;
+ if ((pi = getRegisteredProxy()) != null) {
+ connectionConfiguration = new ConnectionConfiguration(getXMPPServer(), getXMPPPort(),
+ pi);
} else {
- connectionConfiguration = new ConnectionConfiguration(getXMPPServer(), DEFAULT_XMPP_PORT);
+ connectionConfiguration = new ConnectionConfiguration(getXMPPServer(), getXMPPPort());
}
if (getRegisteredXMPPTLSUse())
connectionConfiguration.setSecurityMode(ConnectionConfiguration.SecurityMode.required);
@@ -81,11 +80,9 @@
xmppConnection.connect();
AccountManager accountManager = new AccountManager(xmppConnection);
accountManager.createAccount(username, password);
- Toast toast = Toast.makeText(getApplicationContext(), "Account " + username + " "
- + getString(R.string.create_account_successfull_after), NOTIFICATION_DURATION);
+ Toast toast = Toast.makeText(getApplicationContext(), String.format(getString(R.string.create_account_successfull_after),username), NOTIFICATION_DURATION);
toast.show();
} catch (XMPPException e) {
- Log.e(getString(R.string.create_account_tag), e.getMessage());
createErrorDialog(e.getMessage());
return false;
}
@@ -98,7 +95,6 @@
* @param errMsg the error message
*/
private void createErrorDialog(String errMsg) {
- Log.v(getString(R.string.create_account_tag), errMsg);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.create_account_err_dialog_title).setMessage(errMsg).setCancelable(false);
builder.setNeutralButton(R.string.create_account_close_dialog_button, new DialogInterface.OnClickListener() {
@@ -130,7 +126,7 @@
* @return Registered proxy password
*/
private String getRegisteredProxyPassword() {
- return mSettings.getString(getString(R.string.settings_key_proxy_password), DEFAULT_STRING_VALUE);
+ return mSettings.getString("settings_key_proxy_password", DEFAULT_STRING_VALUE);
}
/**
@@ -139,7 +135,7 @@
*/
private int getRegisteredProxyPort() {
return Integer
- .parseInt(mSettings.getString(getString(R.string.settings_key_proxy_port), DEFAULT_STRING_VALUE));
+ .parseInt(mSettings.getString("settings_key_proxy_port", DEFAULT_STRING_VALUE));
}
/**
@@ -147,7 +143,7 @@
* @return Registered proxy server
*/
private String getRegisteredProxyServer() {
- return mSettings.getString(getString(R.string.settings_key_proxy_server), DEFAULT_STRING_VALUE);
+ return mSettings.getString("settings_key_proxy_server", DEFAULT_STRING_VALUE);
}
/**
@@ -156,7 +152,7 @@
*/
private ProxyInfo.ProxyType getRegisteredProxyType() {
ProxyInfo.ProxyType result;
- switch (mSettings.getInt(getString(R.string.settings_key_proxy_type), DEFAULT_INT_VALUE)) {
+ switch (mSettings.getInt("settings_key_proxy_type", DEFAULT_INT_VALUE)) {
case 0:
result = ProxyInfo.ProxyType.HTTP;
break;
@@ -164,12 +160,11 @@
result = ProxyInfo.ProxyType.SOCKS4;
break;
case 2:
- Log.i(getString(R.string.create_account_tag), "SOCKS5 PROXY");
result = ProxyInfo.ProxyType.SOCKS5;
break;
default:
result = ProxyInfo.ProxyType.NONE;
- break;
+ break;
}
return result;
}
@@ -179,7 +174,7 @@
* @return Registered proxy use
*/
private boolean getRegisteredProxyUse() {
- return mSettings.getBoolean(getString(R.string.settings_key_proxy_use), DEFAULT_BOOLEAN_VALUE);
+ return mSettings.getBoolean("settings_key_proxy_use", DEFAULT_BOOLEAN_VALUE);
}
/**
@@ -187,7 +182,18 @@
* @return Registered proxy username
*/
private String getRegisteredProxyUsername() {
- return mSettings.getString(getString(R.string.settings_key_proxy_username), DEFAULT_STRING_VALUE);
+ return mSettings.getString("settings_key_proxy_username", DEFAULT_STRING_VALUE);
+ }
+
+ /**
+ * Retrieve xmpp port from the preferences.
+ * @return Registered xmpp port
+ */
+ private int getXMPPPort() {
+ int port = DEFAULT_XMPP_PORT;
+ if (mSettings.getBoolean("settings_key_specific_server", false))
+ port = Integer.parseInt(mSettings.getString("settings_key_xmpp_port", "5222"));
+ return port;
}
/**
@@ -196,7 +202,11 @@
*/
private String getXMPPServer() {
TextView xmppServerTextView = (TextView) findViewById(R.id.create_account_username);
- String xmppServer = StringUtils.parseServer(xmppServerTextView.getText().toString());
+ String xmppServer = "";
+ if (mSettings.getBoolean("settings_key_specific_server", false))
+ xmppServer = mSettings.getString("settings_key_xmpp_server", "");
+ else
+ xmppServer = StringUtils.parseServer(xmppServerTextView.getText().toString());
return xmppServer;
}
@@ -205,7 +215,7 @@
* @return Registered TLS use
*/
private boolean getRegisteredXMPPTLSUse() {
- return mSettings.getBoolean(getString(R.string.settings_key_xmpp_tls_use), DEFAULT_BOOLEAN_VALUE);
+ return mSettings.getBoolean("settings_key_xmpp_tls_use", DEFAULT_BOOLEAN_VALUE);
}
/**
@@ -215,7 +225,7 @@
private boolean checkPasswords() {
final String passwordFieldValue = ((EditText) findViewById(R.id.create_account_password)).getText().toString();
final String passwordConfirmFielddValue = ((EditText) findViewById(R.id.create_account_confirm_password))
- .getText().toString();
+ .getText().toString();
return passwordFieldValue.equals(passwordConfirmFielddValue);
}
@@ -237,9 +247,9 @@
mCreateAccountButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String usernameFieldValue = ((EditText) findViewById(R.id.create_account_username)).getText()
- .toString();
+ .toString();
String passwordFieldValue = ((EditText) findViewById(R.id.create_account_password)).getText()
- .toString();
+ .toString();
String username = StringUtils.parseName(usernameFieldValue);
if (!checkEmail())
createErrorDialog(getString(R.string.create_account_err_username));
@@ -256,10 +266,10 @@
createAccountLoginButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String usernameFieldValue = ((EditText) findViewById(R.id.create_account_username)).getText()
- .toString();
+ .toString();
String username = StringUtils.parseName(usernameFieldValue);
String passwordFieldValue = ((EditText) findViewById(R.id.create_account_password)).getText()
- .toString();
+ .toString();
if (!checkEmail())
createErrorDialog(getString(R.string.create_account_err_username));
else if (!checkPasswords())
@@ -268,10 +278,10 @@
if (createAccount(username, passwordFieldValue)) {
SharedPreferences.Editor settingsEditor = mSettings.edit();
settingsEditor
- .putString(getString(R.string.settings_key_account_username), usernameFieldValue);
+ .putString("settings_key_account_username", usernameFieldValue);
settingsEditor
- .putString(getString(R.string.settings_key_account_password), passwordFieldValue);
- settingsEditor.putBoolean(getString(R.string.PreferenceIsConfigured), true);
+ .putString("settings_key_account_password", passwordFieldValue);
+ settingsEditor.putBoolean("PreferenceIsConfigured", true);
settingsEditor.commit();
finish();
}
--- a/src/com/beem/project/beem/ui/Login.java Thu Dec 03 01:37:47 2009 +0100
+++ b/src/com/beem/project/beem/ui/Login.java Thu Dec 03 10:49:44 2009 +0100
@@ -7,7 +7,6 @@
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
-import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -22,7 +21,6 @@
*/
public class Login extends Activity {
- private static final String TAG = "Login2";
private SharedPreferences mSettings;
private TextView mTextView;
private boolean mIsConfigured;
@@ -38,7 +36,7 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
- mTextView = (TextView)findViewById(R.id.log_as_msg);
+ mTextView = (TextView) findViewById(R.id.log_as_msg);
mSettings = PreferenceManager.getDefaultSharedPreferences(this);
}
@@ -60,15 +58,11 @@
if (requestCode == 42) {
mIsResult = true;
if (resultCode == Activity.RESULT_OK) {
- Log.d(TAG, "Connected !!! Launch contact list");
startActivity(new Intent(this, ContactList.class));
finish();
- } else if (resultCode == Activity.RESULT_CANCELED) { // or error ?
- // Set an intent with data in like the error msg
- Log.d(TAG, "NOT Connected !!!");
+ } else if (resultCode == Activity.RESULT_CANCELED) {
if (data != null) {
String tmp = data.getExtras().getString("message");
- Log.d(TAG, tmp);
Toast.makeText(Login.this, tmp, Toast.LENGTH_SHORT).show();
mTextView.setText(tmp);
}
@@ -76,9 +70,6 @@
}
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
@@ -87,9 +78,6 @@
return true;
}
- /**
- * {@inheritDoc}
- */
@Override
public final boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
@@ -124,5 +112,4 @@
AlertDialog aboutDialog = builder.create();
aboutDialog.show();
}
-
}
--- a/src/com/beem/project/beem/ui/LoginAnim.java Thu Dec 03 01:37:47 2009 +0100
+++ b/src/com/beem/project/beem/ui/LoginAnim.java Thu Dec 03 10:49:44 2009 +0100
@@ -48,6 +48,42 @@
}
@Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.login_anim);
+ mLogo = (ImageView) findViewById(R.id.loginanim_logo_anim);
+ mRotateAnim = AnimationUtils.loadAnimation(this, R.anim.rotate_and_scale);
+ mCancelBt = (Button) findViewById(R.id.loginanim_cancel_button);
+ mCancelBt.setOnClickListener(new ClickListener());
+ mProgressBar = (ProgressBar) findViewById(R.id.loginanim_progressbar);
+ mProgressBar.setIndeterminate(true);
+ }
+
+ @Override
+ protected void onStart() {
+ super.onStart();
+ mLogo.startAnimation(mRotateAnim);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ if (mTask == null)
+ mTask = new LoginTask();
+ if (mXmppFacade == null)
+ bindService(LoginAnim.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ if (mXmppFacade != null) { // and async task not en cours
+ unbindService(mServConn);
+ mXmppFacade = null;
+ }
+ }
+
+ @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO use onBackPressed on Eclair (2.0)
if (keyCode == KeyEvent.KEYCODE_BACK && mTask.getStatus() != AsyncTask.Status.FINISHED) {
@@ -60,53 +96,15 @@
}
/**
- * {@inheritDoc}
+ * Click event listener on cancel button.
*/
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.login_anim);
- mLogo = (ImageView) findViewById(R.id.loginanim_logo_anim);
- mRotateAnim = AnimationUtils.loadAnimation(this, R.anim.rotate_and_scale);
- mCancelBt = (Button) findViewById(R.id.loginanim_cancel_button);
- mCancelBt.setOnClickListener(new ClickListener());
- mProgressBar = (ProgressBar) findViewById(R.id.loginanim_progressbar);
- mProgressBar.setIndeterminate(true);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onStart() {
- super.onStart();
- mLogo.startAnimation(mRotateAnim);
- }
+ private class ClickListener implements OnClickListener {
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onResume() {
- super.onResume();
- if (mTask == null) {
- mTask = new LoginTask();
- }
- if (mXmppFacade == null) {
- bindService(LoginAnim.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
+ /**
+ * Constructor.
+ */
+ ClickListener() {
}
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- if (mXmppFacade != null) { // and async task not en cours
- unbindService(mServConn);
- mXmppFacade = null;
- }
- }
-
- private class ClickListener implements OnClickListener {
@Override
public void onClick(View v) {
@@ -120,14 +118,22 @@
}
}
+ /**
+ * Asynchronous class for connection.
+ */
class LoginTask extends AsyncTask<IXmppFacade, Void, Boolean> {
private IXmppConnection mConnection;
private String mMsg;
+ /**
+ * Constructor.
+ */
+ LoginTask() {
+ }
+
@Override
protected Boolean doInBackground(IXmppFacade... params) {
- Log.d(TAG, "Launch the task");
boolean result = true;
IXmppFacade facade = params[0];
try {
@@ -138,20 +144,17 @@
mMsg = mConnection.getErrorMessage();
}
} catch (RemoteException e) {
- Log.d(TAG, "Error while connecting", e);
mMsg = "Exception during connection";
result = false;
}
- Log.d(TAG, "Connection result? " + result);
return result;
}
@Override
protected void onPostExecute(Boolean result) {
- if (result == null || !result) { // Task cancelled on exception
- Log.d(TAG, "Exception or cancelation of the connection");
- if (result == false) {
+ if (result == null || !result) { // Task cancelled or exception
+ if (!result) {
Intent i = new Intent();
i.putExtra("message", mMsg);
LoginAnim.this.setResult(Activity.RESULT_CANCELED, i);
@@ -159,6 +162,7 @@
LoginAnim.this.setResult(Activity.RESULT_CANCELED);
LoginAnim.this.finish();
} else {
+ mCancelBt.setEnabled(false);
LoginAnim.this.startService(LoginAnim.SERVICE_INTENT);
LoginAnim.this.setResult(Activity.RESULT_OK);
LoginAnim.this.finish();
@@ -179,8 +183,14 @@
}
+ /**
+ * The service connection used to connect to the Beem service.
+ */
private class LoginServiceConnection implements ServiceConnection {
+ /**
+ * Constructor.
+ */
public LoginServiceConnection() {
}
@@ -193,7 +203,6 @@
@Override
public void onServiceDisconnected(ComponentName name) {
- Log.d(TAG, "Service disconnected.");
mXmppFacade = null;
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/utils/BeemConnectivity.java Thu Dec 03 10:49:44 2009 +0100
@@ -0,0 +1,46 @@
+package com.beem.project.beem.utils;
+
+import android.content.Context;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.NetworkInfo.DetailedState;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.telephony.TelephonyManager;
+
+public class BeemConnectivity {
+ static public boolean isConnected(Context ctx) {
+ ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo ni = cm.getActiveNetworkInfo();
+ return ni.isConnected();
+ }
+
+ public static boolean isWifi(Context ctx) {
+ WifiManager wm = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
+ WifiInfo wi = wm.getConnectionInfo();
+ if (wi != null)
+ return false;
+ if (wi != null
+ && (WifiInfo.getDetailedStateOf(wi.getSupplicantState()) == DetailedState.OBTAINING_IPADDR || WifiInfo
+ .getDetailedStateOf(wi.getSupplicantState()) == DetailedState.CONNECTED)) {
+ return false;
+ }
+ return false;
+ }
+
+ public static boolean isUmts(Context ctx) {
+ TelephonyManager tm = (TelephonyManager)ctx.getSystemService(Context.TELEPHONY_SERVICE);
+ if (tm.getNetworkType() >= TelephonyManager.NETWORK_TYPE_UMTS)
+ return true;
+ return false;
+ }
+
+ public static boolean isEdge(Context ctx) {
+ TelephonyManager tm = (TelephonyManager)ctx.getSystemService(Context.TELEPHONY_SERVICE);
+ if (tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_EDGE)
+ return true;
+ return false;
+ }
+
+
+}