Add search provider for storage dashboard.

Bug: 31800690
Test: manual
Change-Id: Icb906bf3b3698c1379e10cf6e346d489675ad940
This commit is contained in:
Fan Zhang
2016-10-04 17:48:32 -07:00
parent 1d4495f985
commit 31a285387d
7 changed files with 70 additions and 6 deletions

View File

@@ -18,10 +18,19 @@ package com.android.settings.deviceinfo;
import android.content.Context;
import android.os.Bundle;
import android.os.UserManager;
import android.provider.SearchIndexableResource;
import android.support.v7.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class StorageDashboardFragment extends DashboardFragment {
@@ -62,4 +71,35 @@ public class StorageDashboardFragment extends DashboardFragment {
displayTilesAsPreference(TAG, getPreferenceScreen(),
mDashboardFeatureProvider.getTilesForStorageCategory());
}
/**
* For Search.
*/
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(
Context context, boolean enabled) {
if (!FeatureFactory.getFactory(context).getDashboardFeatureProvider(context)
.isEnabled()) {
return null;
}
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.storage_dashboard_fragment;
return Arrays.asList(sir);
}
@Override
public List<String> getNonIndexableKeys(Context context) {
if (!FeatureFactory.getFactory(context).getDashboardFeatureProvider(context)
.isEnabled()) {
return null;
}
final ManageStoragePreferenceController controller =
new ManageStoragePreferenceController(context);
final List<String> keys = new ArrayList<>();
controller.updateNonIndexableKeys(keys);
return keys;
}
};
}