diff options
Diffstat (limited to 'java/com/android/dialer/calllogutils/CallTypeIconsView.java')
-rw-r--r-- | java/com/android/dialer/calllogutils/CallTypeIconsView.java | 89 |
1 files changed, 31 insertions, 58 deletions
diff --git a/java/com/android/dialer/calllogutils/CallTypeIconsView.java b/java/com/android/dialer/calllogutils/CallTypeIconsView.java index 5644dc865..61208bc9a 100644 --- a/java/com/android/dialer/calllogutils/CallTypeIconsView.java +++ b/java/com/android/dialer/calllogutils/CallTypeIconsView.java @@ -17,7 +17,6 @@ package com.android.dialer.calllogutils; import android.content.Context; -import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; @@ -33,18 +32,12 @@ import java.util.List; /** * View that draws one or more symbols for different types of calls (missed calls, outgoing etc). - * The symbols are set up horizontally. If {@code useLargeIcons} is set in the xml attributes, - * alternatively this view will only render one icon (Call Type, HD or Video). - * - * <p>As this view doesn't create subviews, it is better suited for ListView-recycling than a - * regular LinearLayout using ImageViews. + * The symbols are set up horizontally. As this view doesn't create subviews, it is better suited + * for ListView-recycling that a regular LinearLayout using ImageViews. */ public class CallTypeIconsView extends View { - private final boolean useLargeIcons; - private static Resources sResources; - private static Resources sLargeResouces; private List<Integer> mCallTypes = new ArrayList<>(3); private boolean mShowVideo = false; private boolean mShowHd = false; @@ -57,15 +50,8 @@ public class CallTypeIconsView extends View { public CallTypeIconsView(Context context, AttributeSet attrs) { super(context, attrs); - TypedArray typedArray = - context.getTheme().obtainStyledAttributes(attrs, R.styleable.CallTypeIconsView, 0, 0); - useLargeIcons = typedArray.getBoolean(R.styleable.CallTypeIconsView_useLargeIcons, false); - typedArray.recycle(); if (sResources == null) { - sResources = new Resources(context, false); - } - if (sLargeResouces == null && useLargeIcons) { - sLargeResouces = new Resources(context, true); + sResources = new Resources(context); } } @@ -81,7 +67,7 @@ public class CallTypeIconsView extends View { final Drawable drawable = getCallTypeDrawable(callType); mWidth += drawable.getIntrinsicWidth() + sResources.iconMargin; - mHeight = Math.max(mHeight, drawable.getIntrinsicWidth()); + mHeight = Math.max(mHeight, drawable.getIntrinsicHeight()); invalidate(); } @@ -126,25 +112,24 @@ public class CallTypeIconsView extends View { } private Drawable getCallTypeDrawable(int callType) { - Resources resources = useLargeIcons ? sLargeResouces : sResources; switch (callType) { case AppCompatConstants.CALLS_INCOMING_TYPE: case AppCompatConstants.CALLS_ANSWERED_EXTERNALLY_TYPE: - return resources.incoming; + return sResources.incoming; case AppCompatConstants.CALLS_OUTGOING_TYPE: - return resources.outgoing; + return sResources.outgoing; case AppCompatConstants.CALLS_MISSED_TYPE: - return resources.missed; + return sResources.missed; case AppCompatConstants.CALLS_VOICEMAIL_TYPE: - return resources.voicemail; + return sResources.voicemail; case AppCompatConstants.CALLS_BLOCKED_TYPE: - return resources.blocked; + return sResources.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 // distinguish between rejected and missed calls). Instead of crashing, just // assume that all unknown call types are missed calls. - return resources.missed; + return sResources.missed; } } @@ -155,32 +140,27 @@ public class CallTypeIconsView extends View { @Override protected void onDraw(Canvas canvas) { - Resources resources = useLargeIcons ? sLargeResouces : sResources; int left = 0; - // If we are using large icons, we should only show one icon (video, hd or call type) with - // priority give to HD or Video. So we skip the call type icon if we plan to show them. - if (!useLargeIcons || !(mShowHd || mShowVideo)) { - for (Integer callType : mCallTypes) { - final Drawable drawable = getCallTypeDrawable(callType); - final int right = left + drawable.getIntrinsicWidth(); - drawable.setBounds(left, 0, right, drawable.getIntrinsicHeight()); - drawable.draw(canvas); - left = right + resources.iconMargin; - } + for (Integer callType : mCallTypes) { + final Drawable drawable = getCallTypeDrawable(callType); + final int right = left + drawable.getIntrinsicWidth(); + drawable.setBounds(left, 0, right, drawable.getIntrinsicHeight()); + drawable.draw(canvas); + left = right + sResources.iconMargin; } // If showing the video call icon, draw it scaled appropriately. if (mShowVideo) { - final Drawable drawable = resources.videoCall; - final int right = left + resources.videoCall.getIntrinsicWidth(); - drawable.setBounds(left, 0, right, resources.videoCall.getIntrinsicHeight()); + final Drawable drawable = sResources.videoCall; + final int right = left + sResources.videoCall.getIntrinsicWidth(); + drawable.setBounds(left, 0, right, sResources.videoCall.getIntrinsicHeight()); drawable.draw(canvas); } // If showing HD call icon, draw it scaled appropriately. if (mShowHd) { - final Drawable drawable = resources.hdCall; - final int right = left + resources.hdCall.getIntrinsicWidth(); - drawable.setBounds(left, 0, right, resources.hdCall.getIntrinsicHeight()); + final Drawable drawable = sResources.hdCall; + final int right = left + sResources.hdCall.getIntrinsicWidth(); + drawable.setBounds(left, 0, right, sResources.hdCall.getIntrinsicHeight()); drawable.draw(canvas); } } @@ -217,44 +197,37 @@ public class CallTypeIconsView extends View { * * @param context The current context. */ - public Resources(Context context, boolean largeIcons) { + public Resources(Context context) { final android.content.res.Resources r = context.getResources(); - int iconId = - largeIcons ? R.drawable.quantum_ic_call_received_white_24 : R.drawable.ic_call_arrow; - incoming = r.getDrawable(iconId); + incoming = r.getDrawable(R.drawable.ic_call_arrow); incoming.setColorFilter(r.getColor(R.color.answered_call), PorterDuff.Mode.MULTIPLY); // Create a rotated instance of the call arrow for outgoing calls. - outgoing = BitmapUtil.getRotatedDrawable(r, iconId, 180f); + outgoing = BitmapUtil.getRotatedDrawable(r, R.drawable.ic_call_arrow, 180f); outgoing.setColorFilter(r.getColor(R.color.answered_call), PorterDuff.Mode.MULTIPLY); // Need to make a copy of the arrow drawable, otherwise the same instance colored // above will be recolored here. - iconId = largeIcons ? R.drawable.quantum_ic_call_missed_white_24 : R.drawable.ic_call_arrow; - missed = r.getDrawable(iconId).mutate(); + missed = r.getDrawable(R.drawable.ic_call_arrow).mutate(); missed.setColorFilter(r.getColor(R.color.missed_call), PorterDuff.Mode.MULTIPLY); - iconId = R.drawable.quantum_ic_voicemail_white_24; - voicemail = largeIcons ? r.getDrawable(iconId) : getScaledBitmap(context, iconId); + voicemail = r.getDrawable(R.drawable.quantum_ic_voicemail_white_18); voicemail.setColorFilter( r.getColor(R.color.dialer_secondary_text_color), PorterDuff.Mode.MULTIPLY); - iconId = R.drawable.quantum_ic_block_white_24; - blocked = largeIcons ? r.getDrawable(iconId) : getScaledBitmap(context, iconId); + blocked = getScaledBitmap(context, R.drawable.ic_block_24dp); blocked.setColorFilter(r.getColor(R.color.blocked_call), PorterDuff.Mode.MULTIPLY); - iconId = R.drawable.quantum_ic_videocam_white_24; - videoCall = largeIcons ? r.getDrawable(iconId) : getScaledBitmap(context, iconId); + videoCall = getScaledBitmap(context, R.drawable.quantum_ic_videocam_white_24); videoCall.setColorFilter( r.getColor(R.color.dialer_secondary_text_color), PorterDuff.Mode.MULTIPLY); - iconId = R.drawable.quantum_ic_hd_white_24; - hdCall = largeIcons ? r.getDrawable(iconId) : getScaledBitmap(context, iconId); + hdCall = getScaledBitmap(context, R.drawable.quantum_ic_hd_white_24); hdCall.setColorFilter( r.getColor(R.color.dialer_secondary_text_color), PorterDuff.Mode.MULTIPLY); - iconMargin = largeIcons ? 0 : r.getDimensionPixelSize(R.dimen.call_log_icon_margin); + 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 |