summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNancy Chen <nancychen@google.com>2014-10-28 18:29:29 -0700
committerNancy Chen <nancychen@google.com>2014-10-31 15:24:17 -0700
commitcdf8212b904cd1afc3fcd169553d05138dd82fdf (patch)
treed3e42ded2ae49debe81618b1fbebb54efc5810b3
parent272b84b3ef3d948ba1c9703b39525477d9d6f272 (diff)
Add an additional line to Call Log for PhoneAccount name
Add a line under call log to display PhoneAccount label in the color of the account/SIM. Bug: 17971273 Change-Id: I16c37ae8828245f928bc3867a498a29e73b5925c
-rw-r--r--res/layout/call_log_list_item.xml19
-rw-r--r--src/com/android/dialer/PhoneCallDetailsHelper.java22
-rw-r--r--src/com/android/dialer/PhoneCallDetailsViews.java14
-rw-r--r--src/com/android/dialer/calllog/PhoneAccountUtils.java29
4 files changed, 45 insertions, 39 deletions
diff --git a/res/layout/call_log_list_item.xml b/res/layout/call_log_list_item.xml
index c77a1f7ad..db59b74d3 100644
--- a/res/layout/call_log_list_item.xml
+++ b/res/layout/call_log_list_item.xml
@@ -112,15 +112,6 @@
android:layout_marginEnd="@dimen/call_log_icon_margin"
android:layout_gravity="center_vertical"
/>
- <ImageView
- android:id="@+id/call_account_icon"
- android:layout_width="@dimen/call_provider_small_icon_size"
- android:layout_height="@dimen/call_provider_small_icon_size"
- android:layout_marginEnd="@dimen/call_log_icon_margin"
- android:layout_gravity="center_vertical"
- android:tint="?attr/call_log_secondary_text_color"
- android:scaleType="centerInside"
- />
<TextView
android:id="@+id/call_location_and_date"
android:layout_width="wrap_content"
@@ -132,6 +123,16 @@
android:singleLine="true"
/>
</LinearLayout>
+ <TextView
+ android:id="@+id/call_account_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginEnd="@dimen/call_log_icon_margin"
+ android:textColor="?attr/call_log_secondary_text_color"
+ android:textSize="@dimen/call_log_secondary_text_size"
+ android:visibility="gone"
+ android:singleLine="true"
+ />
</LinearLayout>
<ImageView
android:id="@+id/call_indicator_icon"
diff --git a/src/com/android/dialer/PhoneCallDetailsHelper.java b/src/com/android/dialer/PhoneCallDetailsHelper.java
index e8884319c..2e1651a70 100644
--- a/src/com/android/dialer/PhoneCallDetailsHelper.java
+++ b/src/com/android/dialer/PhoneCallDetailsHelper.java
@@ -22,6 +22,7 @@ import android.graphics.drawable.Drawable;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.CommonDataKinds.Phone;
+import android.telecom.PhoneAccount;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.view.View;
@@ -35,6 +36,7 @@ import com.android.dialer.calllog.PhoneAccountUtils;
import com.android.dialer.calllog.PhoneNumberDisplayHelper;
import com.android.dialer.calllog.PhoneNumberUtilsWrapper;
import com.android.dialer.util.DialerUtils;
+
import com.google.common.collect.Lists;
import java.util.ArrayList;
@@ -106,13 +108,21 @@ public class PhoneCallDetailsHelper {
// Set the call count, location and date.
setCallCountAndDate(views, callCount, callLocationAndDate);
- // set the account icon if it exists
- Drawable accountIcon = PhoneAccountUtils.getAccountIcon(mContext, details.accountHandle);
- if (accountIcon != null) {
- views.callAccountIcon.setVisibility(View.VISIBLE);
- views.callAccountIcon.setImageDrawable(accountIcon);
+ // Set the account label if it exists.
+ String accountLabel = PhoneAccountUtils.getAccountLabel(mContext, details.accountHandle);
+
+ if (accountLabel != null) {
+ views.callAccountLabel.setVisibility(View.VISIBLE);
+ views.callAccountLabel.setText(accountLabel);
+ int color = PhoneAccountUtils.getAccountColor(mContext, details.accountHandle);
+ if (color == PhoneAccount.NO_COLOR) {
+ int defaultColor = R.color.dialtacts_secondary_text_color;
+ views.callAccountLabel.setTextColor(mContext.getResources().getColor(defaultColor));
+ } else {
+ views.callAccountLabel.setTextColor(color);
+ }
} else {
- views.callAccountIcon.setVisibility(View.GONE);
+ views.callAccountLabel.setVisibility(View.GONE);
}
final CharSequence nameText;
diff --git a/src/com/android/dialer/PhoneCallDetailsViews.java b/src/com/android/dialer/PhoneCallDetailsViews.java
index 67babc1f7..05026d6ee 100644
--- a/src/com/android/dialer/PhoneCallDetailsViews.java
+++ b/src/com/android/dialer/PhoneCallDetailsViews.java
@@ -30,19 +30,19 @@ public final class PhoneCallDetailsViews {
public final TextView nameView;
public final View callTypeView;
public final CallTypeIconsView callTypeIcons;
- public final ImageView callAccountIcon;
public final TextView callLocationAndDate;
public final TextView voicemailTranscriptionView;
+ public final TextView callAccountLabel;
private PhoneCallDetailsViews(TextView nameView, View callTypeView,
- CallTypeIconsView callTypeIcons, ImageView callAccountIcon,
- TextView callLocationAndDate, TextView voicemailTranscriptionView) {
+ CallTypeIconsView callTypeIcons, TextView callLocationAndDate,
+ TextView voicemailTranscriptionView, TextView callAccountLabel) {
this.nameView = nameView;
this.callTypeView = callTypeView;
this.callTypeIcons = callTypeIcons;
- this.callAccountIcon = callAccountIcon;
this.callLocationAndDate = callLocationAndDate;
this.voicemailTranscriptionView = voicemailTranscriptionView;
+ this.callAccountLabel = callAccountLabel;
}
/**
@@ -56,9 +56,9 @@ public final class PhoneCallDetailsViews {
return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name),
view.findViewById(R.id.call_type),
(CallTypeIconsView) view.findViewById(R.id.call_type_icons),
- (ImageView) view.findViewById(R.id.call_account_icon),
(TextView) view.findViewById(R.id.call_location_and_date),
- (TextView) view.findViewById(R.id.voicemail_transcription));
+ (TextView) view.findViewById(R.id.voicemail_transcription),
+ (TextView) view.findViewById(R.id.call_account_label));
}
public static PhoneCallDetailsViews createForTest(Context context) {
@@ -66,7 +66,7 @@ public final class PhoneCallDetailsViews {
new TextView(context),
new View(context),
new CallTypeIconsView(context),
- new ImageView(context),
+ new TextView(context),
new TextView(context),
new TextView(context));
}
diff --git a/src/com/android/dialer/calllog/PhoneAccountUtils.java b/src/com/android/dialer/calllog/PhoneAccountUtils.java
index eb9e433bf..7ab212fdd 100644
--- a/src/com/android/dialer/calllog/PhoneAccountUtils.java
+++ b/src/com/android/dialer/calllog/PhoneAccountUtils.java
@@ -61,35 +61,30 @@ public class PhoneAccountUtils {
}
/**
- * Extract account icon from PhoneAccount object.
+ * Extract account label from PhoneAccount object.
*/
- public static Drawable getAccountIcon(Context context, PhoneAccountHandle phoneAccount) {
- final PhoneAccount account = getAccountOrNull(context, phoneAccount);
- if (account == null) {
- return null;
- }
- return account.getIcon(context);
+ public static String getAccountLabel(Context context, PhoneAccountHandle accountHandle) {
+ PhoneAccount account = getAccountOrNull(context, accountHandle);
+ return account == null ? null : account.getLabel().toString();
}
/**
- * Extract account label from PhoneAccount object.
+ * Extract account color from PhoneAccount object.
*/
- public static String getAccountLabel(Context context, PhoneAccountHandle phoneAccount) {
- final PhoneAccount account = getAccountOrNull(context, phoneAccount);
- if (account == null) {
- return null;
- }
- return account.getLabel().toString();
+ public static int getAccountColor(Context context, PhoneAccountHandle accountHandle) {
+ PhoneAccount account = getAccountOrNull(context, accountHandle);
+ return account == null ? PhoneAccount.NO_COLOR : account.getColor();
}
/**
* Retrieve the account metadata, but if the account does not exist or the device has only a
* single registered and enabled account, return null.
*/
- private static PhoneAccount getAccountOrNull(Context context, PhoneAccountHandle phoneAccount) {
- final TelecomManager telecomManager =
+ private static PhoneAccount getAccountOrNull(Context context,
+ PhoneAccountHandle accountHandle) {
+ TelecomManager telecomManager =
(TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
- final PhoneAccount account = telecomManager.getPhoneAccount(phoneAccount);
+ final PhoneAccount account = telecomManager.getPhoneAccount(accountHandle);
if (account == null || !telecomManager.hasMultipleCallCapableAccounts()) {
return null;
}