summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/speeddial
diff options
context:
space:
mode:
authorcalderwoodra <calderwoodra@google.com>2018-04-26 13:00:04 -0700
committerCopybara-Service <copybara-piper@google.com>2018-04-26 20:37:51 -0700
commit4db07410fbf823158a8cd3edcc7a6e1d72cc607f (patch)
tree0a7561302e6a9cc929e33a8b1cbea448abbf923c /java/com/android/dialer/speeddial
parent49c5ea2e3085ff4f54b75a936b5a37ae96452b70 (diff)
Build out the bottom sheet for suggested contacts in Speed Dial.
The bottom sheet should include: - contact row - voice call - video call - sms - divider - add favorite (follow up) - remove (follow up) - contact info Bug: 77761183 Test: WIP PiperOrigin-RevId: 194440839 Change-Id: I78e0e0fc0a4834338a59b458fe7639786de57877
Diffstat (limited to 'java/com/android/dialer/speeddial')
-rw-r--r--java/com/android/dialer/speeddial/SpeedDialFragment.java114
-rw-r--r--java/com/android/dialer/speeddial/SuggestionViewHolder.java35
-rw-r--r--java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java12
-rw-r--r--java/com/android/dialer/speeddial/res/layout/suggestion_row_layout.xml5
4 files changed, 142 insertions, 24 deletions
diff --git a/java/com/android/dialer/speeddial/SpeedDialFragment.java b/java/com/android/dialer/speeddial/SpeedDialFragment.java
index b76db1cf3..018f97888 100644
--- a/java/com/android/dialer/speeddial/SpeedDialFragment.java
+++ b/java/com/android/dialer/speeddial/SpeedDialFragment.java
@@ -16,6 +16,7 @@
package com.android.dialer.speeddial;
+import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
@@ -41,6 +42,12 @@ import com.android.dialer.common.concurrent.DialerExecutorComponent;
import com.android.dialer.common.concurrent.SupportUiListener;
import com.android.dialer.constants.ActivityRequestCodes;
import com.android.dialer.duo.DuoComponent;
+import com.android.dialer.historyitemactions.DividerModule;
+import com.android.dialer.historyitemactions.HistoryItemActionBottomSheet;
+import com.android.dialer.historyitemactions.HistoryItemActionModule;
+import com.android.dialer.historyitemactions.HistoryItemBottomSheetHeaderInfo;
+import com.android.dialer.historyitemactions.IntentModule;
+import com.android.dialer.historyitemactions.SharedModules;
import com.android.dialer.logging.DialerImpression;
import com.android.dialer.logging.Logger;
import com.android.dialer.precall.PreCall;
@@ -54,8 +61,11 @@ import com.android.dialer.speeddial.draghelper.SpeedDialLayoutManager;
import com.android.dialer.speeddial.loader.SpeedDialUiItem;
import com.android.dialer.speeddial.loader.UiItemLoaderComponent;
import com.android.dialer.util.IntentUtil;
+import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.Futures;
+import java.util.ArrayList;
+import java.util.List;
/**
* Fragment for displaying:
@@ -301,8 +311,61 @@ public class SpeedDialFragment extends Fragment {
private final class SpeedDialSuggestedListener implements SuggestedContactsListener {
@Override
- public void onOverFlowMenuClicked(SpeedDialUiItem speedDialUiItem) {
- // TODO(calderwoodra) show overflow menu for suggested contacts
+ public void onOverFlowMenuClicked(
+ SpeedDialUiItem speedDialUiItem, HistoryItemBottomSheetHeaderInfo headerInfo) {
+ List<HistoryItemActionModule> modules = new ArrayList<>();
+ Channel defaultChannel = speedDialUiItem.defaultChannel();
+
+ // Add voice call module
+ Channel voiceChannel = speedDialUiItem.getDeterministicVoiceChannel();
+ if (voiceChannel != null) {
+ modules.add(
+ IntentModule.newCallModule(
+ getContext(),
+ new CallIntentBuilder(voiceChannel.number(), CallInitiationType.Type.SPEED_DIAL)
+ .setAllowAssistedDial(true)));
+ } else {
+ modules.add(new DisambigDialogModule(speedDialUiItem, /* isVideo = */ false));
+ }
+
+ // Add video if we can determine the correct channel
+ Channel videoChannel = speedDialUiItem.getDeterministicVideoChannel();
+ if (videoChannel != null) {
+ modules.add(
+ IntentModule.newCallModule(
+ getContext(),
+ new CallIntentBuilder(videoChannel.number(), CallInitiationType.Type.SPEED_DIAL)
+ .setIsVideoCall(true)
+ .setAllowAssistedDial(true)));
+ } else if (speedDialUiItem.hasVideoChannels()) {
+ modules.add(new DisambigDialogModule(speedDialUiItem, /* isVideo = */ true));
+ }
+
+ // Add sms module
+ Optional<HistoryItemActionModule> smsModule =
+ SharedModules.createModuleForSendingTextMessage(
+ getContext(), defaultChannel.number(), false);
+ if (smsModule.isPresent()) {
+ modules.add(smsModule.get());
+ }
+
+ modules.add(new DividerModule());
+
+ // TODO(calderwoodra): add to favorites module
+ // TODO(calderwoodra): remove from strequent module
+
+ // Contact info module
+ modules.add(
+ new ContactInfoModule(
+ getContext(),
+ new Intent(
+ Intent.ACTION_VIEW,
+ Uri.withAppendedPath(
+ Contacts.CONTENT_URI, String.valueOf(speedDialUiItem.contactId()))),
+ R.string.contact_menu_contact_info,
+ R.drawable.context_menu_contact_icon));
+
+ HistoryItemActionBottomSheet.show(getContext(), headerInfo, modules);
}
@Override
@@ -321,6 +384,53 @@ public class SpeedDialFragment extends Fragment {
new CallIntentBuilder(channel.number(), CallInitiationType.Type.SPEED_DIAL)
.setIsVideoCall(channel.isVideoTechnology()));
}
+
+ private final class ContactInfoModule extends IntentModule {
+
+ public ContactInfoModule(Context context, Intent intent, int text, int image) {
+ super(context, intent, text, image);
+ }
+
+ @Override
+ public boolean tintDrawable() {
+ return false;
+ }
+ }
+
+ private final class DisambigDialogModule implements HistoryItemActionModule {
+
+ private final SpeedDialUiItem speedDialUiItem;
+ private final boolean isVideo;
+
+ DisambigDialogModule(SpeedDialUiItem speedDialUiItem, boolean isVideo) {
+ this.speedDialUiItem = speedDialUiItem;
+ this.isVideo = isVideo;
+ }
+
+ @Override
+ public int getStringId() {
+ if (isVideo) {
+ return R.string.contact_menu_video_call;
+ } else {
+ return R.string.contact_menu_voice_call;
+ }
+ }
+
+ @Override
+ public int getDrawableId() {
+ if (isVideo) {
+ return R.drawable.quantum_ic_videocam_vd_theme_24;
+ } else {
+ return R.drawable.quantum_ic_phone_vd_theme_24;
+ }
+ }
+
+ @Override
+ public boolean onClick() {
+ DisambigDialog.show(speedDialUiItem, getChildFragmentManager());
+ return true;
+ }
+ }
}
private static final class SpeedDialContextMenuItemListener implements ContextMenuItemListener {
diff --git a/java/com/android/dialer/speeddial/SuggestionViewHolder.java b/java/com/android/dialer/speeddial/SuggestionViewHolder.java
index 546ffbdff..578e0b328 100644
--- a/java/com/android/dialer/speeddial/SuggestionViewHolder.java
+++ b/java/com/android/dialer/speeddial/SuggestionViewHolder.java
@@ -17,27 +17,25 @@
package com.android.dialer.speeddial;
import android.content.Context;
-import android.provider.ContactsContract.Contacts;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
-import android.widget.QuickContactBadge;
import android.widget.TextView;
import com.android.dialer.common.Assert;
-import com.android.dialer.glidephotomanager.GlidePhotoManagerComponent;
-import com.android.dialer.glidephotomanager.PhotoInfo;
+import com.android.dialer.historyitemactions.HistoryItemBottomSheetHeaderInfo;
import com.android.dialer.location.GeoUtil;
import com.android.dialer.phonenumberutil.PhoneNumberHelper;
import com.android.dialer.speeddial.database.SpeedDialEntry.Channel;
import com.android.dialer.speeddial.loader.SpeedDialUiItem;
+import com.android.dialer.widget.ContactPhotoView;
/** ViewHolder for displaying suggested contacts in {@link SpeedDialFragment}. */
public class SuggestionViewHolder extends RecyclerView.ViewHolder implements OnClickListener {
private final SuggestedContactsListener listener;
- private final QuickContactBadge photoView;
+ private final ContactPhotoView photoView;
private final TextView nameOrNumberView;
private final TextView numberView;
@@ -71,34 +69,31 @@ public class SuggestionViewHolder extends RecyclerView.ViewHolder implements OnC
nameOrNumberView.setText(speedDialUiItem.name());
numberView.setText(secondaryInfo);
- GlidePhotoManagerComponent.get(context)
- .glidePhotoManager()
- .loadQuickContactBadge(
- photoView,
- PhotoInfo.newBuilder()
- .setPhotoId(speedDialUiItem.photoId())
- .setPhotoUri(speedDialUiItem.photoUri())
- .setName(speedDialUiItem.name())
- .setIsVideo(speedDialUiItem.defaultChannel().isVideoTechnology())
- .setLookupUri(
- Contacts.getLookupUri(speedDialUiItem.contactId(), speedDialUiItem.lookupKey())
- .toString())
- .build());
+ photoView.setPhoto(speedDialUiItem.getPhotoInfo());
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.overflow) {
- listener.onOverFlowMenuClicked(speedDialUiItem);
+ listener.onOverFlowMenuClicked(speedDialUiItem, getHeaderInfo());
} else {
listener.onRowClicked(speedDialUiItem.defaultChannel());
}
}
+ private HistoryItemBottomSheetHeaderInfo getHeaderInfo() {
+ return HistoryItemBottomSheetHeaderInfo.newBuilder()
+ .setPhotoInfo(speedDialUiItem.getPhotoInfo())
+ .setPrimaryText(nameOrNumberView.getText().toString())
+ .setSecondaryText(numberView.getText().toString())
+ .build();
+ }
+
/** Listener/Callback for {@link SuggestionViewHolder} parents. */
public interface SuggestedContactsListener {
- void onOverFlowMenuClicked(SpeedDialUiItem speedDialUiItem);
+ void onOverFlowMenuClicked(
+ SpeedDialUiItem speedDialUiItem, HistoryItemBottomSheetHeaderInfo headerInfo);
/** Called when a suggested contact is clicked. */
void onRowClicked(Channel channel);
diff --git a/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java b/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java
index a2bdfb89a..c5a3ea3ed 100644
--- a/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java
+++ b/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java
@@ -18,10 +18,12 @@ package com.android.dialer.speeddial.loader;
import android.database.Cursor;
import android.provider.ContactsContract.CommonDataKinds.Phone;
+import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.android.dialer.common.Assert;
+import com.android.dialer.glidephotomanager.PhotoInfo;
import com.android.dialer.speeddial.database.SpeedDialEntry;
import com.android.dialer.speeddial.database.SpeedDialEntry.Channel;
import com.google.auto.value.AutoValue;
@@ -139,6 +141,16 @@ public abstract class SpeedDialUiItem {
return builder.build();
}
+ public PhotoInfo getPhotoInfo() {
+ return PhotoInfo.newBuilder()
+ .setPhotoId(photoId())
+ .setPhotoUri(photoUri())
+ .setName(name())
+ .setIsVideo(defaultChannel() != null && defaultChannel().isVideoTechnology())
+ .setLookupUri(Contacts.getLookupUri(contactId(), lookupKey()).toString())
+ .build();
+ }
+
public SpeedDialEntry buildSpeedDialEntry() {
return SpeedDialEntry.builder()
.setId(speedDialEntryId())
diff --git a/java/com/android/dialer/speeddial/res/layout/suggestion_row_layout.xml b/java/com/android/dialer/speeddial/res/layout/suggestion_row_layout.xml
index ff95b5906..868606065 100644
--- a/java/com/android/dialer/speeddial/res/layout/suggestion_row_layout.xml
+++ b/java/com/android/dialer/speeddial/res/layout/suggestion_row_layout.xml
@@ -21,7 +21,7 @@
android:minHeight="72dp"
android:background="?android:attr/selectableItemBackground">
- <QuickContactBadge
+ <com.android.dialer.widget.ContactPhotoView
android:id="@+id/avatar"
android:layout_width="48dp"
android:layout_height="48dp"
@@ -59,5 +59,6 @@
android:scaleType="center"
android:tint="@color/secondary_text_color"
android:src="@drawable/quantum_ic_more_vert_white_24"
- android:background="?android:selectableItemBackgroundBorderless"/>
+ android:background="?android:selectableItemBackgroundBorderless"
+ android:contentDescription="@string/content_description_overflow"/>
</RelativeLayout> \ No newline at end of file