Search in sources :

Example 1 with SearchFeatureProviderImpl

use of com.android.settings.search.SearchFeatureProviderImpl in project android_packages_apps_Settings by LineageOS.

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 2 with SearchFeatureProviderImpl

use of com.android.settings.search.SearchFeatureProviderImpl in project android_packages_apps_Settings by omnirom.

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 3 with SearchFeatureProviderImpl

use of com.android.settings.search.SearchFeatureProviderImpl 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 4 with SearchFeatureProviderImpl

use of com.android.settings.search.SearchFeatureProviderImpl in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class SliceBroadcastReceiverTest method setUp.

@Before
public void setUp() {
    mContext = spy(RuntimeEnvironment.application);
    mDb = SlicesDatabaseHelper.getInstance(mContext).getWritableDatabase();
    mReceiver = new SliceBroadcastReceiver();
    SlicesDatabaseHelper helper = SlicesDatabaseHelper.getInstance(mContext);
    helper.setIndexedState();
    mSearchFeatureProvider = new SearchFeatureProviderImpl();
    mFakeFeatureFactory = FakeFeatureFactory.setupForTest();
    mFakeFeatureFactory.searchFeatureProvider = mSearchFeatureProvider;
}
Also used : SearchFeatureProviderImpl(com.android.settings.search.SearchFeatureProviderImpl) Before(org.junit.Before)

Example 5 with SearchFeatureProviderImpl

use of com.android.settings.search.SearchFeatureProviderImpl in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class XmlControllerAttributeTest method setUp.

@Before
public void setUp() {
    mContext = RuntimeEnvironment.application;
    mSearchProvider = new SearchFeatureProviderImpl();
    FakeFeatureFactory.setupForTest().searchFeatureProvider = mSearchProvider;
}
Also used : SearchFeatureProviderImpl(com.android.settings.search.SearchFeatureProviderImpl) Before(org.junit.Before)

Aggregations

SearchFeatureProviderImpl (com.android.settings.search.SearchFeatureProviderImpl)10 Context (android.content.Context)6 PreferenceScreen (android.support.v7.preference.PreferenceScreen)6 AccessiblePreferenceCategory (com.android.settings.AccessiblePreferenceCategory)6 AuthenticatorHelper (com.android.settingslib.accounts.AuthenticatorHelper)6 Before (org.junit.Before)3 SearchFeatureProvider (com.android.settings.search.SearchFeatureProvider)1 FakeFeatureFactory (com.android.settings.testutils.FakeFeatureFactory)1 Locale (java.util.Locale)1 Test (org.junit.Test)1 Config (org.robolectric.annotation.Config)1