1/* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.contacts.common.compat; 18 19import android.telephony.PhoneNumberUtils; 20import android.text.style.TtsSpan; 21 22/** 23 * This class contains static utility methods extracted from PhoneNumberUtils, and the methods were 24 * added in API level 23. In this way, we could enable the corresponding functionality for pre-M 25 * devices. We need maintain this class and keep it synced with PhoneNumberUtils. Another thing to 26 * keep in mind is that we use com.google.i18n rather than com.android.i18n in here, so we need make 27 * sure the application behavior is preserved. 28 */ 29public class PhoneNumberUtilsCompat { 30 31 /** Not instantiable. */ 32 private PhoneNumberUtilsCompat() {} 33 34 public static String formatNumber( 35 String phoneNumber, String phoneNumberE164, String defaultCountryIso) { 36 return PhoneNumberUtils.formatNumber(phoneNumber, phoneNumberE164, defaultCountryIso); 37 } 38 39 public static CharSequence createTtsSpannable(CharSequence phoneNumber) { 40 return PhoneNumberUtils.createTtsSpannable(phoneNumber); 41 } 42 43 public static TtsSpan createTtsSpan(String phoneNumber) { 44 return PhoneNumberUtils.createTtsSpan(phoneNumber); 45 } 46} 47