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
diff --git a/java/com/android/incallui/InCallActivity.java b/java/com/android/incallui/InCallActivity.java
index 86799bf..68de8dc 100644
--- a/java/com/android/incallui/InCallActivity.java
+++ b/java/com/android/incallui/InCallActivity.java
@@ -55,6 +55,8 @@
import android.widget.CheckBox;
import android.widget.Toast;
import com.android.contacts.common.widget.SelectPhoneAccountDialogFragment;
+import com.android.contacts.common.widget.SelectPhoneAccountDialogOptions;
+import com.android.contacts.common.widget.SelectPhoneAccountDialogOptionsUtil;
import com.android.dialer.animation.AnimUtils;
import com.android.dialer.animation.AnimationListenerAdapter;
import com.android.dialer.common.Assert;
@@ -395,16 +397,30 @@
waitingForAccountCall.getNumber(),
result.getSuggestion().orNull(),
result.getDataId().orNull()));
+ SelectPhoneAccountDialogOptions.Builder optionsBuilder =
+ SelectPhoneAccountDialogOptions.newBuilder()
+ .setTitle(R.string.select_phone_account_for_calls)
+ .setCanSetDefault(result.getDataId().isPresent())
+ .setSetDefaultLabel(R.string.select_phone_account_for_calls_remember)
+ .setCallId(waitingForAccountCall.getId());
+
+ for (PhoneAccountHandle phoneAccountHandle : phoneAccountHandles) {
+ SelectPhoneAccountDialogOptions.Entry.Builder entryBuilder =
+ SelectPhoneAccountDialogOptions.Entry.newBuilder();
+ SelectPhoneAccountDialogOptionsUtil.setPhoneAccountHandle(
+ entryBuilder, phoneAccountHandle);
+ Optional<String> hint =
+ SuggestionProvider.getHint(
+ this, phoneAccountHandle, result.getSuggestion().orNull());
+ if (hint.isPresent()) {
+ entryBuilder.setHint(hint.get());
+ }
+ optionsBuilder.addEntries(entryBuilder);
+ }
+
selectPhoneAccountDialogFragment =
SelectPhoneAccountDialogFragment.newInstance(
- R.string.select_phone_account_for_calls,
- result.getDataId().isPresent() /* canSetDefault */,
- R.string.select_phone_account_for_calls_remember /* setDefaultResId */,
- phoneAccountHandles,
- selectPhoneAccountListener,
- waitingForAccountCall.getId(),
- SuggestionProvider.buildHint(
- this, phoneAccountHandles, result.getSuggestion().orNull() /* hints */));
+ optionsBuilder.build(), selectPhoneAccountListener);
selectPhoneAccountDialogFragment.show(
getFragmentManager(), Tags.SELECT_ACCOUNT_FRAGMENT);
}))