diff options
author | Tyler Gunn <tgunn@google.com> | 2014-07-10 12:28:43 -0700 |
---|---|---|
committer | Tyler Gunn <tgunn@google.com> | 2014-07-10 12:28:43 -0700 |
commit | 8b0e858d5b4c50813dbe2b5c244e7013814b23ec (patch) | |
tree | e17124adb6cfd3f4e70595baf4f66d847292bc1d /src/com/android/dialer/calllog/CallTypeIconsView.java | |
parent | 70d301e1239c9324c071c10888bf6d7b0b48ddaa (diff) | |
download | android_packages_apps_Dialer-8b0e858d5b4c50813dbe2b5c244e7013814b23ec.tar.gz android_packages_apps_Dialer-8b0e858d5b4c50813dbe2b5c244e7013814b23ec.tar.bz2 android_packages_apps_Dialer-8b0e858d5b4c50813dbe2b5c244e7013814b23ec.zip |
Adding support for video call icon and data usage in call log.
Bug: 16013684
Bug: 16015261
Change-Id: Ie75443d641c1e09a5772bb618aba55de8583716b
Diffstat (limited to 'src/com/android/dialer/calllog/CallTypeIconsView.java')
-rw-r--r-- | src/com/android/dialer/calllog/CallTypeIconsView.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/com/android/dialer/calllog/CallTypeIconsView.java b/src/com/android/dialer/calllog/CallTypeIconsView.java index afbced41c..382056c72 100644 --- a/src/com/android/dialer/calllog/CallTypeIconsView.java +++ b/src/com/android/dialer/calllog/CallTypeIconsView.java @@ -17,8 +17,11 @@ package com.android.dialer.calllog; import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.PorterDuff; +import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.provider.CallLog.Calls; import android.util.AttributeSet; @@ -38,6 +41,7 @@ import java.util.List; */ public class CallTypeIconsView extends View { private List<Integer> mCallTypes = Lists.newArrayListWithCapacity(3); + private boolean mShowVideo = false; private Resources mResources; private int mWidth; private int mHeight; @@ -67,6 +71,20 @@ public class CallTypeIconsView extends View { invalidate(); } + /** + * Determines whether the video call icon will be shown. + * + * @param showVideo True where the video icon should be shown. + */ + public void setShowVideo(boolean showVideo) { + mShowVideo = showVideo; + if (showVideo) { + mWidth += mResources.videoCall.getIntrinsicWidth(); + mHeight = Math.max(mHeight, mResources.videoCall.getIntrinsicHeight()); + invalidate(); + } + } + @NeededForTesting public int getCount() { return mCallTypes.size(); @@ -111,6 +129,14 @@ public class CallTypeIconsView extends View { drawable.draw(canvas); left = right + mResources.iconMargin; } + + // If showing the video call icon, draw it scaled appropriately. + if (mShowVideo) { + final Drawable drawable = mResources.videoCall; + final int right = left + mResources.videoCall.getIntrinsicWidth(); + drawable.setBounds(left, 0, right, mResources.videoCall.getIntrinsicHeight()); + drawable.draw(canvas); + } } private static class Resources { @@ -136,6 +162,11 @@ public class CallTypeIconsView extends View { public final Drawable voicemail; /** + * Drawable repesenting a video call. + */ + public final Drawable videoCall; + + /** * The margin to use for icons. */ public final int iconMargin; @@ -163,6 +194,21 @@ public class CallTypeIconsView extends View { missed.setColorFilter(r.getColor(R.color.missed_call), PorterDuff.Mode.MULTIPLY); 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_wht_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); + videoCall.setColorFilter(r.getColor(R.color.dialtacts_secondary_text_color), + PorterDuff.Mode.MULTIPLY); + iconMargin = r.getDimensionPixelSize(R.dimen.call_log_icon_margin); } } |