From 604d48099cd8e0bcf2f992237082600837630038 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Thu, 19 Sep 2013 17:44:12 -0700 Subject: Ignore separators when typing in Dialer search box Bug: 10842248 Change-Id: Id0c65385af4277120ba6a57c357b980caec149c2 --- .../dialer/list/DialerPhoneNumberListAdapter.java | 24 +++------------------- .../dialer/list/RegularSearchListAdapter.java | 1 - src/com/android/dialer/list/SearchFragment.java | 4 ---- .../dialer/list/SmartDialSearchFragment.java | 2 -- 4 files changed, 3 insertions(+), 28 deletions(-) diff --git a/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java b/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java index e9117107e..4f3a4dabf 100644 --- a/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java +++ b/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java @@ -3,7 +3,6 @@ package com.android.dialer.list; import android.content.Context; import android.content.res.Resources; import android.telephony.PhoneNumberUtils; -import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; @@ -29,9 +28,8 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { public final static int SHORTCUT_INVALID = -1; public final static int SHORTCUT_DIRECT_CALL = 0; public final static int SHORTCUT_ADD_NUMBER_TO_CONTACTS = 1; - public final static int SHORTCUT_ADD_NEW_NAMED_CONTACT = 2; - public final static int SHORTCUT_COUNT = 3; + public final static int SHORTCUT_COUNT = 2; private final boolean[] mShortcutEnabled = new boolean[SHORTCUT_COUNT]; @@ -147,10 +145,6 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { text = resources.getString(R.string.search_shortcut_add_to_contacts); drawableId = R.drawable.ic_add_person_dk; break; - case SHORTCUT_ADD_NEW_NAMED_CONTACT: - text = resources.getString(R.string.search_shortcut_add_to_contacts); - drawableId = R.drawable.ic_add_person_dk; - break; default: throw new IllegalArgumentException("Invalid shortcut type"); } @@ -169,20 +163,8 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { @Override public void setQueryString(String queryString) { - boolean containsNonDialableCharacters = false; - for (int i = 0; i < queryString.length(); i++) { - if (!PhoneNumberUtils.isDialable(queryString.charAt(i))) { - containsNonDialableCharacters = true; - break; - } - } - - if (containsNonDialableCharacters) { - mFormattedQueryString = null; - } else { - mFormattedQueryString = PhoneNumberUtils.formatNumber(queryString, mCountryIso); - } - + mFormattedQueryString = PhoneNumberUtils.formatNumber( + PhoneNumberUtils.convertAndStrip(queryString), mCountryIso); super.setQueryString(queryString); } } diff --git a/src/com/android/dialer/list/RegularSearchListAdapter.java b/src/com/android/dialer/list/RegularSearchListAdapter.java index 58779124e..05af3c7ff 100644 --- a/src/com/android/dialer/list/RegularSearchListAdapter.java +++ b/src/com/android/dialer/list/RegularSearchListAdapter.java @@ -67,7 +67,6 @@ public class RegularSearchListAdapter extends DialerPhoneNumberListAdapter { // a dialable number, then clicking add to contact should add it as a number. // Otherwise, it should add it to a new contact as a name. setShortcutEnabled(SHORTCUT_ADD_NUMBER_TO_CONTACTS, showNumberShortcuts); - setShortcutEnabled(SHORTCUT_ADD_NEW_NAMED_CONTACT, !showNumberShortcuts); super.setQueryString(queryString); } } diff --git a/src/com/android/dialer/list/SearchFragment.java b/src/com/android/dialer/list/SearchFragment.java index 0302d9724..006729b93 100644 --- a/src/com/android/dialer/list/SearchFragment.java +++ b/src/com/android/dialer/list/SearchFragment.java @@ -106,10 +106,6 @@ public class SearchFragment extends PhoneNumberPickerFragment { final String number = adapter.getFormattedQueryString(); final Intent intent = DialtactsActivity.getAddNumberToContactIntent(number); startActivityWithErrorToast(intent); - } else if (shortcutType == DialerPhoneNumberListAdapter.SHORTCUT_ADD_NEW_NAMED_CONTACT) { - final String name = adapter.getQueryString(); - final Intent intent = DialtactsActivity.getInsertContactWithNameIntent(name); - startActivityWithErrorToast(intent); } } diff --git a/src/com/android/dialer/list/SmartDialSearchFragment.java b/src/com/android/dialer/list/SmartDialSearchFragment.java index 4248c85fb..0efe9186b 100644 --- a/src/com/android/dialer/list/SmartDialSearchFragment.java +++ b/src/com/android/dialer/list/SmartDialSearchFragment.java @@ -41,8 +41,6 @@ public class SmartDialSearchFragment extends SearchFragment { // Disable the direct call shortcut for the smart dial fragment, since the call button // will already be showing anyway. adapter.setShortcutEnabled(SmartDialNumberListAdapter.SHORTCUT_DIRECT_CALL, false); - adapter.setShortcutEnabled(SmartDialNumberListAdapter.SHORTCUT_ADD_NEW_NAMED_CONTACT, - false); return adapter; } -- cgit v1.2.3