--- a/AndroidManifest.xml Sat Feb 05 21:25:11 2011 +0100
+++ b/AndroidManifest.xml Fri Feb 25 15:11:29 2011 +0100
@@ -13,7 +13,8 @@
</intent-filter>
</activity>
<activity android:name=".ui.wizard.Account" android:label="Account wizard" />
- <activity android:name=".ui.wizard.AccountConfigure" android:label="Account wizard" />
+ <activity android:name=".ui.wizard.AccountConfigure"
+ android:label="Account wizard" />
<activity android:name=".ui.LoginAnim" android:label="@string/login_login_progress"
android:launchMode="singleTop" android:screenOrientation="portrait" />
<activity android:name=".ui.Settings" android:label="@string/edit_settings_name">
@@ -30,8 +31,7 @@
</intent-filter>
</activity>
<activity android:name=".ui.ChangeStatus" android:label="@string/ChangeStatusActTitle"
- android:launchMode="singleTask"
- android:windowSoftInputMode="stateHidden" >
+ android:launchMode="singleTask" android:windowSoftInputMode="stateHidden">
<intent-filter android:label="Beem Connection">
<action
android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
@@ -76,6 +76,14 @@
android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter> </receiver>
-->
+ <service android:name=".account.AuthenticatorService"
+ android:exported="true" android:process=":auth">
+ <intent-filter>
+ <action android:name="android.accounts.AccountAuthenticator" />
+ </intent-filter>
+ <meta-data android:name="android.accounts.AccountAuthenticator"
+ android:resource="@xml/authenticator" />
+ </service>
<service android:name="BeemService" android:enabled="true"
android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_SERVICE">
<intent-filter>
@@ -87,13 +95,15 @@
</application>
<permission android:permissionGroup="android.permission-group.NETWORK"
android:label="BeemService" android:description="@string/BeemServiceDescription"
- android:name="com.beem.project.beem.BEEM_SERVICE"/>
- <uses-permission android:name="android.permission.INTERNET"/>
- <uses-permission android:name="android.permission.VIBRATE"/>
+ android:name="com.beem.project.beem.BEEM_SERVICE" />
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
- <uses-permission android:name="com.beem.project.beem.BEEM_SERVICE"/>
- <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="7" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="com.beem.project.beem.BEEM_SERVICE" />
+ <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
+ <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />
<supports-screens android:largeScreens="true"
- android:normalScreens="true" android:smallScreens="true" android:anyDensity="true" />
-</manifest>
+ android:normalScreens="true" android:smallScreens="true"
+ android:anyDensity="true" />
+</manifest>
\ No newline at end of file
--- a/default.properties Sat Feb 05 21:25:11 2011 +0100
+++ b/default.properties Fri Feb 25 15:11:29 2011 +0100
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-7
+target=android-8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/res/xml/authenticator.xml Fri Feb 25 15:11:29 2011 +0100
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<account-authenticator
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:accountType="com.beem.project.com"
+ android:icon="@drawable/beem_launcher_icon_silver"
+ android:smallIcon="@drawable/beem_status_icon"
+ android:label="@string/app_name"
+ android:accountPreferences="@xml/preferences" />
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/account/Authenticator.java Fri Feb 25 15:11:29 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;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/account/AuthenticatorService.java Fri Feb 25 15:11:29 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;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/account/SyncAdapter.java Fri Feb 25 15:11:29 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) {
+ }
+
+}
--- a/src/com/beem/project/beem/ui/wizard/AccountConfigure.java Sat Feb 05 21:25:11 2011 +0100
+++ b/src/com/beem/project/beem/ui/wizard/AccountConfigure.java Fri Feb 25 15:11:29 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 <darisk972@gmail.com>
*/
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) {
}
}
}