Search in sources :

Example 6 with SearchIndexableRaw

use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.

the class EmergencyInfoPreferenceController method updateRawDataToIndex.

@Override
public void updateRawDataToIndex(List<SearchIndexableRaw> rawData) {
    if (isAvailable()) {
        SearchIndexableRaw data = new SearchIndexableRaw(mContext);
        final Resources res = mContext.getResources();
        data.title = res.getString(com.android.settings.R.string.emergency_info_title);
        data.screenTitle = res.getString(com.android.settings.R.string.emergency_info_title);
        rawData.add(data);
    }
}
Also used : SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) Resources(android.content.res.Resources)

Example 7 with SearchIndexableRaw

use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.

the class BaseSearchIndexProvider method getDynamicRawDataToIndex.

@Override
@CallSuper
public List<SearchIndexableRaw> getDynamicRawDataToIndex(Context context, boolean enabled) {
    final List<SearchIndexableRaw> dynamicRaws = new ArrayList<>();
    if (!isPageSearchEnabled(context)) {
        // Entire page should be suppressed, do not add dynamic raw data.
        return dynamicRaws;
    }
    final List<AbstractPreferenceController> controllers = getPreferenceControllers(context);
    if (controllers == null || controllers.isEmpty()) {
        return dynamicRaws;
    }
    for (AbstractPreferenceController controller : controllers) {
        if (controller instanceof PreferenceControllerMixin) {
            ((PreferenceControllerMixin) controller).updateDynamicRawDataToIndex(dynamicRaws);
        } else if (controller instanceof BasePreferenceController) {
            ((BasePreferenceController) controller).updateDynamicRawDataToIndex(dynamicRaws);
        } else {
            Log.e(TAG, controller.getClass().getName() + " must implement " + PreferenceControllerMixin.class.getName() + " treating the dynamic indexable");
        }
    }
    return dynamicRaws;
}
Also used : BasePreferenceController(com.android.settings.core.BasePreferenceController) AbstractPreferenceController(com.android.settingslib.core.AbstractPreferenceController) PreferenceControllerMixin(com.android.settings.core.PreferenceControllerMixin) ArrayList(java.util.ArrayList) SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) CallSuper(androidx.annotation.CallSuper)

Example 8 with SearchIndexableRaw

use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.

the class SettingsSearchIndexablesProvider method getDynamicSearchIndexableRawData.

private List<SearchIndexableRaw> getDynamicSearchIndexableRawData(Context context, SearchIndexableData bundle) {
    final Indexable.SearchIndexProvider provider = bundle.getSearchIndexProvider();
    final List<SearchIndexableRaw> providerRaws = provider.getDynamicRawDataToIndex(context, true);
    if (providerRaws == null) {
        return new ArrayList<>();
    }
    for (SearchIndexableRaw raw : providerRaws) {
        // The classname and intent information comes from the PreIndexData
        // This will be more clear when provider conversion is done at PreIndex time.
        raw.className = bundle.getTargetClass().getName();
    }
    return providerRaws;
}
Also used : ArrayList(java.util.ArrayList) SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) Indexable(com.android.settingslib.search.Indexable)

Example 9 with SearchIndexableRaw

use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.

the class SettingsSearchIndexablesProvider method queryDynamicRawData.

/**
 * Gets a Cursor of dynamic Raw data similar to queryRawData. We use those data in search query
 * time
 */
@Nullable
@Override
public Cursor queryDynamicRawData(String[] projection) {
    final Context context = getContext();
    final List<SearchIndexableRaw> rawList = new ArrayList<>();
    final Collection<SearchIndexableData> bundles = FeatureFactory.getFactory(context).getSearchFeatureProvider().getSearchIndexableResources().getProviderValues();
    for (SearchIndexableData bundle : bundles) {
        rawList.addAll(getDynamicSearchIndexableRawData(context, bundle));
        // Refresh the search enabled state for indexing injection raw data
        final Indexable.SearchIndexProvider provider = bundle.getSearchIndexProvider();
        if (provider instanceof BaseSearchIndexProvider) {
            refreshSearchEnabledState(context, (BaseSearchIndexProvider) provider);
        }
    }
    rawList.addAll(getInjectionIndexableRawData(context));
    final MatrixCursor cursor = new MatrixCursor(INDEXABLES_RAW_COLUMNS);
    for (SearchIndexableRaw raw : rawList) {
        cursor.addRow(createIndexableRawColumnObjects(raw));
    }
    return cursor;
}
Also used : Context(android.content.Context) ArrayList(java.util.ArrayList) SearchIndexableData(com.android.settingslib.search.SearchIndexableData) SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) Indexable(com.android.settingslib.search.Indexable) MatrixCursor(android.database.MatrixCursor) Nullable(androidx.annotation.Nullable)

Example 10 with SearchIndexableRaw

use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.

the class AccountPreferenceControllerTest method updateRawDataToIndex_DisabledUser_shouldNotUpdate.

@Test
public void updateRawDataToIndex_DisabledUser_shouldNotUpdate() {
    final List<SearchIndexableRaw> data = new ArrayList<>();
    final List<UserInfo> infos = new ArrayList<>();
    infos.add(new UserInfo(1, "user 1", UserInfo.FLAG_DISABLED));
    when(mUserManager.isManagedProfile()).thenReturn(false);
    when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
    mController.updateRawDataToIndex(data);
    assertThat(data).isEmpty();
}
Also used : ArrayList(java.util.ArrayList) SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) UserInfo(android.content.pm.UserInfo) Test(org.junit.Test)

Aggregations

SearchIndexableRaw (com.android.settingslib.search.SearchIndexableRaw)19 ArrayList (java.util.ArrayList)14 Test (org.junit.Test)10 UserInfo (android.content.pm.UserInfo)8 Indexable (com.android.settingslib.search.Indexable)3 Resources (android.content.res.Resources)2 MatrixCursor (android.database.MatrixCursor)2 SearchIndexableData (com.android.settingslib.search.SearchIndexableData)2 Account (android.accounts.Account)1 ComponentName (android.content.ComponentName)1 Context (android.content.Context)1 Intent (android.content.Intent)1 ResolveInfo (android.content.pm.ResolveInfo)1 CallSuper (androidx.annotation.CallSuper)1 Nullable (androidx.annotation.Nullable)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 BasePreferenceController (com.android.settings.core.BasePreferenceController)1 PreferenceControllerMixin (com.android.settings.core.PreferenceControllerMixin)1 DashboardFeatureProvider (com.android.settings.dashboard.DashboardFeatureProvider)1 AbstractPreferenceController (com.android.settingslib.core.AbstractPreferenceController)1