Loading res/values/cm_dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -15,4 +15,6 @@ <dimen name="coachmark_hint_text">14sp</dimen> <dimen name="coachmark_touch_padding">14sp</dimen> <dimen name="callerinfo_provider_picker_logo_width">98dp</dimen> <dimen name="callerinfo_provider_picker_logo_height">20dp</dimen> </resources> No newline at end of file src/com/android/dialer/callerinfo/CallerInfoProviderPicker.java +7 −3 Original line number Diff line number Diff line Loading @@ -144,8 +144,12 @@ public class CallerInfoProviderPicker { subText = Html.fromHtml(text); } int logoWidth = context.getResources().getDimensionPixelSize( R.dimen.callerinfo_provider_picker_logo_width); int logoHeight = context.getResources().getDimensionPixelSize( R.dimen.callerinfo_provider_picker_logo_height); Bitmap logo = ImageUtils.drawableToBitmap(info.getBrandLogo()); Bitmap scaledLogo = ImageUtils.scaleBitmapToTarget(logo, logoHeight, logoWidth); int resId = info.hasProperty(ProviderInfo.PROPERTY_SUPPORTS_SPAM) ? R.string.callerinfo_provider_auth_desc : R.string.callerinfo_provider_auth_desc_no_spam; Loading @@ -158,8 +162,8 @@ public class CallerInfoProviderPicker { nudge.setSubhead(subText.toString()); } if (logo != null) { nudge.setTitleImage(logo); if (scaledLogo != null) { nudge.setTitleImage(scaledLogo); } Intent enableIntent = buildEnableIntent(context, component, info, metricsReason); Loading src/com/android/dialer/util/ImageUtils.java +12 −17 Original line number Diff line number Diff line Loading @@ -77,10 +77,9 @@ public class ImageUtils { /** * Scale bitmap to the defined bounds. The bitmap will be scaled while maintaining the * aspect ratio and center-cropped(vertically and horizontally) if it exceeds the * defined bounds. * aspect ratio */ public static Bitmap scaleAndCropBitmapToTarget(Bitmap bitmap, int targetHeight, public static Bitmap scaleBitmapToTarget(Bitmap bitmap, int targetHeight, int targetWidth) { if (bitmap == null) { return bitmap; Loading @@ -89,25 +88,23 @@ public class ImageUtils { int bitmapHeight = bitmap.getHeight(); int bitmapWidth = bitmap.getWidth(); int deltaWidth = targetWidth - bitmapWidth; int deltaHeight = targetHeight - bitmapHeight; int deltaWidth = Math.abs(targetWidth - bitmapWidth); int deltaHeight = Math.abs(targetHeight - bitmapHeight); // nothing to do if src bitmap is bigger than or equal to the target if (deltaWidth <= 0 && deltaHeight <= 0) // nothing to do if one of the dimensions doesn't change as the aspect ratio // needs to be preserved if (deltaWidth == 0 || deltaHeight == 0) return bitmap; // scale bitmap along the dimension that is lacking the greatest float scale = Math.max( ((float)targetWidth) / bitmapWidth, // scale bitmap to fit target bounds float scale = Math.min( ((float)targetWidth) / bitmapWidth, ((float)targetHeight) / bitmapHeight); // calculate the new bitmap dimensions int newHeight = (int) Math.ceil(bitmapHeight * scale); int newWidth = (int) Math.ceil(bitmapWidth * scale); int newHeight = (int) Math.floor(bitmapHeight * scale); int newWidth = (int) Math.floor(bitmapWidth * scale); Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, false); // center the bitmap vertically and horizontally int startX = Math.max(0, (newWidth - targetWidth) / 2); int startY = Math.max(0, (newHeight - targetHeight) / 2); if (DEBUG) { Log.i(TAG, "bitmapWidth : " + bitmapWidth); Log.i(TAG, "bitmapHeight : " + bitmapHeight); Loading @@ -115,11 +112,9 @@ public class ImageUtils { Log.i(TAG, "deltaHeight : " + deltaHeight); Log.i(TAG, "newWidth : " + newWidth); Log.i(TAG, "newHeight : " + newHeight); Log.i(TAG, "startX : " + startX); Log.i(TAG, "startY : " + startY); } return Bitmap.createBitmap(scaledBitmap, startX, startY, targetWidth, targetHeight); return scaledBitmap; } /** Loading Loading
res/values/cm_dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -15,4 +15,6 @@ <dimen name="coachmark_hint_text">14sp</dimen> <dimen name="coachmark_touch_padding">14sp</dimen> <dimen name="callerinfo_provider_picker_logo_width">98dp</dimen> <dimen name="callerinfo_provider_picker_logo_height">20dp</dimen> </resources> No newline at end of file
src/com/android/dialer/callerinfo/CallerInfoProviderPicker.java +7 −3 Original line number Diff line number Diff line Loading @@ -144,8 +144,12 @@ public class CallerInfoProviderPicker { subText = Html.fromHtml(text); } int logoWidth = context.getResources().getDimensionPixelSize( R.dimen.callerinfo_provider_picker_logo_width); int logoHeight = context.getResources().getDimensionPixelSize( R.dimen.callerinfo_provider_picker_logo_height); Bitmap logo = ImageUtils.drawableToBitmap(info.getBrandLogo()); Bitmap scaledLogo = ImageUtils.scaleBitmapToTarget(logo, logoHeight, logoWidth); int resId = info.hasProperty(ProviderInfo.PROPERTY_SUPPORTS_SPAM) ? R.string.callerinfo_provider_auth_desc : R.string.callerinfo_provider_auth_desc_no_spam; Loading @@ -158,8 +162,8 @@ public class CallerInfoProviderPicker { nudge.setSubhead(subText.toString()); } if (logo != null) { nudge.setTitleImage(logo); if (scaledLogo != null) { nudge.setTitleImage(scaledLogo); } Intent enableIntent = buildEnableIntent(context, component, info, metricsReason); Loading
src/com/android/dialer/util/ImageUtils.java +12 −17 Original line number Diff line number Diff line Loading @@ -77,10 +77,9 @@ public class ImageUtils { /** * Scale bitmap to the defined bounds. The bitmap will be scaled while maintaining the * aspect ratio and center-cropped(vertically and horizontally) if it exceeds the * defined bounds. * aspect ratio */ public static Bitmap scaleAndCropBitmapToTarget(Bitmap bitmap, int targetHeight, public static Bitmap scaleBitmapToTarget(Bitmap bitmap, int targetHeight, int targetWidth) { if (bitmap == null) { return bitmap; Loading @@ -89,25 +88,23 @@ public class ImageUtils { int bitmapHeight = bitmap.getHeight(); int bitmapWidth = bitmap.getWidth(); int deltaWidth = targetWidth - bitmapWidth; int deltaHeight = targetHeight - bitmapHeight; int deltaWidth = Math.abs(targetWidth - bitmapWidth); int deltaHeight = Math.abs(targetHeight - bitmapHeight); // nothing to do if src bitmap is bigger than or equal to the target if (deltaWidth <= 0 && deltaHeight <= 0) // nothing to do if one of the dimensions doesn't change as the aspect ratio // needs to be preserved if (deltaWidth == 0 || deltaHeight == 0) return bitmap; // scale bitmap along the dimension that is lacking the greatest float scale = Math.max( ((float)targetWidth) / bitmapWidth, // scale bitmap to fit target bounds float scale = Math.min( ((float)targetWidth) / bitmapWidth, ((float)targetHeight) / bitmapHeight); // calculate the new bitmap dimensions int newHeight = (int) Math.ceil(bitmapHeight * scale); int newWidth = (int) Math.ceil(bitmapWidth * scale); int newHeight = (int) Math.floor(bitmapHeight * scale); int newWidth = (int) Math.floor(bitmapWidth * scale); Bitmap scaledBitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, false); // center the bitmap vertically and horizontally int startX = Math.max(0, (newWidth - targetWidth) / 2); int startY = Math.max(0, (newHeight - targetHeight) / 2); if (DEBUG) { Log.i(TAG, "bitmapWidth : " + bitmapWidth); Log.i(TAG, "bitmapHeight : " + bitmapHeight); Loading @@ -115,11 +112,9 @@ public class ImageUtils { Log.i(TAG, "deltaHeight : " + deltaHeight); Log.i(TAG, "newWidth : " + newWidth); Log.i(TAG, "newHeight : " + newHeight); Log.i(TAG, "startX : " + startX); Log.i(TAG, "startY : " + startY); } return Bitmap.createBitmap(scaledBitmap, startX, startY, targetWidth, targetHeight); return scaledBitmap; } /** Loading