summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/precall
diff options
context:
space:
mode:
authortwyen <twyen@google.com>2017-11-20 15:13:07 -0800
committerCopybara-Service <copybara-piper@google.com>2017-11-20 17:43:06 -0800
commitba99befea1f4402a854351f80d8627909a532331 (patch)
treea6d98ea4ac1ba093cb7af1731fccceece0242da7 /java/com/android/dialer/precall
parentf2d88b65fe86a7e2a67958ae0ac7e1961de9ac44 (diff)
Implement SIM selection dialog
Bug: 64216442,64214592,64213352 Test: N/A PiperOrigin-RevId: 176424724 Change-Id: I1709156098a14ac3bd35d98b913e7b881fcd9b2b
Diffstat (limited to 'java/com/android/dialer/precall')
-rw-r--r--java/com/android/dialer/precall/impl/CallingAccountSelector.java45
-rw-r--r--java/com/android/dialer/precall/impl/res/values/strings.xml12
2 files changed, 51 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() {
diff --git a/java/com/android/dialer/precall/impl/res/values/strings.xml b/java/com/android/dialer/precall/impl/res/values/strings.xml
index 894394662..0d30ac9e5 100644
--- a/java/com/android/dialer/precall/impl/res/values/strings.xml
+++ b/java/com/android/dialer/precall/impl/res/values/strings.xml
@@ -19,4 +19,16 @@
multiple SIMs [CHAR LIMIT=40]-->
<string name="pre_call_select_phone_account">Call with</string>
+ <!-- Checkbox label when selecting a SIM when calling a contact, to use the selected SIM for the
+ same contact and never ask again [CHAR LIMIT=40]-->
+ <string name="pre_call_select_phone_account_remember">Remember this choice</string>
+
+ <!-- Hint text under a SIM when selecting SIM to call, indicating the SIM is on the same carrier
+ as the outgoing call.[CHAR LIMIT=40]-->
+ <string name="pre_call_select_phone_account_hint_intra_carrier">Same carrier</string>
+
+ <!-- Hint text under a SIM when selecting SIM to call, indicating user often use the SIM to call
+ the contact.[CHAR LIMIT=40]-->
+ <string name="pre_call_select_phone_account_hint_frequent">You use often</string>
+
</resources> \ No newline at end of file