From 7f50c08fb998786a2963e979cd5b4347e64808e3 Mon Sep 17 00:00:00 2001 From: Satish Sampath Date: Fri, 12 Jun 2009 11:58:46 +0100 Subject: Show proper suggestion item hilite on selection. With the new implementation of using a SuggestionItemView, we no longer need to draw a solid background for all items in the suggestion listview. Hence removing the code to draw a default white background, and make the item transparent so the listview-drawn selection hilite shows through. --- core/java/android/app/SuggestionsAdapter.java | 14 ++------------ core/res/res/values/attrs.xml | 4 +--- core/res/res/values/colors.xml | 1 - core/res/res/values/themes.xml | 1 - 4 files changed, 3 insertions(+), 17 deletions(-) (limited to 'core') diff --git a/core/java/android/app/SuggestionsAdapter.java b/core/java/android/app/SuggestionsAdapter.java index 8c5cee3..ed76f4e 100644 --- a/core/java/android/app/SuggestionsAdapter.java +++ b/core/java/android/app/SuggestionsAdapter.java @@ -68,9 +68,6 @@ class SuggestionsAdapter extends ResourceCursorAdapter { 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. // This is used to indicate the index of the "More results..." list item so that when @@ -102,11 +99,6 @@ 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; @@ -303,9 +295,6 @@ class SuggestionsAdapter extends ResourceCursorAdapter { if (mBackgroundColorCol != -1) { backgroundColor = cursor.getInt(mBackgroundColorCol); } - if (backgroundColor == 0) { - backgroundColor = mDefaultBackgroundColor; - } ((SuggestionItemView)view).setColor(backgroundColor); final boolean isHtml = mFormatCol > 0 && "html".equals(cursor.getString(mFormatCol)); @@ -524,6 +513,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { protected SuggestionItemView(Context context, Cursor cursor) { // Initialize ourselves super(context); + mBackgroundColor = 0; // transparent by default. // For our layout use the default list item height from the current theme. TypedValue lineHeight = new TypedValue(); @@ -551,7 +541,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { @Override public void dispatchDraw(Canvas canvas) { - if (!isPressed()) { + if (mBackgroundColor != 0 && !isPressed() && !isSelected()) { canvas.drawColor(mBackgroundColor); } super.dispatchDraw(canvas); diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 99fe9c8..23ab573 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -82,9 +82,7 @@ - - - + diff --git a/core/res/res/values/colors.xml b/core/res/res/values/colors.xml index 29d8f73..d284d0f 100644 --- a/core/res/res/values/colors.xml +++ b/core/res/res/values/colors.xml @@ -75,7 +75,6 @@ #7fa87f - @android:color/white @android:color/lighter_gray diff --git a/core/res/res/values/themes.xml b/core/res/res/values/themes.xml index 0641021..f37d514 100644 --- a/core/res/res/values/themes.xml +++ b/core/res/res/values/themes.xml @@ -185,7 +185,6 @@ @android:layout/preference_child - @android:color/search_widget_item_background @android:color/search_widget_corpus_item_background -- cgit v1.1