diff options
| author | Mark Punzalan <markpun@google.com> | 2022-03-24 20:26:38 +0000 |
|---|---|---|
| committer | Mark Punzalan <markpun@google.com> | 2022-03-30 05:35:46 +0000 |
| commit | 6c3d2f7b7d297adea907536934c9e592fc9d77b2 (patch) | |
| tree | 46f5832042bc8658eec1591a585e91f688084e47 /core/java | |
| parent | 0effa3401313404854c4ed71908141a3ae297881 (diff) | |
Trigger newly-registered callbacks with events from currently active
translations.
Bug: 192331240
Test: atest android.translation.cts.UiTranslationManagerTest
Test: Manually on device:
1. Kill Gboard
2. Open translatable Chat conversation, wait for Live Translate
4. Focus on chat input
5. Auto-translate on Gboard is opened, and debug logs show
"TranslationManagerServiceImpl: Triggering callback for..."
Change-Id: Ida82a947491e8157fac5cd43939d6d358fbe6c7b
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/view/translation/UiTranslationManager.java | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/core/java/android/view/translation/UiTranslationManager.java b/core/java/android/view/translation/UiTranslationManager.java index 01acdfec6c27..9fc7b07200ae 100644 --- a/core/java/android/view/translation/UiTranslationManager.java +++ b/core/java/android/view/translation/UiTranslationManager.java @@ -163,7 +163,6 @@ public final class UiTranslationManager { /** * @removed Use {@link #startTranslation(TranslationSpec, TranslationSpec, List, ActivityId, * UiTranslationSpec)} instead. - * * @hide */ @RequiresPermission(android.Manifest.permission.MANAGE_UI_TRANSLATION) @@ -180,13 +179,13 @@ public final class UiTranslationManager { /** * Request ui translation for a given Views. * - * @param sourceSpec {@link TranslationSpec} for the data to be translated. - * @param targetSpec {@link TranslationSpec} for the translated data. - * @param viewIds A list of the {@link View}'s {@link AutofillId} which needs to be translated - * @param activityId the identifier for the Activity which needs ui translation + * @param sourceSpec {@link TranslationSpec} for the data to be translated. + * @param targetSpec {@link TranslationSpec} for the translated data. + * @param viewIds A list of the {@link View}'s {@link AutofillId} which needs to be + * translated + * @param activityId the identifier for the Activity which needs ui translation * @param uiTranslationSpec configuration for translation of the specified views * @throws IllegalArgumentException if the no {@link View}'s {@link AutofillId} in the list - * * @hide */ @RequiresPermission(android.Manifest.permission.MANAGE_UI_TRANSLATION) @@ -220,8 +219,7 @@ public final class UiTranslationManager { * * @param activityId the identifier for the Activity which needs ui translation * @throws NullPointerException the activityId or - * {@link android.app.assist.ActivityId#getToken()} is {@code null} - * + * {@link android.app.assist.ActivityId#getToken()} is {@code null} * @hide */ @RequiresPermission(android.Manifest.permission.MANAGE_UI_TRANSLATION) @@ -245,8 +243,7 @@ public final class UiTranslationManager { * * @param activityId the identifier for the Activity which needs ui translation * @throws NullPointerException the activityId or - * {@link android.app.assist.ActivityId#getToken()} is {@code null} - * + * {@link android.app.assist.ActivityId#getToken()} is {@code null} * @hide */ @RequiresPermission(android.Manifest.permission.MANAGE_UI_TRANSLATION) @@ -270,8 +267,7 @@ public final class UiTranslationManager { * * @param activityId the identifier for the Activity which needs ui translation * @throws NullPointerException the activityId or - * {@link android.app.assist.ActivityId#getToken()} is {@code null} - * + * {@link android.app.assist.ActivityId#getToken()} is {@code null} * @hide */ @RequiresPermission(android.Manifest.permission.MANAGE_UI_TRANSLATION) @@ -290,20 +286,29 @@ public final class UiTranslationManager { } /** - * Register for notifications of UI Translation state changes on the foreground activity. This + * Register for notifications of UI Translation state changes on the foreground Activity. This * is available to the owning application itself and also the current input method. * <p> * The application whose UI is being translated can use this to customize the UI Translation * behavior in ways that aren't made easy by methods like * {@link View#onCreateViewTranslationRequest(int[], Consumer)}. - * * <p> * Input methods can use this to offer complementary features to UI Translation; for example, * enabling outgoing message translation when the system is translating incoming messages in a * communication app. + * <p> + * Starting from {@link android.os.Build.VERSION_CODES#TIRAMISU}, if Activities are already + * being translated when a callback is registered, methods on the callback will be invoked for + * each translated activity, depending on the state of translation: + * <ul> + * <li>If translation is <em>not</em> paused, + * {@link UiTranslationStateCallback#onStarted} will be invoked.</li> + * <li>If translation <em>is</em> paused, {@link UiTranslationStateCallback#onStarted} + * will first be invoked, followed by {@link UiTranslationStateCallback#onPaused}.</li> + * </ul> * * @param callback the callback to register for receiving the state change - * notifications + * notifications */ public void registerUiTranslationStateCallback( @NonNull @CallbackExecutor Executor executor, @@ -355,9 +360,8 @@ public final class UiTranslationManager { * called or Activity is destroyed. * * @param activityDestroyed if the ui translation is finished because of activity destroyed. - * @param activityId the identifier for the Activity which needs ui translation - * @param componentName the ui translated Activity componentName. - * + * @param activityId the identifier for the Activity which needs ui translation + * @param componentName the ui translated Activity componentName. * @hide */ public void onTranslationFinished(boolean activityDestroyed, ActivityId activityId, |
