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

Commit f247977c authored by Abodunrinwa Toki's avatar Abodunrinwa Toki Committed by android-build-merger
Browse files

Merge "DO NOT MERGE Disable smart sharing for password fields." into oc-dev

am: 66ca42d5

Change-Id: I0e57e666f790c94ddf04d304a633c835a99d3d69
parents bd710193 66ca42d5
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ final class SelectionActionModeHelper {

    public void startActionModeAsync(boolean adjustSelection) {
        cancelAsyncTask();
        if (isNoOpTextClassifier() || !hasSelection()) {
        if (skipTextClassification()) {
            // No need to make an async call for a no-op TextClassifier.
            // Do not call the TextClassifier if there is no selection.
            startActionMode(null);
@@ -88,7 +88,7 @@ final class SelectionActionModeHelper {

    public void invalidateActionModeAsync() {
        cancelAsyncTask();
        if (isNoOpTextClassifier() || !hasSelection()) {
        if (skipTextClassification()) {
            // No need to make an async call for a no-op TextClassifier.
            // Do not call the TextClassifier if there is no selection.
            invalidateActionMode(null);
@@ -132,8 +132,16 @@ final class SelectionActionModeHelper {
        mTextClassification = null;
    }

    private boolean isNoOpTextClassifier() {
        return mEditor.getTextView().getTextClassifier() == TextClassifier.NO_OP;
    private boolean skipTextClassification() {
        final TextView textView = mEditor.getTextView();
        // No need to make an async call for a no-op TextClassifier.
        final boolean noOpTextClassifier = textView.getTextClassifier() == TextClassifier.NO_OP;
        // Do not call the TextClassifier if there is no selection.
        final boolean noSelection = textView.getSelectionEnd() == textView.getSelectionStart();
        // Do not call the TextClassifier if this is a password field.
        final boolean password = textView.hasPasswordTransformationMethod()
                || TextView.isPasswordInputType(textView.getInputType());
        return noOpTextClassifier || noSelection || password;
    }

    private boolean hasSelection() {
+1 −1
Original line number Diff line number Diff line
@@ -5674,7 +5674,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
        return mTransformation instanceof PasswordTransformationMethod;
    }

    private static boolean isPasswordInputType(int inputType) {
    static boolean isPasswordInputType(int inputType) {
        final int variation =
                inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION);
        return variation