summaryrefslogtreecommitdiffstats
path: root/chips
diff options
context:
space:
mode:
authorTom Taylor <tomtaylor@google.com>2012-05-03 15:21:08 -0700
committerTom Taylor <tomtaylor@google.com>2012-05-03 15:21:08 -0700
commit577223c7c81bd5fe0c00a1b8eeeecd50f61369a8 (patch)
tree6337f58db650d473c9f7e6a448ee0a0b0142cb23 /chips
parentf64cbf19fb2bc09835a46472c8efd8c6c07fa5ab (diff)
downloadandroid_frameworks_ex-577223c7c81bd5fe0c00a1b8eeeecd50f61369a8.tar.gz
android_frameworks_ex-577223c7c81bd5fe0c00a1b8eeeecd50f61369a8.tar.bz2
android_frameworks_ex-577223c7c81bd5fe0c00a1b8eeeecd50f61369a8.zip
Don't autoselect first item in dropdown
Bug 6434183 When in phone mode and the user types something that happens to bring up the dropdown, don't auto-select the first item if they don't choose something. This was preventing users from entering numbers and shortcuts that happened to be close matches to existing contacts. Unless the user selects an item, keep what they manually entered. The change looks much bigger than is really is. The only real change is in commitChip. The rest of the changes are to call a helper function, rather than duplicating the same code throughout the file. Change-Id: Ia0ec24a3667770fa5d43ff870ed87019b732627e
Diffstat (limited to 'chips')
-rw-r--r--chips/src/com/android/ex/chips/RecipientEditTextView.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java
index eb8c639..fc725f5 100644
--- a/chips/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java
@@ -906,8 +906,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
if (TextUtils.isEmpty(token)) {
return null;
}
- if (((BaseRecipientAdapter)getAdapter()).getQueryType() ==
- BaseRecipientAdapter.QUERY_TYPE_PHONE && isPhoneNumber(token)) {
+ if (isPhoneQuery() && isPhoneNumber(token)) {
return RecipientEntry
.constructFakeEntry(token);
}
@@ -1093,7 +1092,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
private boolean commitChip(int start, int end, Editable editable) {
ListAdapter adapter = getAdapter();
if (adapter != null && adapter.getCount() > 0 && enoughToFilter()
- && end == getSelectionEnd()) {
+ && end == getSelectionEnd() && !isPhoneQuery()) {
// choose the first entry.
submitItemAtPosition(0);
dismissDropDown();
@@ -1451,8 +1450,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
display = null;
}
String trimmedDisplayText;
- if (((BaseRecipientAdapter)getAdapter()).getQueryType() ==
- BaseRecipientAdapter.QUERY_TYPE_PHONE && isPhoneNumber(address)) {
+ if (isPhoneQuery() && isPhoneNumber(address)) {
trimmedDisplayText = address.trim();
} else {
if (address != null) {
@@ -1480,8 +1478,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
if (TextUtils.isEmpty(display) || TextUtils.equals(display, address)) {
display = null;
}
- if (address != null && !(((BaseRecipientAdapter)getAdapter()).getQueryType() ==
- BaseRecipientAdapter.QUERY_TYPE_PHONE && isPhoneNumber(address))) {
+ if (address != null && !(isPhoneQuery() && isPhoneNumber(address))) {
// Tokenize out the address in case the address already
// contained the username as well.
Rfc822Token[] tokenized = Rfc822Tokenizer.tokenize(address);
@@ -2490,8 +2487,7 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
Button button = (Button)mCopyDialog.findViewById(android.R.id.button1);
button.setOnClickListener(this);
int btnTitleId;
- if (((BaseRecipientAdapter)getAdapter()).getQueryType() ==
- BaseRecipientAdapter.QUERY_TYPE_PHONE) {
+ if (isPhoneQuery()) {
btnTitleId = R.string.copy_number;
} else {
btnTitleId = R.string.copy_email;
@@ -2532,4 +2528,9 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
clipboard.setPrimaryClip(ClipData.newPlainText("", mCopyAddress));
mCopyDialog.dismiss();
}
+
+ protected boolean isPhoneQuery() {
+ return ((BaseRecipientAdapter)getAdapter()).getQueryType() ==
+ BaseRecipientAdapter.QUERY_TYPE_PHONE;
+ }
}