diff options
| author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-09-24 01:06:12 +0000 |
|---|---|---|
| committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-09-24 01:06:12 +0000 |
| commit | 57b2b936b822b0f474dfa83b6286203289ed8066 (patch) | |
| tree | 520c953a0691596b5241e2f6638d174c5852e19e /core/java/android | |
| parent | e9201876ec0118c5dd6419a416a07bc5f25be3de (diff) | |
| parent | 6e60223a6388c6a513628c08d468015d2249484e (diff) | |
Snap for 7761456 from 6e60223a6388c6a513628c08d468015d2249484e to sc-qpr1-release
Change-Id: Id0efe1d94af074da448186876438b8081e6d0910
Diffstat (limited to 'core/java/android')
5 files changed, 23 insertions, 7 deletions
diff --git a/core/java/android/hardware/camera2/impl/CameraExtensionJpegProcessor.java b/core/java/android/hardware/camera2/impl/CameraExtensionJpegProcessor.java index 3b1cb94a6619..425f22c31306 100644 --- a/core/java/android/hardware/camera2/impl/CameraExtensionJpegProcessor.java +++ b/core/java/android/hardware/camera2/impl/CameraExtensionJpegProcessor.java @@ -58,7 +58,7 @@ public class CameraExtensionJpegProcessor implements ICaptureProcessorImpl { private static final class JpegParameters { public HashSet<Long> mTimeStamps = new HashSet<>(); - public int mRotation = JPEG_DEFAULT_ROTATION; // CCW multiple of 90 degrees + public int mRotation = JPEG_DEFAULT_ROTATION; // CW multiple of 90 degrees public int mQuality = JPEG_DEFAULT_QUALITY; // [0..100] } @@ -100,7 +100,8 @@ public class CameraExtensionJpegProcessor implements ICaptureProcessorImpl { Integer orientation = captureBundles.get(0).captureResult.get( CaptureResult.JPEG_ORIENTATION); if (orientation != null) { - ret.mRotation = orientation / 90; + // The jpeg encoder expects CCW rotation, convert from CW + ret.mRotation = (360 - (orientation % 360)) / 90; } else { Log.w(TAG, "No jpeg rotation set, using default: " + JPEG_DEFAULT_ROTATION); } diff --git a/core/java/android/text/method/TranslationTransformationMethod.java b/core/java/android/text/method/TranslationTransformationMethod.java index 80387aa8d66d..43d186ee9d21 100644 --- a/core/java/android/text/method/TranslationTransformationMethod.java +++ b/core/java/android/text/method/TranslationTransformationMethod.java @@ -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) { diff --git a/core/java/android/view/translation/UiTranslationController.java b/core/java/android/view/translation/UiTranslationController.java index 442d099f0678..f1c5a080a77b 100644 --- a/core/java/android/view/translation/UiTranslationController.java +++ b/core/java/android/view/translation/UiTranslationController.java @@ -598,9 +598,8 @@ public class UiTranslationController { final View rootView = roots.get(rootNum).getView(); if (rootView instanceof ViewGroup) { findViewsTraversalByAutofillIds((ViewGroup) rootView, sourceViewIds); - } else { - addViewIfNeeded(sourceViewIds, rootView); } + addViewIfNeeded(sourceViewIds, rootView); } } @@ -611,9 +610,8 @@ public class UiTranslationController { final View child = viewGroup.getChildAt(i); if (child instanceof ViewGroup) { findViewsTraversalByAutofillIds((ViewGroup) child, sourceViewIds); - } else { - addViewIfNeeded(sourceViewIds, child); } + addViewIfNeeded(sourceViewIds, child); } } diff --git a/core/java/android/view/translation/ViewTranslationCallback.java b/core/java/android/view/translation/ViewTranslationCallback.java index a0756622ca69..66c028b48dc6 100644 --- a/core/java/android/view/translation/ViewTranslationCallback.java +++ b/core/java/android/view/translation/ViewTranslationCallback.java @@ -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 diff --git a/core/java/android/widget/TextViewTranslationCallback.java b/core/java/android/widget/TextViewTranslationCallback.java index 9d60009031f9..152405bf4d37 100644 --- a/core/java/android/widget/TextViewTranslationCallback.java +++ b/core/java/android/widget/TextViewTranslationCallback.java @@ -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, |
