Search in sources :

Example 16 with AuthenticatorHelper

use of com.android.settingslib.accounts.AuthenticatorHelper in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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);
    }
}
Also used : Context(android.content.Context) AuthenticatorHelper(com.android.settingslib.accounts.AuthenticatorHelper) PreferenceScreen(androidx.preference.PreferenceScreen) Bundle(android.os.Bundle) UserHandle(android.os.UserHandle) VisibleForTesting(androidx.annotation.VisibleForTesting)

Example 17 with AuthenticatorHelper

use of com.android.settingslib.accounts.AuthenticatorHelper in project Resurrection_packages_apps_Settings by ResurrectionRemix.

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 18 with AuthenticatorHelper

use of com.android.settingslib.accounts.AuthenticatorHelper in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class TopLevelAccountEntryPreferenceController method getSummary.

@Override
public CharSequence getSummary() {
    final AuthenticatorHelper authHelper = new AuthenticatorHelper(mContext, UserHandle.of(UserHandle.myUserId()), null);
    final String[] types = authHelper.getEnabledAccountTypes();
    final BidiFormatter bidiFormatter = BidiFormatter.getInstance();
    final List<CharSequence> summaries = new ArrayList<>();
    if (types == null || types.length == 0) {
        summaries.add(mContext.getString(R.string.account_dashboard_default_summary));
    } else {
        // Show up to 3 account types, ignore any null value
        int accountToAdd = Math.min(3, types.length);
        for (int i = 0; i < types.length && accountToAdd > 0; i++) {
            final CharSequence label = authHelper.getLabelForType(mContext, types[i]);
            if (TextUtils.isEmpty(label)) {
                continue;
            }
            summaries.add(bidiFormatter.unicodeWrap(label));
            accountToAdd--;
        }
    }
    return ListFormatter.getInstance().format(summaries);
}
Also used : AuthenticatorHelper(com.android.settingslib.accounts.AuthenticatorHelper) BidiFormatter(android.text.BidiFormatter) ArrayList(java.util.ArrayList)

Example 19 with AuthenticatorHelper

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

the class AccountPreferenceController method updateProfileUi.

private void updateProfileUi(final UserInfo userInfo) {
    if (mFragment.getPreferenceManager() == null) {
        return;
    }
    final ProfileData data = mProfiles.get(userInfo.id);
    if (data != null) {
        data.pendingRemoval = false;
        data.userInfo = userInfo;
        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(mFragment.getPreferenceManager().getContext());
    preferenceGroup.setOrder(mAccountProfileOrder++);
    // default title; may be modified below
    preferenceGroup.setTitle(R.string.account_settings);
    if (isSingleProfile()) {
        final String title = context.getString(R.string.account_for_section_header, BidiFormatter.getInstance().unicodeWrap(userInfo.name));
        preferenceGroup.setTitle(title);
        preferenceGroup.setContentDescription(title);
    } else if (userInfo.isManagedProfile()) {
        if (mType == ProfileSelectFragment.ProfileType.ALL) {
            preferenceGroup.setTitle(R.string.category_work);
            final String workGroupSummary = getWorkGroupSummary(context, userInfo);
            preferenceGroup.setSummary(workGroupSummary);
            preferenceGroup.setContentDescription(mContext.getString(R.string.accessibility_category_work, workGroupSummary));
        }
        profileData.removeWorkProfilePreference = newRemoveWorkProfilePreference();
        mHelper.enforceRestrictionOnPreference(profileData.removeWorkProfilePreference, DISALLOW_REMOVE_MANAGED_PROFILE, UserHandle.myUserId());
        profileData.managedProfilePreference = newManagedProfileSettings();
    } else {
        if (mType == ProfileSelectFragment.ProfileType.ALL) {
            preferenceGroup.setTitle(R.string.category_personal);
            preferenceGroup.setContentDescription(mContext.getString(R.string.accessibility_category_personal));
        }
    }
    final PreferenceScreen screen = mFragment.getPreferenceScreen();
    if (screen != null) {
        screen.addPreference(preferenceGroup);
    }
    profileData.preferenceGroup = preferenceGroup;
    if (userInfo.isEnabled()) {
        profileData.authenticatorHelper = new AuthenticatorHelper(context, userInfo.getUserHandle(), this);
        profileData.addAccountPreference = newAddAccountPreference();
        mHelper.enforceRestrictionOnPreference(profileData.addAccountPreference, DISALLOW_MODIFY_ACCOUNTS, userInfo.id);
    }
    mProfiles.put(userInfo.id, profileData);
}
Also used : Context(android.content.Context) AuthenticatorHelper(com.android.settingslib.accounts.AuthenticatorHelper) PreferenceScreen(androidx.preference.PreferenceScreen) AccessiblePreferenceCategory(com.android.settings.AccessiblePreferenceCategory)

Example 20 with AuthenticatorHelper

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

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)

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