Loading core/java/android/text/method/TranslationTransformationMethod.java +7 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,13 @@ public class TranslationTransformationMethod implements TransformationMethod2 { return mOriginalTranslationMethod; } /** * Returns the {@link TextView}'s {@link ViewTranslationResponse}. */ public ViewTranslationResponse getViewTranslationResponse() { return mTranslationResponse; } @Override public CharSequence getTransformation(CharSequence source, View view) { if (!mAllowLengthChanges) { Loading core/java/android/view/translation/ViewTranslationCallback.java +5 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,11 @@ public interface ViewTranslationCallback { * method will not be called before {@link View#onViewTranslationResponse} or * {@link View#onVirtualViewTranslationResponses}. * * <p> NOTE: It is possible the user changes text that causes a new * {@link ViewTranslationResponse} returns to show the new translation. If you cache the * {@link ViewTranslationResponse} here, you should remember to keep the cached value up * to date. * * <p> NOTE: For TextView implementation, {@link ContentCaptureSession#notifyViewTextChanged} * shouldn't be called with the translated text, simply calling setText() here will trigger the * method. You should either override {@code View#onProvideContentCaptureStructure()} to report Loading core/java/android/widget/TextViewTranslationCallback.java +6 −1 Original line number Diff line number Diff line Loading @@ -70,7 +70,12 @@ public class TextViewTranslationCallback implements ViewTranslationCallback { + "onViewTranslationResponse()."); return false; } if (mTranslationTransformation == null) { // It is possible user changes text and new translation response returns, system should // update the translation response to keep the result up to date. // Because TextView.setTransformationMethod() will skip the same TransformationMethod // instance, we should create a new one to let new translation can work. if (mTranslationTransformation == null || !response.equals(mTranslationTransformation.getViewTranslationResponse())) { TransformationMethod originalTranslationMethod = ((TextView) view).getTransformationMethod(); mTranslationTransformation = new TranslationTransformationMethod(response, Loading Loading
core/java/android/text/method/TranslationTransformationMethod.java +7 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,13 @@ public class TranslationTransformationMethod implements TransformationMethod2 { return mOriginalTranslationMethod; } /** * Returns the {@link TextView}'s {@link ViewTranslationResponse}. */ public ViewTranslationResponse getViewTranslationResponse() { return mTranslationResponse; } @Override public CharSequence getTransformation(CharSequence source, View view) { if (!mAllowLengthChanges) { Loading
core/java/android/view/translation/ViewTranslationCallback.java +5 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,11 @@ public interface ViewTranslationCallback { * method will not be called before {@link View#onViewTranslationResponse} or * {@link View#onVirtualViewTranslationResponses}. * * <p> NOTE: It is possible the user changes text that causes a new * {@link ViewTranslationResponse} returns to show the new translation. If you cache the * {@link ViewTranslationResponse} here, you should remember to keep the cached value up * to date. * * <p> NOTE: For TextView implementation, {@link ContentCaptureSession#notifyViewTextChanged} * shouldn't be called with the translated text, simply calling setText() here will trigger the * method. You should either override {@code View#onProvideContentCaptureStructure()} to report Loading
core/java/android/widget/TextViewTranslationCallback.java +6 −1 Original line number Diff line number Diff line Loading @@ -70,7 +70,12 @@ public class TextViewTranslationCallback implements ViewTranslationCallback { + "onViewTranslationResponse()."); return false; } if (mTranslationTransformation == null) { // It is possible user changes text and new translation response returns, system should // update the translation response to keep the result up to date. // Because TextView.setTransformationMethod() will skip the same TransformationMethod // instance, we should create a new one to let new translation can work. if (mTranslationTransformation == null || !response.equals(mTranslationTransformation.getViewTranslationResponse())) { TransformationMethod originalTranslationMethod = ((TextView) view).getTransformationMethod(); mTranslationTransformation = new TranslationTransformationMethod(response, Loading