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

This commit is contained in:
TreeHugger Robot
2017-10-31 03:01:08 +00:00
committed by Android (Google) Code Review
2 changed files with 13 additions and 5 deletions

View File

@@ -68,7 +68,7 @@ final class SelectionActionModeHelper {
public void startActionModeAsync(boolean adjustSelection) { public void startActionModeAsync(boolean adjustSelection) {
cancelAsyncTask(); cancelAsyncTask();
if (isNoOpTextClassifier() || !hasSelection()) { if (skipTextClassification()) {
// No need to make an async call for a no-op TextClassifier. // No need to make an async call for a no-op TextClassifier.
// Do not call the TextClassifier if there is no selection. // Do not call the TextClassifier if there is no selection.
startActionMode(null); startActionMode(null);
@@ -88,7 +88,7 @@ final class SelectionActionModeHelper {
public void invalidateActionModeAsync() { public void invalidateActionModeAsync() {
cancelAsyncTask(); cancelAsyncTask();
if (isNoOpTextClassifier() || !hasSelection()) { if (skipTextClassification()) {
// No need to make an async call for a no-op TextClassifier. // No need to make an async call for a no-op TextClassifier.
// Do not call the TextClassifier if there is no selection. // Do not call the TextClassifier if there is no selection.
invalidateActionMode(null); invalidateActionMode(null);
@@ -132,8 +132,16 @@ final class SelectionActionModeHelper {
mTextClassification = null; mTextClassification = null;
} }
private boolean isNoOpTextClassifier() { private boolean skipTextClassification() {
return mEditor.getTextView().getTextClassifier() == TextClassifier.NO_OP; 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() { private boolean hasSelection() {

View File

@@ -5674,7 +5674,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return mTransformation instanceof PasswordTransformationMethod; return mTransformation instanceof PasswordTransformationMethod;
} }
private static boolean isPasswordInputType(int inputType) { static boolean isPasswordInputType(int inputType) {
final int variation = final int variation =
inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION); inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION);
return variation return variation