Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cdf8212b authored by Nancy Chen's avatar Nancy Chen
Browse files

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
parent 272b84b3
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -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"
+16 −6
Original line number Diff line number Diff line
@@ -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;
+7 −7
Original line number Diff line number Diff line
@@ -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));
    }
+12 −17
Original line number Diff line number Diff line
@@ -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;
        }