summaryrefslogtreecommitdiff
path: root/core/java/android/widget/TextView.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/widget/TextView.java')
-rw-r--r--core/java/android/widget/TextView.java23
1 files changed, 7 insertions, 16 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 93f72640bd3f..e745b8cf769b 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -14240,13 +14240,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
* Collects a {@link ViewTranslationRequest} which represents the content to be translated in
* the view.
*
- * <p>NOTE: When overriding the method, it should not translate the password. If the subclass
- * uses {@link TransformationMethod} to display the translated result, it's also not recommend
- * to translate text is selectable or editable.
+ * <p>NOTE: When overriding the method, it should not collect a request to translate this
+ * TextView if it is displaying a password.
*
* @param supportedFormats the supported translation format. The value could be {@link
* android.view.translation.TranslationSpec#DATA_FORMAT_TEXT}.
- * @return the {@link ViewTranslationRequest} which contains the information to be translated.
+ * @param requestsCollector {@link Consumer} to receiver the {@link ViewTranslationRequest}
+ * which contains the information to be translated.
*/
@Override
public void onCreateViewTranslationRequest(@NonNull int[] supportedFormats,
@@ -14268,18 +14268,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
return;
}
boolean isPassword = isAnyPasswordInputType() || hasPasswordTransformationMethod();
- // TODO(b/177214256): support selectable text translation.
- // We use the TransformationMethod to implement showing the translated text. The
- // TextView does not support the text length change for TransformationMethod. If the
- // text is selectable or editable, it will crash while selecting the text. To support
- // it, it needs broader changes to text APIs, we only allow to translate non selectable
- // and editable text in S.
- if (isTextEditable() || isPassword || isTextSelectable()) {
- if (UiTranslationController.DEBUG) {
- Log.w(LOG_TAG, "Cannot create translation request. editable = "
- + isTextEditable() + ", isPassword = " + isPassword + ", selectable = "
- + isTextSelectable());
- }
+ if (isTextEditable() || isPassword) {
+ Log.w(LOG_TAG, "Cannot create translation request. editable = "
+ + isTextEditable() + ", isPassword = " + isPassword);
return;
}
// TODO(b/176488462): apply the view's important for translation