Format the phone number with the number country's convention.
If the phone number doesn't have country code, the current country's convention will be used. Change-Id: I3f6ea0104d1a67071bd3beadb667c7159e915eef
This commit is contained in:
@@ -70,6 +70,7 @@ public class CallerInfo {
|
||||
*/
|
||||
public String name;
|
||||
public String phoneNumber;
|
||||
public String nomalizedNumber;
|
||||
|
||||
public String cnapName;
|
||||
public int numberPresentation;
|
||||
@@ -150,6 +151,12 @@ public class CallerInfo {
|
||||
info.phoneNumber = cursor.getString(columnIndex);
|
||||
}
|
||||
|
||||
// Look for the normalized number
|
||||
columnIndex = cursor.getColumnIndex(PhoneLookup.NORMALIZED_NUMBER);
|
||||
if (columnIndex != -1) {
|
||||
info.nomalizedNumber = cursor.getString(columnIndex);
|
||||
}
|
||||
|
||||
// Look for the label/type combo
|
||||
columnIndex = cursor.getColumnIndex(PhoneLookup.LABEL);
|
||||
if (columnIndex != -1) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.content.AsyncQueryHandler;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.SQLException;
|
||||
import android.location.CountryDetector;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@@ -229,7 +230,11 @@ public class CallerInfoAsyncQuery {
|
||||
mCallerInfo = CallerInfo.getCallerInfo(mQueryContext, mQueryUri, cursor);
|
||||
// Use the number entered by the user for display.
|
||||
if (!TextUtils.isEmpty(cw.number)) {
|
||||
mCallerInfo.phoneNumber = PhoneNumberUtils.formatNumber(cw.number);
|
||||
CountryDetector detector = (CountryDetector) mQueryContext.getSystemService(
|
||||
Context.COUNTRY_DETECTOR);
|
||||
mCallerInfo.phoneNumber = PhoneNumberUtils.formatNumber(cw.number,
|
||||
mCallerInfo.nomalizedNumber,
|
||||
detector.detectCountry().getCountryIso());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user