# HG changeset patch # User "Vincent Veronis" # Date 1300559491 -3600 # Node ID be08c91576360e27ef2ee0e45404c0abd11715e7 # Parent 85977e23817aecbc7eea1790695ff6cb2c94ae2f# Parent 2236fe5b2db178d4a8e7e4fde96043ba19efb45c Merge beem-account and Beem-avatar diff -r 2236fe5b2db1 -r be08c9157636 AndroidManifest.xml --- a/AndroidManifest.xml Sat Mar 05 17:44:41 2011 +0100 +++ b/AndroidManifest.xml Sat Mar 19 19:31:31 2011 +0100 @@ -13,25 +13,62 @@ - + - + + + + + + android:launchMode="singleTop"> + + + + - - + android:launchMode="singleTask" android:windowSoftInputMode="stateHidden"> + + + + + + + + + + + + + + - - - - - + android:launchMode="singleTask"> + + + + + + + + + + + + + + - + + + + + + + + - - + android:name="com.beem.project.beem.BEEM_SERVICE" /> + + - - - - + + + + + android:normalScreens="true" android:smallScreens="true" + android:anyDensity="true" /> diff -r 2236fe5b2db1 -r be08c9157636 default.properties --- a/default.properties Sat Mar 05 17:44:41 2011 +0100 +++ b/default.properties Sat Mar 19 19:31:31 2011 +0100 @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-7 +target=android-8 diff -r 2236fe5b2db1 -r be08c9157636 res/xml/authenticator.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/res/xml/authenticator.xml Sat Mar 19 19:31:31 2011 +0100 @@ -0,0 +1,8 @@ + + \ No newline at end of file diff -r 2236fe5b2db1 -r be08c9157636 src/com/beem/project/beem/account/Authenticator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/account/Authenticator.java Sat Mar 19 19:31:31 2011 +0100 @@ -0,0 +1,67 @@ +package com.beem.project.beem.account; + +import com.beem.project.beem.ui.wizard.AccountConfigure; + +import android.accounts.AbstractAccountAuthenticator; +import android.accounts.Account; +import android.accounts.AccountAuthenticatorResponse; +import android.accounts.AccountManager; +import android.accounts.NetworkErrorException; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; + +public class Authenticator extends AbstractAccountAuthenticator { + + private Context mContext; + + public Authenticator(Context context) { + super(context); + mContext = context; + } + + @Override + public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, + String[] requiredFeatures, Bundle options) throws NetworkErrorException { + Intent intent = new Intent(mContext, AccountConfigure.class); + intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); + Bundle reply = new Bundle(); + reply.putParcelable(AccountManager.KEY_INTENT, intent); + return reply; + } + + @Override + public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) + throws NetworkErrorException { + return null; + } + + @Override + public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) { + return null; + } + + @Override + public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, + Bundle options) throws NetworkErrorException { + return null; + } + + @Override + public String getAuthTokenLabel(String authTokenType) { + return null; + } + + @Override + public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features) + throws NetworkErrorException { + return null; + } + + @Override + public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, + Bundle options) throws NetworkErrorException { + return null; + } + +} diff -r 2236fe5b2db1 -r be08c9157636 src/com/beem/project/beem/account/AuthenticatorService.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/account/AuthenticatorService.java Sat Mar 19 19:31:31 2011 +0100 @@ -0,0 +1,29 @@ +package com.beem.project.beem.account; + +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; + +public class AuthenticatorService extends Service { + + private Authenticator mAuth; + + public AuthenticatorService() { + super(); + } + + @Override + public void onCreate() { + super.onCreate(); + mAuth = new Authenticator(getApplicationContext()); + } + + @Override + public IBinder onBind(Intent intent) { + IBinder ret = null; + if (intent.getAction().equals(android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT)) + ret = mAuth.getIBinder(); + return ret; + } + +} diff -r 2236fe5b2db1 -r be08c9157636 src/com/beem/project/beem/account/SyncAdapter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/account/SyncAdapter.java Sat Mar 19 19:31:31 2011 +0100 @@ -0,0 +1,27 @@ + +package com.beem.project.beem.account; + +import android.accounts.Account; +import android.accounts.AccountManager; +import android.content.AbstractThreadedSyncAdapter; +import android.content.ContentProviderClient; +import android.content.Context; +import android.content.SyncResult; +import android.os.Bundle; + + +public class SyncAdapter extends AbstractThreadedSyncAdapter { + + private Context mContext; + + public SyncAdapter(Context context, boolean autoInitialize) { + super(context, autoInitialize); + mContext = context; + } + + @Override + public void onPerformSync(Account account, Bundle extras, String authority, + ContentProviderClient provider, SyncResult syncResult) { + } + +} diff -r 2236fe5b2db1 -r be08c9157636 src/com/beem/project/beem/ui/wizard/AccountConfigure.java --- a/src/com/beem/project/beem/ui/wizard/AccountConfigure.java Sat Mar 05 17:44:41 2011 +0100 +++ b/src/com/beem/project/beem/ui/wizard/AccountConfigure.java Sat Mar 19 19:31:31 2011 +0100 @@ -40,9 +40,14 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. -*/ + */ package com.beem.project.beem.ui.wizard; +import org.jivesoftware.smack.util.StringUtils; + +import android.accounts.Account; +import android.accounts.AccountAuthenticatorResponse; +import android.accounts.AccountManager; import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; @@ -58,16 +63,13 @@ import android.widget.Button; import android.widget.EditText; -import org.jivesoftware.smack.util.StringUtils; - +import com.beem.project.beem.BeemApplication; +import com.beem.project.beem.R; import com.beem.project.beem.ui.Login; import com.beem.project.beem.ui.Settings; -import com.beem.project.beem.BeemApplication; -import com.beem.project.beem.R; /** * Activity to enter the information required in order to configure a XMPP account. - * * @author Da Risk */ public class AccountConfigure extends Activity implements OnClickListener { @@ -81,6 +83,7 @@ private final PasswordTextWatcher mPasswordTextWatcher = new PasswordTextWatcher(); private boolean mValidJid; private boolean mValidPassword; + private AccountManager mAccountManager; /** * Constructor. @@ -99,7 +102,6 @@ mAccountJID = (EditText) findViewById(R.id.account_username); mAccountPassword = (EditText) findViewById(R.id.account_password); - InputFilter[] orgFilters = mAccountJID.getFilters(); InputFilter[] newFilters = new InputFilter[orgFilters.length + 1]; int i; @@ -109,6 +111,7 @@ mAccountJID.setFilters(newFilters); mAccountJID.addTextChangedListener(mJidTextWatcher); mAccountPassword.addTextChangedListener(mPasswordTextWatcher); + mAccountManager = AccountManager.get(this); } @Override @@ -150,6 +153,22 @@ edit.putString(BeemApplication.ACCOUNT_USERNAME_KEY, mAccountJID.getText().toString()); edit.putString(BeemApplication.ACCOUNT_PASSWORD_KEY, mAccountPassword.getText().toString()); edit.commit(); + Account account = new Account(mAccountJID.getText().toString(), "com.beem.project.com"); + boolean accountCreated = mAccountManager.addAccountExplicitly(account, mAccountPassword.getText().toString(), + null); + Bundle extras = getIntent().getExtras(); + if (extras != null) { + if (accountCreated) { + AccountAuthenticatorResponse response = extras + .getParcelable(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE); + Bundle result = new Bundle(); + result.putString(AccountManager.KEY_ACCOUNT_NAME, mAccountJID.getText().toString()); + result.putString(AccountManager.KEY_ACCOUNT_TYPE, "com.beem.project.com"); + response.onResult(result); + finish(); + } + } + } /** @@ -195,11 +214,11 @@ } @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { + public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { + public void onTextChanged(CharSequence s, int start, int before, int count) { } } @@ -221,11 +240,11 @@ } @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { + public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { + public void onTextChanged(CharSequence s, int start, int before, int count) { } } }