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

Commit fe170261 authored by Flavio Lerda's avatar Flavio Lerda
Browse files

Use a single text view for count and date of calls.

This further reduces the number of views needed to render the call log.

At the same time, fix a few minor issues that are needed for pixel
perfect UI:
- Do not show the text when the item is new.
- Instead, for new items, highlight the date in the color associated
  with the item (blue for voicemail, red for missed calls).
- Do not put a separating slash between the count and the date.

Bug: 5099652
Change-Id: I18b71463e7398f00f0fe8fecbeb334b67d618312
parent db0d8669
Loading
Loading
Loading
Loading
+1 −22
Original line number Diff line number Diff line
@@ -141,28 +141,7 @@
                    android:layout_gravity="center_vertical"
                />
                <TextView
                    android:id="@+id/call_type_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="@dimen/call_log_inner_margin"
                    android:layout_gravity="center_vertical"
                    android:textColor="?attr/call_log_secondary_text_color"
                    android:textSize="14sp"
                    android:singleLine="true"
                />
                <TextView
                    android:id="@+id/call_type_separator"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="@dimen/call_log_inner_margin"
                    android:layout_gravity="center_vertical"
                    android:textColor="?attr/call_log_secondary_text_color"
                    android:textSize="14sp"
                    android:text="@string/call_log_type_date_separator"
                    android:singleLine="true"
                />
                <TextView
                    android:id="@+id/date"
                    android:id="@+id/call_count_and_date"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_vertical"
+2 −5
Original line number Diff line number Diff line
@@ -1635,9 +1635,6 @@
    <!-- Message to show when there is an error playing back the voicemail. [CHAR LIMIT=40] -->
    <string name="voicemail_playback_error">Could not play voicemail</string>

    <!-- The separator between the call type text and the date in the call log [CHAR LIMIT=3] -->
    <string name="call_log_type_date_separator">/</string>

    <!-- The header in the call log used to identify missed calls and voicemail that have not yet been consumed [CHAR LIMIT=10] -->
    <string name="call_log_new_header">New</string>

@@ -1677,8 +1674,8 @@
    <!--  Fastest voicemail playback speed. [CHAR LIMIT=30] -->
    <string name="voicemail_speed_fastest">fastest speed</string>

    <!-- The counter for calls in a group in the call log [CHAR LIMIT=5] -->
    <string name="call_log_item_count">(%1$d)</string>
    <!-- The counter for calls in a group and the date of the latest call as shown in the call log [CHAR LIMIT=15] -->
    <string name="call_log_item_count_and_date">(<xliff:g id="count">%1$d</xliff:g>) <xliff:g id="date">%2$s</xliff:g></string>

    <!-- Hint text in the group name box in the edit group view. [CHAR LIMIT=20]-->
    <string name="group_name_hint">Group\'s Name</string>
+57 −30
Original line number Diff line number Diff line
@@ -24,9 +24,12 @@ import android.content.res.Resources;
import android.graphics.Typeface;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.telephony.PhoneNumberUtils;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.view.View;
import android.widget.TextView;

