diff options
Diffstat (limited to 'java/com/android/dialer/app')
5 files changed, 25 insertions, 32 deletions
diff --git a/java/com/android/dialer/app/calllog/CallLogAdapter.java b/java/com/android/dialer/app/calllog/CallLogAdapter.java index d3fd36520..f5474eec6 100644 --- a/java/com/android/dialer/app/calllog/CallLogAdapter.java +++ b/java/com/android/dialer/app/calllog/CallLogAdapter.java @@ -53,7 +53,6 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import com.android.contacts.common.ContactsUtils; -import com.android.contacts.common.preference.ContactsPreferences; import com.android.dialer.app.R; import com.android.dialer.app.calllog.CallLogFragment.CallLogFragmentListener; import com.android.dialer.app.calllog.CallLogGroupBuilder.GroupCreator; @@ -73,6 +72,7 @@ import com.android.dialer.common.concurrent.AsyncTaskExecutor; import com.android.dialer.common.concurrent.AsyncTaskExecutors; import com.android.dialer.compat.android.provider.VoicemailCompat; import com.android.dialer.configprovider.ConfigProviderComponent; +import com.android.dialer.contacts.ContactsComponent; import com.android.dialer.duo.Duo; import com.android.dialer.duo.DuoComponent; import com.android.dialer.duo.DuoListener; @@ -506,7 +506,6 @@ public class CallLogAdapter extends GroupingListAdapter private final Map<Long, Integer> dayGroups = new ArrayMap<>(); private boolean loading = true; - private ContactsPreferences contactsPreferences; private boolean isSpamEnabled; @@ -551,8 +550,6 @@ public class CallLogAdapter extends GroupingListAdapter callLogGroupBuilder = new CallLogGroupBuilder(activity.getApplicationContext(), this); this.filteredNumberAsyncQueryHandler = Assert.isNotNull(filteredNumberAsyncQueryHandler); - contactsPreferences = new ContactsPreferences(this.activity); - blockReportSpamListener = new BlockReportSpamListener( this.activity, @@ -674,7 +671,6 @@ public class CallLogAdapter extends GroupingListAdapter if (PermissionsUtil.hasPermission(activity, android.Manifest.permission.READ_CONTACTS)) { contactInfoCache.start(); } - contactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY); isSpamEnabled = SpamComponent.get(activity).spamSettings().isSpamEnabled(); getDuo().registerListener(this); notifyDataSetChanged(); @@ -1078,7 +1074,8 @@ public class CallLogAdapter extends GroupingListAdapter details.contactUri = info.lookupUri; details.namePrimary = info.name; details.nameAlternative = info.nameAlternative; - details.nameDisplayOrder = contactsPreferences.getDisplayOrder(); + details.nameDisplayOrder = + ContactsComponent.get(activity).contactDisplayPreferences().getDisplayOrder(); details.numberType = info.type; details.numberLabel = info.label; details.photoUri = info.photoUri; diff --git a/java/com/android/dialer/app/list/OldSpeedDialFragment.java b/java/com/android/dialer/app/list/OldSpeedDialFragment.java index 9b83d54ef..9922ee232 100644 --- a/java/com/android/dialer/app/list/OldSpeedDialFragment.java +++ b/java/com/android/dialer/app/list/OldSpeedDialFragment.java @@ -113,9 +113,6 @@ public class OldSpeedDialFragment extends Fragment public void onResume() { Trace.beginSection(TAG + " onResume"); super.onResume(); - if (contactTileAdapter != null) { - contactTileAdapter.refreshContactsPreferences(); - } if (PermissionsUtil.hasContactsReadPermissions(getContext())) { if (getLoaderManager().getLoader(LOADER_ID_CONTACT_TILE) == null) { getLoaderManager().initLoader(LOADER_ID_CONTACT_TILE, null, contactTileLoaderListener); diff --git a/java/com/android/dialer/app/list/PhoneFavoriteSquareTileView.java b/java/com/android/dialer/app/list/PhoneFavoriteSquareTileView.java index 6b41547c2..8fe67f4f0 100644 --- a/java/com/android/dialer/app/list/PhoneFavoriteSquareTileView.java +++ b/java/com/android/dialer/app/list/PhoneFavoriteSquareTileView.java @@ -104,7 +104,7 @@ public class PhoneFavoriteSquareTileView extends PhoneFavoriteTileView { @Override protected String getNameForView(ContactEntry contactEntry) { - return contactEntry.getPreferredDisplayName(); + return contactEntry.getPreferredDisplayName(getContext()); } public ContactEntry getContactEntry() { diff --git a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java index a20185989..4cc48a6de 100644 --- a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java +++ b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java @@ -37,10 +37,10 @@ import android.widget.BaseAdapter; import com.android.contacts.common.ContactTileLoaderFactory; import com.android.contacts.common.list.ContactEntry; import com.android.contacts.common.list.ContactTileView; -import com.android.contacts.common.preference.ContactsPreferences; import com.android.dialer.app.R; import com.android.dialer.common.LogUtil; import com.android.dialer.contactphoto.ContactPhotoManager; +import com.android.dialer.contacts.ContactsComponent; import com.android.dialer.duo.Duo; import com.android.dialer.duo.DuoComponent; import com.android.dialer.logging.InteractionEvent; @@ -78,11 +78,11 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop private OnDataSetChangedForAnimationListener dataSetChangedListener; private Context context; private Resources resources; - private ContactsPreferences contactsPreferences; private final Comparator<ContactEntry> contactEntryComparator = new Comparator<ContactEntry>() { @Override public int compare(ContactEntry lhs, ContactEntry rhs) { + return ComparisonChain.start() .compare(lhs.pinned, rhs.pinned) .compare(getPreferredSortName(lhs), getPreferredSortName(rhs)) @@ -90,11 +90,9 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop } private String getPreferredSortName(ContactEntry contactEntry) { - if (contactsPreferences.getSortOrder() == ContactsPreferences.SORT_ORDER_PRIMARY - || TextUtils.isEmpty(contactEntry.nameAlternative)) { - return contactEntry.namePrimary; - } - return contactEntry.nameAlternative; + return ContactsComponent.get(context) + .contactDisplayPreferences() + .getSortName(contactEntry.namePrimary, contactEntry.nameAlternative); } }; /** Back up of the temporarily removed Contact during dragging. */ @@ -121,7 +119,6 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop this.listener = listener; this.context = context; resources = context.getResources(); - contactsPreferences = new ContactsPreferences(this.context); numFrequents = 0; contactEntries = new ArrayList<>(); } @@ -140,11 +137,6 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop this.inDragging = inDragging; } - void refreshContactsPreferences() { - contactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY); - contactsPreferences.refreshValue(ContactsPreferences.SORT_ORDER_KEY); - } - /** * Gets the number of frequents from the passed in cursor. * @@ -256,7 +248,6 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop (!TextUtils.isEmpty(nameAlternative)) ? nameAlternative : resources.getString(R.string.missing_name); - contact.nameDisplayOrder = contactsPreferences.getDisplayOrder(); contact.photoUri = (photoUri != null ? Uri.parse(photoUri) : null); contact.lookupKey = lookupKey; contact.lookupUri = diff --git a/java/com/android/dialer/app/res/xml/display_options_settings.xml b/java/com/android/dialer/app/res/xml/display_options_settings.xml index 0b4e11d47..60301dbe8 100644 --- a/java/com/android/dialer/app/res/xml/display_options_settings.xml +++ b/java/com/android/dialer/app/res/xml/display_options_settings.xml @@ -18,14 +18,22 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> - <com.android.contacts.common.preference.SortOrderPreference - android:dialogTitle="@string/display_options_sort_list_by" - android:key="sortOrder" - android:title="@string/display_options_sort_list_by"/> + <ListPreference + android:dialogTitle="@string/display_options_sort_list_by" + android:key="@string/display_options_sort_list_by_key" + android:summary="%s" + android:entries="@array/contact_sort_order_entries" + android:entryValues="@array/contact_sort_order_values" + android:title="@string/display_options_sort_list_by" + android:defaultValue="1"/> - <com.android.contacts.common.preference.DisplayOrderPreference - android:dialogTitle="@string/display_options_view_names_as" - android:key="displayOrder" - android:title="@string/display_options_view_names_as"/> + <ListPreference + android:dialogTitle="@string/display_options_view_names_as" + android:key="@string/display_options_view_names_as_key" + android:summary="%s" + android:entries="@array/contact_display_order_entries" + android:entryValues="@array/contact_display_order_values" + android:title="@string/display_options_view_names_as" + android:defaultValue="1"/> </PreferenceScreen> |