From 222c96dbbfa184416d459b2661ca89438a0eed85 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Tue, 5 May 2015 16:29:03 -0700 Subject: Shown actions for queries with at least one digit. It can be confusing to show the "smartdial" string converting chars to digits, so only show the actions in a potential vanity-scenario. Bug: 20699894 Change-Id: I4df5e94841c519cc591d1d5333d48efa739124e7 --- .../android/dialer/list/RegularSearchListAdapter.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/com/android/dialer') diff --git a/src/com/android/dialer/list/RegularSearchListAdapter.java b/src/com/android/dialer/list/RegularSearchListAdapter.java index 3c55bc012..6c7045814 100644 --- a/src/com/android/dialer/list/RegularSearchListAdapter.java +++ b/src/com/android/dialer/list/RegularSearchListAdapter.java @@ -68,7 +68,9 @@ public class RegularSearchListAdapter extends DialerPhoneNumberListAdapter { @Override public void setQueryString(String queryString) { - final boolean showNumberShortcuts = !TextUtils.isEmpty(getFormattedQueryString()); + // Don't show actions if the query string contains a letter. + final boolean showNumberShortcuts = !TextUtils.isEmpty(getFormattedQueryString()) + && hasDigitsInQueryString(); boolean changed = false; changed |= setShortcutEnabled(SHORTCUT_DIRECT_CALL, showNumberShortcuts); changed |= setShortcutEnabled(SHORTCUT_SEND_SMS_MESSAGE, showNumberShortcuts); @@ -79,4 +81,18 @@ public class RegularSearchListAdapter extends DialerPhoneNumberListAdapter { } super.setQueryString(queryString); } + + /** + * Whether there is at least one digit in the query string. + */ + private boolean hasDigitsInQueryString() { + String queryString = getQueryString(); + int length = queryString.length(); + for (int i = 0; i < length; i++) { + if (Character.isDigit(queryString.charAt(i))) { + return true; + } + } + return false; + } } -- cgit v1.2.3