Add search provider for storage dashboard.
Bug: 31800690 Test: manual Change-Id: Icb906bf3b3698c1379e10cf6e346d489675ad940
This commit is contained in:
@@ -14,7 +14,9 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/storage_settings">
|
||||
<com.android.settings.dashboard.DashboardTilePreference
|
||||
android:key="pref_manage_storage"
|
||||
android:title="@string/storage_menu_manage"
|
||||
|
@@ -19,6 +19,8 @@ import android.content.Context;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A controller that manages event for preference.
|
||||
*/
|
||||
@@ -43,6 +45,12 @@ public abstract class PreferenceController {
|
||||
*/
|
||||
public abstract boolean handlePreferenceTreeClick(Preference preference);
|
||||
|
||||
/**
|
||||
* Updates non-indexable keys for search provider.
|
||||
*
|
||||
* Called by SearchIndexProvider#getNonIndexableKeys
|
||||
*/
|
||||
public abstract void updateNonIndexableKeys(List<String> keys);
|
||||
|
||||
/**
|
||||
* Removes preference from screen.
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@@ -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)) {
|
||||
|
@@ -34,6 +34,7 @@ import com.android.settings.applications.SpecialAccessSettings;
|
||||
import com.android.settings.bluetooth.BluetoothSettings;
|
||||
import com.android.settings.datausage.DataUsageMeteredSettings;
|
||||
import com.android.settings.datausage.DataUsageSummary;
|
||||
import com.android.settings.deviceinfo.StorageDashboardFragment;
|
||||
import com.android.settings.deviceinfo.StorageSettings;
|
||||
import com.android.settings.display.ScreenZoomSettings;
|
||||
import com.android.settings.fuelgauge.BatterySaverSettings;
|
||||
@@ -186,6 +187,7 @@ public final class Ranking {
|
||||
sRankMap.put(DeviceInfoSettings.class.getName(), RANK_DEVICE_INFO);
|
||||
sRankMap.put(LegalSettings.class.getName(), RANK_DEVICE_INFO);
|
||||
|
||||
sRankMap.put(StorageDashboardFragment.class.getName(), RANK_STORAGE);
|
||||
sRankMap.put(SystemDashboardFragment.class.getName(), RANK_DEVICE_INFO);
|
||||
|
||||
sBaseRankMap.put("com.android.settings", 0);
|
||||
|
@@ -35,6 +35,7 @@ import com.android.settings.applications.SpecialAccessSettings;
|
||||
import com.android.settings.bluetooth.BluetoothSettings;
|
||||
import com.android.settings.datausage.DataUsageMeteredSettings;
|
||||
import com.android.settings.datausage.DataUsageSummary;
|
||||
import com.android.settings.deviceinfo.StorageDashboardFragment;
|
||||
import com.android.settings.deviceinfo.StorageSettings;
|
||||
import com.android.settings.display.ScreenZoomSettings;
|
||||
import com.android.settings.fuelgauge.BatterySaverSettings;
|
||||
@@ -334,6 +335,12 @@ public final class SearchIndexableResources {
|
||||
NO_DATA_RES_ID,
|
||||
SystemDashboardFragment.class.getName(),
|
||||
R.drawable.ic_settings_about));
|
||||
sResMap.put(StorageDashboardFragment.class.getName(),
|
||||
new SearchIndexableResource(
|
||||
Ranking.getRankForClassName(StorageDashboardFragment.class.getName()),
|
||||
NO_DATA_RES_ID,
|
||||
StorageDashboardFragment.class.getName(),
|
||||
R.drawable.ic_settings_storage));
|
||||
}
|
||||
|
||||
private SearchIndexableResources() {
|
||||
|
Reference in New Issue
Block a user