summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java
diff options
context:
space:
mode:
authorcalderwoodra <calderwoodra@google.com>2017-11-17 18:17:53 -0800
committerZachary Heidepriem <zachh@google.com>2017-11-18 08:32:12 -0800
commit5a2b1b2e7cbe8fd5c402ffe0386920b3a63340fa (patch)
tree2e00a0a7ba6e87cdbed46d3f4137597d7ee236fb /java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java
parentf8785b93d38b0e65b5a49500231dc26457792cc9 (diff)
Added place voice call search action to regular search.
When a user types a phone number into the search bar, there isn't an intuitive way for them to place a call when the number doesn't match any existing contacts in the new search UI. This change adds the option to place a voice call from regular search, like the old UI. Bug: 69385190 Test: NSFT PiperOrigin-RevId: 176189153 Change-Id: I6c1561bcce104c56855d996570a79b34da7230ff
Diffstat (limited to 'java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java')
-rw-r--r--java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java37
1 files changed, 32 insertions, 5 deletions
diff --git a/java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java b/java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java
index b557a8259..76c71d6ac 100644
--- a/java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java
+++ b/java/com/android/dialer/searchfragment/list/SearchActionViewHolder.java
@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.Intent;
import android.support.annotation.IntDef;
import android.support.annotation.StringRes;
+import android.support.annotation.VisibleForTesting;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.View.OnClickListener;
@@ -49,7 +50,8 @@ final class SearchActionViewHolder extends RecyclerView.ViewHolder implements On
Action.CREATE_NEW_CONTACT,
Action.ADD_TO_CONTACT,
Action.SEND_SMS,
- Action.MAKE_VILTE_CALL
+ Action.MAKE_VILTE_CALL,
+ Action.MAKE_VOICE_CALL
})
@interface Action {
int INVALID = 0;
@@ -61,6 +63,8 @@ final class SearchActionViewHolder extends RecyclerView.ViewHolder implements On
int SEND_SMS = 3;
/** Attempts to make a VILTE call to the number. */
int MAKE_VILTE_CALL = 4;
+ /** Places a voice call to the number. */
+ int MAKE_VOICE_CALL = 5;
}
private final Context context;
@@ -70,6 +74,7 @@ final class SearchActionViewHolder extends RecyclerView.ViewHolder implements On
private @Action int action;
private int position;
private String query;
+ private CallInitiationType.Type callInitiationType;
SearchActionViewHolder(View view) {
super(view);
@@ -79,10 +84,11 @@ final class SearchActionViewHolder extends RecyclerView.ViewHolder implements On
view.setOnClickListener(this);
}
- void setAction(@Action int action, int position, String query) {
+ void setAction(@Action int action, int position, String query, CallInitiationType.Type type) {
this.action = action;
this.position = position;
this.query = query;
+ this.callInitiationType = type;
switch (action) {
case Action.ADD_TO_CONTACT:
actionText.setText(R.string.search_shortcut_add_to_contact);
@@ -100,12 +106,23 @@ final class SearchActionViewHolder extends RecyclerView.ViewHolder implements On
actionText.setText(R.string.search_shortcut_send_sms_message);
actionImage.setImageResource(R.drawable.quantum_ic_message_vd_theme_24);
break;
+ case Action.MAKE_VOICE_CALL:
+ actionText.setText(context.getString(R.string.search_shortcut_make_voice_call, query));
+ actionImage.setImageResource(R.drawable.quantum_ic_phone_vd_theme_24);
+ break;
case Action.INVALID:
default:
throw Assert.createIllegalStateFailException("Invalid action: " + action);
+
}
}
+ @VisibleForTesting
+ @Action
+ int getAction() {
+ return action;
+ }
+
@Override
public void onClick(View v) {
switch (action) {
@@ -123,14 +140,14 @@ final class SearchActionViewHolder extends RecyclerView.ViewHolder implements On
break;
case Action.MAKE_VILTE_CALL:
- CallSpecificAppData callSpecificAppData =
+ CallSpecificAppData videoCallSpecificAppData =
CallSpecificAppData.newBuilder()
- .setCallInitiationType(CallInitiationType.Type.DIALPAD)
+ .setCallInitiationType(callInitiationType)
.setPositionOfSelectedSearchResult(position)
.setCharactersInSearchString(query.length())
.build();
PreCall.start(
- context, new CallIntentBuilder(query, callSpecificAppData).setIsVideoCall(true));
+ context, new CallIntentBuilder(query, videoCallSpecificAppData).setIsVideoCall(true));
break;
case Action.SEND_SMS:
@@ -138,6 +155,16 @@ final class SearchActionViewHolder extends RecyclerView.ViewHolder implements On
DialerUtils.startActivityWithErrorToast(context, intent);
break;
+ case Action.MAKE_VOICE_CALL:
+ CallSpecificAppData voiceCallSpecificAppData =
+ CallSpecificAppData.newBuilder()
+ .setCallInitiationType(callInitiationType)
+ .setPositionOfSelectedSearchResult(position)
+ .setCharactersInSearchString(query.length())
+ .build();
+ PreCall.start(context, new CallIntentBuilder(query, voiceCallSpecificAppData));
+ break;
+
case Action.INVALID:
default:
throw Assert.createIllegalStateFailException("Invalid action: " + action);