summaryrefslogtreecommitdiff
path: root/src/com/android/dialer/calllog/CallLogAdapter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/dialer/calllog/CallLogAdapter.java')
-rw-r--r--src/com/android/dialer/calllog/CallLogAdapter.java30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index 3dccf27bb..ae20e4943 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -16,18 +16,20 @@
package com.android.dialer.calllog;
+import com.google.common.annotations.VisibleForTesting;
+
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.database.Cursor;
import android.net.Uri;
-import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.support.v7.widget.RecyclerView;
import android.os.Bundle;
import android.os.Trace;
import android.preference.PreferenceManager;
import android.provider.CallLog;
+import android.provider.ContactsContract.CommonDataKinds.Phone;
+import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.telecom.PhoneAccountHandle;
import android.telephony.PhoneNumberUtils;
@@ -39,6 +41,7 @@ import android.view.View.AccessibilityDelegate;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
+import com.android.contacts.common.preference.ContactsPreferences;
import com.android.contacts.common.util.PermissionsUtil;
import com.android.dialer.PhoneCallDetails;
import com.android.dialer.R;
@@ -51,8 +54,6 @@ import com.android.dialer.filterednumber.FilterNumberDialogFragment;
import com.android.dialer.util.PhoneNumberUtil;
import com.android.dialer.voicemail.VoicemailPlaybackPresenter;
-import com.google.common.annotations.VisibleForTesting;
-
import java.util.HashMap;
import java.util.Map;
@@ -118,12 +119,14 @@ public class CallLogAdapter extends GroupingListAdapter
* its day group. This hashmap provides a means of determining the previous day group without
* having to reverse the cursor to the start of the previous day call log entry.
*/
- private HashMap<Long,Integer> mDayGroups = new HashMap<Long, Integer>();
+ private HashMap<Long, Integer> mDayGroups = new HashMap<>();
private boolean mLoading = true;
private SharedPreferences mPrefs;
+ private ContactsPreferences mContactsPreferences;
+
protected boolean mShowVoicemailPromoCard = false;
/** Instance of helper class for managing views. */
@@ -254,7 +257,7 @@ public class CallLogAdapter extends GroupingListAdapter
CallTypeHelper callTypeHelper = new CallTypeHelper(resources);
mTelecomCallLogCache = new TelecomCallLogCache(mContext);
- mBlockedIdCache = new HashMap<NumberWithCountryIso, Integer>();
+ mBlockedIdCache = new HashMap<>();
PhoneCallDetailsHelper phoneCallDetailsHelper =
new PhoneCallDetailsHelper(mContext, resources, mTelecomCallLogCache);
mCallLogListItemHelper =
@@ -264,6 +267,7 @@ public class CallLogAdapter extends GroupingListAdapter
new FilteredNumberAsyncQueryHandler(mContext.getContentResolver());
mPrefs = PreferenceManager.getDefaultSharedPreferences(context);
+ mContactsPreferences = new ContactsPreferences(mContext);
maybeShowVoicemailPromoCard();
}
@@ -311,6 +315,7 @@ public class CallLogAdapter extends GroupingListAdapter
if (PermissionsUtil.hasPermission(mContext, android.Manifest.permission.READ_CONTACTS)) {
mContactInfoCache.start();
}
+ mContactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY);
}
public void onPause() {
@@ -460,9 +465,10 @@ public class CallLogAdapter extends GroupingListAdapter
details.dataUsage = c.getLong(CallLogQuery.DATA_USAGE);
}
- if (!TextUtils.isEmpty(info.name)) {
+ String preferredName = getPreferredDisplayName(info);
+ if (!TextUtils.isEmpty(preferredName)) {
details.contactUri = info.lookupUri;
- details.name = info.name;
+ details.name = preferredName;
details.numberType = info.type;
details.numberLabel = info.label;
details.photoUri = info.photoUri;
@@ -532,6 +538,14 @@ public class CallLogAdapter extends GroupingListAdapter
mCallLogListItemHelper.setPhoneCallDetails(views, details);
}
+ private String getPreferredDisplayName(ContactInfo contactInfo) {
+ if (mContactsPreferences.getDisplayOrder() == ContactsPreferences.DISPLAY_ORDER_PRIMARY ||
+ TextUtils.isEmpty(contactInfo.nameAlternative)) {
+ return contactInfo.name;
+ }
+ return contactInfo.nameAlternative;
+ }
+
@Override
public int getItemCount() {
return super.getItemCount() + (mShowVoicemailPromoCard ? 1 : 0)