Finitions modification login de bart.
--- a/AndroidManifest.xml Sat Nov 28 02:45:33 2009 +0100
+++ b/AndroidManifest.xml Thu Dec 03 01:37:08 2009 +0100
@@ -5,38 +5,20 @@
<application android:label="@string/app_name"
android:icon="@drawable/beem_launcher_icon_silver" android:theme="@style/Theme.BEEM.Default"
android:debuggable="true" android:name="@string/app_name">
- <activity android:name=".ui.Login" android:label="@string/app_name" android:screenOrientation="portrait"
- android:launchMode="singleTask">
+ <activity android:name=".ui.Login" android:label="@string/app_name"
+ android:screenOrientation="portrait" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+ </activity>
+ <activity android:name=".ui.LoginAnim" android:label="ANIM"
+ android:launchMode="singleTop">
<intent-filter android:label="Beem Connection">
<action
android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
</intent-filter>
</activity>
-
- <activity android:name=".ui.Login2" android:label="NEWLOGIN"
- android:launchMode="singleTask">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
- <activity android:name=".ui.LoginAnim" android:label="ANIM"
- >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- <intent-filter android:label="Beem Connection">
- <action
- android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
- </intent-filter>
- </activity>
-
<activity android:name=".ui.Settings" android:label="@string/edit_settings_name">
<intent-filter android:label="Beem Connection">
<action
--- a/res/layout/login_anim.xml Sat Nov 28 02:45:33 2009 +0100
+++ b/res/layout/login_anim.xml Thu Dec 03 01:37:08 2009 +0100
@@ -1,19 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_height="fill_parent"
- android:layout_width="fill_parent"
- android:orientation="vertical" >
- <ImageView android:id="@+id/loginanim_logo_anim" android:src="@drawable/beem_launcher_icon_color" android:layout_height="fill_parent" android:layout_width="fill_parent"
- android:layout_weight="1"/>
- <!-- TODO traduction -->
- <ProgressBar android:id="@+id/loginanim_progressbar"
- android:layout_width= "fill_parent" android:layout_height="fill_parent" android:layout_weight="1" />
- <TextView android:id="@+id/loginanim_error_label"
- android:layout_height="wrap_content" android:layout_width="fill_parent" />
- <Button android:id= "@+id/loginanim_cancel_button"
- android:layout_height="wrap_content" android:layout_width="fill_parent"
- android:layout_gravity="bottom"
- android:text="Cancel" />
+ android:layout_height="fill_parent" android:layout_width="fill_parent"
+ android:orientation="vertical">
+ <ImageView android:id="@+id/loginanim_logo_anim" android:src="@drawable/beem_launcher_icon_color"
+ android:layout_height="fill_parent" android:layout_width="fill_parent"
+ android:layout_weight="1" />
+ <ProgressBar android:id="@+id/loginanim_progressbar"
+ android:layout_width="fill_parent" android:layout_height="fill_parent"
+ android:layout_weight="1" />
+ <Button android:id="@+id/loginanim_cancel_button"
+ android:layout_height="wrap_content" android:layout_width="fill_parent"
+ android:layout_gravity="bottom" android:text="@string/CancelButton" />
</LinearLayout>
--- a/res/menu/edit_settings.xml Sat Nov 28 02:45:33 2009 +0100
+++ b/res/menu/edit_settings.xml Thu Dec 03 01:37:08 2009 +0100
@@ -3,10 +3,6 @@
android:visible="true"
android:icon="@drawable/ic_menu_invite"
android:title="@string/settings_menu_create_account" />
- <item android:id="@+id/settings_menu_login"
- android:visible="true"
- android:title="@string/settings_menu_login"
- android:icon="@drawable/ic_menu_login" />
<item android:id="@+id/settings_menu_privacy_lists"
android:visible="true"
android:title="@string/settings_menu_privacy_lists"
--- a/res/menu/login.xml Sat Nov 28 02:45:33 2009 +0100
+++ b/res/menu/login.xml Thu Dec 03 01:37:08 2009 +0100
@@ -1,4 +1,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@+id/login_menu_login"
+ android:visible="true"
+ android:title="@string/login_menu_login"
+ android:icon="@drawable/ic_menu_login" />
<item android:id="@+id/login_menu_settings"
android:visible="true"
android:title="@string/login_menu_settings"
--- a/res/values-fr/strings.xml Sat Nov 28 02:45:33 2009 +0100
+++ b/res/values-fr/strings.xml Thu Dec 03 01:37:08 2009 +0100
@@ -170,12 +170,12 @@
<string name="login_login_progress">Connexion en cours. Veuillez patienter...</string>
<string name="login_error_msg">Malheureusement, une erreur est survenu.\n\nDétail
de l\'erreur :\n%s</string>
+ <string name="login_menu_login">Se connecter</string>
<!--
EditSettings Activity
-->
<string name="settings_menu_create_account">Créer un compte</string>
- <string name="settings_menu_login">Se connecter</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>
--- a/res/values/strings.xml Sat Nov 28 02:45:33 2009 +0100
+++ b/res/values/strings.xml Thu Dec 03 01:37:08 2009 +0100
@@ -160,10 +160,10 @@
<string name="login_max_retry">Max retry</string>
<string name="login_error_msg">Unfortunately, an error occured.\n\nError
detail:\n%s</string>
+ <string name="login_menu_login">Login</string>
<!-- EditSettings Activity -->
<string name="settings_menu_create_account">Create an account</string>
- <string name="settings_menu_login">Login</string>
<string name="settings_menu_privacy_lists">Manage my privacy lists</string>
<string name="settings_saved_ok">The settings have been saved successfully.</string>
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Sat Nov 28 02:45:33 2009 +0100
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Thu Dec 03 01:37:08 2009 +0100
@@ -10,7 +10,6 @@
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Presence;
-import org.jivesoftware.smack.packet.StreamError;
import org.jivesoftware.smackx.ChatStateManager;
import org.jivesoftware.smackx.ServiceDiscoveryManager;
import org.jivesoftware.smackx.jingle.JingleManager;
@@ -29,9 +28,9 @@
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.ChangeStatus;
import com.beem.project.beem.ui.Subscription;
import com.beem.project.beem.utils.BeemBroadcastReceiver;
-import com.beem.project.beem.ui.ChangeStatus;
import com.beem.project.beem.utils.Status;
/**
--- a/src/com/beem/project/beem/ui/Chat.java Sat Nov 28 02:45:33 2009 +0100
+++ b/src/com/beem/project/beem/ui/Chat.java Thu Dec 03 01:37:08 2009 +0100
@@ -740,7 +740,6 @@
* JID attribute mutator.
* @param bareJid A String containing the author's bare JID of the message.
*/
- @SuppressWarnings("unused")
public void setBareJid(String bareJid) {
mBareJid = bareJid;
}
@@ -749,7 +748,6 @@
* Name attribute mutator.
* @param name A String containing the author's name of the message.
*/
- @SuppressWarnings("unused")
public void setName(String name) {
mName = name;
}
--- a/src/com/beem/project/beem/ui/ContactList.java Sat Nov 28 02:45:33 2009 +0100
+++ b/src/com/beem/project/beem/ui/ContactList.java Thu Dec 03 01:37:08 2009 +0100
@@ -23,13 +23,13 @@
import android.os.IBinder;
import android.os.RemoteException;
import android.preference.PreferenceManager;
+import android.view.ContextMenu;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
-import android.view.ContextMenu;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Gallery;
@@ -37,7 +37,6 @@
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
-import android.widget.AdapterView.OnItemLongClickListener;
import com.beem.project.beem.R;
import com.beem.project.beem.service.Contact;
@@ -189,7 +188,7 @@
mListContact.clear();
stopService(SERVICE_INTENT);
finish();
- startActivity(new Intent(this, Login.class));
+ // startActivity(new Intent(this, Login.class));
}
}
}
@@ -211,8 +210,10 @@
super.onStop();
if (mContactDialog != null)
mContactDialog.dismiss();
- if (mReceiver.isBinded())
+ if (mReceiver.isBinded()) {
unbindService(mServConn);
+ mReceiver.setBinded(false);
+ }
}
@Override
@@ -224,6 +225,7 @@
/**
* Comparator Contact by Name.
*/
+ @SuppressWarnings("unused")
private class ComparatorContactListByName<T> implements Comparator<T> {
/**
* Constructor.
--- a/src/com/beem/project/beem/ui/Login.java Sat Nov 28 02:45:33 2009 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,393 +0,0 @@
-package com.beem.project.beem.ui;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.ProgressDialog;
-import android.content.ComponentName;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.os.SystemClock;
-import android.preference.PreferenceManager;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.beem.project.beem.R;
-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.Status;
-
-/**
- * This class represents an activity which allows the user to connect to an XMPP server with his username/password.
- * @author Jean-Manuel Da Silva <dasilvj at beem-project dot com>
- */
-public class Login extends Activity {
-
- private static final String TAG = "Login";
- private static final int REQUEST_CODE = 1;
- private static final Intent SERVICE_INTENT = new Intent();
- static {
- SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService"));
- }
-
- private final Handler mConnectionHandler = new Handler();
- private final ConnectionRunnable mConnectionRunnable = new ConnectionRunnable();
- private ProgressDialog mProgressDialog;
-
- private boolean mIsConnectedService;
- private final ServiceConnection mServConn = new BeemServiceConnection();
- private IXmppFacade mXmppFacade;
-
- private SharedPreferences mSettings;
- private boolean mIsConfigured;
- private int mRetry;
- private IXmppConnection mXmppConnection;
-
- /**
- * Constructor.
- */
- public Login() {
- }
-
- /**
- * Create an about "BEEM" dialog.
- */
- public void createAboutDialog() {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle(R.string.login_about_title).setMessage(R.string.login_about_msg).setCancelable(false);
- builder.setNeutralButton(R.string.login_about_button, new DialogInterface.OnClickListener() {
-
- public void onClick(DialogInterface dialog, int whichButton) {
- dialog.cancel();
- }
- });
- AlertDialog aboutDialog = builder.create();
- aboutDialog.show();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- Log.d(TAG, "BEGIN onCreate.");
- mSettings = PreferenceManager.getDefaultSharedPreferences(this);
- setContentView(R.layout.login);
- mProgressDialog = new ProgressDialog(this);
- Log.d(TAG, "END onCreate.");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onStop() {
- super.onStop();
- Log.d(TAG, "BEGIN onStop.");
- if (mIsConfigured && (mIsConnectedService || mXmppFacade != null)) {
- boolean isConnected = false;
- if (mXmppConnection != null) {
- try {
- isConnected = mXmppConnection.isAuthentificated();
- } catch (RemoteException e) {
- e.printStackTrace();
- }
- }
- unbindService(mServConn);
- if (!isConnected) {
- stopService(SERVICE_INTENT);
- }
- mXmppFacade = null;
- }
- Log.d(TAG, "END onStop.");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onPause() {
- super.onPause();
- Log.d(TAG, "BEGIN onPause.");
- mConnectionHandler.removeCallbacks(mConnectionRunnable);
- mProgressDialog.dismiss();
- Log.d(TAG, "END onPause.");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onResume() {
- super.onResume();
- Log.d(TAG, "BEGIN onResume.");
- Log.d(TAG, "END onResume.");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onStart() {
- super.onStart();
- Log.d(TAG, "BEGIN onStart.");
- mIsConfigured = mSettings.getBoolean("PreferenceIsConfigured", false);
- if (mIsConfigured && !mIsConnectedService) {
- try {
- Thread.sleep(1000); // HACK: Pour éviter de rebinder un service
- // pas encore arreter.
- } catch (InterruptedException e) {
- Log.e(TAG, e.getMessage());
- }
- bindService(Login.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
- mIsConnectedService = true;
- }
- Log.d(TAG, "END onStart.");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (requestCode == REQUEST_CODE) {
- if (resultCode == RESULT_OK) {
- stopService(SERVICE_INTENT);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.login, menu);
- return true;
- }
-
- /**
- * Callback for menu item selected.
- * @param item the item selected
- * @return true on success, false otherwise
- */
- @Override
- public final boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.login_menu_settings:
- startActivity(new Intent(Login.this, Settings.class));
- return true;
- case R.id.login_menu_about:
- createAboutDialog();
- return true;
- default:
- return false;
- }
- }
-
- /**
- * Connection runnable.
- * @author nikita
- */
- private class ConnectionRunnable implements Runnable {
-
- /**
- * Constructor.
- */
- public ConnectionRunnable() {
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void run() {
- if (mRetry++ > 3) {
- Toast.makeText(Login.this, R.string.login_max_retry, Toast.LENGTH_LONG).show();
- mConnectionHandler.removeCallbacks(mConnectionRunnable);
- } else {
- mIsConfigured = mSettings.getBoolean("PreferenceIsConfigured", false);
- if (mIsConfigured) {
- bindService(Login.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
- }
- }
-
- }
- }
-
- /**
- * Listener use to check the state of the connection with the server.
- */
- private class BeemConnectionListener extends IBeemConnectionListener.Stub {
-
- /**
- * Constructor.
- */
- public BeemConnectionListener() {
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void connectionClosed() throws RemoteException {
- Log.d(TAG, "BEGIN connectionClosed.");
- if (mXmppFacade != null) {
- launchReconnectionHandler();
- mXmppFacade = null;
- }
- Log.d(TAG, "END connectionClosed.");
- }
-
- @Override
- public void connectionClosedOnError() throws RemoteException {
- Log.d(TAG, "BEGIN connectionClosedOnError.");
- if (mXmppFacade != null) {
- launchReconnectionHandler();
- mXmppFacade = null;
- }
- Log.d(TAG, "END connectionClosedOnError.");
- }
-
- @Override
- public void connectionFailed(String errorMsg) throws RemoteException {
- Log.d(TAG, "BEGIN connectionFailed.");
- if (mXmppFacade != null) {
- Login.this.unbindService(mServConn);
- Login.this.stopService(SERVICE_INTENT);
- mIsConnectedService = false;
- mXmppFacade = null;
- }
- dismissProgressDialog();
- showToast(errorMsg);
- launchReconnectionHandler();
- Log.d(TAG, "END connectionFailed.");
- }
-
- /**
- * launch reconnection handler.
- */
- private void launchReconnectionHandler() {
- mConnectionHandler.postAtTime(mConnectionRunnable, Integer.parseInt(mSettings.getString(
- "settings_key_reco_delay", "10"))
- * 1000 + SystemClock.uptimeMillis());
- }
-
- /**
- * Show an error message with a toast.
- * @param errorMsg The message to display.
- */
- private void showToast(final String errorMsg) {
- mConnectionHandler.post(new Runnable() {
- /**
- * @{inheritDoc
- */
- @Override
- public void run() {
- Toast.makeText(Login.this, errorMsg, Toast.LENGTH_LONG).show();
- TextView labelError = (TextView) findViewById(R.id.log_as_msg);
- labelError.setText(getString(R.string.login_error_msg, errorMsg));
- }
- });
- }
-
- /**
- * Dismiss the progress dialog.
- */
- private void dismissProgressDialog() {
- mConnectionHandler.post(new Runnable() {
-
- /**
- * @{inheritDoc
- */
- @Override
- public void run() {
- mProgressDialog.dismiss();
- }
- });
- }
-
- @Override
- public void onConnect() throws RemoteException {
- Log.d(TAG, "BEGIN onConnect.");
- dismissProgressDialog();
- mXmppFacade.changeStatus(Status.CONTACT_STATUS_AVAILABLE, null);
- mRetry = 0;
- startActivity(new Intent(Login.this, ContactList.class));
- finish();
- Log.d(TAG, "END onConnect.");
- }
-
- @Override
- public void reconnectingIn(int seconds) throws RemoteException {
- }
-
- @Override
- public void reconnectionFailed() throws RemoteException {
- }
-
- @Override
- public void reconnectionSuccessful() throws RemoteException {
- }
- }
-
- /**
- * ServiceConnection use to connect to the Beem Service.
- */
- private class BeemServiceConnection implements ServiceConnection {
- /**
- * Constructor.
- */
- public BeemServiceConnection() {
- }
-
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- Log.d(TAG, "BEGIN onServiceConnected.");
- mXmppFacade = IXmppFacade.Stub.asInterface(service);
- mIsConnectedService = true;
- try {
- mXmppConnection = mXmppFacade.createConnection();
- mXmppConnection.addConnectionListener(new BeemConnectionListener());
- if (!mXmppConnection.isAuthentificated()) {
- mConnectionHandler.post(new Runnable() {
- @Override
- public void run() {
- mProgressDialog.setMessage(getString(R.string.login_login_progress));
- mProgressDialog.show();
- }
- });
- Login.this.startService(Login.SERVICE_INTENT);
- } else {
- startActivity(new Intent(Login.this, ContactList.class));
- finish();
- }
- } catch (RemoteException e) {
- Log.e(TAG, e.getMessage());
- }
- Log.d(TAG, "END onServiceConnected.");
- }
-
- @Override
- public void onServiceDisconnected(ComponentName name) {
- Log.d(TAG, "BEGIN onServiceDisconnected.");
- mIsConnectedService = false;
- mXmppFacade = null;
- Log.d(TAG, "END onServiceDisconnected.");
- }
- }
-}
--- a/src/com/beem/project/beem/ui/Login2.java Sat Nov 28 02:45:33 2009 +0100
+++ b/src/com/beem/project/beem/ui/Login2.java Thu Dec 03 01:37:08 2009 +0100
@@ -2,38 +2,43 @@
import android.app.Activity;
import android.app.AlertDialog;
+import android.content.DialogInterface;
import android.content.Intent;
-import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
-import com.beem.project.beem.R;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.beem.project.beem.R;
/**
* This class is the main Activity for the Beem project.
* @author Da Risk <darisk972@gmai.com>
*/
-public class Login2 extends Activity {
+public class Login extends Activity {
private static final String TAG = "Login2";
private SharedPreferences mSettings;
+ private TextView mTextView;
private boolean mIsConfigured;
+ private boolean mIsResult;
/**
* Constructor.
*/
- public Login2() {
+ public Login() {
}
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
+ mTextView = (TextView)findViewById(R.id.log_as_msg);
mSettings = PreferenceManager.getDefaultSharedPreferences(this);
}
@@ -41,25 +46,32 @@
protected void onStart() {
super.onStart();
mIsConfigured = mSettings.getBoolean("PreferenceIsConfigured", false);
- //TODO utiliser une options des preference plutot.
- if (mIsConfigured) {
- Intent i = new Intent (this, LoginAnim.class);
+ // TODO utiliser une options des preference plutot.
+ if (mIsConfigured && !mIsResult) {
+ mTextView.setText("");
+ Intent i = new Intent(this, LoginAnim.class);
startActivityForResult(i, 42);
+ mIsResult = false;
}
}
@Override
- protected void onActivityResult (int requestCode, int resultCode, Intent data) {
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == 42) {
+ mIsResult = true;
if (resultCode == Activity.RESULT_OK) {
Log.d(TAG, "Connected !!! Launch contact list");
- Intent i = new Intent(this, ContactList.class);
- startActivity(i);
+ startActivity(new Intent(this, ContactList.class));
finish();
- } else if (resultCode == Activity.RESULT_CANCELED) { // or error ?
+ } else if (resultCode == Activity.RESULT_CANCELED) { // or error ?
// Set an intent with data in like the error msg
Log.d(TAG, "NOT Connected !!!");
-
+ 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);
+ }
}
}
}
@@ -82,11 +94,16 @@
public final boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.login_menu_settings:
- startActivity(new Intent(Login2.this, Settings.class));
+ mTextView.setText("");
+ startActivity(new Intent(Login.this, Settings.class));
return true;
case R.id.login_menu_about:
createAboutDialog();
return true;
+ case R.id.login_menu_login:
+ Intent i = new Intent(this, LoginAnim.class);
+ startActivityForResult(i, 42);
+ return true;
default:
return false;
}
--- a/src/com/beem/project/beem/ui/LoginAnim.java Sat Nov 28 02:45:33 2009 +0100
+++ b/src/com/beem/project/beem/ui/LoginAnim.java Thu Dec 03 01:37:08 2009 +0100
@@ -1,31 +1,29 @@
package com.beem.project.beem.ui;
import android.app.Activity;
-import android.content.ServiceConnection;
import android.content.ComponentName;
import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.AsyncTask;
import android.os.Bundle;
-import android.os.AsyncTask;
import android.os.IBinder;
import android.os.RemoteException;
-import android.view.View.OnClickListener;
+import android.util.Log;
+import android.view.KeyEvent;
import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
import android.widget.Button;
-import android.view.animation.Animation;
import android.widget.ImageView;
-import android.widget.TextView;
import android.widget.ProgressBar;
-import android.view.animation.AnimationUtils;
-import android.view.KeyEvent;
+
import com.beem.project.beem.R;
-import android.util.Log;
-import com.beem.project.beem.service.aidl.IXmppFacade;
import com.beem.project.beem.service.aidl.IXmppConnection;
import com.beem.project.beem.service.aidl.IXmppFacade;
/**
- * This class is an activity which display an animation during the connection
- * with the server.
+ * This class is an activity which display an animation during the connection with the server.
* @author Da Risk <darisk972@gmail.com>
*/
public class LoginAnim extends Activity {
@@ -37,10 +35,9 @@
}
private ImageView mLogo;
private Animation mRotateAnim;
- private TextView mErrorLabel;
private final ServiceConnection mServConn = new LoginServiceConnection();
private IXmppFacade mXmppFacade;
- private AsyncTask<IXmppFacade, Void, Boolean>mTask;
+ private AsyncTask<IXmppFacade, Void, Boolean> mTask;
private Button mCancelBt;
private ProgressBar mProgressBar;
@@ -54,7 +51,7 @@
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO use onBackPressed on Eclair (2.0)
if (keyCode == KeyEvent.KEYCODE_BACK && mTask.getStatus() != AsyncTask.Status.FINISHED) {
- if (! mTask.cancel(true)) {
+ if (!mTask.cancel(true)) {
Log.d(TAG, "Can't interrupt the connection");
}
setResult(Activity.RESULT_CANCELED);
@@ -70,10 +67,9 @@
super.onCreate(savedInstanceState);
setContentView(R.layout.login_anim);
mLogo = (ImageView) findViewById(R.id.loginanim_logo_anim);
- mErrorLabel = (TextView) findViewById(R.id.loginanim_error_label);
mRotateAnim = AnimationUtils.loadAnimation(this, R.anim.rotate_and_scale);
mCancelBt = (Button) findViewById(R.id.loginanim_cancel_button);
- mCancelBt.setOnClickListener( new ClickListener());
+ mCancelBt.setOnClickListener(new ClickListener());
mProgressBar = (ProgressBar) findViewById(R.id.loginanim_progressbar);
mProgressBar.setIndeterminate(true);
}
@@ -84,7 +80,7 @@
@Override
protected void onStart() {
super.onStart();
- mLogo.startAnimation(mRotateAnim);
+ mLogo.startAnimation(mRotateAnim);
}
/**
@@ -110,25 +106,40 @@
}
}
+ private class ClickListener implements OnClickListener {
+
+ @Override
+ public void onClick(View v) {
+ if (v == mCancelBt) {
+ if (!mTask.cancel(true)) {
+ Log.d(TAG, "Can't interrupt the connection");
+ }
+ setResult(Activity.RESULT_CANCELED);
+ finish();
+ }
+ }
+ }
+
class LoginTask extends AsyncTask<IXmppFacade, Void, Boolean> {
private IXmppConnection mConnection;
+ private String mMsg;
@Override
- protected Boolean doInBackground(IXmppFacade ... params) {
+ protected Boolean doInBackground(IXmppFacade... params) {
+ Log.d(TAG, "Launch the task");
boolean result = true;
IXmppFacade facade = params[0];
try {
mConnection = facade.createConnection();
if (!mConnection.isAuthentificated()) {
result = mConnection.connectSync();
- if (!result) {
- // set bad message ?
- }
+ if (!result)
+ mMsg = mConnection.getErrorMessage();
}
} catch (RemoteException e) {
Log.d(TAG, "Error while connecting", e);
- // set bad message ?
+ mMsg = "Exception during connection";
result = false;
}
Log.d(TAG, "Connection result? " + result);
@@ -137,25 +148,18 @@
@Override
protected void onPostExecute(Boolean result) {
+
if (result == null || !result) { // Task cancelled on exception
- String msg;
Log.d(TAG, "Exception or cancelation of the connection");
- try {
- if (!result)
- msg = mConnection.getErrorMessage();
- else
- msg = "Exception during connection";
- } catch (RemoteException e) {
- Log.d(TAG, "Exception or cancelation of the connection");
- msg = "Remote Exception";
- }
- //TODO create an intent and store the error msg in. Return this intent on result.
- LoginAnim.this.mErrorLabel.setText("Error !!!\n" + msg);
- LoginAnim.this.setResult(Activity.RESULT_CANCELED);
+ if (result == false) {
+ Intent i = new Intent();
+ i.putExtra("message", mMsg);
+ LoginAnim.this.setResult(Activity.RESULT_CANCELED, i);
+ } else
+ LoginAnim.this.setResult(Activity.RESULT_CANCELED);
LoginAnim.this.finish();
} else {
LoginAnim.this.startService(LoginAnim.SERVICE_INTENT);
- //LoginAnim.this.startActivity(new Intent(LoginAnim.this, ContactList.class));
LoginAnim.this.setResult(Activity.RESULT_OK);
LoginAnim.this.finish();
}
@@ -163,7 +167,6 @@
@Override
protected void onCancelled() {
- mCancelBt.setText("Cancelled. Retry");
try {
if (mConnection != null && mConnection.isAuthentificated()) {
mConnection.disconnect();
@@ -184,29 +187,14 @@
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mXmppFacade = IXmppFacade.Stub.asInterface(service);
- Log.d(TAG, "Launch the task");
if (mTask.getStatus() == AsyncTask.Status.PENDING)
mTask = mTask.execute(mXmppFacade);
}
-
+
@Override
public void onServiceDisconnected(ComponentName name) {
Log.d(TAG, "Service disconnected.");
mXmppFacade = null;
}
}
-
- private class ClickListener implements OnClickListener {
-
- @Override
- public void onClick(View v) {
- if (v == mCancelBt) {
- if (! mTask.cancel(true)) {
- Log.d(TAG, "Can't interrupt the connection");
- }
- setResult(Activity.RESULT_CANCELED);
- finish();
- }
- }
- }
}
--- a/src/com/beem/project/beem/ui/Settings.java Sat Nov 28 02:45:33 2009 +0100
+++ b/src/com/beem/project/beem/ui/Settings.java Thu Dec 03 01:37:08 2009 +0100
@@ -92,16 +92,6 @@
i = new Intent(this, CreateAccount.class);
startActivity(i);
return true;
- case R.id.settings_menu_login:
- setResult(RESULT_OK);
- SharedPreferences settings = getPreferenceManager().getSharedPreferences();
- settings.edit().putBoolean(
- "PreferenceIsConfigured",
- !"".equals(settings.getString("settings_key_account_username", ""))
- || !"".equals(settings.getString("settings_key_account_password", ""))).commit();
- this.stopService(SERVICE_INTENT);
- finish();
- return true;
case R.id.settings_menu_privacy_lists:
/*
* i = new Intent(this, PrivacyList.class); startActivity(i);
--- a/src/com/beem/project/beem/ui/UserInfo.java Sat Nov 28 02:45:33 2009 +0100
+++ b/src/com/beem/project/beem/ui/UserInfo.java Thu Dec 03 01:37:08 2009 +0100
@@ -16,7 +16,6 @@
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
-import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
--- a/src/com/beem/project/beem/utils/BeemBroadcastReceiver.java Sat Nov 28 02:45:33 2009 +0100
+++ b/src/com/beem/project/beem/utils/BeemBroadcastReceiver.java Thu Dec 03 01:37:08 2009 +0100
@@ -8,8 +8,6 @@
import android.util.Log;
import android.widget.Toast;
-import com.beem.project.beem.ui.Login;
-
/**
* Manage broadcast disconnect intent.
* @author nikita
@@ -41,7 +39,7 @@
if (mIsBinded)
context.unbindService(mService);
setBinded(false);
- // TODO ce code est commenté car il empeche de gerer un cancel sur une connexion
+ // TODO ce code est comment car il empeche de gerer un cancel sur une connexion
// start activity if unexpected disconnection
// if (!intent.getBooleanExtra("normally", false))
// context.startActivity(new Intent(context, Login.class));