diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2014-04-01 14:30:07 -0700 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2014-04-02 14:26:59 -0700 |
commit | 019b87f17a51fef7fd4b6696dbea5c50fe8b6d07 (patch) | |
tree | ef946a8ad02d3f0200a1ee6ffab44d19b4727e8d | |
parent | 627ef9706bfd659d53998ee4b4870719288b6094 (diff) | |
download | packages_apps_Settings-019b87f17a51fef7fd4b6696dbea5c50fe8b6d07.zip packages_apps_Settings-019b87f17a51fef7fd4b6696dbea5c50fe8b6d07.tar.gz packages_apps_Settings-019b87f17a51fef7fd4b6696dbea5c50fe8b6d07.tar.bz2 |
Add indexing for Limited Interruptions (notifications) preferences
- implement the contract for SEARCH_INDEX_DATA_PROVIDER
- some code styling too
Change-Id: I106d1d9493eb945ea71e500acd43a1fc6096bb1f
-rw-r--r-- | src/com/android/settings/ZenModeSettings.java | 79 | ||||
-rw-r--r-- | src/com/android/settings/search/SearchIndexableResources.java | 64 |
2 files changed, 123 insertions, 20 deletions
diff --git a/src/com/android/settings/ZenModeSettings.java b/src/com/android/settings/ZenModeSettings.java index 897df7e..65acb15 100644 --- a/src/com/android/settings/ZenModeSettings.java +++ b/src/com/android/settings/ZenModeSettings.java @@ -20,6 +20,7 @@ import android.app.ActionBar; import android.app.Activity; import android.content.Context; import android.database.ContentObserver; +import android.content.res.Resources; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.net.Uri; @@ -27,6 +28,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.provider.Settings.Global; +import android.provider.SearchIndexableResource; import android.util.Log; import android.util.TypedValue; import android.view.Gravity; @@ -43,8 +45,13 @@ import android.widget.RelativeLayout; import android.widget.ScrollView; import android.widget.Switch; import android.widget.TextView; +import com.android.settings.search.Indexable; +import com.android.settings.search.SearchIndexableRaw; -public class ZenModeSettings extends SettingsPreferenceFragment { +import java.util.ArrayList; +import java.util.List; + +public class ZenModeSettings extends SettingsPreferenceFragment implements Indexable { private static final String TAG = "ZenModeSettings"; private static final boolean DEBUG = false; @@ -282,4 +289,74 @@ public class ZenModeSettings extends SettingsPreferenceFragment { } } } + + // Enable indexing of searchable data + public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new Indexable.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>(); + final Resources res = context.getResources(); + + SearchIndexableRaw data = new SearchIndexableRaw(context); + data.title = res.getString(R.string.zen_mode_settings_title); + data.screenTitle = res.getString(R.string.zen_mode_settings_title); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = "When on"; + data.screenTitle = res.getString(R.string.zen_mode_settings_title); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = "Calls"; + data.screenTitle = res.getString(R.string.zen_mode_settings_title); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = "Text & SMS Messages"; + data.screenTitle = res.getString(R.string.zen_mode_settings_title); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = "Alarms & Timers"; + data.screenTitle = res.getString(R.string.zen_mode_settings_title); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = "Other Interruptions"; + data.screenTitle = res.getString(R.string.zen_mode_settings_title); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = "Automatically turn on"; + data.screenTitle = res.getString(R.string.zen_mode_settings_title); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = "While driving"; + data.screenTitle = res.getString(R.string.zen_mode_settings_title); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = "While in meetings"; + data.screenTitle = res.getString(R.string.zen_mode_settings_title); + result.add(data); + + data = new SearchIndexableRaw(context); + data.title = "During a set time period"; + data.screenTitle = res.getString(R.string.zen_mode_settings_title); + result.add(data); + + return result; + } + }; + } diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java index 061be54..bc6725e 100644 --- a/src/com/android/settings/search/SearchIndexableResources.java +++ b/src/com/android/settings/search/SearchIndexableResources.java @@ -30,6 +30,7 @@ import com.android.settings.SecuritySettings; import com.android.settings.SoundSettings; import com.android.settings.WallpaperTypeSettings; import com.android.settings.WirelessSettings; +import com.android.settings.ZenModeSettings; import com.android.settings.accessibility.AccessibilitySettings; import com.android.settings.bluetooth.BluetoothSettings; import com.android.settings.deviceinfo.Memory; @@ -89,97 +90,122 @@ public final class SearchIndexableResources { R.drawable.ic_settings_bluetooth2)); sResMap.put(DataUsageMeteredSettings.class.getName(), - new SearchIndexableResource(RANK_DATA_USAGE, R.xml.data_usage_metered_prefs, + new SearchIndexableResource(RANK_DATA_USAGE, + R.xml.data_usage_metered_prefs, DataUsageMeteredSettings.class.getName(), R.drawable.ic_settings_data_usage)); sResMap.put(WirelessSettings.class.getName(), - new SearchIndexableResource(RANK_WIRELESS, R.xml.wireless_settings, + new SearchIndexableResource(RANK_WIRELESS, + R.xml.wireless_settings, WirelessSettings.class.getName(), R.drawable.empty_icon)); sResMap.put(HomeSettings.class.getName(), - new SearchIndexableResource(RANK_HOME, R.xml.home_selection, + new SearchIndexableResource(RANK_HOME, + R.xml.home_selection, HomeSettings.class.getName(), R.drawable.ic_settings_home)); sResMap.put(SoundSettings.class.getName(), - new SearchIndexableResource(RANK_SOUND, R.xml.sound_settings, + new SearchIndexableResource(RANK_SOUND, + R.xml.sound_settings, SoundSettings.class.getName(), R.drawable.ic_settings_sound)); sResMap.put(DisplaySettings.class.getName(), - new SearchIndexableResource(RANK_DISPLAY, R.xml.display_settings, + new SearchIndexableResource(RANK_DISPLAY, + R.xml.display_settings, DisplaySettings.class.getName(), R.drawable.ic_settings_display)); sResMap.put(WallpaperTypeSettings.class.getName(), - new SearchIndexableResource(RANK_WALLPAPER, NO_DATA_RES_ID, + new SearchIndexableResource(RANK_WALLPAPER, + NO_DATA_RES_ID, WallpaperTypeSettings.class.getName(), R.drawable.ic_settings_display)); sResMap.put(NotificationSettings.class.getName(), - new SearchIndexableResource(RANK_NOTIFICATIONS, R.xml.notification_settings, + new SearchIndexableResource(RANK_NOTIFICATIONS, + R.xml.notification_settings, NotificationSettings.class.getName(), R.drawable.ic_settings_notifications)); + sResMap.put(ZenModeSettings.class.getName(), + new SearchIndexableResource(RANK_NOTIFICATIONS, + NO_DATA_RES_ID, + ZenModeSettings.class.getName(), + R.drawable.ic_settings_notifications)); + sResMap.put(Memory.class.getName(), - new SearchIndexableResource(RANK_MEMORY, R.xml.device_info_memory, + new SearchIndexableResource(RANK_MEMORY, + R.xml.device_info_memory, Memory.class.getName(), R.drawable.ic_settings_storage)); sResMap.put(PowerUsageSummary.class.getName(), - new SearchIndexableResource(RANK_POWER_USAGE, R.xml.power_usage_summary, + new SearchIndexableResource(RANK_POWER_USAGE, + R.xml.power_usage_summary, PowerUsageSummary.class.getName(), R.drawable.ic_settings_battery)); sResMap.put(UserSettings.class.getName(), - new SearchIndexableResource(RANK_USERS, R.xml.user_settings, + new SearchIndexableResource(RANK_USERS, + R.xml.user_settings, UserSettings.class.getName(), R.drawable.ic_settings_multiuser)); sResMap.put(LocationSettings.class.getName(), - new SearchIndexableResource(RANK_LOCATION, R.xml.location_settings, + new SearchIndexableResource(RANK_LOCATION, + R.xml.location_settings, LocationSettings.class.getName(), R.drawable.ic_settings_location)); sResMap.put(SecuritySettings.class.getName(), - new SearchIndexableResource(RANK_SECURITY, R.xml.security_settings, + new SearchIndexableResource(RANK_SECURITY, + R.xml.security_settings, SecuritySettings.class.getName(), R.drawable.ic_settings_security)); sResMap.put(InputMethodAndLanguageSettings.class.getName(), - new SearchIndexableResource(RANK_IME, R.xml.language_settings, + new SearchIndexableResource(RANK_IME, + R.xml.language_settings, InputMethodAndLanguageSettings.class.getName(), R.drawable.ic_settings_language)); sResMap.put(PrivacySettings.class.getName(), - new SearchIndexableResource(RANK_PRIVACY, R.xml.privacy_settings, + new SearchIndexableResource(RANK_PRIVACY, + R.xml.privacy_settings, PrivacySettings.class.getName(), R.drawable.ic_settings_backup)); sResMap.put(DateTimeSettings.class.getName(), - new SearchIndexableResource(RANK_DATE_TIME, R.xml.date_time_prefs, + new SearchIndexableResource(RANK_DATE_TIME, + R.xml.date_time_prefs, DateTimeSettings.class.getName(), R.drawable.ic_settings_date_time)); sResMap.put(AccessibilitySettings.class.getName(), - new SearchIndexableResource(RANK_ACCESSIBILITY, R.xml.accessibility_settings, + new SearchIndexableResource(RANK_ACCESSIBILITY, + R.xml.accessibility_settings, AccessibilitySettings.class.getName(), R.drawable.ic_settings_accessibility)); sResMap.put(PrintSettingsFragment.class.getName(), - new SearchIndexableResource(RANK_PRINTING, R.xml.print_settings, + new SearchIndexableResource(RANK_PRINTING, + R.xml.print_settings, PrintSettingsFragment.class.getName(), com.android.internal.R.drawable.ic_print)); sResMap.put(DevelopmentSettings.class.getName(), - new SearchIndexableResource(RANK_DEVELOPEMENT, R.xml.development_prefs, + new SearchIndexableResource(RANK_DEVELOPEMENT, + R.xml.development_prefs, DevelopmentSettings.class.getName(), R.drawable.ic_settings_development)); sResMap.put(DeviceInfoSettings.class.getName(), - new SearchIndexableResource(RANK_DEVICE_INFO, R.xml.device_info_settings, + new SearchIndexableResource(RANK_DEVICE_INFO, + R.xml.device_info_settings, DeviceInfoSettings.class.getName(), R.drawable.ic_settings_about)); } |