Loading core/java/android/widget/TextView.java +39 −16 Original line number Diff line number Diff line Loading @@ -447,7 +447,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener drawableBottom = null; int drawablePadding = 0; int ellipsize = -1; boolean singleLine = true; boolean singleLine = false; int maxlength = -1; CharSequence text = ""; CharSequence hint = null; Loading Loading @@ -791,7 +791,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener ? inputType : EditorInfo.TYPE_CLASS_TEXT; } else if (inputType != EditorInfo.TYPE_NULL) { setInputType(inputType, true); singleLine = !isMultilineInputType(inputType); singleLine = (inputType&(EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE)) != (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE); } else if (phone) { mInput = DialerKeyListener.getInstance(); mInputType = inputType = EditorInfo.TYPE_CLASS_PHONE; Loading @@ -810,6 +813,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener TextKeyListener.Capitalize cap; inputType = EditorInfo.TYPE_CLASS_TEXT; if (!singleLine) { inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE; } switch (autocap) { case 1: cap = TextKeyListener.Capitalize.SENTENCES; Loading @@ -836,6 +843,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } else if (editable) { mInput = TextKeyListener.getInstance(); mInputType = EditorInfo.TYPE_CLASS_TEXT; if (!singleLine) { mInputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE; } } else { mInput = null; Loading Loading @@ -878,10 +888,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener drawableLeft, drawableTop, drawableRight, drawableBottom); setCompoundDrawablePadding(drawablePadding); setSingleLine(singleLine); if (singleLine && mInput == null && ellipsize < 0) { if (singleLine) { setSingleLine(); if (mInput == null && ellipsize < 0) { ellipsize = 3; // END } } switch (ellipsize) { case 1: Loading Loading @@ -1144,7 +1157,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } catch (IncompatibleClassChangeError e) { mInputType = EditorInfo.TYPE_CLASS_TEXT; } setSingleLine(mSingleLine); if ((mInputType&EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) { if (mSingleLine) { mInputType &= ~EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE; } else { mInputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE; } } } else { mInputType = EditorInfo.TYPE_NULL; } Loading Loading @@ -2972,11 +2992,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return mHint; } private boolean isMultilineInputType(int type) { return (type & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE)) == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE); } /** * Set the type of the content with a constant as defined for * {@link EditorInfo#inputType}. This will take care of changing Loading Loading @@ -3013,14 +3028,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } boolean singleLine = !isMultilineInputType(type); boolean multiLine = (type&(EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE)) == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE); // We need to update the single line mode if it has changed or we // were previously in password mode. if (mSingleLine != singleLine || forceUpdate) { if (mSingleLine == multiLine || forceUpdate) { // Change single line mode, but only change the transformation if // we are not in password mode. applySingleLine(singleLine, !isPassword); applySingleLine(!multiLine, !isPassword); } InputMethodManager imm = InputMethodManager.peekInstance(); Loading Loading @@ -4728,7 +4746,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_ENTER_ACTION; } } if (isMultilineInputType(outAttrs.inputType)) { if ((outAttrs.inputType & (InputType.TYPE_MASK_CLASS | InputType.TYPE_TEXT_FLAG_MULTI_LINE)) == (InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE)) { // Multi-line text editors should always show an enter key. outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_ENTER_ACTION; } Loading Loading @@ -6071,7 +6092,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener */ @android.view.RemotableViewMethod public void setSingleLine(boolean singleLine) { if ((mInputType & EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) { if ((mInputType&EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) { if (singleLine) { mInputType &= ~EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE; } else { Loading @@ -6087,7 +6109,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener setLines(1); setHorizontallyScrolling(true); if (applyTransformation) { setTransformationMethod(SingleLineTransformationMethod.getInstance()); setTransformationMethod(SingleLineTransformationMethod. getInstance()); } } else { setMaxLines(Integer.MAX_VALUE); Loading Loading
core/java/android/widget/TextView.java +39 −16 Original line number Diff line number Diff line Loading @@ -447,7 +447,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener drawableBottom = null; int drawablePadding = 0; int ellipsize = -1; boolean singleLine = true; boolean singleLine = false; int maxlength = -1; CharSequence text = ""; CharSequence hint = null; Loading Loading @@ -791,7 +791,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener ? inputType : EditorInfo.TYPE_CLASS_TEXT; } else if (inputType != EditorInfo.TYPE_NULL) { setInputType(inputType, true); singleLine = !isMultilineInputType(inputType); singleLine = (inputType&(EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE)) != (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE); } else if (phone) { mInput = DialerKeyListener.getInstance(); mInputType = inputType = EditorInfo.TYPE_CLASS_PHONE; Loading @@ -810,6 +813,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener TextKeyListener.Capitalize cap; inputType = EditorInfo.TYPE_CLASS_TEXT; if (!singleLine) { inputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE; } switch (autocap) { case 1: cap = TextKeyListener.Capitalize.SENTENCES; Loading @@ -836,6 +843,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } else if (editable) { mInput = TextKeyListener.getInstance(); mInputType = EditorInfo.TYPE_CLASS_TEXT; if (!singleLine) { mInputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE; } } else { mInput = null; Loading Loading @@ -878,10 +888,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener drawableLeft, drawableTop, drawableRight, drawableBottom); setCompoundDrawablePadding(drawablePadding); setSingleLine(singleLine); if (singleLine && mInput == null && ellipsize < 0) { if (singleLine) { setSingleLine(); if (mInput == null && ellipsize < 0) { ellipsize = 3; // END } } switch (ellipsize) { case 1: Loading Loading @@ -1144,7 +1157,14 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } catch (IncompatibleClassChangeError e) { mInputType = EditorInfo.TYPE_CLASS_TEXT; } setSingleLine(mSingleLine); if ((mInputType&EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) { if (mSingleLine) { mInputType &= ~EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE; } else { mInputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE; } } } else { mInputType = EditorInfo.TYPE_NULL; } Loading Loading @@ -2972,11 +2992,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return mHint; } private boolean isMultilineInputType(int type) { return (type & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE)) == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE); } /** * Set the type of the content with a constant as defined for * {@link EditorInfo#inputType}. This will take care of changing Loading Loading @@ -3013,14 +3028,17 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } boolean singleLine = !isMultilineInputType(type); boolean multiLine = (type&(EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE)) == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE); // We need to update the single line mode if it has changed or we // were previously in password mode. if (mSingleLine != singleLine || forceUpdate) { if (mSingleLine == multiLine || forceUpdate) { // Change single line mode, but only change the transformation if // we are not in password mode. applySingleLine(singleLine, !isPassword); applySingleLine(!multiLine, !isPassword); } InputMethodManager imm = InputMethodManager.peekInstance(); Loading Loading @@ -4728,7 +4746,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_ENTER_ACTION; } } if (isMultilineInputType(outAttrs.inputType)) { if ((outAttrs.inputType & (InputType.TYPE_MASK_CLASS | InputType.TYPE_TEXT_FLAG_MULTI_LINE)) == (InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE)) { // Multi-line text editors should always show an enter key. outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_ENTER_ACTION; } Loading Loading @@ -6071,7 +6092,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener */ @android.view.RemotableViewMethod public void setSingleLine(boolean singleLine) { if ((mInputType & EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) { if ((mInputType&EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) { if (singleLine) { mInputType &= ~EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE; } else { Loading @@ -6087,7 +6109,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener setLines(1); setHorizontallyScrolling(true); if (applyTransformation) { setTransformationMethod(SingleLineTransformationMethod.getInstance()); setTransformationMethod(SingleLineTransformationMethod. getInstance()); } } else { setMaxLines(Integer.MAX_VALUE); Loading