Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 829fd682 authored by Rohit Yengisetty's avatar Rohit Yengisetty
Browse files

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
(cherry picked from commit c9ec0e37)
parent b7703a96
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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.
 */
@@ -339,6 +341,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);