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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java

Issue 2721043002: [NTP::Downloads] Scale up type based icons. (Closed)
Patch Set: dfalcantara@ comment. Created 3 years, 10 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
Index: chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
index 1b843659fd4ee2fb96ec8e786f5a1cf952eed62c..b989159158052b5abf18049dd18069fc7d1783b1 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java
@@ -16,6 +16,7 @@ import android.graphics.Color;
import android.net.Uri;
import android.os.StrictMode;
import android.provider.Browser;
+import android.support.annotation.IntDef;
import android.support.annotation.Nullable;
import android.support.customtabs.CustomTabsIntent;
import android.text.TextUtils;
@@ -51,6 +52,8 @@ import org.chromium.ui.base.DeviceFormFactor;
import org.chromium.ui.widget.Toast;
import java.io.File;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;
@@ -86,6 +89,16 @@ public class DownloadUtils {
static final String ELLIPSIS = "\u2026";
/**
+ * Possible sizes of type-based icons.
+ */
+ @IntDef({ICON_SIZE_24_DP, ICON_SIZE_36_DP})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface IconSize {}
+
+ public static final int ICON_SIZE_24_DP = 24;
+ public static final int ICON_SIZE_36_DP = 36;
+
+ /**
* Displays the download manager UI. Note the UI is different on tablets and on phones.
* @return Whether the UI was shown.
*/
@@ -649,10 +662,10 @@ public class DownloadUtils {
/**
* Abbreviate a file name into a given number of characters with ellipses.
- * e.g. thisisaverylongfilename.txt => thisisave....txt
- * @param fileName File name to abbreviate
- * @param limit Character limit
- * @return Abbreviated file name
+ * e.g. "thisisaverylongfilename.txt" => "thisisave....txt".
+ * @param fileName File name to abbreviate.
+ * @param limit Character limit.
+ * @return Abbreviated file name.
*/
public static String getAbbreviatedFileName(String fileName, int limit) {
assert limit >= 1; // Abbreviated file name should at least be 1 characters (a...)
@@ -675,30 +688,37 @@ public class DownloadUtils {
/**
* Return an icon for a given file type.
- * @param fileType Type of the file as returned by DownloadFilter
- * @return Resource ID of the corresponding icon
+ * @param fileType Type of the file as returned by DownloadFilter.
+ * @param iconSize Size of the returned icon.
+ * @return Resource ID of the corresponding icon.
*/
- public static int getIconResId(int fileType) {
+ public static int getIconResId(int fileType, @IconSize int iconSize) {
switch (fileType) {
case DownloadFilter.FILTER_PAGE:
- return R.drawable.ic_drive_site_white_24dp;
+ return iconSize == ICON_SIZE_24_DP ? R.drawable.ic_drive_site_white_24dp
+ : R.drawable.ic_drive_site_white_36dp;
case DownloadFilter.FILTER_VIDEO:
- return R.drawable.ic_play_arrow_white_24dp;
+ return iconSize == ICON_SIZE_24_DP ? R.drawable.ic_play_arrow_white_24dp
+ : R.drawable.ic_play_arrow_white_36dp;
case DownloadFilter.FILTER_AUDIO:
- return R.drawable.ic_music_note_white_24dp;
+ return iconSize == ICON_SIZE_24_DP ? R.drawable.ic_music_note_white_24dp
+ : R.drawable.ic_music_note_white_36dp;
case DownloadFilter.FILTER_IMAGE:
- return R.drawable.ic_image_white_24dp;
+ return iconSize == ICON_SIZE_24_DP ? R.drawable.ic_image_white_24dp
+ : R.drawable.ic_image_white_36dp;
case DownloadFilter.FILTER_DOCUMENT:
- return R.drawable.ic_drive_text_white_24dp;
+ return iconSize == ICON_SIZE_24_DP ? R.drawable.ic_drive_text_white_24dp
+ : R.drawable.ic_drive_text_white_36dp;
default:
- return R.drawable.ic_drive_file_white_24dp;
+ return iconSize == ICON_SIZE_24_DP ? R.drawable.ic_drive_file_white_24dp
+ : R.drawable.ic_drive_text_white_36dp;
Theresa 2017/05/24 21:57:11 Is this supposed to be ic_drive_file_white_36dp?
vitaliii 2017/05/26 09:41:12 Yes (copy-paste mistake). Good catch! Fix: https
}
}
/**
* Return a background color for the file type icon.
- * @param context Context from which to extract the resources
- * @return Background color
+ * @param context Context from which to extract the resources.
+ * @return Background color.
*/
public static int getIconBackgroundColor(Context context) {
return ApiCompatibilityUtils.getColor(context.getResources(), R.color.light_active_color);
@@ -706,8 +726,8 @@ public class DownloadUtils {
/**
* Return a foreground color list for the file type icon.
- * @param context Context from which to extract the resources
- * @return a foreground color list
+ * @param context Context from which to extract the resources.
+ * @return a foreground color list.
*/
public static ColorStateList getIconForegroundColorList(Context context) {
return ApiCompatibilityUtils.getColorStateList(

Powered by Google App Engine
This is Rietveld 408576698