From 5578d928bf777f721ec0ec04c84ddb7d3ea56edb Mon Sep 17 00:00:00 2001 From: twyen Date: Mon, 25 Jun 2018 12:36:26 -0700 Subject: 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 --- .../dialer/speeddial/loader/SpeedDialUiItemMutator.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'java/com/android/dialer/speeddial/loader') diff --git a/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java b/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java index 72f0a68c6..b0b83ac32 100644 --- a/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java +++ b/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java @@ -31,13 +31,14 @@ import android.support.annotation.MainThread; import android.support.annotation.WorkerThread; import android.util.ArrayMap; import android.util.ArraySet; -import com.android.contacts.common.preference.ContactsPreferences; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.Annotations.BackgroundExecutor; import com.android.dialer.common.concurrent.DialerExecutor.SuccessListener; import com.android.dialer.common.concurrent.DialerFutureSerializer; import com.android.dialer.common.database.Selection; +import com.android.dialer.contacts.displaypreference.ContactDisplayPreferences; +import com.android.dialer.contacts.displaypreference.ContactDisplayPreferences.DisplayOrder; import com.android.dialer.duo.DuoComponent; import com.android.dialer.inject.ApplicationContext; import com.android.dialer.speeddial.database.SpeedDialEntry; @@ -84,15 +85,16 @@ public final class SpeedDialUiItemMutator { private final ListeningExecutorService backgroundExecutor; // Used to ensure that only one refresh flow runs at a time. private final DialerFutureSerializer dialerFutureSerializer = new DialerFutureSerializer(); - private final ContactsPreferences contactsPreferences; + private final ContactDisplayPreferences contactDisplayPreferences; @Inject public SpeedDialUiItemMutator( @ApplicationContext Context appContext, - @BackgroundExecutor ListeningExecutorService backgroundExecutor) { + @BackgroundExecutor ListeningExecutorService backgroundExecutor, + ContactDisplayPreferences contactDisplayPreferences) { this.appContext = appContext; this.backgroundExecutor = backgroundExecutor; - this.contactsPreferences = new ContactsPreferences(appContext); + this.contactDisplayPreferences = contactDisplayPreferences; } /** @@ -183,7 +185,6 @@ public final class SpeedDialUiItemMutator { @WorkerThread private ImmutableList insertNewContactEntry(Uri contactUri) { Assert.isWorkerThread(); - contactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY); try (Cursor cursor = appContext .getContentResolver() @@ -225,7 +226,6 @@ public final class SpeedDialUiItemMutator { private ImmutableList loadSpeedDialUiItemsInternal() { Trace.beginSection("loadSpeedDialUiItemsInternal"); Assert.isWorkerThread(); - contactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY); Trace.beginSection("getAllEntries"); SpeedDialEntryDao db = getSpeedDialEntryDao(); Trace.endSection(); // getAllEntries @@ -663,6 +663,6 @@ public final class SpeedDialUiItemMutator { } private boolean isPrimaryDisplayNameOrder() { - return contactsPreferences.getDisplayOrder() == ContactsPreferences.DISPLAY_ORDER_PRIMARY; + return contactDisplayPreferences.getDisplayOrder() == DisplayOrder.PRIMARY; } } -- cgit v1.2.3