From ec3f41e70e779666ff8a75b481390d1fef6b0168 Mon Sep 17 00:00:00 2001 From: Joanne Chung Date: Fri, 17 Sep 2021 17:06:44 +0800 Subject: [PATCH] Fix translation doesn't work on ViewGroup The system will add requested view reference into cache but it is possible the requested translation view is a viewgroup, we don't add this into view reference list that cause the translation doesn't work on ViewGroup. Bug: 200233857 Test: atest CtsTranslationTestCases Test: manual. Use a sample code to request translation for a viewgroup and make sure it is added into view reference list. Test: manual verify with issue client app, it works. Change-Id: Ie593a1a436fd046373412ae2955a78057d22b892 --- .../android/view/translation/UiTranslationController.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/java/android/view/translation/UiTranslationController.java b/core/java/android/view/translation/UiTranslationController.java index 442d099f06785..f1c5a080a77b3 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); } }