From 610ac9cd2867bb714cdec50835a29f1a1dc04907 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sat, 3 Oct 2015 16:21:10 -0700 Subject: Show blocked icon in call log. For calls of type BLOCKED, show the blocked call icon. Bug: 23943480 Change-Id: Ic1477090c31d51322dbe04dac29f1ca3b0dae4d1 --- res/values/colors.xml | 3 +- res/values/dimens.xml | 2 + .../android/dialer/calllog/CallTypeIconsView.java | 52 +++++++++++----------- .../database/FilteredNumberAsyncQueryHandler.java | 2 +- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/res/values/colors.xml b/res/values/colors.xml index e80ee6913..f0765bab9 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -92,9 +92,10 @@ #ff2e58 - @color/dialer_green_highlight_color + + @color/dialtacts_secondary_text_color #ffffff diff --git a/res/values/dimens.xml b/res/values/dimens.xml index d35a78d12..fa0b917f6 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -154,4 +154,6 @@ 12sp 32dp 14sp + + 12dp diff --git a/src/com/android/dialer/calllog/CallTypeIconsView.java b/src/com/android/dialer/calllog/CallTypeIconsView.java index d680cfe42..cfd8f9748 100644 --- a/src/com/android/dialer/calllog/CallTypeIconsView.java +++ b/src/com/android/dialer/calllog/CallTypeIconsView.java @@ -114,6 +114,8 @@ public class CallTypeIconsView extends View { return mResources.missed; case AppCompatConstants.CALLS_VOICEMAIL_TYPE: return mResources.voicemail; + case AppCompatConstants.CALLS_BLOCKED_TYPE: + return mResources.blocked; default: // It is possible for users to end up with calls with unknown call types in their // call history, possibly due to 3rd party call log implementations (e.g. to @@ -150,29 +152,22 @@ public class CallTypeIconsView extends View { private static class Resources { - /** - * Drawable representing an incoming answered call. - */ + // Drawable representing an incoming answered call. public final Drawable incoming; - /** - * Drawable respresenting an outgoing call. - */ + // Drawable respresenting an outgoing call. public final Drawable outgoing; - /** - * Drawable representing an incoming missed call. - */ + // Drawable representing an incoming missed call. public final Drawable missed; - /** - * Drawable representing a voicemail. - */ + // Drawable representing a voicemail. public final Drawable voicemail; - /** - * Drawable repesenting a video call. - */ + // Drawable representing a blocked call. + public final Drawable blocked; + + // Drawable repesenting a video call. public final Drawable videoCall; /** @@ -204,21 +199,26 @@ public class CallTypeIconsView extends View { voicemail = r.getDrawable(R.drawable.ic_call_voicemail_holo_dark); - // Get the video call icon, scaled to match the height of the call arrows. - // We want the video call icon to be the same height as the call arrows, while keeping - // the same width aspect ratio. - Bitmap videoIcon = BitmapFactory.decodeResource(context.getResources(), - R.drawable.ic_videocam_24dp); - int scaledHeight = missed.getIntrinsicHeight(); - int scaledWidth = (int) ((float) videoIcon.getWidth() * - ((float) missed.getIntrinsicHeight() / - (float) videoIcon.getHeight())); - Bitmap scaled = Bitmap.createScaledBitmap(videoIcon, scaledWidth, scaledHeight, false); - videoCall = new BitmapDrawable(context.getResources(), scaled); + blocked = getScaledBitmap(context, R.drawable.ic_block_24dp); + blocked.setColorFilter(r.getColor(R.color.blocked_call), PorterDuff.Mode.MULTIPLY); + + videoCall = getScaledBitmap(context, R.drawable.ic_videocam_24dp); videoCall.setColorFilter(r.getColor(R.color.dialtacts_secondary_text_color), PorterDuff.Mode.MULTIPLY); iconMargin = r.getDimensionPixelSize(R.dimen.call_log_icon_margin); } + + // Gets the icon, scaled to the height of the call type icons. This helps display all the + // icons to be the same height, while preserving their width aspect ratio. + private Drawable getScaledBitmap(Context context, int resourceId) { + Bitmap icon = BitmapFactory.decodeResource(context.getResources(), resourceId); + int scaledHeight = + context.getResources().getDimensionPixelSize(R.dimen.call_type_icon_size); + int scaledWidth = (int) ((float) icon.getWidth() + * ((float) scaledHeight / (float) icon.getHeight())); + Bitmap scaledIcon = Bitmap.createScaledBitmap(icon, scaledWidth, scaledHeight, false); + return new BitmapDrawable(context.getResources(), scaledIcon); + } } } diff --git a/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java b/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java index 9da9cc15b..c5d2f6f70 100644 --- a/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java +++ b/src/com/android/dialer/database/FilteredNumberAsyncQueryHandler.java @@ -247,4 +247,4 @@ public class FilteredNumberAsyncQueryHandler extends AsyncQueryHandler { } }, uri, null, null, null, null); } -} \ No newline at end of file +} -- cgit v1.2.3