# HG changeset patch
# User "Vincent Veronis"
# Date 1300586129 -3600
# Node ID e221906b6fc79a5e75c7a70064ba171a47fd3dda
# Parent c555133a4d720563458b83ec7db0d58c78e33bd9
Add the list of accounts in the Login.View
Send to the BeemService the account name for the connection
diff -r c555133a4d72 -r e221906b6fc7 res/layout/login.xml
--- a/res/layout/login.xml Sun Mar 20 00:57:46 2011 +0100
+++ b/res/layout/login.xml Sun Mar 20 02:55:29 2011 +0100
@@ -1,17 +1,13 @@
-
-
-
-
-
-
-
+
+
+
+
+
\ No newline at end of file
diff -r c555133a4d72 -r e221906b6fc7 res/layout/login_row_account.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/login_row_account.xml Sun Mar 20 02:55:29 2011 +0100
@@ -0,0 +1,5 @@
+
+
\ No newline at end of file
diff -r c555133a4d72 -r e221906b6fc7 src/com/beem/project/beem/BeemService.java
--- a/src/com/beem/project/beem/BeemService.java Sun Mar 20 00:57:46 2011 +0100
+++ b/src/com/beem/project/beem/BeemService.java Sun Mar 20 02:55:29 2011 +0100
@@ -124,7 +124,7 @@
public IBinder onBind(Intent intent) {
Log.d(TAG, "ONBIND()");
//TODO: Prendre le bon mbind dans le tableau
- return mBind.get("beem@elyzion.net");
+ return mBind.get(intent.getExtras().getString("account_name"));
}
@Override
@@ -212,12 +212,12 @@
* @param notif the notification to show
*/
public void sendNotification(int id, Notification notif) {
-// if (mSettings.getBoolean(BeemApplication.NOTIFICATION_VIBRATE_KEY, true))
-// notif.defaults |= Notification.DEFAULT_VIBRATE;
-// notif.defaults |= Notification.DEFAULT_LIGHTS;
-// String ringtoneStr = mSettings.getString(BeemApplication.NOTIFICATION_SOUND_KEY, "");
-// notif.sound = Uri.parse(ringtoneStr);
-// mNotificationManager.notify(id, notif);
+ // if (mSettings.getBoolean(BeemApplication.NOTIFICATION_VIBRATE_KEY, true))
+ // notif.defaults |= Notification.DEFAULT_VIBRATE;
+ // notif.defaults |= Notification.DEFAULT_LIGHTS;
+ // String ringtoneStr = mSettings.getString(BeemApplication.NOTIFICATION_SOUND_KEY, "");
+ // notif.sound = Uri.parse(ringtoneStr);
+ // mNotificationManager.notify(id, notif);
}
/**
diff -r c555133a4d72 -r e221906b6fc7 src/com/beem/project/beem/ui/Login.java
--- a/src/com/beem/project/beem/ui/Login.java Sun Mar 20 00:57:46 2011 +0100
+++ b/src/com/beem/project/beem/ui/Login.java Sun Mar 20 02:55:29 2011 +0100
@@ -40,9 +40,14 @@
Flavien Astraud, November 26, 2009
Head of the EIP Laboratory.
-*/
+ */
package com.beem.project.beem.ui;
+import java.util.ArrayList;
+import java.util.List;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Application;
@@ -51,16 +56,21 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
+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.widget.AdapterView;
+import android.widget.BaseAdapter;
+import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
+import android.widget.AdapterView.OnItemClickListener;
import com.beem.project.beem.BeemApplication;
import com.beem.project.beem.R;
-import com.beem.project.beem.ui.wizard.Account;
-import com.beem.project.beem.utils.BeemConnectivity;
/**
* This class is the main Activity for the Beem project.
@@ -70,9 +80,12 @@
private static final int LOGIN_REQUEST_CODE = 1;
private TextView mTextView;
- private boolean mIsResult;
private BeemApplication mBeemApplication;
+ List mListAccount = new ArrayList();
+ private BeemAccountList mAdapterAccountList;
+ private final BeemAccountListOnClick mOnAccountClick = new BeemAccountListOnClick();
+
/**
* Constructor.
*/
@@ -95,26 +108,21 @@
}
setContentView(R.layout.login);
mTextView = (TextView) findViewById(R.id.log_as_msg);
+ ListView listView = (ListView) findViewById(R.id.accountlist);
+ mAdapterAccountList = new BeemAccountList(getLayoutInflater());
+ listView.setOnItemClickListener(mOnAccountClick);
+ listView.setAdapter(mAdapterAccountList);
}
@Override
protected void onStart() {
super.onStart();
- if (mBeemApplication.isAccountConfigured() && !mIsResult
- && BeemConnectivity.isConnected(getApplicationContext())) {
- mTextView.setText("");
- Intent i = new Intent(this, LoginAnim.class);
- startActivityForResult(i, LOGIN_REQUEST_CODE);
- mIsResult = false;
- } else {
- mTextView.setText(R.string.login_start_msg);
- }
+ mTextView.setText(R.string.login_start_msg);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == LOGIN_REQUEST_CODE) {
- mIsResult = true;
if (resultCode == Activity.RESULT_OK) {
startActivity(new Intent(this, ContactList.class));
finish();
@@ -187,4 +195,67 @@
AlertDialog aboutDialog = builder.create();
aboutDialog.show();
}
+
+ private class BeemAccountList extends BaseAdapter {
+
+ private LayoutInflater mInflater;
+
+ public BeemAccountList(LayoutInflater layoutInflater) {
+ mInflater = layoutInflater;
+ AccountManager am = AccountManager.get(Login.this);
+ Account allAccount[] = am.getAccountsByType("com.beem.project.com");
+ for (Account account : allAccount) {
+ mListAccount.add(account.name);
+ mListAccount.add(account.name);
+
+ }
+ }
+
+ @Override
+ public int getCount() {
+ return mListAccount.size();
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return mListAccount.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View v = convertView;
+ if (convertView == null) {
+ v = mInflater.inflate(R.layout.login_row_account, null);
+ }
+ TextView tv = (TextView) v.findViewById(R.id.accountname);
+ tv.setText(mListAccount.get(position));
+ return v;
+ }
+ }
+
+ /**
+ * Event simple click on item of the contact list.
+ */
+ private class BeemAccountListOnClick implements OnItemClickListener {
+ /**
+ * Constructor.
+ */
+ public BeemAccountListOnClick() {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onItemClick(AdapterView> arg0, View v, int pos, long lpos) {
+ Intent i = new Intent(Login.this, LoginAnim.class);
+ i.putExtra("account_name", mListAccount.get(pos));
+ startActivityForResult(i, LOGIN_REQUEST_CODE);
+ }
+ }
}
diff -r c555133a4d72 -r e221906b6fc7 src/com/beem/project/beem/ui/LoginAnim.java
--- a/src/com/beem/project/beem/ui/LoginAnim.java Sun Mar 20 00:57:46 2011 +0100
+++ b/src/com/beem/project/beem/ui/LoginAnim.java Sun Mar 20 02:55:29 2011 +0100
@@ -121,8 +121,9 @@
if (mTask == null)
mTask = new LoginTask();
if (mXmppFacade == null) {
- Intent i = new Intent();
- bindService(LoginAnim.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE);
+ Intent i = new Intent(LoginAnim.SERVICE_INTENT);
+ i.putExtra("account_name", getIntent().getExtras().getString("account_name"));
+ bindService(i, mServConn, BIND_AUTO_CREATE);
}
}