Refactor ContactPreference
Moving it outside contacts.commons reduces dependency to legacy code. Also removed redundant implementations such as caching SharedPreferences (it is already cached), custom ListPreferences (standard ListPreferences already have what we want), and corrected preference storage location (allow standard ListPreferences to work)
TEST=TAP
Test: TAP
PiperOrigin-RevId: 202000393
Change-Id: I45374e610b3510784b5a4da92e5d8462cbfc92bb
diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java
index 91255cc..b9e6744 100644
--- a/java/com/android/incallui/CallCardPresenter.java
+++ b/java/com/android/incallui/CallCardPresenter.java
@@ -44,11 +44,10 @@
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import com.android.contacts.common.ContactsUtils;
-import com.android.contacts.common.preference.ContactsPreferences;
-import com.android.contacts.common.util.ContactDisplayUtils;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.android.dialer.configprovider.ConfigProviderComponent;
+import com.android.dialer.contacts.ContactsComponent;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;
import com.android.dialer.multimedia.MultimediaData;
@@ -123,7 +122,6 @@
private String secondaryNumber;
private ContactCacheEntry primaryContactInfo;
private ContactCacheEntry secondaryContactInfo;
- @Nullable private ContactsPreferences contactsPreferences;
private boolean isFullscreen = false;
private InCallScreen inCallScreen;
private boolean isInCallScreenReady;
@@ -159,7 +157,6 @@
public void onInCallScreenDelegateInit(InCallScreen inCallScreen) {
Assert.isNotNull(inCallScreen);
this.inCallScreen = inCallScreen;
- contactsPreferences = ContactsPreferencesFactory.newContactsPreferences(context);
// Call may be null if disconnect happened already.
DialerCall call = CallList.getInstance().getFirstCall();
@@ -184,9 +181,6 @@
public void onInCallScreenReady() {
LogUtil.i("CallCardPresenter.onInCallScreenReady", null);
Assert.checkState(!isInCallScreenReady);
- if (contactsPreferences != null) {
- contactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY);
- }
// Contact search may have completed before ui is ready.
if (primaryContactInfo != null) {
@@ -985,8 +979,9 @@
/** Gets the name to display for the call. */
private String getNameForCall(ContactCacheEntry contactInfo) {
String preferredName =
- ContactDisplayUtils.getPreferredDisplayName(
- contactInfo.namePrimary, contactInfo.nameAlternative, contactsPreferences);
+ ContactsComponent.get(context)
+ .contactDisplayPreferences()
+ .getDisplayName(contactInfo.namePrimary, contactInfo.nameAlternative);
if (TextUtils.isEmpty(preferredName)) {
return TextUtils.isEmpty(contactInfo.number)
? null