Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java |
| index 04cc8ffa80ae953a77f3f050f1cb11b1a70222a6..8adbda2a4d884a4b674e5961fd9b58d9471adc32 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java |
| @@ -502,8 +502,8 @@ public class ShortcutHelper { |
| * @param resources Resources to retrieve the dimension from. |
| * @return the dimensions in dp which the icon should have. |
| */ |
| - public static int getIdealHomescreenIconSizeInDp(Context context) { |
| - return getIdealSizeFromResourceInDp(context, R.dimen.webapp_home_screen_icon_size); |
| + public static int getIdealHomescreenIconSizeInPx(Context context) { |
| + return getIdealSizeFromResourceInPx(context, R.dimen.webapp_home_screen_icon_size); |
| } |
| /** |
| @@ -512,13 +512,12 @@ public class ShortcutHelper { |
| * @param resources Resources to retrieve the dimension from. |
| * @return the lower bound of the size which the icon should have in dp. |
| */ |
| - public static int getMinimumHomescreenIconSizeInDp(Context context) { |
| + public static int getMinimumHomescreenIconSizeInPx(Context context) { |
| float sizeInPx = context.getResources().getDimension(R.dimen.webapp_home_screen_icon_size); |
| float density = context.getResources().getDisplayMetrics().density; |
| float idealIconSizeInDp = sizeInPx / density; |
| - float minimumIconSizeInPx = idealIconSizeInDp * (density - 1); |
| - return Math.round(minimumIconSizeInPx / density); |
| + return Math.round(idealIconSizeInDp * (density - 1)); |
| } |
| /** |
| @@ -526,8 +525,8 @@ public class ShortcutHelper { |
| * @param resources Resources to retrieve the dimension from. |
| * @return the dimensions in dp which the image should have. |
| */ |
| - public static int getIdealSplashImageSizeInDp(Context context) { |
| - return getIdealSizeFromResourceInDp(context, R.dimen.webapp_splash_image_size_ideal); |
| + public static int getIdealSplashImageSizeInPx(Context context) { |
| + return getIdealSizeFromResourceInPx(context, R.dimen.webapp_splash_image_size_ideal); |
| } |
| /** |
| @@ -535,8 +534,8 @@ public class ShortcutHelper { |
| * @param resources Resources to retrieve the dimension from. |
| * @return the lower bound of the size which the image should have in dp. |
| */ |
| - public static int getMinimumSplashImageSizeInDp(Context context) { |
| - return getIdealSizeFromResourceInDp(context, R.dimen.webapp_splash_image_size_minimum); |
| + public static int getMinimumSplashImageSizeInPx(Context context) { |
| + return getIdealSizeFromResourceInPx(context, R.dimen.webapp_splash_image_size_minimum); |
| } |
| /** |
| @@ -593,10 +592,10 @@ public class ShortcutHelper { |
| Context context = ContextUtils.getApplicationContext(); |
| // This ordering must be kept up to date with the C++ ShortcutHelper. |
| return new int[] { |
| - getIdealHomescreenIconSizeInDp(context), |
| - getMinimumHomescreenIconSizeInDp(context), |
| - getIdealSplashImageSizeInDp(context), |
| - getMinimumSplashImageSizeInDp(context) |
| + getIdealHomescreenIconSizeInPx(context), |
| + getMinimumHomescreenIconSizeInPx(context), |
| + getIdealSplashImageSizeInPx(context), |
| + getMinimumSplashImageSizeInPx(context) |
| }; |
| } |
| @@ -617,10 +616,8 @@ public class ShortcutHelper { |
| return false; |
| } |
| - private static int getIdealSizeFromResourceInDp(Context context, int resource) { |
| - float sizeInPx = context.getResources().getDimension(resource); |
| - float density = context.getResources().getDisplayMetrics().density; |
| - return Math.round(sizeInPx / density); |
| + private static int getIdealSizeFromResourceInPx(Context context, int resource) { |
|
dominickn
2016/12/19 06:23:32
Nit: rename this to getSizeFromResourceInPx (it's
|
| + return Math.round(context.getResources().getDimension(resource)); |
| } |
| private static Bitmap getBitmapFromResourceId(Context context, int id, int density) { |