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

@@ -22,6 +22,8 @@ import android.support.v7.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
import java.util.List;
public class ManageStoragePreferenceController extends PreferenceController {
public static final String KEY_MANAGE_STORAGE = "pref_manage_storage";
@@ -37,6 +39,13 @@ public class ManageStoragePreferenceController extends PreferenceController {
}
}
@Override
public void updateNonIndexableKeys(List<String> keys) {
if (!isAvailable()) {
keys.add(KEY_MANAGE_STORAGE);
}
}
@Override
public boolean handlePreferenceTreeClick(Preference preference) {
return false;

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;
}
};
}

View File

@@ -62,11 +62,7 @@ public class SystemUpdatePreferenceController extends PreferenceController {
}
}
/**
* Updates non-indexable keys for search provider.
*
* Called by SearchIndexProvider#getNonIndexableKeys
*/
@Override
public void updateNonIndexableKeys(List<String> keys) {
// TODO: system update needs to be fixed for non-owner user b/22760654
if (!isAvailable(mContext, KEY_SYSTEM_UPDATE_SETTINGS)) {