diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/settings/DisplaySettings.java | 39 | ||||
-rw-r--r-- | src/com/android/settings/search/SearchIndexableResources.java | 2 |
2 files changed, 36 insertions, 5 deletions
diff --git a/src/com/android/settings/DisplaySettings.java b/src/com/android/settings/DisplaySettings.java index 3bf7cce16..75236de8c 100644 --- a/src/com/android/settings/DisplaySettings.java +++ b/src/com/android/settings/DisplaySettings.java @@ -16,6 +16,9 @@ package com.android.settings; +import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settings.search.Indexable; + import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE; import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC; import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL; @@ -36,13 +39,15 @@ import android.preference.ListPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceScreen; +import android.provider.SearchIndexableResource; import android.provider.Settings; import android.util.Log; import java.util.ArrayList; +import java.util.List; public class DisplaySettings extends SettingsPreferenceFragment implements - Preference.OnPreferenceChangeListener, OnPreferenceClickListener { + Preference.OnPreferenceChangeListener, OnPreferenceClickListener, Indexable { private static final String TAG = "DisplaySettings"; /** If there is no setting in the provider, use this. */ @@ -90,9 +95,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements mFontSizePref.setOnPreferenceChangeListener(this); mFontSizePref.setOnPreferenceClickListener(this); - boolean automaticBrightnessAvailable = getResources().getBoolean( - com.android.internal.R.bool.config_automatic_brightness_available); - if (automaticBrightnessAvailable) { + if (isAutomaticBrightnessAvailable(getResources())) { mAutoBrightnessPreference = (CheckBoxPreference) findPreference(KEY_AUTO_BRIGHTNESS); mAutoBrightnessPreference.setOnPreferenceChangeListener(this); } else { @@ -100,6 +103,10 @@ public class DisplaySettings extends SettingsPreferenceFragment implements } } + private static boolean isAutomaticBrightnessAvailable(Resources res) { + return res.getBoolean(com.android.internal.R.bool.config_automatic_brightness_available); + } + private void updateTimeoutPreferenceDescription(long currentTimeout) { ListPreference preference = mScreenTimeoutPreference; String summary; @@ -286,4 +293,28 @@ public class DisplaySettings extends SettingsPreferenceFragment implements } return false; } + + public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new BaseSearchIndexProvider() { + @Override + public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, + boolean enabled) { + ArrayList<SearchIndexableResource> result = new ArrayList<>(1); + + SearchIndexableResource sir = new SearchIndexableResource(context); + sir.xmlResId = R.xml.display_settings; + result.add(sir); + + return result; + } + + @Override + public List<String> getNonIndexableKeys(Context context) { + ArrayList<String> nonIndexableKeys = new ArrayList<>(1); + if (!isAutomaticBrightnessAvailable(context.getResources())) { + nonIndexableKeys.add(KEY_AUTO_BRIGHTNESS); + } + return nonIndexableKeys; + } + }; } diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java index 51566486a..01d3c0738 100644 --- a/src/com/android/settings/search/SearchIndexableResources.java +++ b/src/com/android/settings/search/SearchIndexableResources.java @@ -101,7 +101,7 @@ public final class SearchIndexableResources { sResMap.put(DisplaySettings.class.getName(), new SearchIndexableResource( Ranking.getRankForClassName(DisplaySettings.class.getName()), - R.xml.display_settings, + NO_DATA_RES_ID, DisplaySettings.class.getName(), R.drawable.ic_settings_display)); |