Loading core/java/android/view/translation/UiTranslationController.java +20 −0 Original line number Diff line number Diff line Loading @@ -302,6 +302,11 @@ public class UiTranslationController { } final LongSparseArray<ViewTranslationResponse> virtualChildResponse = translatedResult.valueAt(i); if (DEBUG) { // TODO(b/182433547): remove before S release Log.v(TAG, "onVirtualViewTranslationCompleted: receive " + virtualChildResponse + " for AutofillId " + autofillId); } mActivity.runOnUiThread(() -> { if (view.getViewTranslationCallback() == null) { if (DEBUG) { Loading Loading @@ -341,8 +346,13 @@ public class UiTranslationController { } for (int i = 0; i < resultCount; i++) { final ViewTranslationResponse response = translatedResult.valueAt(i); if (DEBUG) { // TODO(b/182433547): remove before S release Log.v(TAG, "onTranslationCompleted: response= " + response); } final AutofillId autofillId = response.getAutofillId(); if (autofillId == null) { Log.w(TAG, "No AutofillId is set in ViewTranslationResponse:" + response); continue; } final View view = mViews.get(autofillId).get(); Loading Loading @@ -394,6 +404,9 @@ public class UiTranslationController { final TranslationRequest request = new TranslationRequest.Builder() .setViewTranslationRequests(requests) .build(); if (DEBUG) { Log.d(TAG, "sendTranslationRequest: request= " + request); } translator.requestUiTranslate(request, (r) -> r.run(), this::onTranslationCompleted); } Loading Loading @@ -508,10 +521,17 @@ public class UiTranslationController { private void runForEachView(BiConsumer<View, ViewTranslationCallback> action) { synchronized (mLock) { final ArrayMap<AutofillId, WeakReference<View>> views = new ArrayMap<>(mViews); if (views.size() == 0) { Log.w(TAG, "No views can be excuted for runForEachView."); } mActivity.runOnUiThread(() -> { final int viewCounts = views.size(); for (int i = 0; i < viewCounts; i++) { final View view = views.valueAt(i).get(); if (DEBUG) { // TODO(b/182433547): remove before S release Log.d(TAG, "runForEachView: view= " + view); } if (view == null || view.getViewTranslationCallback() == null) { if (DEBUG) { Log.d(TAG, "View was gone or ViewTranslationCallback for autofillid " Loading core/java/android/widget/TextViewTranslationCallback.java +5 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.widget; import android.annotation.NonNull; import android.os.Build; import android.text.method.TranslationTransformationMethod; import android.util.Log; import android.view.View; Loading @@ -34,7 +35,10 @@ public class TextViewTranslationCallback implements ViewTranslationCallback { private static final String TAG = "TextViewTranslationCallback"; private static final boolean DEBUG = Log.isLoggable(UiTranslationManager.LOG_TAG, Log.DEBUG); // TODO(b/182433547): remove Build.IS_DEBUGGABLE before ship. Enable the logging in debug build // to help the debug during the development phase private static final boolean DEBUG = Log.isLoggable(UiTranslationManager.LOG_TAG, Log.DEBUG) || Build.IS_DEBUGGABLE; private TranslationTransformationMethod mTranslationTransformation; Loading Loading
core/java/android/view/translation/UiTranslationController.java +20 −0 Original line number Diff line number Diff line Loading @@ -302,6 +302,11 @@ public class UiTranslationController { } final LongSparseArray<ViewTranslationResponse> virtualChildResponse = translatedResult.valueAt(i); if (DEBUG) { // TODO(b/182433547): remove before S release Log.v(TAG, "onVirtualViewTranslationCompleted: receive " + virtualChildResponse + " for AutofillId " + autofillId); } mActivity.runOnUiThread(() -> { if (view.getViewTranslationCallback() == null) { if (DEBUG) { Loading Loading @@ -341,8 +346,13 @@ public class UiTranslationController { } for (int i = 0; i < resultCount; i++) { final ViewTranslationResponse response = translatedResult.valueAt(i); if (DEBUG) { // TODO(b/182433547): remove before S release Log.v(TAG, "onTranslationCompleted: response= " + response); } final AutofillId autofillId = response.getAutofillId(); if (autofillId == null) { Log.w(TAG, "No AutofillId is set in ViewTranslationResponse:" + response); continue; } final View view = mViews.get(autofillId).get(); Loading Loading @@ -394,6 +404,9 @@ public class UiTranslationController { final TranslationRequest request = new TranslationRequest.Builder() .setViewTranslationRequests(requests) .build(); if (DEBUG) { Log.d(TAG, "sendTranslationRequest: request= " + request); } translator.requestUiTranslate(request, (r) -> r.run(), this::onTranslationCompleted); } Loading Loading @@ -508,10 +521,17 @@ public class UiTranslationController { private void runForEachView(BiConsumer<View, ViewTranslationCallback> action) { synchronized (mLock) { final ArrayMap<AutofillId, WeakReference<View>> views = new ArrayMap<>(mViews); if (views.size() == 0) { Log.w(TAG, "No views can be excuted for runForEachView."); } mActivity.runOnUiThread(() -> { final int viewCounts = views.size(); for (int i = 0; i < viewCounts; i++) { final View view = views.valueAt(i).get(); if (DEBUG) { // TODO(b/182433547): remove before S release Log.d(TAG, "runForEachView: view= " + view); } if (view == null || view.getViewTranslationCallback() == null) { if (DEBUG) { Log.d(TAG, "View was gone or ViewTranslationCallback for autofillid " Loading
core/java/android/widget/TextViewTranslationCallback.java +5 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.widget; import android.annotation.NonNull; import android.os.Build; import android.text.method.TranslationTransformationMethod; import android.util.Log; import android.view.View; Loading @@ -34,7 +35,10 @@ public class TextViewTranslationCallback implements ViewTranslationCallback { private static final String TAG = "TextViewTranslationCallback"; private static final boolean DEBUG = Log.isLoggable(UiTranslationManager.LOG_TAG, Log.DEBUG); // TODO(b/182433547): remove Build.IS_DEBUGGABLE before ship. Enable the logging in debug build // to help the debug during the development phase private static final boolean DEBUG = Log.isLoggable(UiTranslationManager.LOG_TAG, Log.DEBUG) || Build.IS_DEBUGGABLE; private TranslationTransformationMethod mTranslationTransformation; Loading