Loading api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -941,6 +941,7 @@ package android { field public static final int tension = 16843370; // 0x101026a field public static final int testOnly = 16843378; // 0x1010272 field public static final int text = 16843087; // 0x101014f field public static final int textAllCaps = 16843680; // 0x10103a0 field public static final int textAppearance = 16842804; // 0x1010034 field public static final int textAppearanceButton = 16843271; // 0x1010207 field public static final int textAppearanceInverse = 16842805; // 0x1010035 Loading Loading @@ -26151,6 +26152,7 @@ package android.widget { method public boolean onTextContextMenuItem(int); method public void removeTextChangedListener(android.text.TextWatcher); method protected void resetLayoutDirectionResolution(); method public void setAllCaps(boolean); method public final void setAutoLinkMask(int); method public void setCompoundDrawablePadding(int); method public void setCompoundDrawables(android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable); core/java/android/text/method/AllCapsTransformationMethod.java 0 → 100644 +59 −0 Original line number Diff line number Diff line /* * 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. */ package android.text.method; import android.content.Context; import android.graphics.Rect; import android.util.Log; import android.view.View; import java.util.Locale; /** * Transforms source text into an ALL CAPS string, locale-aware. * * @hide */ public class AllCapsTransformationMethod implements TransformationMethod2 { private static final String TAG = "AllCapsTransformationMethod"; private boolean mEnabled; private Locale mLocale; public AllCapsTransformationMethod(Context context) { mLocale = context.getResources().getConfiguration().locale; } @Override public CharSequence getTransformation(CharSequence source, View view) { if (mEnabled) { return source != null ? source.toString().toUpperCase(mLocale) : null; } Log.w(TAG, "Caller did not enable length changes; not transforming text"); return source; } @Override public void onFocusChanged(View view, CharSequence sourceText, boolean focused, int direction, Rect previouslyFocusedRect) { } @Override public void setLengthChangesAllowed(boolean allowLengthChanges) { mEnabled = allowLengthChanges; } } core/java/android/text/method/TransformationMethod2.java 0 → 100644 +33 −0 Original line number Diff line number Diff line /* * 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. */ package android.text.method; /** * TransformationMethod2 extends the TransformationMethod interface * and adds the ability to relax restrictions of TransformationMethod. * * @hide */ public interface TransformationMethod2 extends TransformationMethod { /** * Relax the contract of TransformationMethod to allow length changes, * or revert to the length-restricted behavior. * * @param allowLengthChanges true to allow the transformation to change the length * of the input string. */ public void setLengthChangesAllowed(boolean allowLengthChanges); } core/java/android/widget/TextView.java +58 −9 Original line number Diff line number Diff line Loading @@ -16,6 +16,11 @@ package android.widget; import com.android.internal.util.FastMath; import com.android.internal.widget.EditableInputConnection; import org.xmlpull.v1.XmlPullParserException; import android.R; import android.content.ClipData; import android.content.ClipData.Item; Loading Loading @@ -62,6 +67,7 @@ import android.text.StaticLayout; import android.text.TextPaint; import android.text.TextUtils; import android.text.TextWatcher; import android.text.method.AllCapsTransformationMethod; import android.text.method.ArrowKeyMovementMethod; import android.text.method.DateKeyListener; import android.text.method.DateTimeKeyListener; Loading @@ -76,6 +82,7 @@ import android.text.method.SingleLineTransformationMethod; import android.text.method.TextKeyListener; import android.text.method.TimeKeyListener; import android.text.method.TransformationMethod; import android.text.method.TransformationMethod2; import android.text.method.WordIterator; import android.text.style.ClickableSpan; import android.text.style.ParagraphStyle; Loading Loading @@ -125,11 +132,6 @@ import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; import android.widget.RemoteViews.RemoteView; import com.android.internal.util.FastMath; import com.android.internal.widget.EditableInputConnection; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import java.lang.ref.WeakReference; import java.text.BreakIterator; Loading Loading @@ -424,6 +426,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener int textSize = 15; int typefaceIndex = -1; int styleIndex = -1; boolean allCaps = false; /* * Look the appearance up without checking first if it exists because Loading Loading @@ -471,6 +474,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener case com.android.internal.R.styleable.TextAppearance_textStyle: styleIndex = appearance.getInt(attr, -1); break; case com.android.internal.R.styleable.TextAppearance_textAllCaps: allCaps = appearance.getBoolean(attr, false); break; } } Loading Loading @@ -822,6 +829,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener case com.android.internal.R.styleable.TextView_suggestionsEnabled: mSuggestionsEnabled = a.getBoolean(attr, true); break; case com.android.internal.R.styleable.TextView_textAllCaps: allCaps = a.getBoolean(attr, false); break; } } a.recycle(); Loading Loading @@ -1004,6 +1015,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } setRawTextSize(textSize); if (allCaps) { setTransformationMethod(new AllCapsTransformationMethod(getContext())); } if (password || passwordInputType || webPasswordInputType || numberPasswordInputType) { setTransformationMethod(PasswordTransformationMethod.getInstance()); typefaceIndex = MONOSPACE; Loading Loading @@ -1331,6 +1346,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mTransformation = method; if (method instanceof TransformationMethod2) { TransformationMethod2 method2 = (TransformationMethod2) method; mAllowTransformationLengthChange = !mTextIsSelectable && !(mText instanceof Editable); method2.setLengthChangesAllowed(mAllowTransformationLengthChange); } else { mAllowTransformationLengthChange = false; } setText(mText); } Loading Loading @@ -1775,6 +1798,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener setTypefaceByIndex(typefaceIndex, styleIndex); if (appearance.getBoolean(com.android.internal.R.styleable.TextAppearance_textAllCaps, false)) { setTransformationMethod(new AllCapsTransformationMethod(getContext())); } appearance.recycle(); } Loading Loading @@ -2823,14 +2851,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mBufferType = type; mText = text; if (mTransformation == null) if (mTransformation == null) { mTransformed = text; else } else { mTransformed = mTransformation.getTransformation(text, this); } final int textLength = text.length(); if (text instanceof Spannable) { if (text instanceof Spannable && !mAllowTransformationLengthChange) { Spannable sp = (Spannable) text; // Remove any ChangeWatchers that might have come Loading @@ -2852,7 +2881,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (mTransformation != null) { sp.setSpan(mTransformation, 0, textLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE); } if (mMovement != null) { Loading Loading @@ -6569,6 +6597,26 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener setSingleLine(true); } /** * Sets the properties of this field to transform input to ALL CAPS * display. This may use a "small caps" formatting if available. * This setting will be ignored if this field is editable or selectable. * * This call replaces the current transformation method. Disabling this * will not necessarily restore the previous behavior from before this * was enabled. * * @see #setTransformationMethod(TransformationMethod) * @attr ref android.R.styleable#TextView_textAllCaps */ public void setAllCaps(boolean allCaps) { if (allCaps) { setTransformationMethod(new AllCapsTransformationMethod(getContext())); } else { setTransformationMethod(null); } } /** * If true, sets the properties of this field (number of lines, horizontally scrolling, * transformation method) to be for a single-line input; if false, restores these to the default Loading Loading @@ -10254,6 +10302,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener private MovementMethod mMovement; private TransformationMethod mTransformation; private boolean mAllowTransformationLengthChange; private ChangeWatcher mChangeWatcher; private ArrayList<TextWatcher> mListeners = null; Loading core/java/com/android/internal/view/menu/ActionMenuItemView.java +1 −6 Original line number Diff line number Diff line Loading @@ -154,12 +154,7 @@ public class ActionMenuItemView extends LinearLayout // populate accessibility description with title setContentDescription(title); if (mShowTextAllCaps && title != null) { mTextButton.setText(title.toString().toUpperCase( getContext().getResources().getConfiguration().locale)); } else { mTextButton.setText(mTitle); } updateTextButtonVisibility(); } Loading Loading
api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -941,6 +941,7 @@ package android { field public static final int tension = 16843370; // 0x101026a field public static final int testOnly = 16843378; // 0x1010272 field public static final int text = 16843087; // 0x101014f field public static final int textAllCaps = 16843680; // 0x10103a0 field public static final int textAppearance = 16842804; // 0x1010034 field public static final int textAppearanceButton = 16843271; // 0x1010207 field public static final int textAppearanceInverse = 16842805; // 0x1010035 Loading Loading @@ -26151,6 +26152,7 @@ package android.widget { method public boolean onTextContextMenuItem(int); method public void removeTextChangedListener(android.text.TextWatcher); method protected void resetLayoutDirectionResolution(); method public void setAllCaps(boolean); method public final void setAutoLinkMask(int); method public void setCompoundDrawablePadding(int); method public void setCompoundDrawables(android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable, android.graphics.drawable.Drawable);
core/java/android/text/method/AllCapsTransformationMethod.java 0 → 100644 +59 −0 Original line number Diff line number Diff line /* * 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. */ package android.text.method; import android.content.Context; import android.graphics.Rect; import android.util.Log; import android.view.View; import java.util.Locale; /** * Transforms source text into an ALL CAPS string, locale-aware. * * @hide */ public class AllCapsTransformationMethod implements TransformationMethod2 { private static final String TAG = "AllCapsTransformationMethod"; private boolean mEnabled; private Locale mLocale; public AllCapsTransformationMethod(Context context) { mLocale = context.getResources().getConfiguration().locale; } @Override public CharSequence getTransformation(CharSequence source, View view) { if (mEnabled) { return source != null ? source.toString().toUpperCase(mLocale) : null; } Log.w(TAG, "Caller did not enable length changes; not transforming text"); return source; } @Override public void onFocusChanged(View view, CharSequence sourceText, boolean focused, int direction, Rect previouslyFocusedRect) { } @Override public void setLengthChangesAllowed(boolean allowLengthChanges) { mEnabled = allowLengthChanges; } }
core/java/android/text/method/TransformationMethod2.java 0 → 100644 +33 −0 Original line number Diff line number Diff line /* * 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. */ package android.text.method; /** * TransformationMethod2 extends the TransformationMethod interface * and adds the ability to relax restrictions of TransformationMethod. * * @hide */ public interface TransformationMethod2 extends TransformationMethod { /** * Relax the contract of TransformationMethod to allow length changes, * or revert to the length-restricted behavior. * * @param allowLengthChanges true to allow the transformation to change the length * of the input string. */ public void setLengthChangesAllowed(boolean allowLengthChanges); }
core/java/android/widget/TextView.java +58 −9 Original line number Diff line number Diff line Loading @@ -16,6 +16,11 @@ package android.widget; import com.android.internal.util.FastMath; import com.android.internal.widget.EditableInputConnection; import org.xmlpull.v1.XmlPullParserException; import android.R; import android.content.ClipData; import android.content.ClipData.Item; Loading Loading @@ -62,6 +67,7 @@ import android.text.StaticLayout; import android.text.TextPaint; import android.text.TextUtils; import android.text.TextWatcher; import android.text.method.AllCapsTransformationMethod; import android.text.method.ArrowKeyMovementMethod; import android.text.method.DateKeyListener; import android.text.method.DateTimeKeyListener; Loading @@ -76,6 +82,7 @@ import android.text.method.SingleLineTransformationMethod; import android.text.method.TextKeyListener; import android.text.method.TimeKeyListener; import android.text.method.TransformationMethod; import android.text.method.TransformationMethod2; import android.text.method.WordIterator; import android.text.style.ClickableSpan; import android.text.style.ParagraphStyle; Loading Loading @@ -125,11 +132,6 @@ import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; import android.widget.RemoteViews.RemoteView; import com.android.internal.util.FastMath; import com.android.internal.widget.EditableInputConnection; import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import java.lang.ref.WeakReference; import java.text.BreakIterator; Loading Loading @@ -424,6 +426,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener int textSize = 15; int typefaceIndex = -1; int styleIndex = -1; boolean allCaps = false; /* * Look the appearance up without checking first if it exists because Loading Loading @@ -471,6 +474,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener case com.android.internal.R.styleable.TextAppearance_textStyle: styleIndex = appearance.getInt(attr, -1); break; case com.android.internal.R.styleable.TextAppearance_textAllCaps: allCaps = appearance.getBoolean(attr, false); break; } } Loading Loading @@ -822,6 +829,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener case com.android.internal.R.styleable.TextView_suggestionsEnabled: mSuggestionsEnabled = a.getBoolean(attr, true); break; case com.android.internal.R.styleable.TextView_textAllCaps: allCaps = a.getBoolean(attr, false); break; } } a.recycle(); Loading Loading @@ -1004,6 +1015,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } setRawTextSize(textSize); if (allCaps) { setTransformationMethod(new AllCapsTransformationMethod(getContext())); } if (password || passwordInputType || webPasswordInputType || numberPasswordInputType) { setTransformationMethod(PasswordTransformationMethod.getInstance()); typefaceIndex = MONOSPACE; Loading Loading @@ -1331,6 +1346,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mTransformation = method; if (method instanceof TransformationMethod2) { TransformationMethod2 method2 = (TransformationMethod2) method; mAllowTransformationLengthChange = !mTextIsSelectable && !(mText instanceof Editable); method2.setLengthChangesAllowed(mAllowTransformationLengthChange); } else { mAllowTransformationLengthChange = false; } setText(mText); } Loading Loading @@ -1775,6 +1798,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener setTypefaceByIndex(typefaceIndex, styleIndex); if (appearance.getBoolean(com.android.internal.R.styleable.TextAppearance_textAllCaps, false)) { setTransformationMethod(new AllCapsTransformationMethod(getContext())); } appearance.recycle(); } Loading Loading @@ -2823,14 +2851,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener mBufferType = type; mText = text; if (mTransformation == null) if (mTransformation == null) { mTransformed = text; else } else { mTransformed = mTransformation.getTransformation(text, this); } final int textLength = text.length(); if (text instanceof Spannable) { if (text instanceof Spannable && !mAllowTransformationLengthChange) { Spannable sp = (Spannable) text; // Remove any ChangeWatchers that might have come Loading @@ -2852,7 +2881,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (mTransformation != null) { sp.setSpan(mTransformation, 0, textLength, Spanned.SPAN_INCLUSIVE_INCLUSIVE); } if (mMovement != null) { Loading Loading @@ -6569,6 +6597,26 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener setSingleLine(true); } /** * Sets the properties of this field to transform input to ALL CAPS * display. This may use a "small caps" formatting if available. * This setting will be ignored if this field is editable or selectable. * * This call replaces the current transformation method. Disabling this * will not necessarily restore the previous behavior from before this * was enabled. * * @see #setTransformationMethod(TransformationMethod) * @attr ref android.R.styleable#TextView_textAllCaps */ public void setAllCaps(boolean allCaps) { if (allCaps) { setTransformationMethod(new AllCapsTransformationMethod(getContext())); } else { setTransformationMethod(null); } } /** * If true, sets the properties of this field (number of lines, horizontally scrolling, * transformation method) to be for a single-line input; if false, restores these to the default Loading Loading @@ -10254,6 +10302,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener private MovementMethod mMovement; private TransformationMethod mTransformation; private boolean mAllowTransformationLengthChange; private ChangeWatcher mChangeWatcher; private ArrayList<TextWatcher> mListeners = null; Loading
core/java/com/android/internal/view/menu/ActionMenuItemView.java +1 −6 Original line number Diff line number Diff line Loading @@ -154,12 +154,7 @@ public class ActionMenuItemView extends LinearLayout // populate accessibility description with title setContentDescription(title); if (mShowTextAllCaps && title != null) { mTextButton.setText(title.toString().toUpperCase( getContext().getResources().getConfiguration().locale)); } else { mTextButton.setText(mTitle); } updateTextButtonVisibility(); } Loading