summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/speeddial/ContextMenu.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/dialer/speeddial/ContextMenu.java')
-rw-r--r--java/com/android/dialer/speeddial/ContextMenu.java65
1 files changed, 53 insertions, 12 deletions
diff --git a/java/com/android/dialer/speeddial/ContextMenu.java b/java/com/android/dialer/speeddial/ContextMenu.java
index b6ac98862..126373c12 100644
--- a/java/com/android/dialer/speeddial/ContextMenu.java
+++ b/java/com/android/dialer/speeddial/ContextMenu.java
@@ -21,14 +21,23 @@ import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
+import android.widget.TextView;
+import com.android.dialer.speeddial.database.SpeedDialEntry.Channel;
import com.android.dialer.speeddial.loader.SpeedDialUiItem;
/** Floating menu which presents contact options available to the contact. */
public class ContextMenu extends LinearLayout {
- private SpeedDialUiItem speedDialUiItem;
private ContextMenuItemListener listener;
+ private TextView videoView;
+ private TextView smsView;
+
+ private SpeedDialUiItem speedDialUiItem;
+ private Channel voiceChannel;
+ private Channel videoChannel;
+ private Channel smsChannel;
+
public ContextMenu(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
@@ -36,12 +45,14 @@ public class ContextMenu extends LinearLayout {
@Override
protected void onFinishInflate() {
super.onFinishInflate();
- findViewById(R.id.voice_call_container)
- .setOnClickListener(v -> listener.placeVoiceCall(speedDialUiItem));
- findViewById(R.id.video_call_container)
- .setOnClickListener(v -> listener.placeVideoCall(speedDialUiItem));
- findViewById(R.id.send_message_container)
- .setOnClickListener(v -> listener.openSmsConversation(speedDialUiItem));
+
+ videoView = findViewById(R.id.video_call_container);
+ videoView.setOnClickListener(v -> placeVideoCall());
+
+ smsView = findViewById(R.id.send_message_container);
+ smsView.setOnClickListener(v -> listener.openSmsConversation(smsChannel.number()));
+
+ findViewById(R.id.voice_call_container).setOnClickListener(v -> placeVoiceCall());
findViewById(R.id.remove_container)
.setOnClickListener(v -> listener.removeFavoriteContact(speedDialUiItem));
findViewById(R.id.contact_info_container)
@@ -65,6 +76,15 @@ public class ContextMenu extends LinearLayout {
setX((float) (childLocation[0] + .5 * childLayout.getWidth() - .5 * getWidth()));
setY(childLocation[1] - parentLocation[1] + childLayout.getHeight());
+ voiceChannel = speedDialUiItem.getDeterministicVoiceChannel();
+ videoChannel = speedDialUiItem.getDeterministicVideoChannel();
+ videoView.setVisibility(
+ videoChannel == null && !speedDialUiItem.hasVideoChannels() ? View.GONE : View.VISIBLE);
+
+ // TODO(calderwoodra): disambig dialog for texts?
+ smsChannel = voiceChannel;
+ smsView.setVisibility(smsChannel == null ? View.GONE : View.VISIBLE);
+
// TODO(calderwoodra): a11y
// TODO(calderwoodra): animate this similar to the bubble menu
setVisibility(View.VISIBLE);
@@ -81,6 +101,22 @@ public class ContextMenu extends LinearLayout {
}
}
+ private void placeVoiceCall() {
+ if (voiceChannel == null) {
+ listener.disambiguateCall(speedDialUiItem);
+ } else {
+ listener.placeCall(voiceChannel);
+ }
+ }
+
+ private void placeVideoCall() {
+ if (videoChannel == null) {
+ listener.disambiguateCall(speedDialUiItem);
+ } else {
+ listener.placeCall(videoChannel);
+ }
+ }
+
public boolean isVisible() {
return getVisibility() == View.VISIBLE;
}
@@ -88,14 +124,19 @@ public class ContextMenu extends LinearLayout {
/** Listener to report user clicks on menu items. */
public interface ContextMenuItemListener {
- /** Called when the user selects "voice call" option from the context menu. */
- void placeVoiceCall(SpeedDialUiItem speedDialUiItem);
+ /** Called when the user selects "voice call" or "video call" option from the context menu. */
+ void placeCall(Channel channel);
- /** Called when the user selects "video call" option from the context menu. */
- void placeVideoCall(SpeedDialUiItem speedDialUiItem);
+ /**
+ * Called when the user selects "voice call" or "video call" option from the context menu, but
+ * it's not clear which channel they want to call.
+ *
+ * <p>TODO(calderwoodra): discuss with product how we want to handle these cases
+ */
+ void disambiguateCall(SpeedDialUiItem speedDialUiItem);
/** Called when the user selects "send message" from the context menu. */
- void openSmsConversation(SpeedDialUiItem speedDialUiItem);
+ void openSmsConversation(String number);
/** Called when the user selects "remove" from the context menu. */
void removeFavoriteContact(SpeedDialUiItem speedDialUiItem);