summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/CallDetailActivity.java4
-rw-r--r--src/com/android/dialer/calllog/ContactInfoHelper.java42
2 files changed, 45 insertions, 1 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java
index 05c1e7fdc..d0e18bfcf 100644
--- a/src/com/android/dialer/CallDetailActivity.java
+++ b/src/com/android/dialer/CallDetailActivity.java
@@ -55,6 +55,8 @@ import com.android.contacts.common.ContactPhotoManager;
import com.android.contacts.common.CallUtil;
import com.android.contacts.common.ClipboardUtils;
import com.android.contacts.common.GeoUtil;
+import com.android.contacts.common.util.Constants;
+import com.android.contacts.common.util.UriUtils;
import com.android.dialer.BackScrollManager.ScrollableHeader;
import com.android.dialer.calllog.CallDetailHistoryAdapter;
import com.android.dialer.calllog.CallTypeHelper;
@@ -450,7 +452,7 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
nameOrNumber = firstDetails.number;
}
- if (contactUri != null) {
+ if (contactUri != null && !UriUtils.isEncodedContactUri(contactUri)) {
mainActionIntent = new Intent(Intent.ACTION_VIEW, contactUri);
// This will launch People's detail contact screen, so we probably want to
// treat it as a separate People task.
diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java
index 10412814d..5d7aa1bef 100644
--- a/src/com/android/dialer/calllog/ContactInfoHelper.java
+++ b/src/com/android/dialer/calllog/ContactInfoHelper.java
@@ -19,15 +19,25 @@ package com.android.dialer.calllog;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
+import android.provider.ContactsContract;
+import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
+import android.provider.ContactsContract.Directory;
+import android.provider.ContactsContract.DisplayNameSources;
import android.provider.ContactsContract.PhoneLookup;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
+import android.util.Log;
+import com.android.contacts.common.util.Constants;
import com.android.contacts.common.util.UriUtils;
import com.android.dialer.service.CachedNumberLookupService;
+import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo;
import com.android.dialerbind.ServiceFactory;
+import org.json.JSONException;
+import org.json.JSONObject;
+
/**
* Utility class to look up the contact information for a given number.
*/
@@ -92,6 +102,7 @@ public class ContactInfoHelper {
updatedInfo = new ContactInfo();
updatedInfo.number = number;
updatedInfo.formattedNumber = formatPhoneNumber(number, null, countryIso);
+ updatedInfo.lookupUri = createTemporaryContactUri(number);
} else {
updatedInfo = info;
}
@@ -100,6 +111,37 @@ public class ContactInfoHelper {
}
/**
+ * Creates a JSON-encoded lookup uri for a unknown number without an associated contact
+ *
+ * @param number - Unknown phone number
+ * @return JSON-encoded URI that can be used to perform a lookup when clicking
+ * on the quick contact card.
+ */
+ private static Uri createTemporaryContactUri(String number) {
+ try {
+ final JSONObject contactRows = new JSONObject()
+ .put(Phone.CONTENT_ITEM_TYPE, new JSONObject()
+ .put(Phone.NUMBER, number)
+ .put(Phone.TYPE, Phone.TYPE_CUSTOM));
+
+ final String jsonString = new JSONObject()
+ .put(Contacts.DISPLAY_NAME, number)
+ .put(Contacts.DISPLAY_NAME_SOURCE, DisplayNameSources.PHONE)
+ .put(Contacts.CONTENT_ITEM_TYPE, contactRows)
+ .toString();
+
+ return Contacts.CONTENT_LOOKUP_URI.buildUpon()
+ .appendPath(Constants.LOOKUP_URI_ENCODED)
+ .appendQueryParameter(Constants.LOOKUP_URI_JSON, jsonString)
+ .appendQueryParameter(ContactsContract.DIRECTORY_PARAM_KEY,
+ String.valueOf(Long.MAX_VALUE))
+ .build();
+ } catch (JSONException e) {
+ return null;
+ }
+ }
+
+ /**
* Looks up a contact using the given URI.
* <p>
* It returns null if an error occurs, {@link ContactInfo#EMPTY} if no matching contact is