SharedPreferences load account settings from android.account and
beem.settings menu options
--- a/src/com/beem/project/beem/account/Authenticator.java Wed Mar 30 23:29:12 2011 +0200
+++ b/src/com/beem/project/beem/account/Authenticator.java Thu Mar 31 21:49:28 2011 +0200
@@ -36,35 +36,42 @@
@Override
public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options)
throws NetworkErrorException {
+ Log.e("AUTHENTICATOR", "CONFIRM CREDENTIAL");
return null;
}
@Override
public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
+ Log.e("AUTHENTICATOR", "edit properties");
return null;
}
@Override
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType,
Bundle options) throws NetworkErrorException {
+ Log.e("AUTHENTICATOR", "get auth token");
return null;
}
@Override
public String getAuthTokenLabel(String authTokenType) {
+ Log.e("AUTHENTICATOR", "get auth token label");
return null;
}
@Override
public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features)
throws NetworkErrorException {
+ Log.e("AUTHENTICATOR", "has features");
return null;
}
@Override
public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType,
Bundle options) throws NetworkErrorException {
+ Log.e("AUTHENTICATOR", "update credentials");
return null;
+
}
}
--- a/src/com/beem/project/beem/ui/Settings.java Wed Mar 30 23:29:12 2011 +0200
+++ b/src/com/beem/project/beem/ui/Settings.java Thu Mar 31 21:49:28 2011 +0200
@@ -43,10 +43,13 @@
*/
package com.beem.project.beem.ui;
+import android.accounts.Account;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
+import android.preference.PreferenceManager;
+import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@@ -73,7 +76,17 @@
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- getSharedPreferences(getIntent().getExtras().getString("account_name"), MODE_PRIVATE);
+ Account account = getIntent().getParcelableExtra("account");
+ PreferenceManager pn = getPreferenceManager();
+ if (account != null) { // if we come from android.account interface
+ pn.setSharedPreferencesName(account.name);
+ }
+ else if (getIntent().getExtras() != null) { // if we come from beem interface
+ pn.setSharedPreferencesName(getIntent().getExtras().getString("account_name"));
+ } else {
+
+ }
+
addPreferencesFromResource(R.layout.preferences);
}
--- a/src/com/beem/project/beem/ui/wizard/AccountConfigure.java Wed Mar 30 23:29:12 2011 +0200
+++ b/src/com/beem/project/beem/ui/wizard/AccountConfigure.java Thu Mar 31 21:49:28 2011 +0200
@@ -52,12 +52,12 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
-import android.preference.PreferenceManager;
import android.text.Editable;
import android.text.InputFilter;
import android.text.LoginFilter;
import android.text.TextUtils;
import android.text.TextWatcher;
+import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
@@ -133,7 +133,10 @@
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == MANUAL_CONFIGURATION) {
- SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
+ final String jid = mAccountJID.getText().toString();
+ //SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
+ Log.e("ACCOUNT CONFIGURE", "ACCOUNT NAME PREFERENCES : " + jid);
+ SharedPreferences settings = getSharedPreferences(jid, MODE_PRIVATE);
String login = settings.getString(BeemApplication.ACCOUNT_USERNAME_KEY, "");
String password = settings.getString(BeemApplication.ACCOUNT_PASSWORD_KEY, "");
mAccountJID.setText(login);
@@ -149,6 +152,7 @@
*/
private void configureAccount() {
final String jid = mAccountJID.getText().toString();
+ Log.e("ACCOUNT CONFIGURE", "ACCOUNT NAME PREFERENCES : " + jid);
SharedPreferences settings = getSharedPreferences(jid, MODE_PRIVATE); //PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor edit = settings.edit();
edit.putString(BeemApplication.ACCOUNT_USERNAME_KEY, jid);