From 66adad0ab9921afcf3aefab270c030ceee9888df Mon Sep 17 00:00:00 2001 From: twyen Date: Tue, 24 Apr 2018 13:51:08 -0700 Subject: Add "enabled" to SelectPhoneAccountDialogFragment. This is used to inform the user an account cannot be used right now. On most dual SIM devices, only a single SIM can make calls at the same time. The UI will be implemented in a followup CL. This CL also packs the parameters of SelectPhoneAccountDialogFragment into a proto. There are too many arguments and it needs structured representation. TEST=TAP Bug: 69675796,72618783 Test: TAP PiperOrigin-RevId: 194139636 Change-Id: I7d9f92c73b650654fff28ba625a2c8e3dfa0b96c --- .../suggestion/SuggestionProvider.java | 45 ++++++++-------------- 1 file changed, 17 insertions(+), 28 deletions(-) (limited to 'java/com/android/dialer/preferredsim') 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 buildHint( - Context context, - List phoneAccountHandles, - @Nullable Suggestion suggestion) { + static Optional getHint( + Context context, PhoneAccountHandle phoneAccountHandle, @Nullable Suggestion suggestion) { if (suggestion == null) { - return null; + return Optional.absent(); } - List 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; } } -- cgit v1.2.3