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

Commit 222c96db authored by Andrew Lee's avatar Andrew Lee
Browse files

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
parent 5e6431ec
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -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;
    }
}