summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java
diff options
context:
space:
mode:
authorEric Erfanian <erfanian@google.com>2018-04-25 19:00:11 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-04-25 19:00:11 +0000
commit43ed0dc0666e9d2e2837a2019e2765f10f43dff8 (patch)
treeac6491831c0d331f8582a65eda60143cb0798fd0 /java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java
parent34ed7da073bbac5b8a4283c495c588ef3b0ea32b (diff)
parent79a407ee27e6c8f6447f3a8c71ae2c7f6b33f591 (diff)
Merge changes I5b8ad5ca,I0011019c,I8ee43ce8,I35e0748a,I9e9947ad, ...
* changes: Show clear frequents option in the toolbar if there are suggested contacts. Use UI listener for preferred account worker in in call UI Make SIM Selection hint multi-line Convert CequintCallerIdContact into an @AutoValue Newly starred SpeedDialUiItems now have SpeedDialEntry ids set. Disable entries in CallingAccountSelector that are not selectable Add "enabled" to SelectPhoneAccountDialogFragment. Add skeleton for CequintPhoneLookup Log send button impressions for RTT call. Show international call on wifi dialog without InCallActivity. Expose active calls from in call UI
Diffstat (limited to 'java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java')
-rw-r--r--java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java45
1 files changed, 17 insertions, 28 deletions
diff --git a/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java b/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java
index f710f734c..50ae01fd0 100644
--- a/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java
+++ b/java/com/android/dialer/preferredsim/suggestion/SuggestionProvider.java
@@ -24,10 +24,9 @@ import android.telecom.PhoneAccountHandle;
import com.android.dialer.common.Assert;
import com.android.dialer.common.LogUtil;
import com.google.common.base.Optional;
-import java.util.ArrayList;
-import java.util.List;
/** Provides hints to the user when selecting a SIM to make a call. */
+@SuppressWarnings("Guava")
public interface SuggestionProvider {
String EXTRA_SIM_SUGGESTION_REASON = "sim_suggestion_reason";
@@ -80,35 +79,25 @@ public interface SuggestionProvider {
@NonNull Context context, @NonNull String number, @NonNull PhoneAccountHandle newAccount);
/**
- * Return a list of suggestion strings matching the list position of the {@code
- * phoneAccountHandles}. The list will contain {@code null} if the PhoneAccountHandle does not
- * have suggestions.
+ * Return the hint for {@code phoneAccountHandle}. Absent if no hint is available for the account.
*/
- @Nullable
- static List<String> buildHint(
- Context context,
- List<PhoneAccountHandle> phoneAccountHandles,
- @Nullable Suggestion suggestion) {
+ static Optional<String> getHint(
+ Context context, PhoneAccountHandle phoneAccountHandle, @Nullable Suggestion suggestion) {
if (suggestion == null) {
- return null;
+ return Optional.absent();
}
- List<String> hints = new ArrayList<>();
- for (PhoneAccountHandle phoneAccountHandle : phoneAccountHandles) {
- if (!phoneAccountHandle.equals(suggestion.phoneAccountHandle)) {
- hints.add(null);
- continue;
- }
- switch (suggestion.reason) {
- case INTRA_CARRIER:
- hints.add(context.getString(R.string.pre_call_select_phone_account_hint_intra_carrier));
- break;
- case FREQUENT:
- hints.add(context.getString(R.string.pre_call_select_phone_account_hint_frequent));
- break;
- default:
- LogUtil.w("CallingAccountSelector.buildHint", "unhandled reason " + suggestion.reason);
- }
+ if (!phoneAccountHandle.equals(suggestion.phoneAccountHandle)) {
+ return Optional.absent();
+ }
+ switch (suggestion.reason) {
+ case INTRA_CARRIER:
+ return Optional.of(
+ context.getString(R.string.pre_call_select_phone_account_hint_intra_carrier));
+ case FREQUENT:
+ return Optional.of(context.getString(R.string.pre_call_select_phone_account_hint_frequent));
+ default:
+ LogUtil.w("CallingAccountSelector.getHint", "unhandled reason " + suggestion.reason);
+ return Optional.absent();
}
- return hints;
}
}