summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/accounts/AccountPreferenceBase.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings/accounts/AccountPreferenceBase.java')
-rw-r--r--src/com/android/settings/accounts/AccountPreferenceBase.java82
1 files changed, 45 insertions, 37 deletions
diff --git a/src/com/android/settings/accounts/AccountPreferenceBase.java b/src/com/android/settings/accounts/AccountPreferenceBase.java
index 2759a8f..bb60871 100644
--- a/src/com/android/settings/accounts/AccountPreferenceBase.java
+++ b/src/com/android/settings/accounts/AccountPreferenceBase.java
@@ -1,4 +1,5 @@
/*
+
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,50 +17,63 @@
package com.android.settings.accounts;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.android.settings.SettingsPreferenceFragment;
-import com.google.android.collect.Maps;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
import android.accounts.AuthenticatorDescription;
-import android.accounts.OnAccountsUpdateListener;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
-import android.content.SyncAdapterType;
import android.content.SyncStatusObserver;
import android.content.pm.PackageManager;
import android.content.res.Resources;
+import android.content.res.Resources.Theme;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
-import android.preference.PreferenceActivity;
+import android.os.UserHandle;
+import android.os.UserManager;
import android.preference.PreferenceScreen;
import android.text.format.DateFormat;
import android.util.Log;
+import android.view.ContextThemeWrapper;
+
+import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.Utils;
+
+import java.util.ArrayList;
+import java.util.Date;
class AccountPreferenceBase extends SettingsPreferenceFragment
- implements OnAccountsUpdateListener {
+ implements AuthenticatorHelper.OnAccountsUpdateListener {
protected static final String TAG = "AccountSettings";
+
public static final String AUTHORITIES_FILTER_KEY = "authorities";
public static final String ACCOUNT_TYPES_FILTER_KEY = "account_types";
+
private final Handler mHandler = new Handler();
+
+ private UserManager mUm;
private Object mStatusChangeListenerHandle;
- private HashMap<String, ArrayList<String>> mAccountTypeToAuthorities = null;
- private AuthenticatorHelper mAuthenticatorHelper = new AuthenticatorHelper();
+ protected AuthenticatorHelper mAuthenticatorHelper;
+ protected UserHandle mUserHandle;
+
private java.text.DateFormat mDateFormat;
private java.text.DateFormat mTimeFormat;
+ @Override
+ public void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ mUm = (UserManager) getSystemService(Context.USER_SERVICE);
+ final Activity activity = getActivity();
+ mUserHandle = Utils.getSecureTargetUser(activity.getActivityToken(), mUm, getArguments(),
+ activity.getIntent().getExtras());
+ mAuthenticatorHelper = new AuthenticatorHelper(activity, mUserHandle, mUm, this);
+ }
+
/**
* Overload to handle account updates.
*/
- public void onAccountsUpdated(Account[] accounts) {
+ @Override
+ public void onAccountsUpdate(UserHandle userHandle) {
}
@@ -115,24 +129,7 @@ class AccountPreferenceBase extends SettingsPreferenceFragment
};
public ArrayList<String> getAuthoritiesForAccountType(String type) {
- if (mAccountTypeToAuthorities == null) {
- mAccountTypeToAuthorities = Maps.newHashMap();
- SyncAdapterType[] syncAdapters = ContentResolver.getSyncAdapterTypes();
- for (int i = 0, n = syncAdapters.length; i < n; i++) {
- final SyncAdapterType sa = syncAdapters[i];
- ArrayList<String> authorities = mAccountTypeToAuthorities.get(sa.accountType);
- if (authorities == null) {
- authorities = new ArrayList<String>();
- mAccountTypeToAuthorities.put(sa.accountType, authorities);
- }
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
- Log.d(TAG, "added authority " + sa.authority + " to accountType "
- + sa.accountType);
- }
- authorities.add(sa.authority);
- }
- }
- return mAccountTypeToAuthorities.get(type);
+ return mAuthenticatorHelper.getAuthoritiesForAccountType(type);
}
/**
@@ -148,8 +145,19 @@ class AccountPreferenceBase extends SettingsPreferenceFragment
try {
desc = mAuthenticatorHelper.getAccountTypeDescription(accountType);
if (desc != null && desc.accountPreferencesId != 0) {
- Context authContext = getActivity().createPackageContext(desc.packageName, 0);
- prefs = getPreferenceManager().inflateFromResource(authContext,
+ // Load the context of the target package, then apply the
+ // base Settings theme (no references to local resources)
+ // and create a context theme wrapper so that we get the
+ // correct text colors. Control colors will still be wrong,
+ // but there's not much we can do about it since we can't
+ // reference local color resources.
+ final Context targetCtx = getActivity().createPackageContextAsUser(
+ desc.packageName, 0, mUserHandle);
+ final Theme baseTheme = getResources().newTheme();
+ baseTheme.applyStyle(com.android.settings.R.style.Theme_SettingsBase, true);
+ final Context themedCtx = new ContextThemeWrapper(targetCtx, 0);
+ themedCtx.getTheme().setTo(baseTheme);
+ prefs = getPreferenceManager().inflateFromResource(themedCtx,
desc.accountPreferencesId, parent);
}
} catch (PackageManager.NameNotFoundException e) {