summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/precall
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2018-04-24 13:51:08 -0700
committerCopybara-Service <copybara-piper@google.com>2018-04-25 11:44:51 -0700
commit66adad0ab9921afcf3aefab270c030ceee9888df (patch)
tree67dcecd86b8a100243a6daaabd11c28d3f347c4f /java/com/android/dialer/precall
parent05d17bda619dfdb7a729959dad098c10d67f84c8 (diff)
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
Diffstat (limited to 'java/com/android/dialer/precall')
-rw-r--r--java/com/android/dialer/precall/impl/CallingAccountSelector.java33
1 files changed, 23 insertions, 10 deletions
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<PhoneAccountHandle> 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<String> 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);
}