Commit 608a1323 authored by newt's avatar newt Committed by Commit bot

Fix RoundedIconGenerator font scaling.

BUG=463638

Review URL: https://codereview.chromium.org/972303002

Cr-Commit-Position: refs/heads/master@{#318970}
parent c329228b
......@@ -303,12 +303,11 @@ public class NotificationUIManager {
res.getDimensionPixelSize(android.R.dimen.notification_large_icon_height);
return new RoundedIconGenerator(
appContext,
(int) (widthPx / density),
(int) (heightPx / density),
(int) (Math.min(widthPx, heightPx) / density / 2),
widthPx,
heightPx,
Math.min(widthPx, heightPx) / 2,
NOTIFICATION_ICON_BG_COLOR,
NOTIFICATION_TEXT_SIZE_DP);
NOTIFICATION_TEXT_SIZE_DP * density);
}
/**
......
......@@ -46,7 +46,7 @@ class WebsitePreference extends Preference implements FaviconImageCallback {
private static final int FAVICON_CORNER_RADIUS_DP = 2;
private static final int FAVICON_SIZE_DP = 16;
private static final int FAVICON_PADDING_DP = 4;
private static final int FAVICON_TEXT_SIZE_SP = 10;
private static final int FAVICON_TEXT_SIZE_DP = 10;
private static final int FAVICON_BACKGROUND_COLOR = 0xff969696;
WebsitePreference(Context context, Website site, String categoryFilter) {
......@@ -86,7 +86,7 @@ class WebsitePreference extends Preference implements FaviconImageCallback {
RoundedIconGenerator faviconGenerator = new RoundedIconGenerator(
getContext(), FAVICON_SIZE_DP, FAVICON_SIZE_DP,
FAVICON_CORNER_RADIUS_DP, FAVICON_BACKGROUND_COLOR,
FAVICON_TEXT_SIZE_SP);
FAVICON_TEXT_SIZE_DP);
image = faviconGenerator.generateIconForUrl(faviconUrl());
}
......
......@@ -14,7 +14,6 @@ import android.graphics.RectF;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.browser.UrlConstants;
......@@ -51,17 +50,16 @@ public class RoundedIconGenerator {
* @param iconWidthDp The width of the generated icon in dp.
* @param iconHeightDp The height of the generated icon in dp.
* @param cornerRadiusDp The radius of the corners in the icon in dp.
* @param backgroundColor Color at which the rounded rectangle should be drawn.
* @param textSizeSp Size at which the text should be drawn in dp.
* @param backgroundColor Color with which the rounded rectangle should be drawn.
* @param textSizeDp Size at which the text should be drawn in dp.
*/
public RoundedIconGenerator(Context context, int iconWidthDp, int iconHeightDp,
int cornerRadiusDp, int backgroundColor, int textSizeSp) {
int cornerRadiusDp, int backgroundColor, int textSizeDp) {
this((int) (context.getResources().getDisplayMetrics().density * iconWidthDp),
(int) (context.getResources().getDisplayMetrics().density * iconHeightDp),
(int) (context.getResources().getDisplayMetrics().density * cornerRadiusDp),
backgroundColor,
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, textSizeSp,
context.getResources().getDisplayMetrics()));
(int) (context.getResources().getDisplayMetrics().density * textSizeDp));
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment