use of android.text.style.TtsSpan in project android_frameworks_base by DirtyUnicorns.
the class PhoneNumberUtils method createTtsSpan.
/**
* Create a {@code TtsSpan} for the supplied {@code String}.
*
* @param phoneNumberString A {@code String} the entirety of which represents a phone number.
* @return A {@code TtsSpan} for {@param phoneNumberString}.
*/
public static TtsSpan createTtsSpan(String phoneNumberString) {
if (phoneNumberString == null) {
return null;
}
// Parse the phone number
final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
PhoneNumber phoneNumber = null;
try {
// Don't supply a defaultRegion so this fails for non-international numbers because
// we don't want to TalkBalk to read a country code (e.g. +1) if it is not already
// present
phoneNumber = phoneNumberUtil.parse(phoneNumberString, /* defaultRegion */
null);
} catch (NumberParseException ignored) {
}
// Build a telephone tts span
final TtsSpan.TelephoneBuilder builder = new TtsSpan.TelephoneBuilder();
if (phoneNumber == null) {
// Strip separators otherwise TalkBack will be silent
// (this behavior was observed with TalkBalk 4.0.2 from their alpha channel)
builder.setNumberParts(splitAtNonNumerics(phoneNumberString));
} else {
if (phoneNumber.hasCountryCode()) {
builder.setCountryCode(Integer.toString(phoneNumber.getCountryCode()));
}
builder.setNumberParts(Long.toString(phoneNumber.getNationalNumber()));
}
return builder.build();
}
use of android.text.style.TtsSpan in project android_frameworks_base by crdroidandroid.
the class PhoneNumberUtils method createTtsSpan.
/**
* Create a {@code TtsSpan} for the supplied {@code String}.
*
* @param phoneNumberString A {@code String} the entirety of which represents a phone number.
* @return A {@code TtsSpan} for {@param phoneNumberString}.
*/
public static TtsSpan createTtsSpan(String phoneNumberString) {
if (phoneNumberString == null) {
return null;
}
// Parse the phone number
final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
PhoneNumber phoneNumber = null;
try {
// Don't supply a defaultRegion so this fails for non-international numbers because
// we don't want to TalkBalk to read a country code (e.g. +1) if it is not already
// present
phoneNumber = phoneNumberUtil.parse(phoneNumberString, /* defaultRegion */
null);
} catch (NumberParseException ignored) {
}
// Build a telephone tts span
final TtsSpan.TelephoneBuilder builder = new TtsSpan.TelephoneBuilder();
if (phoneNumber == null) {
// Strip separators otherwise TalkBack will be silent
// (this behavior was observed with TalkBalk 4.0.2 from their alpha channel)
builder.setNumberParts(splitAtNonNumerics(phoneNumberString));
} else {
if (phoneNumber.hasCountryCode()) {
builder.setCountryCode(Integer.toString(phoneNumber.getCountryCode()));
}
builder.setNumberParts(Long.toString(phoneNumber.getNationalNumber()));
}
return builder.build();
}
use of android.text.style.TtsSpan in project platform_frameworks_base by android.
the class PhoneNumberUtils method createTtsSpan.
/**
* Create a {@code TtsSpan} for the supplied {@code String}.
*
* @param phoneNumberString A {@code String} the entirety of which represents a phone number.
* @return A {@code TtsSpan} for {@param phoneNumberString}.
*/
public static TtsSpan createTtsSpan(String phoneNumberString) {
if (phoneNumberString == null) {
return null;
}
// Parse the phone number
final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
PhoneNumber phoneNumber = null;
try {
// Don't supply a defaultRegion so this fails for non-international numbers because
// we don't want to TalkBalk to read a country code (e.g. +1) if it is not already
// present
phoneNumber = phoneNumberUtil.parse(phoneNumberString, /* defaultRegion */
null);
} catch (NumberParseException ignored) {
}
// Build a telephone tts span
final TtsSpan.TelephoneBuilder builder = new TtsSpan.TelephoneBuilder();
if (phoneNumber == null) {
// Strip separators otherwise TalkBack will be silent
// (this behavior was observed with TalkBalk 4.0.2 from their alpha channel)
builder.setNumberParts(splitAtNonNumerics(phoneNumberString));
} else {
if (phoneNumber.hasCountryCode()) {
builder.setCountryCode(Integer.toString(phoneNumber.getCountryCode()));
}
builder.setNumberParts(Long.toString(phoneNumber.getNationalNumber()));
}
return builder.build();
}
use of android.text.style.TtsSpan in project android_frameworks_base by ResurrectionRemix.
the class PhoneNumberUtils method createTtsSpan.
/**
* Create a {@code TtsSpan} for the supplied {@code String}.
*
* @param phoneNumberString A {@code String} the entirety of which represents a phone number.
* @return A {@code TtsSpan} for {@param phoneNumberString}.
*/
public static TtsSpan createTtsSpan(String phoneNumberString) {
if (phoneNumberString == null) {
return null;
}
// Parse the phone number
final PhoneNumberUtil phoneNumberUtil = PhoneNumberUtil.getInstance();
PhoneNumber phoneNumber = null;
try {
// Don't supply a defaultRegion so this fails for non-international numbers because
// we don't want to TalkBalk to read a country code (e.g. +1) if it is not already
// present
phoneNumber = phoneNumberUtil.parse(phoneNumberString, /* defaultRegion */
null);
} catch (NumberParseException ignored) {
}
// Build a telephone tts span
final TtsSpan.TelephoneBuilder builder = new TtsSpan.TelephoneBuilder();
if (phoneNumber == null) {
// Strip separators otherwise TalkBack will be silent
// (this behavior was observed with TalkBalk 4.0.2 from their alpha channel)
builder.setNumberParts(splitAtNonNumerics(phoneNumberString));
} else {
if (phoneNumber.hasCountryCode()) {
builder.setCountryCode(Integer.toString(phoneNumber.getCountryCode()));
}
builder.setNumberParts(Long.toString(phoneNumber.getNationalNumber()));
}
return builder.build();
}
Aggregations