From 60b2d299ac2808c8e51a202b3ba5bb946192d43e Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Thu, 17 May 2018 16:50:34 -0700 Subject: Update dynamic shortcuts to match speed dial pinned positions. 6. App shortcut list should refresh when changes are made to favorites, does not do so currently. Bug: 79873008 Test: manual PiperOrigin-RevId: 197073422 Change-Id: Ia72bdfab39a11daf8811cb122e819964ec37594f --- java/com/android/dialer/shortcuts/ShortcutRefresher.java | 15 +++++++++++++++ java/com/android/dialer/speeddial/SpeedDialFragment.java | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/java/com/android/dialer/shortcuts/ShortcutRefresher.java b/java/com/android/dialer/shortcuts/ShortcutRefresher.java index 3201d592d..7776aa9f0 100644 --- a/java/com/android/dialer/shortcuts/ShortcutRefresher.java +++ b/java/com/android/dialer/shortcuts/ShortcutRefresher.java @@ -25,6 +25,7 @@ import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutor.Worker; import com.android.dialer.common.concurrent.DialerExecutorComponent; +import com.android.dialer.speeddial.loader.SpeedDialUiItem; import java.util.ArrayList; import java.util.List; @@ -52,6 +53,20 @@ public final class ShortcutRefresher { .executeSerial(new ArrayList<>(contacts)); } + public static List speedDialUiItemsToContactEntries(List items) { + List contactEntries = new ArrayList<>(); + for (SpeedDialUiItem item : items) { + ContactEntry entry = new ContactEntry(); + entry.id = item.contactId(); + entry.lookupKey = item.lookupKey(); + // SpeedDialUiItem name's are already configured for alternative display orders, so we don't + // need to account for them in these entries. + entry.namePrimary = item.name(); + contactEntries.add(entry); + } + return contactEntries; + } + private static final class RefreshWorker implements Worker, Void> { private final Context context; diff --git a/java/com/android/dialer/speeddial/SpeedDialFragment.java b/java/com/android/dialer/speeddial/SpeedDialFragment.java index a645fb82b..c48eb8d68 100644 --- a/java/com/android/dialer/speeddial/SpeedDialFragment.java +++ b/java/com/android/dialer/speeddial/SpeedDialFragment.java @@ -56,6 +56,7 @@ import com.android.dialer.historyitemactions.IntentModule; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.precall.PreCall; +import com.android.dialer.shortcuts.ShortcutRefresher; import com.android.dialer.speeddial.ContextMenu.ContextMenuItemListener; import com.android.dialer.speeddial.FavoritesViewHolder.FavoriteContactsListener; import com.android.dialer.speeddial.HeaderViewHolder.SpeedDialHeaderListener; @@ -209,6 +210,9 @@ public class SpeedDialFragment extends Fragment { }), new DefaultFutureCallback<>(), DialerExecutorComponent.get(getContext()).backgroundExecutor()); + ShortcutRefresher.refresh( + getContext(), + ShortcutRefresher.speedDialUiItemsToContactEntries(adapter.getSpeedDialUiItems())); } @Override -- cgit v1.2.3