Example usage for android.telephony PhoneNumberUtils WAIT

List of usage examples for android.telephony PhoneNumberUtils WAIT

Introduction

In this page you can find the example usage for android.telephony PhoneNumberUtils WAIT.

Prototype

char WAIT

To view the source code for android.telephony PhoneNumberUtils WAIT.

Click Source Link

Usage

From source file:com.silentcircle.vcard.VCardEntry.java

private void addPhone(int type, String data, String label, boolean isPrimary) {
    if (mPhoneList == null) {
        mPhoneList = new ArrayList<PhoneData>();
    }/*from   w  w w .j  a  v  a  2 s.  c om*/
    final StringBuilder builder = new StringBuilder();
    final String trimmed = data.trim();
    final String formattedNumber;
    if (/* type == Phone.TYPE_PAGER || */VCardConfig.refrainPhoneNumberFormatting(mVCardType)) {
        formattedNumber = trimmed;
    } else {
        // TODO: from the view of vCard spec these auto conversions should be removed.
        // Note that some other codes (like the phone number formatter) or modules expect this
        // auto conversion (bug 5178723), so just omitting this code won't be preferable enough
        // (bug 4177894)
        boolean hasPauseOrWait = false;
        final int length = trimmed.length();
        for (int i = 0; i < length; i++) {
            char ch = trimmed.charAt(i);
            // See RFC 3601 and docs for PhoneNumberUtils for more info.
            if (ch == 'p' || ch == 'P') {
                builder.append(PhoneNumberUtils.PAUSE);
                hasPauseOrWait = true;
            } else if (ch == 'w' || ch == 'W') {
                builder.append(PhoneNumberUtils.WAIT);
                hasPauseOrWait = true;
            } else if (('0' <= ch && ch <= '9') || (i == 0 && ch == '+')) {
                builder.append(ch);
            }
        }
        if (!hasPauseOrWait) {
            final int formattingType = VCardUtils.getPhoneNumberFormat(mVCardType);
            formattedNumber = PhoneNumberUtilsPort.formatNumber(builder.toString(), formattingType);
        } else {
            formattedNumber = builder.toString();
        }
    }
    PhoneData phoneData = new PhoneData(formattedNumber, type, label, isPrimary);
    mPhoneList.add(phoneData);
}