diff options
author | Andrew Lee <anwlee@google.com> | 2015-05-05 16:29:03 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2015-05-05 17:54:52 -0700 |
commit | 222c96dbbfa184416d459b2661ca89438a0eed85 (patch) | |
tree | 44b4711a74d8f933866a283d39ffab13d2f74258 /src | |
parent | 5e6431ec9df6cb62cab970c0b46618be3570c2f7 (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/list/RegularSearchListAdapter.java | 18 |
1 files changed, 17 insertions, 1 deletions
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; + } } |