From 71cd19439ef7664b39833da69ce038185ae9ee26 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Fri, 24 Apr 2015 17:16:06 -0700 Subject: Allow dialing SIP calls directly from search Bug: 20554942 Change-Id: I47daa3491223aed7e988e7d81501a281f1566f1c --- .../android/dialer/list/RegularSearchListAdapter.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/com/android/dialer/list/RegularSearchListAdapter.java b/src/com/android/dialer/list/RegularSearchListAdapter.java index 6c7045814..2be8a1dd7 100644 --- a/src/com/android/dialer/list/RegularSearchListAdapter.java +++ b/src/com/android/dialer/list/RegularSearchListAdapter.java @@ -22,6 +22,7 @@ import android.text.TextUtils; import com.android.contacts.common.CallUtil; import com.android.contacts.common.list.DirectoryPartition; +import com.android.contacts.common.util.PhoneNumberHelper; import com.android.dialer.calllog.ContactInfo; import com.android.dialer.service.CachedNumberLookupService; import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo; @@ -30,6 +31,7 @@ import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo; * List adapter to display regular search results. */ public class RegularSearchListAdapter extends DialerPhoneNumberListAdapter { + private boolean mIsQuerySipAddress; public RegularSearchListAdapter(Context context) { super(context); @@ -66,13 +68,25 @@ public class RegularSearchListAdapter extends DialerPhoneNumberListAdapter { return cacheInfo; } + @Override + public String getFormattedQueryString() { + if (mIsQuerySipAddress) { + // Return unnormalized SIP address + return getQueryString(); + } + return super.getFormattedQueryString(); + } + @Override public void setQueryString(String queryString) { // Don't show actions if the query string contains a letter. final boolean showNumberShortcuts = !TextUtils.isEmpty(getFormattedQueryString()) && hasDigitsInQueryString(); + // Email addresses that could be SIP addresses are an exception. + mIsQuerySipAddress = PhoneNumberHelper.isUriNumber(queryString); boolean changed = false; - changed |= setShortcutEnabled(SHORTCUT_DIRECT_CALL, showNumberShortcuts); + changed |= setShortcutEnabled(SHORTCUT_DIRECT_CALL, + showNumberShortcuts || mIsQuerySipAddress); changed |= setShortcutEnabled(SHORTCUT_SEND_SMS_MESSAGE, showNumberShortcuts); changed |= setShortcutEnabled(SHORTCUT_MAKE_VIDEO_CALL, showNumberShortcuts && CallUtil.isVideoEnabled(getContext())); -- cgit v1.2.3