Search in sources :

Example 6 with AuthenticatorHelper

use of com.android.settingslib.accounts.AuthenticatorHelper in project android_packages_apps_Settings by omnirom.

the class AccountSyncPreferenceController method init.

public void init(Account account, UserHandle userHandle) {
    mAccount = account;
    mUserHandle = userHandle;
    mAuthenticatorHelper = new AuthenticatorHelper(mContext, mUserHandle, this);
}
Also used : AuthenticatorHelper(com.android.settingslib.accounts.AuthenticatorHelper)

Example 7 with AuthenticatorHelper

use of com.android.settingslib.accounts.AuthenticatorHelper in project android_packages_apps_Settings by SudaMod.

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);
}
Also used : AuthenticatorHelper(com.android.settingslib.accounts.AuthenticatorHelper) Activity(android.app.Activity)

Example 8 with AuthenticatorHelper

use of com.android.settingslib.accounts.AuthenticatorHelper in project android_packages_apps_Settings by SudaMod.

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);
}
Also used : Context(android.content.Context) AuthenticatorHelper(com.android.settingslib.accounts.AuthenticatorHelper) PreferenceScreen(android.support.v7.preference.PreferenceScreen) SearchFeatureProviderImpl(com.android.settings.search.SearchFeatureProviderImpl) AccessiblePreferenceCategory(com.android.settings.AccessiblePreferenceCategory)

Example 9 with AuthenticatorHelper

use of com.android.settingslib.accounts.AuthenticatorHelper in project android_packages_apps_Settings by SudaMod.

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));
}
Also used : Account(android.accounts.Account) AuthenticatorHelper(com.android.settingslib.accounts.AuthenticatorHelper) ShadowApplication(org.robolectric.shadows.ShadowApplication) Before(org.junit.Before)

Example 10 with AuthenticatorHelper

use of com.android.settingslib.accounts.AuthenticatorHelper in project android_packages_apps_Settings by DirtyUnicorns.

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));
}
Also used : Account(android.accounts.Account) AuthenticatorHelper(com.android.settingslib.accounts.AuthenticatorHelper) ShadowApplication(org.robolectric.shadows.ShadowApplication) Before(org.junit.Before)

Aggregations

AuthenticatorHelper (com.android.settingslib.accounts.AuthenticatorHelper)43 Context (android.content.Context)15 PreferenceScreen (android.support.v7.preference.PreferenceScreen)10 AccessiblePreferenceCategory (com.android.settings.AccessiblePreferenceCategory)8 Account (android.accounts.Account)7 Activity (android.app.Activity)7 Bundle (android.os.Bundle)7 UserHandle (android.os.UserHandle)7 Before (org.junit.Before)7 ShadowApplication (org.robolectric.shadows.ShadowApplication)7 VisibleForTesting (android.support.annotation.VisibleForTesting)5 SearchFeatureProviderImpl (com.android.settings.search.SearchFeatureProviderImpl)5 PreferenceScreen (androidx.preference.PreferenceScreen)4 VisibleForTesting (androidx.annotation.VisibleForTesting)2 BidiFormatter (android.text.BidiFormatter)1 ArrayList (java.util.ArrayList)1