summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/speeddial
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
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')
-rw-r--r--java/com/android/dialer/speeddial/SpeedDialFragment.java37
-rw-r--r--java/com/android/dialer/speeddial/res/values/strings.xml3
2 files changed, 39 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) {
diff --git a/java/com/android/dialer/speeddial/res/values/strings.xml b/java/com/android/dialer/speeddial/res/values/strings.xml
index 59a0ab5d6..028f6a90c 100644
--- a/java/com/android/dialer/speeddial/res/values/strings.xml
+++ b/java/com/android/dialer/speeddial/res/values/strings.xml
@@ -55,4 +55,7 @@
<!-- Text for a button that opens the contact's info [CHAR LIMIT=15]-->
<string name="contact_menu_contact_info">Contact info</string>
+
+ <!-- Text shown to the user in a button to prompt them to mark a contact as a favorite contact [CHAR LIMIT=30]. -->
+ <string name="suggested_contact_bottom_sheet_add_favorite_option">Add to favorites</string>
</resources> \ No newline at end of file