summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/searchfragment
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2018-06-25 12:36:26 -0700
committerCopybara-Service <copybara-piper@google.com>2018-06-26 13:42:08 -0700
commit5578d928bf777f721ec0ec04c84ddb7d3ea56edb (patch)
tree150f643cf67aee21a2ac730d3f7b1f6cada7db47 /java/com/android/dialer/searchfragment
parent03bacec1394032712c534605476fb634b85eee28 (diff)
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
Diffstat (limited to 'java/com/android/dialer/searchfragment')
-rw-r--r--java/com/android/dialer/searchfragment/cp2/SearchContactsCursorLoader.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/java/com/android/dialer/searchfragment/cp2/SearchContactsCursorLoader.java b/java/com/android/dialer/searchfragment/cp2/SearchContactsCursorLoader.java
index 7caa314f3..f4ed21ee4 100644
--- a/java/com/android/dialer/searchfragment/cp2/SearchContactsCursorLoader.java
+++ b/java/com/android/dialer/searchfragment/cp2/SearchContactsCursorLoader.java
@@ -27,8 +27,10 @@ import android.provider.ContactsContract.Directory;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
-import com.android.contacts.common.preference.ContactsPreferences;
import com.android.dialer.common.LogUtil;
+import com.android.dialer.contacts.ContactsComponent;
+import com.android.dialer.contacts.displaypreference.ContactDisplayPreferences.DisplayOrder;
+import com.android.dialer.contacts.displaypreference.ContactDisplayPreferences.SortOrder;
import com.android.dialer.searchfragment.common.Projections;
import com.android.dialer.searchfragment.common.SearchCursor;
import com.android.dialer.smartdial.SmartDialCursorLoader;
@@ -55,9 +57,9 @@ public final class SearchContactsCursorLoader extends CursorLoader {
}
private static String[] getProjection(Context context) {
- ContactsPreferences contactsPrefs = new ContactsPreferences(context);
boolean displayOrderPrimary =
- (contactsPrefs.getDisplayOrder() == ContactsPreferences.DISPLAY_ORDER_PRIMARY);
+ (ContactsComponent.get(context).contactDisplayPreferences().getDisplayOrder()
+ == DisplayOrder.PRIMARY);
return displayOrderPrimary
? Projections.CP2_PROJECTION
: Projections.CP2_PROJECTION_ALTERNATIVE;
@@ -70,9 +72,9 @@ public final class SearchContactsCursorLoader extends CursorLoader {
}
private static String getSortKey(Context context) {
- ContactsPreferences contactsPrefs = new ContactsPreferences(context);
boolean sortOrderPrimary =
- (contactsPrefs.getSortOrder() == ContactsPreferences.SORT_ORDER_PRIMARY);
+ (ContactsComponent.get(context).contactDisplayPreferences().getSortOrder()
+ == SortOrder.BY_PRIMARY);
return sortOrderPrimary ? Phone.SORT_KEY_PRIMARY : Phone.SORT_KEY_ALTERNATIVE;
}