From c9ec0e37a3004c5517e133f7a9e44285cc49f57a Mon Sep 17 00:00:00 2001 From: Rohit Yengisetty Date: Tue, 17 May 2016 17:25:47 -0700 Subject: Add location information from contact-info provider Add City and/or Country information to the call, if that information was surfaced by a caller-info provider Change-Id: I58d860f1473430880ada943296108032e2f0c4cd Issue-Id: OPO-712 --- src/com/android/dialer/calllog/ContactInfoHelper.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java index 8b17ece07..0061d3a3d 100644 --- a/src/com/android/dialer/calllog/ContactInfoHelper.java +++ b/src/com/android/dialer/calllog/ContactInfoHelper.java @@ -52,6 +52,8 @@ import com.cyanogen.lookup.phonenumber.response.StatusCode; import org.json.JSONException; import org.json.JSONObject; +import java.util.Locale; + /** * Utility class to look up the contact information for a given number. */ @@ -340,6 +342,21 @@ public class ContactInfoHelper { contactInfo.spamCount = response.mSpamCount; contactInfo.attributionDrawable = response.mAttributionLogo; + StringBuilder succinctLocation = new StringBuilder(); + // convert country code to country name + String country = new Locale("", response.mCountry).getDisplayCountry(); + + if (!TextUtils.isEmpty(response.mCity)) { + succinctLocation.append(response.mCity); + } + if (!TextUtils.isEmpty(country)) { + if (succinctLocation.length() > 0) { + succinctLocation.append(", "); + } + succinctLocation.append(country); + } + contactInfo.label = succinctLocation.toString(); + // construct encoded lookup uri ContactBuilder contactBuilder = new ContactBuilder(ContactBuilder.REVERSE_LOOKUP, response.mNumber, formattedNumber); -- cgit v1.2.3