From a482522fb8fe4e9959c749f4ec616ae59cf06b28 Mon Sep 17 00:00:00 2001 From: Brandon Maxwell Date: Mon, 12 Oct 2015 12:09:12 -0700 Subject: Moving call type/location for voicemail Combination of two related bugs. 22168682: In the voicemail call log, moved call type/location to below the call action button and removed the call details button as it didn't have any additional information. 22514722: Modified spacing and text sizes for call log. Moved voicemail transcription below call date as in mocks. Bug:22168682,22514722 Change-Id: I557761b815604fee4e6b61f4670608b8fa90d3a7 --- src/com/android/dialer/calllog/CallLogAdapter.java | 4 +- .../android/dialer/calllog/CallLogFragment.java | 18 --------- .../dialer/calllog/CallLogListItemHelper.java | 5 ++- .../dialer/calllog/CallLogListItemViewHolder.java | 36 +++++++++++------ .../dialer/calllog/PhoneCallDetailsHelper.java | 45 ++++++++++++++-------- 5 files changed, 60 insertions(+), 48 deletions(-) (limited to 'src/com/android') diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 703b18f8f..035317010 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -367,7 +367,7 @@ public class CallLogAdapter extends GroupingListAdapter * TODO: This gets called 20-30 times when Dialer starts up for a single call log entry and * should not. It invokes cross-process methods and the repeat execution can get costly. * - * @param ViewHolder The view corresponding to this entry. + * @param viewHolder The view corresponding to this entry. * @param position The position of the entry. */ public void onBindViewHolder(ViewHolder viewHolder, int position) { @@ -419,7 +419,7 @@ public class CallLogAdapter extends GroupingListAdapter c.getString(CallLogQuery.ACCOUNT_COMPONENT_NAME), c.getString(CallLogQuery.ACCOUNT_ID)); final String countryIso = c.getString(CallLogQuery.COUNTRY_ISO); - final ContactInfo cachedContactInfo = mContactInfoHelper.getContactInfo(c); + final ContactInfo cachedContactInfo = ContactInfoHelper.getContactInfo(c); final boolean isVoicemailNumber = mTelecomCallLogCache.isVoicemailNumber(accountHandle, number); diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index b7f068e1f..dff213bce 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -18,20 +18,14 @@ package com.android.dialer.calllog; import static android.Manifest.permission.READ_CALL_LOG; -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.ValueAnimator; import android.app.Activity; -import android.app.DialogFragment; import android.app.Fragment; import android.app.KeyguardManager; import android.content.ContentResolver; import android.content.Context; -import android.content.Intent; import android.content.pm.PackageManager; import android.database.ContentObserver; import android.database.Cursor; -import android.graphics.Rect; import android.os.Bundle; import android.os.Handler; import android.os.Message; @@ -44,28 +38,16 @@ import android.support.v7.widget.LinearLayoutManager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.view.View.OnClickListener; -import android.view.ViewGroup.LayoutParams; -import android.widget.ListView; -import android.widget.TextView; import com.android.contacts.common.GeoUtil; import com.android.contacts.common.util.PermissionsUtil; -import com.android.contacts.common.util.ViewUtil; import com.android.dialer.R; -import com.android.dialer.list.ListsFragment.HostInterface; -import com.android.dialer.util.DialerUtils; import com.android.dialer.util.EmptyLoader; import com.android.dialer.voicemail.VoicemailPlaybackPresenter; -import com.android.dialer.voicemail.VoicemailStatusHelper; -import com.android.dialer.voicemail.VoicemailStatusHelper.StatusMessage; -import com.android.dialer.voicemail.VoicemailStatusHelperImpl; import com.android.dialer.widget.EmptyContentView; import com.android.dialer.widget.EmptyContentView.OnEmptyViewActionButtonClickedListener; import com.android.dialerbind.ObjectFactory; -import java.util.List; - /** * Displays a list of call log entries. To filter for a particular kind of call * (all, missed or voicemails), specify it in the constructor. diff --git a/src/com/android/dialer/calllog/CallLogListItemHelper.java b/src/com/android/dialer/calllog/CallLogListItemHelper.java index 8e45dd36f..84d036487 100644 --- a/src/com/android/dialer/calllog/CallLogListItemHelper.java +++ b/src/com/android/dialer/calllog/CallLogListItemHelper.java @@ -57,7 +57,6 @@ import com.android.dialer.R; /** * Sets the name, label, and number for a contact. * - * @param context The application context. * @param views the views to populate * @param details the details of a phone call needed to fill in the data */ @@ -76,6 +75,10 @@ import com.android.dialer.R; // when the actions ViewStub is inflated. views.nameOrNumber = getNameOrNumber(details); + // The call type or Location associated with the call. Use when setting text for a + // voicemail log's call button + views.callTypeOrLocation = mPhoneCallDetailsHelper.getCallTypeOrLocation(details); + // Cache country iso. Used for number filtering. views.countryIso = details.countryIso; } diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java index 0e234e345..b70ea0751 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java +++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java @@ -161,6 +161,12 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder */ public CharSequence nameOrNumber; + /** + * The call type or Location associated with the call. Cached here for use when setting text + * for a voicemail log's call button + */ + public CharSequence callTypeOrLocation; + /** * Whether this row is for a business or not. */ @@ -171,8 +177,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder */ public ContactInfo info; - private static final int VOICEMAIL_TRANSCRIPTION_MAX_LINES = 10; - private final Context mContext; private final TelecomCallLogCache mTelecomCallLogCache; private final CallLogListItemHelper mCallLogListItemHelper; @@ -342,8 +346,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder * Configures the action buttons in the expandable actions ViewStub. The ViewStub is not * inflated during initial binding, so click handlers, tags and accessibility text must be set * here, if necessary. - * - * @param callLogItem The call log list item view. */ public void inflateActionViewStub() { ViewStub stub = (ViewStub) rootView.findViewById(R.id.call_log_entry_actions_stub); @@ -427,6 +429,14 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder .setText(TextUtils.expandTemplate( mContext.getString(R.string.call_log_action_call), nameOrNumber)); + TextView callTypeOrLocationView = ((TextView) callButtonView.findViewById( + R.id.call_type_or_location_text)); + if (callType == Calls.VOICEMAIL_TYPE && !TextUtils.isEmpty(callTypeOrLocation)) { + callTypeOrLocationView.setText(callTypeOrLocation); + callTypeOrLocationView.setVisibility(View.VISIBLE); + } else { + callTypeOrLocationView.setVisibility(View.GONE); + } callButtonView.setVisibility(View.VISIBLE); } else { callButtonView.setVisibility(View.GONE); @@ -455,9 +465,13 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder voicemailPlaybackView.setVisibility(View.GONE); } - detailsButtonView.setVisibility(View.VISIBLE); - detailsButtonView.setTag( + if (callType == Calls.VOICEMAIL_TYPE) { + detailsButtonView.setVisibility(View.GONE); + } else { + detailsButtonView.setVisibility(View.VISIBLE); + detailsButtonView.setTag( IntentProvider.getCallDetailIntentProvider(rowId, callIds, null)); + } if (info != null && UriUtils.isEncodedContactUri(info.lookupUri)) { createNewContactButtonView.setTag(IntentProvider.getAddContactIntentProvider( @@ -495,7 +509,7 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder * If the action views have never been shown yet for this view, inflate the view stub. */ public void showActions(boolean show) { - expandVoicemailTranscriptionView(show); + showOrHideVoicemailTranscriptionView(show); if (show) { // Inflate the view stub if necessary, and wire up the event handlers. @@ -514,17 +528,17 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder updatePrimaryActionButton(show); } - public void expandVoicemailTranscriptionView(boolean isExpanded) { + public void showOrHideVoicemailTranscriptionView(boolean isExpanded) { if (callType != Calls.VOICEMAIL_TYPE) { return; } final TextView view = phoneCallDetailsViews.voicemailTranscriptionView; - if (TextUtils.isEmpty(view.getText())) { + if (!isExpanded || TextUtils.isEmpty(view.getText())) { + view.setVisibility(View.GONE); return; } - view.setMaxLines(isExpanded ? VOICEMAIL_TRANSCRIPTION_MAX_LINES : 1); - view.setSingleLine(!isExpanded); + view.setVisibility(View.VISIBLE); } public void updatePhoto() { diff --git a/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java b/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java index 37920565a..b16079a9c 100644 --- a/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java +++ b/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java @@ -16,6 +16,7 @@ package com.android.dialer.calllog; +import com.google.common.base.MoreObjects; import com.google.common.collect.Lists; import android.content.Context; @@ -50,6 +51,9 @@ public class PhoneCallDetailsHelper { private final Resources mResources; /** The injected current time in milliseconds since the epoch. Used only by tests. */ private Long mCurrentTimeMillisForTest; + + private CharSequence mPhoneTypeLabelForTest; + private final TelecomCallLogCache mTelecomCallLogCache; /** Calendar used to construct dates */ @@ -138,12 +142,9 @@ public class PhoneCallDetailsHelper { views.nameView.setText(nameText); - if (isVoicemail && !TextUtils.isEmpty(details.transcription)) { - views.voicemailTranscriptionView.setText(details.transcription); - views.voicemailTranscriptionView.setVisibility(View.VISIBLE); - } else { - views.voicemailTranscriptionView.setText(null); - views.voicemailTranscriptionView.setVisibility(View.GONE); + if (isVoicemail) { + views.voicemailTranscriptionView.setText(TextUtils.isEmpty(details.transcription) ? null + : details.transcription); } // Bold if not read @@ -151,10 +152,14 @@ public class PhoneCallDetailsHelper { views.nameView.setTypeface(typeface); views.voicemailTranscriptionView.setTypeface(typeface); views.callLocationAndDate.setTypeface(typeface); + views.callLocationAndDate.setTextColor(mResources.getColor( + details.isRead ? R.color.call_log_detail_color : R.color.call_log_unread_text_color, + mContext.getTheme())); } /** - * Builds a string containing the call location and date. + * Builds a string containing the call location and date. For voicemail logs only the call date + * is returned because location information is displayed in the call action button * * @param details The call details. * @return The call location and date string. @@ -162,15 +167,18 @@ public class PhoneCallDetailsHelper { private CharSequence getCallLocationAndDate(PhoneCallDetails details) { mDescriptionItems.clear(); - // Get type of call (ie mobile, home, etc) if known, or the caller's location. - CharSequence callTypeOrLocation = getCallTypeOrLocation(details); + if (details.callTypes[0] != Calls.VOICEMAIL_TYPE) { + // Get type of call (ie mobile, home, etc) if known, or the caller's location. + CharSequence callTypeOrLocation = getCallTypeOrLocation(details); - // Only add the call type or location if its not empty. It will be empty for unknown - // callers. - if (!TextUtils.isEmpty(callTypeOrLocation)) { - mDescriptionItems.add(callTypeOrLocation); + // Only add the call type or location if its not empty. It will be empty for unknown + // callers. + if (!TextUtils.isEmpty(callTypeOrLocation)) { + mDescriptionItems.add(callTypeOrLocation); + } } - // The date of this call, relative to the current time. + + // The date of this call mDescriptionItems.add(getCallDate(details)); // Create a comma separated list from the call type or location, and call date. @@ -197,8 +205,8 @@ public class PhoneCallDetailsHelper { } else if (!(details.numberType == Phone.TYPE_CUSTOM && TextUtils.isEmpty(details.numberLabel))) { // Get type label only if it will not be "Custom" because of an empty number label. - numberFormattedLabel = Phone.getTypeLabel( - mResources, details.numberType, details.numberLabel); + numberFormattedLabel = MoreObjects.firstNonNull(mPhoneTypeLabelForTest, + Phone.getTypeLabel(mResources, details.numberType, details.numberLabel)); } } @@ -208,6 +216,11 @@ public class PhoneCallDetailsHelper { return numberFormattedLabel; } + @NeededForTesting + public void setPhoneTypeLabelForTest(CharSequence phoneTypeLabel) { + this.mPhoneTypeLabelForTest = phoneTypeLabel; + } + /** * Get the call date/time of the call. For the call log this is relative to the current time. * e.g. 3 minutes ago. For voicemail, see {@link #getGranularDateTime(PhoneCallDetails)} -- cgit v1.2.3