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 --- .../precall/impl/CallingAccountSelector.java | 33 +++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'java/com/android/dialer/precall') diff --git a/java/com/android/dialer/precall/impl/CallingAccountSelector.java b/java/com/android/dialer/precall/impl/CallingAccountSelector.java index 16e7641ba..6514a4941 100644 --- a/java/com/android/dialer/precall/impl/CallingAccountSelector.java +++ b/java/com/android/dialer/precall/impl/CallingAccountSelector.java @@ -28,6 +28,8 @@ import android.telecom.TelecomManager; import android.telephony.PhoneNumberUtils; import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment; import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment.SelectPhoneAccountListener; +import com.android.contacts.common.widget.SelectPhoneAccountDialogOptions; +import com.android.contacts.common.widget.SelectPhoneAccountDialogOptionsUtil; import com.android.dialer.callintent.CallIntentBuilder; import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; @@ -44,6 +46,7 @@ import com.android.dialer.preferredsim.PreferredAccountWorker; import com.android.dialer.preferredsim.suggestion.SuggestionProvider; import com.android.dialer.preferredsim.suggestion.SuggestionProvider.Suggestion; import com.android.dialer.telecom.TelecomUtil; +import com.google.common.base.Optional; import java.util.List; /** PreCallAction to select which phone account to call with. Ignored if there's only one account */ @@ -211,24 +214,34 @@ public class CallingAccountSelector implements PreCallAction { default: } } - List phoneAccountHandles = + SelectPhoneAccountDialogOptions.Builder optionsBuilder = + SelectPhoneAccountDialogOptions.newBuilder() + .setTitle(R.string.pre_call_select_phone_account) + .setCanSetDefault(dataId != null) + .setSetDefaultLabel(R.string.pre_call_select_phone_account_remember); + + for (PhoneAccountHandle phoneAccountHandle : coordinator .getActivity() .getSystemService(TelecomManager.class) - .getCallCapablePhoneAccounts(); + .getCallCapablePhoneAccounts()) { + SelectPhoneAccountDialogOptions.Entry.Builder entryBuilder = + SelectPhoneAccountDialogOptions.Entry.newBuilder(); + SelectPhoneAccountDialogOptionsUtil.setPhoneAccountHandle(entryBuilder, phoneAccountHandle); + Optional hint = + SuggestionProvider.getHint(coordinator.getActivity(), phoneAccountHandle, suggestion); + if (hint.isPresent()) { + entryBuilder.setHint(hint.get()); + } + optionsBuilder.addEntries(entryBuilder); + } selectPhoneAccountDialogFragment = SelectPhoneAccountDialogFragment.newInstance( - R.string.pre_call_select_phone_account, - dataId != null /* canSetDefault */, - R.string.pre_call_select_phone_account_remember, - phoneAccountHandles, + optionsBuilder.build(), new SelectedListener( coordinator, pendingAction, - new PreferredAccountRecorder(number, suggestion, dataId)), - null /* call ID */, - SuggestionProvider.buildHint( - coordinator.getActivity(), phoneAccountHandles, suggestion)); + new PreferredAccountRecorder(number, suggestion, dataId))); selectPhoneAccountDialogFragment.show( coordinator.getActivity().getFragmentManager(), TAG_CALLING_ACCOUNT_SELECTOR); } -- cgit v1.2.3