diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2014-04-02 17:07:36 -0700 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2014-04-02 17:18:56 -0700 |
commit | f66eb7a8c8aa65c704dad4e565ce919ec121705f (patch) | |
tree | 954405aea01b0cab0cb35753ca2aa963080f0216 /src/com/android/settings/deviceinfo/Memory.java | |
parent | fb5e639b30e866ba5a379487ab5b7a77fe175a7b (diff) | |
download | packages_apps_Settings-f66eb7a8c8aa65c704dad4e565ce919ec121705f.zip packages_apps_Settings-f66eb7a8c8aa65c704dad4e565ce919ec121705f.tar.gz packages_apps_Settings-f66eb7a8c8aa65c704dad4e565ce919ec121705f.tar.bz2 |
Add indexing for Storage preferences
- implement the contract for SEARCH_INDEX_DATA_PROVIDER
Change-Id: I131e9176c47ccd697d05961b09546ba0e51059f7
Diffstat (limited to 'src/com/android/settings/deviceinfo/Memory.java')
-rw-r--r-- | src/com/android/settings/deviceinfo/Memory.java | 86 |
1 files changed, 85 insertions, 1 deletions
diff --git a/src/com/android/settings/deviceinfo/Memory.java b/src/com/android/settings/deviceinfo/Memory.java index 4923070..de793cf 100644 --- a/src/com/android/settings/deviceinfo/Memory.java +++ b/src/com/android/settings/deviceinfo/Memory.java @@ -41,6 +41,7 @@ import android.os.storage.StorageManager; import android.os.storage.StorageVolume; import android.preference.Preference; import android.preference.PreferenceScreen; +import android.provider.SearchIndexableResource; import android.util.Log; import android.view.Menu; import android.view.MenuInflater; @@ -51,6 +52,8 @@ import com.android.settings.R; import com.android.settings.SettingsActivity; import com.android.settings.SettingsPreferenceFragment; import com.android.settings.Utils; +import com.android.settings.search.Indexable; +import com.android.settings.search.SearchIndexableRaw; import com.google.android.collect.Lists; import java.util.ArrayList; @@ -60,7 +63,7 @@ import java.util.List; * Panel showing storage usage on disk for known {@link StorageVolume} returned * by {@link StorageManager}. Calculates and displays usage of data types. */ -public class Memory extends SettingsPreferenceFragment { +public class Memory extends SettingsPreferenceFragment implements Indexable{ private static final String TAG = "MemorySettings"; private static final String TAG_CONFIRM_CLEAR_CACHE = "confirmClearCache"; @@ -424,4 +427,85 @@ public class Memory extends SettingsPreferenceFragment { return builder.create(); } } + + /** + * Enable indexing of searchable data + */ + public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new SearchIndexProvider() { + + @Override + public List<SearchIndexableResource> getXmlResourcesToIndex( + Context context, boolean enabled) { + return null; + } + + @Override + public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) { + final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>(); + + SearchIndexableRaw data = new SearchIndexableRaw(context); + data.title = context.getString(R.string.storage_settings); + data.screenTitle = context.getString(R.string.storage_settings); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = context.getString(R.string.internal_storage); + data.screenTitle = context.getString(R.string.storage_settings); + result.add(data); + + data = new SearchIndexableRaw(context); + final StorageVolume[] storageVolumes = StorageManager.from(context).getVolumeList(); + for (StorageVolume volume : storageVolumes) { + if (!volume.isEmulated()) { + data.title = volume.getDescription(context); + data.screenTitle = context.getString(R.string.storage_settings); + result.add(data); + } + } + + data = new SearchIndexableRaw(context); + data.title = context.getString(R.string.memory_size); + data.screenTitle = context.getString(R.string.storage_settings); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = context.getString(R.string.memory_available); + data.screenTitle = context.getString(R.string.storage_settings); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = context.getString(R.string.memory_apps_usage); + data.screenTitle = context.getString(R.string.storage_settings); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = context.getString(R.string.memory_dcim_usage); + data.screenTitle = context.getString(R.string.storage_settings); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = context.getString(R.string.memory_music_usage); + data.screenTitle = context.getString(R.string.storage_settings); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = context.getString(R.string.memory_downloads_usage); + data.screenTitle = context.getString(R.string.storage_settings); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = context.getString(R.string.memory_media_cache_usage); + data.screenTitle = context.getString(R.string.storage_settings); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = context.getString(R.string.memory_media_misc_usage); + data.screenTitle = context.getString(R.string.storage_settings); + result.add(data); + + return result; + } + }; + } |