@@ -60,43 +63,36 @@ public class PhoneCallDetailsHelper {

    /** Fills the call details views with content. */
    public void setPhoneCallDetails(PhoneCallDetailsViews views, PhoneCallDetails details,
            boolean useIcons, boolean isHighlighted) {
        if (useIcons) {
            boolean isHighlighted) {
        // Display up to a given number of icons.
        views.callTypeIcons.clear();
        int count = details.callTypes.length;
        for (int index = 0; index < count && index < MAX_CALL_TYPE_ICONS; ++index) {
            views.callTypeIcons.add(details.callTypes[index]);
        }
        views.callTypeIcons.setVisibility(View.VISIBLE);

        // Show the total call count only if there are more than the maximum number of icons.
        final Integer callCount;
        if (count > MAX_CALL_TYPE_ICONS) {
                views.callTypeText.setVisibility(View.VISIBLE);
                views.callTypeSeparator.setVisibility(View.VISIBLE);
                views.callTypeText.setText(
                        mResources.getString(R.string.call_log_item_count, count));
            } else {
                views.callTypeText.setVisibility(View.GONE);
                views.callTypeSeparator.setVisibility(View.GONE);
            }
            callCount = count;
        } else {
            // Use the name of the first call type.
            // TODO: We should update this to handle the text for multiple calls as well.
            int callType = details.callTypes[0];
            views.callTypeText.setText(
                    isHighlighted ? mCallTypeHelper.getHighlightedCallTypeText(callType)
                            : mCallTypeHelper.getCallTypeText(callType));
            views.callTypeIcons.clear();

            views.callTypeText.setVisibility(View.VISIBLE);
            views.callTypeSeparator.setVisibility(View.VISIBLE);
            views.callTypeIcons.setVisibility(View.GONE);
            callCount = null;
        }
        // The color to highlight the count and date in, if any. This is based on the first call.
        Integer highlightColor =
                isHighlighted ? mCallTypeHelper.getHighlightedColor(details.callTypes[0]) : null;

        CharSequence shortDateText =
        // The date of this call, relative to the current time.
        CharSequence dateText =
            DateUtils.getRelativeTimeSpanString(details.date,
                    getCurrentTimeMillis(),
                    DateUtils.MINUTE_IN_MILLIS,
                    DateUtils.FORMAT_ABBREV_RELATIVE);

        // Set the call count and date.
        setCallCountAndDate(views, callCount, dateText, highlightColor);

        CharSequence numberFormattedLabel = null;
        // Only show a label if the number is shown and it is not a SIP address.
        if (!TextUtils.isEmpty(details.number)
@@ -130,7 +126,6 @@ public class PhoneCallDetailsHelper {
            }
        }

        views.dateView.setText(shortDateText);
        views.nameView.setText(nameText);
        views.numberView.setText(numberText);
    }
@@ -165,4 +160,36 @@ public class PhoneCallDetailsHelper {
            return mCurrentTimeMillisForTest;
        }
    }

    /** Sets the call count and date. */
    private void setCallCountAndDate(PhoneCallDetailsViews views, Integer callCount,
            CharSequence dateText, Integer highlightColor) {
        // Combine the count (if present) and the date.
        final CharSequence text;
        if (callCount != null) {
            text = mResources.getString(
                    R.string.call_log_item_count_and_date, callCount.intValue(), dateText);
        } else {
            text = dateText;
        }

        // Apply the highlight color if present.
        final CharSequence formattedText;
        if (highlightColor != null) {
            formattedText = addBoldAndColor(text, highlightColor);
        } else {
            formattedText = text;
        }

        views.callTypeAndDate.setText(formattedText);
    }

    /** Creates a SpannableString for the given text which is bold and in the given color. */
    private CharSequence addBoldAndColor(CharSequence text, int color) {
        int flags = Spanned.SPAN_INCLUSIVE_INCLUSIVE;
        SpannableString result = new SpannableString(text);
        result.setSpan(new StyleSpan(Typeface.BOLD), 0, text.length(), flags);
        result.setSpan(new ForegroundColorSpan(color), 0, text.length(), flags);
        return result;
    }
}
+4 −13
Original line number Diff line number Diff line
@@ -29,20 +29,15 @@ public final class PhoneCallDetailsViews {
    public final TextView nameView;
    public final View callTypeView;
    public final CallTypeIconsView callTypeIcons;
    public final TextView callTypeText;
    public final View callTypeSeparator;
    public final TextView dateView;
    public final TextView callTypeAndDate;
    public final TextView numberView;

    private PhoneCallDetailsViews(TextView nameView, View callTypeView,
            CallTypeIconsView callTypeIcons, TextView callTypeText, View callTypeSeparator,
            TextView dateView, TextView numberView) {
            CallTypeIconsView callTypeIcons, TextView callTypeAndDate, TextView numberView) {
        this.nameView = nameView;
        this.callTypeView = callTypeView;
        this.callTypeIcons = callTypeIcons;
        this.callTypeText = callTypeText;
        this.callTypeSeparator = callTypeSeparator;
        this.dateView = dateView;
        this.callTypeAndDate = callTypeAndDate;
        this.numberView = numberView;
    }

@@ -57,9 +52,7 @@ 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),
                (TextView) view.findViewById(R.id.call_type_name),
                view.findViewById(R.id.call_type_separator),
                (TextView) view.findViewById(R.id.date),
                (TextView) view.findViewById(R.id.call_count_and_date),
                (TextView) view.findViewById(R.id.number));
    }

@@ -69,8 +62,6 @@ public final class PhoneCallDetailsViews {
                new View(context),
                new CallTypeIconsView(context),
                new TextView(context),
                new View(context),
                new TextView(context),
                new TextView(context));
    }
}
+1 −4
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -760,11 +759,9 @@ public class CallLogFragment extends ListFragment implements ViewPagerVisibility
            }

            final boolean isNew = CallLogQuery.isNewSection(c);
            // Use icons for old items, but text for new ones.
            final boolean useIcons = !isNew;
            // New items also use the highlighted version of the text.
            final boolean isHighlighted = isNew;
            mCallLogViewsHelper.setPhoneCallDetails(views, details, useIcons, isHighlighted);
            mCallLogViewsHelper.setPhoneCallDetails(views, details, isHighlighted);
            setPhoto(views, thumbnailUri, personId, lookupKey);

            // Listen for the first draw
Loading