summaryrefslogtreecommitdiffstats
path: root/src/com/android/dialer/calllog
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2014-07-10 12:28:43 -0700
committerTyler Gunn <tgunn@google.com>2014-07-10 12:28:43 -0700
commit8b0e858d5b4c50813dbe2b5c244e7013814b23ec (patch)
treee17124adb6cfd3f4e70595baf4f66d847292bc1d /src/com/android/dialer/calllog
parent70d301e1239c9324c071c10888bf6d7b0b48ddaa (diff)
downloadandroid_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')
-rw-r--r--src/com/android/dialer/calllog/CallDetailHistoryAdapter.java37
-rw-r--r--src/com/android/dialer/calllog/CallLogAdapter.java29
-rw-r--r--src/com/android/dialer/calllog/CallLogQuery.java4
-rw-r--r--src/com/android/dialer/calllog/CallTypeIconsView.java46
4 files changed, 112 insertions, 4 deletions
diff --git a/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java b/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java
index 67cadb135..cc116e7ad 100644
--- a/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java
+++ b/src/com/android/dialer/calllog/CallDetailHistoryAdapter.java
@@ -19,6 +19,7 @@ package com.android.dialer.calllog;
import android.content.Context;
import android.provider.CallLog.Calls;
import android.text.format.DateUtils;
+import android.text.format.Formatter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -27,6 +28,10 @@ import android.widget.TextView;
import com.android.dialer.PhoneCallDetails;
import com.android.dialer.R;
+import com.android.dialer.util.DialerUtils;
+import com.google.common.collect.Lists;
+
+import java.util.ArrayList;
/**
* Adapter for a ListView containing history items from the details of a call.
@@ -42,6 +47,11 @@ public class CallDetailHistoryAdapter extends BaseAdapter {
private final CallTypeHelper mCallTypeHelper;
private final PhoneCallDetails[] mPhoneCallDetails;
+ /**
+ * List of items to be concatenated together for duration strings.
+ */
+ private ArrayList<CharSequence> mDurationItems = Lists.newArrayList();
+
public CallDetailHistoryAdapter(Context context, LayoutInflater layoutInflater,
CallTypeHelper callTypeHelper, PhoneCallDetails[] phoneCallDetails) {
mContext = context;
@@ -114,6 +124,8 @@ public class CallDetailHistoryAdapter extends BaseAdapter {
int callType = details.callTypes[0];
callTypeIconView.clear();
callTypeIconView.add(callType);
+ callTypeIconView.setShowVideo(
+ (details.features & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO);
callTypeTextView.setText(mCallTypeHelper.getCallTypeText(callType));
// Set the date.
CharSequence dateValue = DateUtils.formatDateRange(mContext, details.date, details.date,
@@ -125,13 +137,13 @@ public class CallDetailHistoryAdapter extends BaseAdapter {
durationView.setVisibility(View.GONE);
} else {
durationView.setVisibility(View.VISIBLE);
- durationView.setText(formatDuration(details.duration));
+ durationView.setText(formatDurationAndDataUsage(details.duration, details.dataUsage));
}
return result;
}
- private String formatDuration(long elapsedSeconds) {
+ private CharSequence formatDuration(long elapsedSeconds) {
long minutes = 0;
long seconds = 0;
@@ -143,4 +155,25 @@ public class CallDetailHistoryAdapter extends BaseAdapter {
return mContext.getString(R.string.callDetailsDurationFormat, minutes, seconds);
}
+
+ /**
+ * Formats a string containing the call duration and the data usage (if specified).
+ *
+ * @param elapsedSeconds Total elapsed seconds.
+ * @param dataUsage Data usage in bytes, or null if not specified.
+ * @return String containing call duration and data usage.
+ */
+ private CharSequence formatDurationAndDataUsage(long elapsedSeconds, Long dataUsage) {
+ CharSequence duration = formatDuration(elapsedSeconds);
+
+ if (dataUsage != null) {
+ mDurationItems.clear();
+ mDurationItems.add(duration);
+ mDurationItems.add(Formatter.formatShortFileSize(mContext, dataUsage));
+
+ return DialerUtils.join(mContext.getResources(), mDurationItems);
+ } else {
+ return duration;
+ }
+ }
}
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index 483c5020a..2987c9e4e 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -742,17 +742,23 @@ public class CallLogAdapter extends GroupingListAdapter
final int[] callTypes = getCallTypes(c, count);
final String geocode = c.getString(CallLogQuery.GEOCODED_LOCATION);
final int sourceType = info.sourceType;
+ final int features = getCallFeatures(c, count);
+ Long dataUsage = null;
+ if (!c.isNull(CallLogQuery.DATA_USAGE)) {
+ dataUsage = c.getLong(CallLogQuery.DATA_USAGE);
+ }
+
final PhoneCallDetails details;
if (TextUtils.isEmpty(name)) {
details = new PhoneCallDetails(number, numberPresentation,
formattedNumber, countryIso, geocode, callTypes, date,
- duration, accountIcon);
+ duration, accountIcon, features, dataUsage);
} else {
details = new PhoneCallDetails(number, numberPresentation,
formattedNumber, countryIso, geocode, callTypes, date,
duration, name, ntype, label, lookupUri, photoUri, sourceType,
- accountIcon);
+ accountIcon, features, dataUsage);
}
mCallLogViewsHelper.setPhoneCallDetails(views, details);
@@ -1182,6 +1188,25 @@ public class CallLogAdapter extends GroupingListAdapter
return callTypes;
}
+ /**
+ * Determine the features which were enabled for any of the calls that make up a call log
+ * entry.
+ *
+ * @param cursor The cursor.
+ * @param count The number of calls for the current call log entry.
+ * @return The features.
+ */
+ private int getCallFeatures(Cursor cursor, int count) {
+ int features = Calls.FEATURES_NONE;
+ int position = cursor.getPosition();
+ for (int index = 0; index < count; ++index) {
+ features |= cursor.getInt(CallLogQuery.FEATURES);
+ cursor.moveToNext();
+ }
+ cursor.moveToPosition(position);
+ return features;
+ }
+
private PhoneAccount getAccount(Cursor c) {
final String component_name = c.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME);
final String account_id = c.getString(CallLogQuery.ACCOUNT_ID);
diff --git a/src/com/android/dialer/calllog/CallLogQuery.java b/src/com/android/dialer/calllog/CallLogQuery.java
index 8b88818a8..904ce7473 100644
--- a/src/com/android/dialer/calllog/CallLogQuery.java
+++ b/src/com/android/dialer/calllog/CallLogQuery.java
@@ -46,6 +46,8 @@ public final class CallLogQuery {
Calls.NUMBER_PRESENTATION, // 17
Calls.PHONE_ACCOUNT_COMPONENT_NAME, // 18
Calls.PHONE_ACCOUNT_ID, // 19
+ Calls.FEATURES, // 20
+ Calls.DATA_USAGE // 21
};
public static final int ID = 0;
@@ -68,4 +70,6 @@ public final class CallLogQuery {
public static final int NUMBER_PRESENTATION = 17;
public static final int ACCOUNT_COMPONENT_NAME = 18;
public static final int ACCOUNT_ID = 19;
+ public static final int FEATURES = 20;
+ public static final int DATA_USAGE = 21;
}
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);
}
}