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

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

Issue 2611623003: Use exact pixel sizes instead of dip in webapp/WebAPK installability code (Closed)
Patch Set: Rebased version of pkotwicz@'s original patch Created 3 years, 12 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 | « no previous file | chrome/browser/android/banners/app_banner_manager_android.h » ('j') | 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/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..6231df55dbc6bbbccabdf0dae2a971bdfbbfacc8 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 getSizeFromResourceInPx(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 getSizeFromResourceInPx(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 getSizeFromResourceInPx(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 getSizeFromResourceInPx(Context context, int resource) {
+ return Math.round(context.getResources().getDimension(resource));
}
private static Bitmap getBitmapFromResourceId(Context context, int id, int density) {
« no previous file with comments | « no previous file | chrome/browser/android/banners/app_banner_manager_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698