/** * Retrieves a string from a string template that takes 1 phone number as argument, * span the number with a telephone {@link TtsSpan}, and return the spanned string. * * @param resources to retrieve the string from * @param stringId ID of the string * @param number to pass in the template * @return CharSequence with the phone number wrapped in a TtsSpan */ public static CharSequence getTtsSpannedPhoneNumber(Resources resources, int stringId, String number){ String msg = resources.getString(stringId, number); return ContactDisplayUtils.getTelephoneTtsSpannable(msg, number); }
/** * Construct the "on {accountLabel} via {viaNumber}" accessibility description for the account * list item, depending on the existence of the accountLabel and viaNumber. * @param viaNumber The number that this call is being placed via. * @param accountLabel The {@link PhoneAccount} label that this call is being placed with. * @return The description of the account that this call has been placed on. */ public static CharSequence createAccountLabelDescription(Resources resources, @Nullable String viaNumber, @Nullable CharSequence accountLabel) { if((!TextUtils.isEmpty(viaNumber)) && !TextUtils.isEmpty(accountLabel)) { String msg = resources.getString(R.string.description_via_number_phone_account, accountLabel, viaNumber); CharSequence accountNumberLabel = ContactDisplayUtils.getTelephoneTtsSpannable(msg, viaNumber); return (accountNumberLabel == null) ? msg : accountNumberLabel; } else if (!TextUtils.isEmpty(viaNumber)) { CharSequence viaNumberLabel = ContactDisplayUtils.getTtsSpannedPhoneNumber(resources, R.string.description_via_number, viaNumber); return (viaNumberLabel == null) ? viaNumber : viaNumberLabel; } else if (!TextUtils.isEmpty(accountLabel)) { return TextUtils.expandTemplate( resources.getString(R.string.description_phone_account), accountLabel); } return ""; } }