Bug 1007645 - Don't use opacity filter on suggested sites' background (r=mfinkle)

This commit is contained in:
Lucas Rocha 2014-05-09 16:40:02 +01:00
Родитель f31b38e070
Коммит 906a24e20b
2 изменённых файлов: 18 добавлений и 5 удалений

Просмотреть файл

@ -39,7 +39,7 @@ public class TopSitesGridItemView extends RelativeLayout {
// Child views.
private final TextView mTitleView;
private final ImageView mThumbnailView;
private final TopSitesThumbnailView mThumbnailView;
// Data backing this view.
private String mTitle;
@ -71,7 +71,7 @@ public class TopSitesGridItemView extends RelativeLayout {
LayoutInflater.from(context).inflate(R.layout.top_sites_grid_item_view, this);
mTitleView = (TextView) findViewById(R.id.title);
mThumbnailView = (ImageView) findViewById(R.id.thumbnail);
mThumbnailView = (TopSitesThumbnailView) findViewById(R.id.thumbnail);
}
/**
@ -286,7 +286,8 @@ public class TopSitesGridItemView extends RelativeLayout {
mThumbnailView.setImageBitmap(favicon);
if (mFaviconURL != null) {
mThumbnailView.setBackgroundColor(Favicons.getFaviconColor(mFaviconURL));
final int bgColor = Favicons.getFaviconColor(mFaviconURL);
mThumbnailView.setBackgroundColorWithOpacityFilter(bgColor);
}
}

Просмотреть файл

@ -87,6 +87,15 @@ public class TopSitesThumbnailView extends ImageView {
}
}
/**
* Sets the background color with a filter to reduce the color opacity.
*
* @param color the color filter to apply over the drawable.
*/
public void setBackgroundColorWithOpacityFilter(int color) {
setBackgroundColor(color & COLOR_FILTER);
}
/**
* Sets the background to a Drawable by applying the specified color as a filter.
*
@ -94,9 +103,12 @@ public class TopSitesThumbnailView extends ImageView {
*/
@Override
public void setBackgroundColor(int color) {
int colorFilter = color == 0 ? DEFAULT_COLOR : color & COLOR_FILTER;
if (color == 0) {
color = DEFAULT_COLOR;
}
Drawable drawable = getResources().getDrawable(R.drawable.top_sites_thumbnail_bg);
drawable.setColorFilter(colorFilter, Mode.SRC_ATOP);
drawable.setColorFilter(color, Mode.SRC_ATOP);
setBackgroundDrawable(drawable);
}
}