summaryrefslogtreecommitdiff
path: root/java
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
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')
-rw-r--r--java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java4
-rw-r--r--java/com/android/dialer/calldetails/CallDetailsEntryViewHolder.java4
-rw-r--r--java/com/android/dialer/calllogutils/CallTypeIconsView.java41
3 files changed, 40 insertions, 9 deletions
diff --git a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
index bca4265b6..230c02328 100644
--- a/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
+++ b/java/com/android/dialer/app/calllog/PhoneCallDetailsHelper.java
@@ -25,6 +25,7 @@ import android.net.Uri;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.support.v4.content.ContextCompat;
+import android.support.v4.os.BuildCompat;
import android.telecom.PhoneAccount;
import android.telecom.PhoneAccountHandle;
import android.telephony.PhoneNumberUtils;
@@ -161,6 +162,9 @@ public class PhoneCallDetailsHelper
views.callTypeIcons.setShowAssistedDialed(
(details.features & TelephonyManagerCompat.FEATURES_ASSISTED_DIALING)
== TelephonyManagerCompat.FEATURES_ASSISTED_DIALING);
+ if (BuildCompat.isAtLeastP()) {
+ views.callTypeIcons.setShowRtt((details.features & Calls.FEATURES_RTT) == Calls.FEATURES_RTT);
+ }
views.callTypeIcons.requestLayout();
views.callTypeIcons.setVisibility(View.VISIBLE);
diff --git a/java/com/android/dialer/calldetails/CallDetailsEntryViewHolder.java b/java/com/android/dialer/calldetails/CallDetailsEntryViewHolder.java
index f50876d50..edf25df99 100644
--- a/java/com/android/dialer/calldetails/CallDetailsEntryViewHolder.java
+++ b/java/com/android/dialer/calldetails/CallDetailsEntryViewHolder.java
@@ -22,6 +22,7 @@ import android.provider.CallLog.Calls;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
+import android.support.v4.os.BuildCompat;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.text.TextUtils;
import android.view.View;
@@ -102,6 +103,9 @@ public class CallDetailsEntryViewHolder extends ViewHolder {
(entry.getFeatures() & Calls.FEATURES_HD_CALL) == Calls.FEATURES_HD_CALL);
callTypeIcon.setShowWifi(
MotorolaUtils.shouldShowWifiIconInCallLog(context, entry.getFeatures()));
+ if (BuildCompat.isAtLeastP()) {
+ callTypeIcon.setShowRtt((entry.getFeatures() & Calls.FEATURES_RTT) == Calls.FEATURES_RTT);
+ }
callTypeText.setText(
callTypeHelper.getCallTypeText(callType, isVideoCall, isPulledCall, isDuoCall));
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);
}
}
}