summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/calllogutils
diff options
context:
space:
mode:
authorwangqi <wangqi@google.com>2018-04-10 15:41:37 -0700
committerCopybara-Service <copybara-piper@google.com>2018-04-10 16:43:45 -0700
commit6dab61fec518d3ff34265b1ce1fb8614e2660fee (patch)
tree2d3de02308322f13d9217009ae86e258a1f7261b /java/com/android/dialer/calllogutils
parent3b995bac4550982c62f805d7c334fbc7ed34b113 (diff)
Add RTT icon to RTT call log.
This is for old call log UI. This change also improves scaling for vector drawable icons. Bug: 67596257 Test: manual PiperOrigin-RevId: 192359601 Change-Id: I3322fe08b668f01c1e3a7ce3264c2988e2703aae
Diffstat (limited to 'java/com/android/dialer/calllogutils')
-rw-r--r--java/com/android/dialer/calllogutils/CallTypeIconsView.java41
1 files changed, 32 insertions, 9 deletions
diff --git a/java/com/android/dialer/calllogutils/CallTypeIconsView.java b/java/com/android/dialer/calllogutils/CallTypeIconsView.java
index 1795438fb..b4cfe8140 100644
--- a/java/com/android/dialer/calllogutils/CallTypeIconsView.java
+++ b/java/com/android/dialer/calllogutils/CallTypeIconsView.java
@@ -49,6 +49,7 @@ public class CallTypeIconsView extends View {
private boolean showHd;
private boolean showWifi;
private boolean showAssistedDialed;
+ private boolean showRtt;
private int width;
private int height;
@@ -145,6 +146,15 @@ public class CallTypeIconsView extends View {
}
}
+ public void setShowRtt(boolean showRtt) {
+ this.showRtt = showRtt;
+ if (showRtt) {
+ width += resources.rttCall.getIntrinsicWidth() + resources.iconMargin;
+ height = Math.max(height, resources.rttCall.getIntrinsicHeight());
+ invalidate();
+ }
+ }
+
public int getCount() {
return callTypes.size();
}
@@ -188,7 +198,7 @@ public class CallTypeIconsView extends View {
// 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 || !(showHd || showVideo || showWifi || showAssistedDialed)) {
+ if (!useLargeIcons || !(showHd || showVideo || showWifi || showAssistedDialed || showRtt)) {
for (Integer callType : callTypes) {
final Drawable drawable = getCallTypeDrawable(callType);
final int right = left + drawable.getIntrinsicWidth();
@@ -214,6 +224,10 @@ public class CallTypeIconsView extends View {
if (showAssistedDialed) {
left = addDrawable(canvas, resources.assistedDialedCall, left) + resources.iconMargin;
}
+ // If showing RTT call icon, draw it scaled appropriately.
+ if (showRtt) {
+ left = addDrawable(canvas, resources.rttCall, left) + resources.iconMargin;
+ }
}
private int addDrawable(Canvas canvas, Drawable drawable, int left) {
@@ -252,6 +266,9 @@ public class CallTypeIconsView extends View {
// Drawable representing an assisted dialed call.
final Drawable assistedDialedCall;
+ // Drawable representing a RTT call.
+ final Drawable rttCall;
+
/** The margin to use for icons. */
final int iconMargin;
@@ -317,6 +334,11 @@ public class CallTypeIconsView extends View {
assistedDialedCall.setColorFilter(
r.getColor(R.color.icon_color_grey), PorterDuff.Mode.MULTIPLY);
+ iconId = R.drawable.quantum_ic_rtt_vd_theme_24;
+ drawable = largeIcons ? r.getDrawable(iconId) : getScaledBitmap(context, iconId);
+ rttCall = drawable.mutate();
+ rttCall.setColorFilter(r.getColor(R.color.icon_color_grey), PorterDuff.Mode.MULTIPLY);
+
iconMargin = largeIcons ? 0 : r.getDimensionPixelSize(R.dimen.call_log_icon_margin);
}
@@ -324,18 +346,19 @@ public class CallTypeIconsView extends View {
// icons to be the same height, while preserving their width aspect ratio.
private Drawable getScaledBitmap(Context context, int resourceId) {
Drawable drawable = context.getDrawable(resourceId);
- Bitmap icon =
- Bitmap.createBitmap(
- drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
+
+ int scaledHeight = context.getResources().getDimensionPixelSize(R.dimen.call_type_icon_size);
+ int scaledWidth =
+ (int)
+ ((float) drawable.getIntrinsicWidth()
+ * ((float) scaledHeight / (float) drawable.getIntrinsicHeight()));
+
+ Bitmap icon = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(icon);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
- 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);
+ return new BitmapDrawable(context.getResources(), icon);
}
}
}