Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3517)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java

Issue 2794513002: Revert "[NTP::Downloads] Replace 36dp ... resources with vector ... ." (Closed)
Patch Set: remove dependent patch. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadItemView.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
index c3f0614bd57eb52b40ca9e05cf6f0ea0067e2b06..9eb08599a8f98e583bcf90b71aa3ab981d265e29 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
@@ -87,7 +87,6 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi
private final boolean mUseFaviconService;
private final ColorStateList mIconForegroundColorList;
private final int mIconBackgroundColor;
- private final int mFileTypeIconPaddingPx;
private FetchImageCallback mImageCallback;
private SnippetArticle mArticle;
@@ -125,8 +124,6 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi
mIconForegroundColorList = DownloadUtils.getIconForegroundColorList(parent.getContext());
mThumbnailProvider = new ThumbnailProviderImpl(
Math.min(mThumbnailView.getMaxWidth(), mThumbnailView.getMaxHeight()));
- mFileTypeIconPaddingPx = mThumbnailView.getResources().getDimensionPixelSize(
- R.dimen.snippets_thumbnail_file_type_icon_padding);
new ImpressionTracker(itemView, this);
new DisplayStyleObserverAdapter(itemView, uiConfig, new DisplayStyleObserver() {
@@ -298,10 +295,25 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi
private void setThumbnailFromFileType(int fileType) {
mThumbnailView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
- mThumbnailView.setPadding(mFileTypeIconPaddingPx, mFileTypeIconPaddingPx,
- mFileTypeIconPaddingPx, mFileTypeIconPaddingPx);
+
+ // The provided asset is 36dp, but the spec requires 32dp. Add padding to force the asset to
+ // be scaled down.
+ final int actualIconSizeDp = 36;
+ final int desiredIconSizeDp = 32;
+ Drawable icon = ApiCompatibilityUtils.getDrawable(mThumbnailView.getResources(),
+ DownloadUtils.getIconResId(fileType, DownloadUtils.ICON_SIZE_36_DP));
+
+ final int drawableSize = icon.getIntrinsicWidth();
+ assert icon.getIntrinsicHeight() == drawableSize;
+
+ final int viewSize = mThumbnailView.getResources().getDimensionPixelSize(
+ R.dimen.snippets_thumbnail_size);
+ final float scale = ((float) desiredIconSizeDp) / actualIconSizeDp;
+ final int padding = (int) (viewSize / 2f - drawableSize * scale / 2f);
+ mThumbnailView.setPadding(padding, padding, padding, padding);
+
mThumbnailView.setBackgroundColor(mIconBackgroundColor);
- mThumbnailView.setImageResource(DownloadUtils.getIconResId(fileType));
+ mThumbnailView.setImageDrawable(icon);
mThumbnailView.setTint(mIconForegroundColorList);
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadItemView.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698