use of com.android.settingslib.accounts.AuthenticatorHelper in project android_packages_apps_Settings by crdroidandroid.
the class AccountDetailDashboardFragment method updateUi.
@VisibleForTesting
void updateUi() {
final Context context = getContext();
UserHandle userHandle = null;
Bundle args = getArguments();
if (args != null && args.containsKey(KEY_USER_HANDLE)) {
userHandle = args.getParcelable(KEY_USER_HANDLE);
}
final AuthenticatorHelper helper = new AuthenticatorHelper(context, userHandle, null);
final AccountTypePreferenceLoader accountTypePreferenceLoader = new AccountTypePreferenceLoader(this, helper, userHandle);
PreferenceScreen prefs = accountTypePreferenceLoader.addPreferencesForType(mAccountType, getPreferenceScreen());
if (prefs != null) {
accountTypePreferenceLoader.updatePreferenceIntents(prefs, mAccountType, mAccount);
}
}
use of com.android.settingslib.accounts.AuthenticatorHelper in project android_packages_apps_Settings by crdroidandroid.
the class AccountHeaderPreferenceController method onResume.
@Override
public void onResume() {
final AuthenticatorHelper helper = new AuthenticatorHelper(mContext, mUserHandle, null);
EntityHeaderController.newInstance(mActivity, mHost, mHeaderPreference.findViewById(R.id.entity_header)).setLabel(mAccount.name).setIcon(helper.getDrawableForType(mContext, mAccount.type)).done(mActivity, true);
}
use of com.android.settingslib.accounts.AuthenticatorHelper in project android_packages_apps_Settings by crdroidandroid.
the class AccountPreferenceBase method onCreate.
@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, this);
mAccountTypePreferenceLoader = new AccountTypePreferenceLoader(this, mAuthenticatorHelper, mUserHandle);
}
use of com.android.settingslib.accounts.AuthenticatorHelper in project android_packages_apps_Settings by crdroidandroid.
the class AccountPreferenceController method updateProfileUi.
private void updateProfileUi(final UserInfo userInfo) {
if (mParent.getPreferenceManager() == null) {
return;
}
final ProfileData data = mProfiles.get(userInfo.id);
if (data != null) {
data.pendingRemoval = false;
if (userInfo.isEnabled()) {
// recreate the authentication helper to refresh the list of enabled accounts
data.authenticatorHelper = new AuthenticatorHelper(mContext, userInfo.getUserHandle(), this);
}
return;
}
final Context context = mContext;
final ProfileData profileData = new ProfileData();
profileData.userInfo = userInfo;
AccessiblePreferenceCategory preferenceGroup = mHelper.createAccessiblePreferenceCategory(mParent.getPreferenceManager().getContext());
preferenceGroup.setOrder(mAccountProfileOrder++);
if (isSingleProfile()) {
preferenceGroup.setTitle(context.getString(R.string.account_for_section_header, userInfo.name));
preferenceGroup.setContentDescription(mContext.getString(R.string.account_settings));
} else if (userInfo.isManagedProfile()) {
preferenceGroup.setTitle(R.string.category_work);
String workGroupSummary = getWorkGroupSummary(context, userInfo);
preferenceGroup.setSummary(workGroupSummary);
preferenceGroup.setContentDescription(mContext.getString(R.string.accessibility_category_work, workGroupSummary));
profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference(context);
mHelper.enforceRestrictionOnPreference(profileData.removeWorkProfilePreference, DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.myUserId());
profileData.managedProfilePreference = newManagedProfileSettings();
} else {
preferenceGroup.setTitle(R.string.category_personal);
preferenceGroup.setContentDescription(mContext.getString(R.string.accessibility_category_personal));
}
final PreferenceScreen screen = mParent.getPreferenceScreen();
if (screen != null) {
screen.addPreference(preferenceGroup);
}
profileData.preferenceGroup = preferenceGroup;
if (userInfo.isEnabled()) {
profileData.authenticatorHelper = new AuthenticatorHelper(context, userInfo.getUserHandle(), this);
profileData.addAccountPreference = newAddAccountPreference(context);
mHelper.enforceRestrictionOnPreference(profileData.addAccountPreference, DISALLOW_MODIFY_ACCOUNTS, userInfo.id);
}
mProfiles.put(userInfo.id, profileData);
new SearchFeatureProviderImpl().getIndexingManager(mContext).updateFromClassNameResource(UserAndAccountDashboardFragment.class.getName(), true);
}
use of com.android.settingslib.accounts.AuthenticatorHelper in project android_packages_apps_Settings by crdroidandroid.
the class AccountTypePreferenceLoaderTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
ShadowApplication shadowContext = ShadowApplication.getInstance();
shadowContext.setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt())).thenReturn(new AuthenticatorDescription[0]);
when(mAccountManager.getAccountsAsUser(anyInt())).thenReturn(new Account[0]);
when(mPreferenceFragment.getActivity().getPackageManager()).thenReturn(mPackageManager);
mContext = shadowContext.getApplicationContext();
mAccount = new Account("name", "type");
final AuthenticatorHelper helper = new AuthenticatorHelper(mContext, UserHandle.CURRENT, null);
mPrefLoader = spy(new AccountTypePreferenceLoader(mPreferenceFragment, helper, UserHandle.CURRENT));
}
Aggregations