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

Commit a61cc931 authored by Gilles Debunne's avatar Gilles Debunne Committed by Android (Google) Code Review
Browse files

Merge "Lock screen should not display password."

parents 5c7d5ae0 d7483bff
Loading
Loading
Loading
Loading
+46 −29
Original line number Original line Diff line number Diff line
@@ -761,6 +761,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener


        BufferType bufferType = BufferType.EDITABLE;
        BufferType bufferType = BufferType.EDITABLE;


        final int variation =
                inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION);
        final boolean passwordInputType = variation
                == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);
        final boolean webPasswordInputType = variation
                == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD);

        if (inputMethod != null) {
        if (inputMethod != null) {
            Class<?> c;
            Class<?> c;


@@ -856,19 +863,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            }
            }
        }
        }


        if (password) {
        // mInputType has been set from inputType, possibly modified by mInputMethod.
            // Caller used the deprecated xml attribute "password".  Ensure that
        // Specialize mInputType to [web]password if we have a text class and the original input
            // the inputType is correct.
        // type was a password.
            boolean normalText = (mInputType & EditorInfo.TYPE_MASK_CLASS)
        if ((mInputType & EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) {
                    == EditorInfo.TYPE_CLASS_TEXT;
            if (password || passwordInputType) {
            if (normalText && !isPasswordInputType(mInputType)) {
                mInputType = (mInputType & ~(EditorInfo.TYPE_MASK_VARIATION))
                mInputType = (mInputType & ~(EditorInfo.TYPE_MASK_VARIATION))
                        | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD;
                        | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD;
            }
            }
        } else if (isPasswordInputType(mInputType)) {
            if (webPasswordInputType) {
            // Caller did not use the deprecated xml attribute "password", but
                mInputType = (mInputType & ~(EditorInfo.TYPE_MASK_VARIATION))
            // did set the input properly.  Set password to true.
                        | EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD;
            password = true;
            }
        }
        }


        if (selectallonfocus) {
        if (selectallonfocus) {
@@ -882,7 +888,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            drawableLeft, drawableTop, drawableRight, drawableBottom);
            drawableLeft, drawableTop, drawableRight, drawableBottom);
        setCompoundDrawablePadding(drawablePadding);
        setCompoundDrawablePadding(drawablePadding);


        setSingleLine(singleLine);
        // Same as setSingleLine, but make sure the transformation method is unchanged.
        setInputTypeSingleLine(singleLine);
        applySingleLine(singleLine, false);

        if (singleLine && mInput == null && ellipsize < 0) {
        if (singleLine && mInput == null && ellipsize < 0) {
                ellipsize = 3; // END
                ellipsize = 3; // END
        }
        }
@@ -911,13 +920,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        }
        }
        setRawTextSize(textSize);
        setRawTextSize(textSize);


        if (password) {
        if (password || passwordInputType || webPasswordInputType) {
            setTransformationMethod(PasswordTransformationMethod.getInstance());
            setTransformationMethod(PasswordTransformationMethod.getInstance());
            typefaceIndex = MONOSPACE;
            typefaceIndex = MONOSPACE;
        } else if ((mInputType&(EditorInfo.TYPE_MASK_CLASS
        } else if ((mInputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION))
                |EditorInfo.TYPE_MASK_VARIATION))
                == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD)) {
                == (EditorInfo.TYPE_CLASS_TEXT
                        |EditorInfo.TYPE_TEXT_VARIATION_PASSWORD)) {
            typefaceIndex = MONOSPACE;
            typefaceIndex = MONOSPACE;
        }
        }


@@ -1148,7 +1155,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            } catch (IncompatibleClassChangeError e) {
            } catch (IncompatibleClassChangeError e) {
                mInputType = EditorInfo.TYPE_CLASS_TEXT;
                mInputType = EditorInfo.TYPE_CLASS_TEXT;
            }
            }
            setSingleLine(mSingleLine);
            // Change inputType, without affecting transformation.
            // No need to applySingleLine since mSingleLine is unchanged.
            setInputTypeSingleLine(mSingleLine);
        } else {
        } else {
            mInputType = EditorInfo.TYPE_NULL;
            mInputType = EditorInfo.TYPE_NULL;
        }
        }
@@ -3051,21 +3060,19 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    }
    }


    private boolean isPasswordInputType(int inputType) {
    private boolean isPasswordInputType(int inputType) {
        final int variation = inputType & (EditorInfo.TYPE_MASK_CLASS
        final int variation =
                | EditorInfo.TYPE_MASK_VARIATION);
                inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION);
        return variation
        return variation
                == (EditorInfo.TYPE_CLASS_TEXT
                == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD)
                        | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD)
                || variation
                        || variation == (EditorInfo.TYPE_CLASS_TEXT
                == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD);
                        | EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD);
    }
    }


    private boolean isVisiblePasswordInputType(int inputType) {
    private boolean isVisiblePasswordInputType(int inputType) {
        final int variation = inputType & (EditorInfo.TYPE_MASK_CLASS
        final int variation =
                | EditorInfo.TYPE_MASK_VARIATION);
                inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION);
        return variation
        return variation
                == (EditorInfo.TYPE_CLASS_TEXT
                == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
                        | EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
    }
    }


    /**
    /**
@@ -6075,6 +6082,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     */
     */
    @android.view.RemotableViewMethod
    @android.view.RemotableViewMethod
    public void setSingleLine(boolean singleLine) {
    public void setSingleLine(boolean singleLine) {
        setInputTypeSingleLine(singleLine);
        applySingleLine(singleLine, true);
    }

    /**
     * Adds or remove the EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE on the mInputType.
     * @param singleLine
     */
    private void setInputTypeSingleLine(boolean singleLine) {
        if ((mInputType & EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) {
        if ((mInputType & EditorInfo.TYPE_MASK_CLASS) == EditorInfo.TYPE_CLASS_TEXT) {
            if (singleLine) {
            if (singleLine) {
                mInputType &= ~EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
                mInputType &= ~EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
@@ -6082,7 +6098,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                mInputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
                mInputType |= EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE;
            }
            }
        }
        }
        applySingleLine(singleLine, true);
    }
    }


    private void applySingleLine(boolean singleLine, boolean applyTransformation) {
    private void applySingleLine(boolean singleLine, boolean applyTransformation) {
@@ -7875,6 +7890,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                if (hasPasswordTransformationMethod()) {
                if (hasPasswordTransformationMethod()) {
                    // selectCurrentWord is not available on a password field and would return an
                    // selectCurrentWord is not available on a password field and would return an
                    // arbitrary 10-charater selection around pressed position. Select all instead.
                    // arbitrary 10-charater selection around pressed position. Select all instead.
                    // Note that cut/copy menu entries are not available for passwords.
                    // This is however useful to delete or paste to replace the entire content.
                    Selection.setSelection((Spannable) mText, 0, mText.length());
                    Selection.setSelection((Spannable) mText, 0, mText.length());
                } else {
                } else {
                    selectCurrentWord();
                    selectCurrentWord();