Loading core/java/android/widget/EditText.java +5 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,11 @@ public class EditText extends TextView { super(context, attrs, defStyleAttr, defStyleRes); } @Override public boolean getFreezesText() { return true; } @Override protected boolean getDefaultEditable() { return true; Loading core/java/android/widget/TextView.java +28 −20 Original line number Diff line number Diff line Loading @@ -4101,27 +4101,26 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener Parcelable superState = super.onSaveInstanceState(); // Save state if we are forced to boolean save = mFreezesText; int start = 0; int end = 0; final boolean freezesText = getFreezesText(); boolean hasSelection = false; int start = -1; int end = -1; if (mText != null) { start = getSelectionStart(); end = getSelectionEnd(); if (start >= 0 || end >= 0) { // Or save state if there is a selection save = true; hasSelection = true; } } if (save) { if (freezesText || hasSelection) { SavedState ss = new SavedState(superState); // XXX Should also save the current scroll position! ss.selStart = start; ss.selEnd = end; if (freezesText) { if (mText instanceof Spanned) { Spannable sp = new SpannableStringBuilder(mText); final Spannable sp = new SpannableStringBuilder(mText); if (mEditor != null) { removeMisspelledSpans(sp); Loading @@ -4132,6 +4131,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } else { ss.text = mText.toString(); } } if (hasSelection) { // XXX Should also save the current scroll position! ss.selStart = start; ss.selEnd = end; } if (isFocused() && start >= 0 && end >= 0) { ss.frozenWithFocus = true; Loading Loading @@ -4224,7 +4230,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * position. By default this is false, not saving the text. Set to true * if the text in the text view is not being saved somewhere else in * persistent storage (such as in a content provider) so that if the * view is later thawed the user will not lose their data. * view is later thawed the user will not lose their data. For * {@link android.widget.EditText} it is always enabled, regardless of * the value of the attribute. * * @param freezesText Controls whether a frozen icicle should include the * entire text data: true to include it, false to not. Loading @@ -4238,7 +4246,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * Return whether this text view is including its entire text contents * in frozen icicles. * in frozen icicles. For {@link android.widget.EditText} it always returns true. * * @return Returns true if text is included, false if it isn't. * Loading Loading @@ -10111,8 +10119,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * {@link View#onSaveInstanceState}. */ public static class SavedState extends BaseSavedState { int selStart; int selEnd; int selStart = -1; int selEnd = -1; CharSequence text; boolean frozenWithFocus; CharSequence error; Loading core/res/res/values/attrs.xml +3 −1 Original line number Diff line number Diff line Loading @@ -4430,7 +4430,9 @@ i inside of its frozen icicle in addition to meta-data such as the current cursor position. By default this is disabled; it can be useful when the contents of a text view is not stored in a persistent place such as a content provider. --> in a persistent place such as a content provider. For {@link android.widget.EditText} it is always enabled, regardless of the value of the attribute. --> <attr name="freezesText" format="boolean" /> <!-- If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle. Loading Loading
core/java/android/widget/EditText.java +5 −0 Original line number Diff line number Diff line Loading @@ -64,6 +64,11 @@ public class EditText extends TextView { super(context, attrs, defStyleAttr, defStyleRes); } @Override public boolean getFreezesText() { return true; } @Override protected boolean getDefaultEditable() { return true; Loading
core/java/android/widget/TextView.java +28 −20 Original line number Diff line number Diff line Loading @@ -4101,27 +4101,26 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener Parcelable superState = super.onSaveInstanceState(); // Save state if we are forced to boolean save = mFreezesText; int start = 0; int end = 0; final boolean freezesText = getFreezesText(); boolean hasSelection = false; int start = -1; int end = -1; if (mText != null) { start = getSelectionStart(); end = getSelectionEnd(); if (start >= 0 || end >= 0) { // Or save state if there is a selection save = true; hasSelection = true; } } if (save) { if (freezesText || hasSelection) { SavedState ss = new SavedState(superState); // XXX Should also save the current scroll position! ss.selStart = start; ss.selEnd = end; if (freezesText) { if (mText instanceof Spanned) { Spannable sp = new SpannableStringBuilder(mText); final Spannable sp = new SpannableStringBuilder(mText); if (mEditor != null) { removeMisspelledSpans(sp); Loading @@ -4132,6 +4131,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } else { ss.text = mText.toString(); } } if (hasSelection) { // XXX Should also save the current scroll position! ss.selStart = start; ss.selEnd = end; } if (isFocused() && start >= 0 && end >= 0) { ss.frozenWithFocus = true; Loading Loading @@ -4224,7 +4230,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * position. By default this is false, not saving the text. Set to true * if the text in the text view is not being saved somewhere else in * persistent storage (such as in a content provider) so that if the * view is later thawed the user will not lose their data. * view is later thawed the user will not lose their data. For * {@link android.widget.EditText} it is always enabled, regardless of * the value of the attribute. * * @param freezesText Controls whether a frozen icicle should include the * entire text data: true to include it, false to not. Loading @@ -4238,7 +4246,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * Return whether this text view is including its entire text contents * in frozen icicles. * in frozen icicles. For {@link android.widget.EditText} it always returns true. * * @return Returns true if text is included, false if it isn't. * Loading Loading @@ -10111,8 +10119,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * {@link View#onSaveInstanceState}. */ public static class SavedState extends BaseSavedState { int selStart; int selEnd; int selStart = -1; int selEnd = -1; CharSequence text; boolean frozenWithFocus; CharSequence error; Loading
core/res/res/values/attrs.xml +3 −1 Original line number Diff line number Diff line Loading @@ -4430,7 +4430,9 @@ i inside of its frozen icicle in addition to meta-data such as the current cursor position. By default this is disabled; it can be useful when the contents of a text view is not stored in a persistent place such as a content provider. --> in a persistent place such as a content provider. For {@link android.widget.EditText} it is always enabled, regardless of the value of the attribute. --> <attr name="freezesText" format="boolean" /> <!-- If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle. Loading