summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/precall/impl/CallingAccountSelector.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/android/dialer/precall/impl/CallingAccountSelector.java')
-rw-r--r--java/com/android/dialer/precall/impl/CallingAccountSelector.java45
1 files changed, 39 insertions, 6 deletions
diff --git a/java/com/android/dialer/precall/impl/CallingAccountSelector.java b/java/com/android/dialer/precall/impl/CallingAccountSelector.java
index d46e31711..fe3a5b631 100644
--- a/java/com/android/dialer/precall/impl/CallingAccountSelector.java
+++ b/java/com/android/dialer/precall/impl/CallingAccountSelector.java
@@ -48,6 +48,7 @@ import com.android.dialer.preferredsim.PreferredSimFallbackContract.PreferredSim
import com.android.dialer.preferredsim.suggestion.SimSuggestionComponent;
import com.android.dialer.preferredsim.suggestion.SuggestionProvider.Suggestion;
import com.google.common.base.Optional;
+import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -158,22 +159,54 @@ public class CallingAccountSelector implements PreCallAction {
PendingAction pendingAction,
@Nullable String dataId,
@Nullable String number,
- @Nullable Suggestion unusedSuggestion) { // TODO(twyen): incoporate suggestion in dialog
+ @Nullable Suggestion suggestion) {
Assert.isMainThread();
+ List<PhoneAccountHandle> phoneAccountHandles =
+ coordinator
+ .getActivity()
+ .getSystemService(TelecomManager.class)
+ .getCallCapablePhoneAccounts();
selectPhoneAccountDialogFragment =
SelectPhoneAccountDialogFragment.newInstance(
R.string.pre_call_select_phone_account,
dataId != null /* canSetDefault */,
- coordinator
- .getActivity()
- .getSystemService(TelecomManager.class)
- .getCallCapablePhoneAccounts(),
+ R.string.pre_call_select_phone_account_remember,
+ phoneAccountHandles,
new SelectedListener(coordinator, pendingAction, dataId, number),
- null /* call ID */);
+ null /* call ID */,
+ buildHint(coordinator.getActivity(), phoneAccountHandles, suggestion));
selectPhoneAccountDialogFragment.show(
coordinator.getActivity().getFragmentManager(), TAG_CALLING_ACCOUNT_SELECTOR);
}
+ @Nullable
+ private static List<String> buildHint(
+ Context context,
+ List<PhoneAccountHandle> phoneAccountHandles,
+ @Nullable Suggestion suggestion) {
+ if (suggestion == null) {
+ return null;
+ }
+ 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:
+ throw Assert.createAssertionFailException("unexpected reason " + suggestion.reason);
+ }
+ }
+ return hints;
+ }
+
@MainThread
@Override
public void onDiscard() {