Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5fae9967 authored by Gilles Debunne's avatar Gilles Debunne
Browse files

Removed debug code in TextView

Bug 6462527

The String parameter was used to debug code during the
refactoring process.

Change-Id: I49a78bbfa3b45c185311d0dbebddddc52515c099
parent 14326fd4
Loading
Loading
Loading
Loading
+31 −38
Original line number Original line Diff line number Diff line
@@ -397,7 +397,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener


    /**
    /**
     * EditText specific data, created on demand when one of the Editor fields is used.
     * EditText specific data, created on demand when one of the Editor fields is used.
     * See {@link #createEditorIfNeeded(String)}.
     * See {@link #createEditorIfNeeded()}.
     */
     */
    private Editor mEditor;
    private Editor mEditor;


@@ -798,20 +798,20 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                break;
                break;


            case com.android.internal.R.styleable.TextView_imeOptions:
            case com.android.internal.R.styleable.TextView_imeOptions:
                createEditorIfNeeded("IME options specified in constructor");
                createEditorIfNeeded();
                mEditor.createInputContentTypeIfNeeded();
                mEditor.createInputContentTypeIfNeeded();
                mEditor.mInputContentType.imeOptions = a.getInt(attr,
                mEditor.mInputContentType.imeOptions = a.getInt(attr,
                        mEditor.mInputContentType.imeOptions);
                        mEditor.mInputContentType.imeOptions);
                break;
                break;


            case com.android.internal.R.styleable.TextView_imeActionLabel:
            case com.android.internal.R.styleable.TextView_imeActionLabel:
                createEditorIfNeeded("IME action label specified in constructor");
                createEditorIfNeeded();
                mEditor.createInputContentTypeIfNeeded();
                mEditor.createInputContentTypeIfNeeded();
                mEditor.mInputContentType.imeActionLabel = a.getText(attr);
                mEditor.mInputContentType.imeActionLabel = a.getText(attr);
                break;
                break;


            case com.android.internal.R.styleable.TextView_imeActionId:
            case com.android.internal.R.styleable.TextView_imeActionId:
                createEditorIfNeeded("IME action id specified in constructor");
                createEditorIfNeeded();
                mEditor.createInputContentTypeIfNeeded();
                mEditor.createInputContentTypeIfNeeded();
                mEditor.mInputContentType.imeActionId = a.getInt(attr,
                mEditor.mInputContentType.imeActionId = a.getInt(attr,
                        mEditor.mInputContentType.imeActionId);
                        mEditor.mInputContentType.imeActionId);
