use of com.android.dialer.lookup.ContactBuilder in project android_packages_apps_Dialer by LineageOS.
the class ZabaSearchReverseLookup method lookupNumber.
/**
* Perform phone number lookup.
*
* @param context The application context
* @param normalizedNumber The normalized phone number
* @param formattedNumber The formatted phone number
* @return The phone number info object
*/
public ContactInfo lookupNumber(Context context, String normalizedNumber, String formattedNumber) throws IOException {
ZabaSearchApi zsa = new ZabaSearchApi(normalizedNumber);
ZabaSearchApi.ContactInfo info = zsa.getContactInfo();
if (info.name == null) {
return null;
}
ContactBuilder builder = new ContactBuilder(ContactBuilder.REVERSE_LOOKUP, normalizedNumber, formattedNumber);
builder.setName(ContactBuilder.Name.createDisplayName(info.name));
builder.addPhoneNumber(ContactBuilder.PhoneNumber.createMainNumber(info.formattedNumber));
builder.addWebsite(ContactBuilder.WebsiteUrl.createProfile(info.website));
if (info.address != null) {
builder.addAddress(ContactBuilder.Address.createFormattedHome(info.address));
}
return builder.build();
}
use of com.android.dialer.lookup.ContactBuilder in project android_packages_apps_Dialer by MoKee.
the class CyngnChineseReverseLookup method lookupNumber.
/**
* Perform phone number lookup.
*
* @param context The application context
* @param normalizedNumber The normalized phone number
* @param formattedNumber The formatted phone number
* @return The phone number info object
*/
public ContactInfo lookupNumber(Context context, String normalizedNumber, String formattedNumber) {
String displayName = queryProvider(context, normalizedNumber);
if (displayName == null) {
return null;
}
if (DEBUG)
Log.d(TAG, "Reverse lookup returned name: " + displayName);
String number = formattedNumber != null ? formattedNumber : normalizedNumber;
ContactBuilder builder = new ContactBuilder(ContactBuilder.REVERSE_LOOKUP, normalizedNumber, formattedNumber);
builder.setName(ContactBuilder.Name.createDisplayName(displayName));
builder.addPhoneNumber(ContactBuilder.PhoneNumber.createMainNumber(number));
builder.setPhotoUri(ContactBuilder.PHOTO_URI_BUSINESS);
return builder.build();
}
use of com.android.dialer.lookup.ContactBuilder in project android_packages_apps_Dialer by MoKee.
the class TelefonbuchReverseLookup method lookupNumber.
/**
* Perform phone number lookup.
*
* @param context The application context
* @param normalizedNumber The normalized phone number
* @param formattedNumber The formatted phone number
* @return The phone number info object
*/
public ContactInfo lookupNumber(Context context, String normalizedNumber, String formattedNumber) throws IOException {
if (normalizedNumber.startsWith("+") && !normalizedNumber.startsWith("+49")) {
// Das Telefonbuch only supports German numbers
return null;
}
TelefonbuchApi.ContactInfo info = TelefonbuchApi.reverseLookup(context, normalizedNumber);
if (info == null) {
return null;
}
ContactBuilder builder = new ContactBuilder(ContactBuilder.REVERSE_LOOKUP, normalizedNumber, formattedNumber);
builder.setName(ContactBuilder.Name.createDisplayName(info.name));
builder.addPhoneNumber(ContactBuilder.PhoneNumber.createMainNumber(info.formattedNumber));
builder.addWebsite(ContactBuilder.WebsiteUrl.createProfile(info.website));
if (info.address != null) {
builder.addAddress(ContactBuilder.Address.createFormattedHome(info.address));
}
return builder.build();
}
use of com.android.dialer.lookup.ContactBuilder in project android_packages_apps_Dialer by MoKee.
the class OpenCnamReverseLookup method lookupNumber.
/**
* Perform phone number lookup.
*
* @param context The application context
* @param normalizedNumber The normalized phone number
* @param formattedNumber The formatted phone number
* @return The phone number info object
*/
public ContactInfo lookupNumber(Context context, String normalizedNumber, String formattedNumber) throws IOException {
if (normalizedNumber.startsWith("+") && !normalizedNumber.startsWith("+1")) {
// Any non-US number will return "We currently accept only US numbers"
return null;
}
String displayName = httpGetRequest(context, normalizedNumber);
if (DEBUG)
Log.d(TAG, "Reverse lookup returned name: " + displayName);
if (displayName.contains("Hobbyist Tier")) {
return null;
}
String number = formattedNumber != null ? formattedNumber : normalizedNumber;
ContactBuilder builder = new ContactBuilder(ContactBuilder.REVERSE_LOOKUP, normalizedNumber, formattedNumber);
builder.setName(ContactBuilder.Name.createDisplayName(displayName));
builder.addPhoneNumber(ContactBuilder.PhoneNumber.createMainNumber(number));
builder.setPhotoUri(ContactBuilder.PHOTO_URI_BUSINESS);
return builder.build();
}
use of com.android.dialer.lookup.ContactBuilder in project android_packages_apps_Dialer by MoKee.
the class YellowPagesReverseLookup method lookupNumber.
/**
* Perform phone number lookup.
*
* @param context The application context
* @param normalizedNumber The normalized phone number
* @param formattedNumber The formatted phone number
* @return The phone number info object
*/
public ContactInfo lookupNumber(Context context, String normalizedNumber, String formattedNumber) throws IOException {
YellowPagesApi ypa = new YellowPagesApi(context, normalizedNumber);
YellowPagesApi.ContactInfo info = ypa.getContactInfo();
if (info.name == null) {
return null;
}
ContactBuilder builder = new ContactBuilder(ContactBuilder.REVERSE_LOOKUP, normalizedNumber, formattedNumber);
builder.setName(ContactBuilder.Name.createDisplayName(info.name));
builder.addPhoneNumber(ContactBuilder.PhoneNumber.createMainNumber(info.formattedNumber));
builder.addWebsite(ContactBuilder.WebsiteUrl.createProfile(info.website));
if (info.address != null) {
ContactBuilder.Address a = new ContactBuilder.Address();
a.formattedAddress = info.address;
a.type = StructuredPostal.TYPE_WORK;
builder.addAddress(a);
}
if (info.photoUrl != null) {
builder.setPhotoUri(info.photoUrl);
} else {
builder.setPhotoUri(ContactBuilder.PHOTO_URI_BUSINESS);
}
return builder.build();
}
Aggregations