summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2014-04-11 18:32:08 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-04-11 18:32:08 +0000
commit09a727e47df21d00a2e6cd814f4a4bc895155047 (patch)
tree7b3f16f6ae96cac14bdc4d7f89b790680a118018
parent047bdb14e953c73d2594ea20b1f150221e965d66 (diff)
parent466358780c0bd5cbb2c2300c321e94e60372b5e1 (diff)
Merge "Use the unnormalized user-entered number when adding to contacts"
-rw-r--r--src/com/android/dialer/DialtactsActivity.java3
-rw-r--r--src/com/android/dialer/list/SearchFragment.java31
2 files changed, 19 insertions, 15 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index efa5896f9..afc1b4425 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -888,6 +888,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
@Override
public void onDialpadQueryChanged(String query) {
+ if (mSmartDialSearchFragment != null) {
+ mSmartDialSearchFragment.setAddToContactNumber(query);
+ }
final String normalizedQuery = SmartDialNameMatcher.normalizeNumber(query,
SmartDialNameMatcher.LATIN_SMART_DIAL_MAP);
if (!TextUtils.equals(mSearchView.getText(), normalizedQuery)) {
diff --git a/src/com/android/dialer/list/SearchFragment.java b/src/com/android/dialer/list/SearchFragment.java
index 006729b93..209cdf808 100644
--- a/src/com/android/dialer/list/SearchFragment.java
+++ b/src/com/android/dialer/list/SearchFragment.java
@@ -16,11 +16,10 @@
package com.android.dialer.list;
import android.app.Activity;
-import android.content.ActivityNotFoundException;
import android.content.Intent;
+import android.text.TextUtils;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
-import android.widget.Toast;
import com.android.contacts.common.list.ContactEntryListAdapter;
import com.android.contacts.common.list.ContactListItemView;
@@ -28,13 +27,19 @@ import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
import com.android.contacts.common.list.PhoneNumberPickerFragment;
import com.android.dialer.DialtactsActivity;
import com.android.dialer.R;
-import com.android.dialer.dialpad.DialpadFragment;
import com.android.dialer.list.OnListFragmentScrolledListener;
+import com.android.dialer.util.DialerUtils;
public class SearchFragment extends PhoneNumberPickerFragment {
private OnListFragmentScrolledListener mActivityScrollListener;
+ /*
+ * Stores the untouched user-entered string that is used to populate the add to contacts
+ * intent.
+ */
+ private String mAddToContactNumber;
+
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
@@ -81,6 +86,10 @@ public class SearchFragment extends PhoneNumberPickerFragment {
}
}
+ public void setAddToContactNumber(String addToContactNumber) {
+ mAddToContactNumber = addToContactNumber;
+ }
+
@Override
protected ContactEntryListAdapter createListAdapter() {
DialerPhoneNumberListAdapter adapter = new DialerPhoneNumberListAdapter(getActivity());
@@ -103,19 +112,11 @@ public class SearchFragment extends PhoneNumberPickerFragment {
listener.onCallNumberDirectly(getQueryString());
}
} else if (shortcutType == DialerPhoneNumberListAdapter.SHORTCUT_ADD_NUMBER_TO_CONTACTS) {
- final String number = adapter.getFormattedQueryString();
+ final String number = TextUtils.isEmpty(mAddToContactNumber) ?
+ adapter.getFormattedQueryString() : mAddToContactNumber;
final Intent intent = DialtactsActivity.getAddNumberToContactIntent(number);
- startActivityWithErrorToast(intent);
- }
- }
-
- private void startActivityWithErrorToast(Intent intent) {
- try {
- startActivity(intent);
- } catch (ActivityNotFoundException e) {
- Toast toast = Toast.makeText(getActivity(), R.string.add_contact_not_available,
- Toast.LENGTH_SHORT);
- toast.show();
+ DialerUtils.startActivityWithErrorToast(getActivity(), intent,
+ R.string.add_contact_not_available);
}
}
}