@@ -883,7 +883,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            }
            }


            try {
            try {
                createEditorIfNeeded("inputMethod in ctor");
                createEditorIfNeeded();
                mEditor.mKeyListener = (KeyListener) c.newInstance();
                mEditor.mKeyListener = (KeyListener) c.newInstance();
            } catch (InstantiationException ex) {
            } catch (InstantiationException ex) {
                throw new RuntimeException(ex);
                throw new RuntimeException(ex);
@@ -898,7 +898,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                mEditor.mInputType = EditorInfo.TYPE_CLASS_TEXT;
                mEditor.mInputType = EditorInfo.TYPE_CLASS_TEXT;
            }
            }
        } else if (digits != null) {
        } else if (digits != null) {
            createEditorIfNeeded("digits in ctor");
            createEditorIfNeeded();
            mEditor.mKeyListener = DigitsKeyListener.getInstance(digits.toString());
            mEditor.mKeyListener = DigitsKeyListener.getInstance(digits.toString());
            // If no input type was specified, we will default to generic
            // If no input type was specified, we will default to generic
            // text, since we can't tell the IME about the set of digits
            // text, since we can't tell the IME about the set of digits
@@ -910,11 +910,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            // If set, the input type overrides what was set using the deprecated singleLine flag.
            // If set, the input type overrides what was set using the deprecated singleLine flag.
            singleLine = !isMultilineInputType(inputType);
            singleLine = !isMultilineInputType(inputType);
        } else if (phone) {
        } else if (phone) {
            createEditorIfNeeded("dialer in ctor");
            createEditorIfNeeded();
            mEditor.mKeyListener = DialerKeyListener.getInstance();
            mEditor.mKeyListener = DialerKeyListener.getInstance();
            mEditor.mInputType = inputType = EditorInfo.TYPE_CLASS_PHONE;
            mEditor.mInputType = inputType = EditorInfo.TYPE_CLASS_PHONE;
        } else if (numeric != 0) {
        } else if (numeric != 0) {
            createEditorIfNeeded("numeric in ctor");
            createEditorIfNeeded();
            mEditor.mKeyListener = DigitsKeyListener.getInstance((numeric & SIGNED) != 0,
            mEditor.mKeyListener = DigitsKeyListener.getInstance((numeric & SIGNED) != 0,
                                                   (numeric & DECIMAL) != 0);
                                                   (numeric & DECIMAL) != 0);
            inputType = EditorInfo.TYPE_CLASS_NUMBER;
            inputType = EditorInfo.TYPE_CLASS_NUMBER;
@@ -951,7 +951,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                break;
                break;
            }
            }


            createEditorIfNeeded("text input in ctor");
            createEditorIfNeeded();
            mEditor.mKeyListener = TextKeyListener.getInstance(autotext, cap);
            mEditor.mKeyListener = TextKeyListener.getInstance(autotext, cap);
            mEditor.mInputType = inputType;
            mEditor.mInputType = inputType;
        } else if (isTextSelectable()) {
        } else if (isTextSelectable()) {
@@ -964,7 +964,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            // So that selection can be changed using arrow keys and touch is handled.
            // So that selection can be changed using arrow keys and touch is handled.
            setMovementMethod(ArrowKeyMovementMethod.getInstance());
            setMovementMethod(ArrowKeyMovementMethod.getInstance());
        } else if (editable) {
        } else if (editable) {
            createEditorIfNeeded("editable input in ctor");
            createEditorIfNeeded();
            mEditor.mKeyListener = TextKeyListener.getInstance();
            mEditor.mKeyListener = TextKeyListener.getInstance();
            mEditor.mInputType = EditorInfo.TYPE_CLASS_TEXT;
            mEditor.mInputType = EditorInfo.TYPE_CLASS_TEXT;
        } else {
        } else {
@@ -987,7 +987,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                webPasswordInputType, numberPasswordInputType);
                webPasswordInputType, numberPasswordInputType);


        if (selectallonfocus) {
        if (selectallonfocus) {
            createEditorIfNeeded("selectallonfocus in constructor");
            createEditorIfNeeded();
            mEditor.mSelectAllOnFocus = true;
            mEditor.mSelectAllOnFocus = true;


            if (bufferType == BufferType.NORMAL)
            if (bufferType == BufferType.NORMAL)
@@ -1335,7 +1335,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        fixFocusableAndClickableSettings();
        fixFocusableAndClickableSettings();


        if (input != null) {
        if (input != null) {
            createEditorIfNeeded("input is not null");
            createEditorIfNeeded();
            try {
            try {
                mEditor.mInputType = mEditor.mKeyListener.getInputType();
                mEditor.mInputType = mEditor.mKeyListener.getInputType();
            } catch (IncompatibleClassChangeError e) {
            } catch (IncompatibleClassChangeError e) {
@@ -1355,7 +1355,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    private void setKeyListenerOnly(KeyListener input) {
    private void setKeyListenerOnly(KeyListener input) {
        if (mEditor == null && input == null) return; // null is the default value
        if (mEditor == null && input == null) return; // null is the default value


        createEditorIfNeeded("setKeyListenerOnly");
        createEditorIfNeeded();
        if (mEditor.mKeyListener != input) {
        if (mEditor.mKeyListener != input) {
            mEditor.mKeyListener = input;
            mEditor.mKeyListener = input;
            if (input != null && !(mText instanceof Editable)) {
            if (input != null && !(mText instanceof Editable)) {
@@ -2383,7 +2383,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     */
     */
    @android.view.RemotableViewMethod
    @android.view.RemotableViewMethod
    public final void setShowSoftInputOnFocus(boolean show) {
    public final void setShowSoftInputOnFocus(boolean show) {
        createEditorIfNeeded("setShowSoftInputOnFocus");
        createEditorIfNeeded();
        mEditor.mShowSoftInputOnFocus = show;
        mEditor.mShowSoftInputOnFocus = show;
    }
    }


@@ -3263,7 +3263,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                    Selection.setSelection((Spannable) mText, ss.selStart, ss.selEnd);
                    Selection.setSelection((Spannable) mText, ss.selStart, ss.selEnd);


                    if (ss.frozenWithFocus) {
                    if (ss.frozenWithFocus) {
                        createEditorIfNeeded("restore instance with focus");
                        createEditorIfNeeded();
                        mEditor.mFrozenWithFocus = true;
                        mEditor.mFrozenWithFocus = true;
                    }
                    }
                }
                }
@@ -3424,7 +3424,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener


        if (type == BufferType.EDITABLE || getKeyListener() != null ||
        if (type == BufferType.EDITABLE || getKeyListener() != null ||
                needEditableForNotification) {
                needEditableForNotification) {
            createEditorIfNeeded("setText with BufferType.EDITABLE or non null mInput");
            createEditorIfNeeded();
            Editable t = mEditableFactory.newEditable(text);
            Editable t = mEditableFactory.newEditable(text);
            text = t;
            text = t;
            setFilters(t, mFilters);
            setFilters(t, mFilters);
@@ -3768,7 +3768,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     */
     */
    public void setRawInputType(int type) {
    public void setRawInputType(int type) {
        if (type == InputType.TYPE_NULL && mEditor == null) return; //TYPE_NULL is the default value
        if (type == InputType.TYPE_NULL && mEditor == null) return; //TYPE_NULL is the default value
        createEditorIfNeeded("non null input type");
        createEditorIfNeeded();
        mEditor.mInputType = type;
        mEditor.mInputType = type;
    }
    }


@@ -3811,7 +3811,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        }
        }
        setRawInputType(type);
        setRawInputType(type);
        if (direct) {
        if (direct) {
            createEditorIfNeeded("setInputType");
            createEditorIfNeeded();
            mEditor.mKeyListener = input;
            mEditor.mKeyListener = input;
        } else {
        } else {
            setKeyListenerOnly(input);
            setKeyListenerOnly(input);
@@ -3837,7 +3837,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     * @attr ref android.R.styleable#TextView_imeOptions
     * @attr ref android.R.styleable#TextView_imeOptions
     */
     */
    public void setImeOptions(int imeOptions) {
    public void setImeOptions(int imeOptions) {
        createEditorIfNeeded("IME options specified");
        createEditorIfNeeded();
        mEditor.createInputContentTypeIfNeeded();
        mEditor.createInputContentTypeIfNeeded();
        mEditor.mInputContentType.imeOptions = imeOptions;
        mEditor.mInputContentType.imeOptions = imeOptions;
    }
    }
@@ -3864,7 +3864,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     * @attr ref android.R.styleable#TextView_imeActionId
     * @attr ref android.R.styleable#TextView_imeActionId
     */
     */
    public void setImeActionLabel(CharSequence label, int actionId) {
    public void setImeActionLabel(CharSequence label, int actionId) {
        createEditorIfNeeded("IME action label specified");
        createEditorIfNeeded();
        mEditor.createInputContentTypeIfNeeded();
        mEditor.createInputContentTypeIfNeeded();
        mEditor.mInputContentType.imeActionLabel = label;
        mEditor.mInputContentType.imeActionLabel = label;
        mEditor.mInputContentType.imeActionId = actionId;
        mEditor.mInputContentType.imeActionId = actionId;
@@ -3901,7 +3901,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     * modifier will, however, allow the user to insert a newline character.
     * modifier will, however, allow the user to insert a newline character.
     */
     */
    public void setOnEditorActionListener(OnEditorActionListener l) {
    public void setOnEditorActionListener(OnEditorActionListener l) {
        createEditorIfNeeded("Editor action listener set");
        createEditorIfNeeded();
        mEditor.createInputContentTypeIfNeeded();
        mEditor.createInputContentTypeIfNeeded();
        mEditor.mInputContentType.onEditorActionListener = l;
        mEditor.mInputContentType.onEditorActionListener = l;
    }
    }
@@ -3998,7 +3998,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     * @attr ref android.R.styleable#TextView_privateImeOptions
     * @attr ref android.R.styleable#TextView_privateImeOptions
     */
     */
    public void setPrivateImeOptions(String type) {
    public void setPrivateImeOptions(String type) {
        createEditorIfNeeded("Private IME option set");
        createEditorIfNeeded();
        mEditor.createInputContentTypeIfNeeded();
        mEditor.createInputContentTypeIfNeeded();
        mEditor.mInputContentType.privateImeOptions = type;
        mEditor.mInputContentType.privateImeOptions = type;
    }
    }
@@ -4026,7 +4026,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     * @attr ref android.R.styleable#TextView_editorExtras
     * @attr ref android.R.styleable#TextView_editorExtras
     */
     */
    public void setInputExtras(int xmlResId) throws XmlPullParserException, IOException {
    public void setInputExtras(int xmlResId) throws XmlPullParserException, IOException {
        createEditorIfNeeded("Input extra set");
        createEditorIfNeeded();
        XmlResourceParser parser = getResources().getXml(xmlResId);
        XmlResourceParser parser = getResources().getXml(xmlResId);
        mEditor.createInputContentTypeIfNeeded();
        mEditor.createInputContentTypeIfNeeded();
        mEditor.mInputContentType.extras = new Bundle();
        mEditor.mInputContentType.extras = new Bundle();
@@ -4045,7 +4045,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     */
     */
    public Bundle getInputExtras(boolean create) {
    public Bundle getInputExtras(boolean create) {
        if (mEditor == null && !create) return null;
        if (mEditor == null && !create) return null;
        createEditorIfNeeded("get Input extra");
        createEditorIfNeeded();
        if (mEditor.mInputContentType == null) {
        if (mEditor.mInputContentType == null) {
            if (!create) return null;
            if (!create) return null;
            mEditor.createInputContentTypeIfNeeded();
            mEditor.createInputContentTypeIfNeeded();
@@ -4097,7 +4097,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     * be cleared (and you should provide a <code>null</code> icon as well).
     * be cleared (and you should provide a <code>null</code> icon as well).
     */
     */
    public void setError(CharSequence error, Drawable icon) {
    public void setError(CharSequence error, Drawable icon) {
        createEditorIfNeeded("setError");
        createEditorIfNeeded();
        mEditor.setError(error, icon);
        mEditor.setError(error, icon);
    }
    }


@@ -4609,7 +4609,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    public void setTextIsSelectable(boolean selectable) {
    public void setTextIsSelectable(boolean selectable) {
        if (!selectable && mEditor == null) return; // false is default value with no edit data
        if (!selectable && mEditor == null) return; // false is default value with no edit data


        createEditorIfNeeded("setTextIsSelectable");
        createEditorIfNeeded();
        if (mEditor.mTextIsSelectable == selectable) return;
        if (mEditor.mTextIsSelectable == selectable) return;


        mEditor.mTextIsSelectable = selectable;
        mEditor.mTextIsSelectable = selectable;
@@ -5422,7 +5422,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     * @return Returns true if the text was successfully extracted, else false.
     * @return Returns true if the text was successfully extracted, else false.
     */
     */
    public boolean extractText(ExtractedTextRequest request, ExtractedText outText) {
    public boolean extractText(ExtractedTextRequest request, ExtractedText outText) {
        createEditorIfNeeded("extractText");
        createEditorIfNeeded();
        return mEditor.extractText(request, outText);
        return mEditor.extractText(request, outText);
    }
    }


@@ -6836,7 +6836,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     */
     */
    @android.view.RemotableViewMethod
    @android.view.RemotableViewMethod
    public void setSelectAllOnFocus(boolean selectAllOnFocus) {
    public void setSelectAllOnFocus(boolean selectAllOnFocus) {
        createEditorIfNeeded("setSelectAllOnFocus");
        createEditorIfNeeded();
        mEditor.mSelectAllOnFocus = selectAllOnFocus;
        mEditor.mSelectAllOnFocus = selectAllOnFocus;


        if (selectAllOnFocus && !(mText instanceof Spannable)) {
        if (selectAllOnFocus && !(mText instanceof Spannable)) {
@@ -6855,7 +6855,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    @android.view.RemotableViewMethod
    @android.view.RemotableViewMethod
    public void setCursorVisible(boolean visible) {
    public void setCursorVisible(boolean visible) {
        if (visible && mEditor == null) return; // visible is the default value with no edit data
        if (visible && mEditor == null) return; // visible is the default value with no edit data
        createEditorIfNeeded("setCursorVisible");
        createEditorIfNeeded();
        if (mEditor.mCursorVisible != visible) {
        if (mEditor.mCursorVisible != visible) {
            mEditor.mCursorVisible = visible;
            mEditor.mCursorVisible = visible;
            invalidate();
            invalidate();
@@ -7914,7 +7914,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     * that case, to allow for quick replacement.
     * that case, to allow for quick replacement.
     */
     */
    public void setCustomSelectionActionModeCallback(ActionMode.Callback actionModeCallback) {
    public void setCustomSelectionActionModeCallback(ActionMode.Callback actionModeCallback) {
        createEditorIfNeeded("custom selection action mode set");
        createEditorIfNeeded();
        mEditor.mCustomSelectionActionModeCallback = actionModeCallback;
        mEditor.mCustomSelectionActionModeCallback = actionModeCallback;
    }
    }


@@ -8285,16 +8285,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     * Also note that for performance reasons, the mEditor is created when needed, but not
     * Also note that for performance reasons, the mEditor is created when needed, but not
     * reset when no more edit-specific fields are needed.
     * reset when no more edit-specific fields are needed.
     */
     */
    private void createEditorIfNeeded(String reason) {
    private void createEditorIfNeeded() {
        if (mEditor == null) {
        if (mEditor == null) {
            if (!(this instanceof EditText)) {
                Log.e(LOG_TAG + " EDITOR", "Creating an Editor on a regular TextView. " + reason);
            }
            mEditor = new Editor(this);
            mEditor = new Editor(this);
        } else {
            if (!(this instanceof EditText)) {
                Log.d(LOG_TAG + " EDITOR", "Redundant Editor creation. " + reason);
            }
        }
        }
    }
    }