am 327b11ab: am 7e12aaa7: am dd5c5cf8: Use ALIGN_BOTTOM instead of ALIGN_BASELINE
* commit '327b11abdb95a185b0e39d48a9a315a615d962a1':
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index e159fd2..fd7775d 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,5 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.ex.chips"
android:versionCode="1">
-</manifest>
\ No newline at end of file
+</manifest>
diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml
index 7423ce5..f7884bd 100644
--- a/res/values-ko/strings.xml
+++ b/res/values-ko/strings.xml
@@ -19,5 +19,5 @@
<string name="more_string" msgid="8495478259330621990">"<xliff:g id="COUNT">%1$s</xliff:g>명 이상"</string>
<string name="copy_email" msgid="7869435992461603532">"이메일 주소 복사"</string>
<string name="copy_number" msgid="530057841276106843">"전화번호 복사"</string>
- <string name="done" msgid="2356320650733788862">"Enter 키"</string>
+ <string name="done" msgid="2356320650733788862">"입력"</string>
</resources>
diff --git a/res/values-pt-rPT/strings.xml b/res/values-pt-rPT/strings.xml
index bfbe1ca..fc991b1 100644
--- a/res/values-pt-rPT/strings.xml
+++ b/res/values-pt-rPT/strings.xml
@@ -19,5 +19,5 @@
<string name="more_string" msgid="8495478259330621990">"+<xliff:g id="COUNT">%1$s</xliff:g>"</string>
<string name="copy_email" msgid="7869435992461603532">"Copiar endereço de email"</string>
<string name="copy_number" msgid="530057841276106843">"Copiar número de telefone"</string>
- <string name="done" msgid="2356320650733788862">"Regressar"</string>
+ <string name="done" msgid="2356320650733788862">"Voltar"</string>
</resources>
diff --git a/src/com/android/ex/chips/RecipientEditTextView.java b/src/com/android/ex/chips/RecipientEditTextView.java
index 41bab18..8b6367f 100644
--- a/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/src/com/android/ex/chips/RecipientEditTextView.java
@@ -57,6 +57,7 @@
import android.text.Layout;
import android.text.Spannable;
import android.text.SpannableString;
+import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.TextUtils;
@@ -409,6 +410,44 @@
}
}
+ private int getExcessTopPadding() {
+ if (sExcessTopPadding == -1) {
+ sExcessTopPadding = (int) (mChipHeight + mLineSpacingExtra);
+ }
+ return sExcessTopPadding;
+ }
+
+ public <T extends ListAdapter & Filterable> void setAdapter(T adapter) {
+ super.setAdapter(adapter);
+ ((BaseRecipientAdapter) adapter)
+ .registerUpdateObserver(new BaseRecipientAdapter.EntriesUpdatedObserver() {
+ @Override
+ public void onChanged(List<RecipientEntry> entries) {
+ // Scroll the chips field to the top of the screen so
+ // that the user can see as many results as possible.
+ if (entries != null && entries.size() > 0) {
+ scrollBottomIntoView();
+ }
+ }
+ });
+ }
+
+ private void scrollBottomIntoView() {
+ if (mScrollView != null && mShouldShrink) {
+ int[] location = new int[2];
+ getLocationOnScreen(location);
+ int height = getHeight();
+ int currentPos = location[1] + height;
+ // Desired position shows at least 1 line of chips below the action
+ // bar. We add excess padding to make sure this is always below other
+ // content.
+ int desiredPos = (int) mChipHeight + mActionBarHeight + getExcessTopPadding();
+ if (currentPos > desiredPos) {
+ mScrollView.scrollBy(0, currentPos - desiredPos);
+ }
+ }
+ }
+
@Override
public void performValidation() {
// Do nothing. Chips handles its own validation.
@@ -921,7 +960,7 @@
String token = editable.toString().substring(tokenStart, tokenEnd);
final String trimmedToken = token.trim();
int commitCharIndex = trimmedToken.lastIndexOf(COMMIT_CHAR_COMMA);
- if (commitCharIndex == trimmedToken.length() - 1) {
+ if (commitCharIndex != -1 && commitCharIndex == trimmedToken.length() - 1) {
token = trimmedToken.substring(0, trimmedToken.length() - 1);
}
RecipientEntry entry = createTokenizedEntry(token);
@@ -1600,6 +1639,9 @@
*/
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ if (position < 0) {
+ return;
+ }
submitItemAtPosition(position);
}
@@ -2249,45 +2291,7 @@
}
}
- @Override
- public <T extends ListAdapter & Filterable> void setAdapter(T adapter) {
- super.setAdapter(adapter);
- ((BaseRecipientAdapter) adapter)
- .registerUpdateObserver(new BaseRecipientAdapter.EntriesUpdatedObserver() {
- @Override
- public void onChanged(List<RecipientEntry> entries) {
- if (entries != null && entries.size() > 0) {
- scrollBottomIntoView();
- }
- }
- });
- }
-
- private void scrollBottomIntoView() {
- if (mScrollView != null && mShouldShrink) {
- int[] location = new int[2];
- getLocationOnScreen(location);
- int height = getHeight();
- int currentPos = location[1] + height;
- // Desired position shows at least 1 line of chips below the action
- // bar.
- // We add excess padding to make sure this is always below other
- // content.
- int desiredPos = (int) mChipHeight + mActionBarHeight + getExcessTopPadding();
- if (currentPos > desiredPos) {
- mScrollView.scrollBy(0, currentPos - desiredPos);
- }
- }
- }
-
- private int getExcessTopPadding() {
- if (sExcessTopPadding == -1) {
- sExcessTopPadding = (int) (mChipHeight + mLineSpacingExtra);
- }
- return sExcessTopPadding;
- }
-
- public boolean lastCharacterIsCommitCharacter(CharSequence s) {
+ public boolean lastCharacterIsCommitCharacter(CharSequence s) {
char last;
int end = getSelectionEnd() == 0 ? 0 : getSelectionEnd() - 1;
int len = length() - 1;
@@ -2366,6 +2370,9 @@
prevTokenStart = tokenStart;
tokenStart = mTokenizer.findTokenStart(text, tokenStart);
findChip = findChip(tokenStart);
+ if (tokenStart == originalTokenStart && findChip == null) {
+ break;
+ }
}
if (tokenStart != originalTokenStart) {
if (findChip != null) {
@@ -2542,11 +2549,10 @@
final Runnable runnable = new Runnable() {
@Override
public void run() {
- Editable oldText = getText();
- int start, end;
+ final Editable text = new SpannableStringBuilder(getText());
int i = 0;
- for (DrawableRecipientChip chip : recipients) {
- DrawableRecipientChip replacement = replacements.get(i);
+ for (final DrawableRecipientChip chip : recipients) {
+ final DrawableRecipientChip replacement = replacements.get(i);
if (replacement != null) {
final RecipientEntry oldEntry = chip.getEntry();
final RecipientEntry newEntry = replacement.getEntry();
@@ -2556,25 +2562,24 @@
if (isBetter) {
// Find the location of the chip in the text currently shown.
- start = oldText.getSpanStart(chip);
+ final int start = text.getSpanStart(chip);
if (start != -1) {
// Replacing the entirety of what the chip represented,
// including the extra space dividing it from other chips.
- end = oldText.getSpanEnd(chip) + 1;
- oldText.removeSpan(chip);
+ final int end = text.getSpanEnd(chip) + 1;
+ text.removeSpan(chip);
// Make sure we always have just 1 space at the end to
// separate this chip from the next chip.
- SpannableString displayText =
+ final SpannableString displayText =
new SpannableString(createAddressText(
- replacement.getEntry()).trim()
- + " ");
+ replacement.getEntry()).trim() + " ");
displayText.setSpan(replacement, 0,
displayText.length() - 1,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
// Replace the old text we found with with the new display
// text, which now may also contain the display name of the
// recipient.
- oldText.replace(start, end, displayText);
+ text.replace(start, end, displayText);
replacement.setOriginalText(displayText.toString());
replacements.set(i, null);
@@ -2584,6 +2589,7 @@
}
i++;
}
+ setText(text);
}
};