summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/speeddial/SpeedDialFragment.java
diff options
context:
space:
mode:
authorcalderwoodra <calderwoodra@google.com>2018-04-28 23:34:05 -0700
committerCopybara-Service <copybara-piper@google.com>2018-04-30 18:15:47 -0700
commita73844d34e1fa90184bf8ecf9fa672e8dcfa4648 (patch)
tree48db2f8874310bf11e21930dc3c3fdc8eca5452c /java/com/android/dialer/speeddial/SpeedDialFragment.java
parenteac73f3067acefffaa8eec7b7a9d8b3cc176e674 (diff)
Implement "Add to favorites" option in suggestions menu.
Bug: 77761183 Test: SpeedDialIntegrationTest PiperOrigin-RevId: 194687428 Change-Id: Ib542122c1ff3104fcb4c08cb7bcbb7f1deb20d76
Diffstat (limited to 'java/com/android/dialer/speeddial/SpeedDialFragment.java')
-rw-r--r--java/com/android/dialer/speeddial/SpeedDialFragment.java37
1 files changed, 36 insertions, 1 deletions
diff --git a/java/com/android/dialer/speeddial/SpeedDialFragment.java b/java/com/android/dialer/speeddial/SpeedDialFragment.java
index 97a5facab..17591aa6c 100644
--- a/java/com/android/dialer/speeddial/SpeedDialFragment.java
+++ b/java/com/android/dialer/speeddial/SpeedDialFragment.java
@@ -350,7 +350,7 @@ public class SpeedDialFragment extends Fragment {
modules.add(new DividerModule());
- // TODO(calderwoodra): add to favorites module
+ modules.add(new StarContactModule(speedDialUiItem));
// TODO(calderwoodra): remove from strequent module
// Contact info module
@@ -384,6 +384,41 @@ public class SpeedDialFragment extends Fragment {
.setIsVideoCall(channel.isVideoTechnology()));
}
+ private final class StarContactModule implements HistoryItemActionModule {
+
+ private final SpeedDialUiItem speedDialUiItem;
+
+ StarContactModule(SpeedDialUiItem speedDialUiItem) {
+ this.speedDialUiItem = speedDialUiItem;
+ }
+
+ @Override
+ public int getStringId() {
+ return R.string.suggested_contact_bottom_sheet_add_favorite_option;
+ }
+
+ @Override
+ public int getDrawableId() {
+ return R.drawable.context_menu_contact_icon;
+ }
+
+ @Override
+ public boolean onClick() {
+ speedDialLoaderListener.listen(
+ getContext(),
+ UiItemLoaderComponent.get(getContext())
+ .speedDialUiItemMutator()
+ .starContact(
+ Uri.withAppendedPath(
+ Phone.CONTENT_FILTER_URI, speedDialUiItem.defaultChannel().number())),
+ SpeedDialFragment.this::onSpeedDialUiItemListLoaded,
+ throwable -> {
+ throw new RuntimeException(throwable);
+ });
+ return true;
+ }
+ }
+
private final class ContactInfoModule extends IntentModule {
public ContactInfoModule(Context context, Intent intent, int text, int image) {