Loading core/java/android/app/SearchManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -1359,6 +1359,15 @@ public class SearchManager */ public final static String SUGGEST_COLUMN_SHORTCUT_ID = "suggest_shortcut_id"; /** * Column name for suggestions cursor. <i>Optional.</i> This column is used to specify the * cursor item's background color if it needs a non-default background color. A non-zero value * indicates a valid background color to override the default. * * @hide For internal use, not part of the public API. */ public final static String SUGGEST_COLUMN_BACKGROUND_COLOR = "suggest_background_color"; /** * Column value for suggestion column {@link #SUGGEST_COLUMN_SHORTCUT_ID} when a suggestion * should not be stored as a shortcut in global search. Loading core/java/android/app/SuggestionsAdapter.java +55 −35 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.server.search.SearchableInfo; import android.text.Html; import android.text.TextUtils; import android.util.Log; import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; Loading Loading @@ -62,6 +63,10 @@ class SuggestionsAdapter extends ResourceCursorAdapter { private int mText2Col; private int mIconName1Col; private int mIconName2Col; private int mBackgroundColorCol; // Cached item background color. private int mDefaultBackgroundColor; // This value is stored in SuggestionsAdapter by the SearchDialog to indicate whether // a particular list item should be selected upon the next call to notifyDataSetChanged. Loading Loading @@ -91,6 +96,11 @@ class SuggestionsAdapter extends ResourceCursorAdapter { Context activityContext = mSearchable.getActivityContext(mContext); mProviderContext = mSearchable.getProviderContext(mContext, activityContext); TypedValue colorValue = new TypedValue(); mProviderContext.getTheme().resolveAttribute( com.android.internal.R.attr.searchWidgetItemBackground, colorValue, true); mDefaultBackgroundColor = mProviderContext.getResources().getColor(colorValue.resourceId); mOutsideDrawablesCache = outsideDrawablesCache; mGlobalSearchMode = globalSearchMode; } Loading Loading @@ -139,6 +149,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { mText2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2); mIconName1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_1); mIconName2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_2); mBackgroundColorCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_BACKGROUND_COLOR); } } Loading Loading @@ -254,6 +265,15 @@ class SuggestionsAdapter extends ResourceCursorAdapter { mDisplayNotifyPos = NONE; // only notify the first time } int backgroundColor = 0; if (mBackgroundColorCol != -1) { backgroundColor = cursor.getInt(mBackgroundColorCol); } if (backgroundColor == 0) { backgroundColor = mDefaultBackgroundColor; } view.setBackgroundColor(backgroundColor); final boolean isHtml = mFormatCol > 0 && "html".equals(cursor.getString(mFormatCol)); setViewText(cursor, views.mText1, mText1Col, isHtml); setViewText(cursor, views.mText2, mText2Col, isHtml); Loading core/res/res/values/attrs.xml +4 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,10 @@ <!-- Text color for urls in search suggestions, used by things like global search and the browser. @hide --> <attr name="textColorSearchUrl" format="reference|color" /> <!-- Search widget result item background. --> <attr name="searchWidgetItemBackground" format="reference|color" /> <!-- Search widget expandable result item background. --> <attr name="searchWidgetCorpusItemBackground" format="reference|color" /> <!-- Text color, typeface, size, and style for "large" text. Defaults to primary text color. --> <attr name="textAppearanceLarge" format="reference" /> Loading core/res/res/values/colors.xml +2 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,8 @@ <!-- For search-related UIs --> <color name="search_url_text">#7fa87f</color> <color name="search_widget_item_background">@android:color/white</color> <color name="search_widget_corpus_item_background">@android:color/lighter_gray</color> </resources> core/res/res/values/themes.xml +4 −0 Original line number Diff line number Diff line Loading @@ -183,6 +183,10 @@ <item name="editTextPreferenceStyle">@android:style/Preference.DialogPreference.EditTextPreference</item> <item name="ringtonePreferenceStyle">@android:style/Preference.RingtonePreference</item> <item name="preferenceLayoutChild">@android:layout/preference_child</item> <!-- Search widget styles --> <item name="searchWidgetItemBackground">@android:color/search_widget_item_background</item> <item name="searchWidgetCorpusItemBackground">@android:color/search_widget_corpus_item_background</item> </style> <!-- Variant of the default (dark) theme with no title bar --> Loading Loading
core/java/android/app/SearchManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -1359,6 +1359,15 @@ public class SearchManager */ public final static String SUGGEST_COLUMN_SHORTCUT_ID = "suggest_shortcut_id"; /** * Column name for suggestions cursor. <i>Optional.</i> This column is used to specify the * cursor item's background color if it needs a non-default background color. A non-zero value * indicates a valid background color to override the default. * * @hide For internal use, not part of the public API. */ public final static String SUGGEST_COLUMN_BACKGROUND_COLOR = "suggest_background_color"; /** * Column value for suggestion column {@link #SUGGEST_COLUMN_SHORTCUT_ID} when a suggestion * should not be stored as a shortcut in global search. Loading
core/java/android/app/SuggestionsAdapter.java +55 −35 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.server.search.SearchableInfo; import android.text.Html; import android.text.TextUtils; import android.util.Log; import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; Loading Loading @@ -62,6 +63,10 @@ class SuggestionsAdapter extends ResourceCursorAdapter { private int mText2Col; private int mIconName1Col; private int mIconName2Col; private int mBackgroundColorCol; // Cached item background color. private int mDefaultBackgroundColor; // This value is stored in SuggestionsAdapter by the SearchDialog to indicate whether // a particular list item should be selected upon the next call to notifyDataSetChanged. Loading Loading @@ -91,6 +96,11 @@ class SuggestionsAdapter extends ResourceCursorAdapter { Context activityContext = mSearchable.getActivityContext(mContext); mProviderContext = mSearchable.getProviderContext(mContext, activityContext); TypedValue colorValue = new TypedValue(); mProviderContext.getTheme().resolveAttribute( com.android.internal.R.attr.searchWidgetItemBackground, colorValue, true); mDefaultBackgroundColor = mProviderContext.getResources().getColor(colorValue.resourceId); mOutsideDrawablesCache = outsideDrawablesCache; mGlobalSearchMode = globalSearchMode; } Loading Loading @@ -139,6 +149,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { mText2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_2); mIconName1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_1); mIconName2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_2); mBackgroundColorCol = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_BACKGROUND_COLOR); } } Loading Loading @@ -254,6 +265,15 @@ class SuggestionsAdapter extends ResourceCursorAdapter { mDisplayNotifyPos = NONE; // only notify the first time } int backgroundColor = 0; if (mBackgroundColorCol != -1) { backgroundColor = cursor.getInt(mBackgroundColorCol); } if (backgroundColor == 0) { backgroundColor = mDefaultBackgroundColor; } view.setBackgroundColor(backgroundColor); final boolean isHtml = mFormatCol > 0 && "html".equals(cursor.getString(mFormatCol)); setViewText(cursor, views.mText1, mText1Col, isHtml); setViewText(cursor, views.mText2, mText2Col, isHtml); Loading
core/res/res/values/attrs.xml +4 −0 Original line number Diff line number Diff line Loading @@ -82,6 +82,10 @@ <!-- Text color for urls in search suggestions, used by things like global search and the browser. @hide --> <attr name="textColorSearchUrl" format="reference|color" /> <!-- Search widget result item background. --> <attr name="searchWidgetItemBackground" format="reference|color" /> <!-- Search widget expandable result item background. --> <attr name="searchWidgetCorpusItemBackground" format="reference|color" /> <!-- Text color, typeface, size, and style for "large" text. Defaults to primary text color. --> <attr name="textAppearanceLarge" format="reference" /> Loading
core/res/res/values/colors.xml +2 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,8 @@ <!-- For search-related UIs --> <color name="search_url_text">#7fa87f</color> <color name="search_widget_item_background">@android:color/white</color> <color name="search_widget_corpus_item_background">@android:color/lighter_gray</color> </resources>
core/res/res/values/themes.xml +4 −0 Original line number Diff line number Diff line Loading @@ -183,6 +183,10 @@ <item name="editTextPreferenceStyle">@android:style/Preference.DialogPreference.EditTextPreference</item> <item name="ringtonePreferenceStyle">@android:style/Preference.RingtonePreference</item> <item name="preferenceLayoutChild">@android:layout/preference_child</item> <!-- Search widget styles --> <item name="searchWidgetItemBackground">@android:color/search_widget_item_background</item> <item name="searchWidgetCorpusItemBackground">@android:color/search_widget_corpus_item_background</item> </style> <!-- Variant of the default (dark) theme with no title bar --> Loading