Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bcfaf36b authored by Joanne Chung's avatar Joanne Chung Committed by Automerger Merge Worker
Browse files

Merge "Fix not show translation if call startTranslation after...

Merge "Fix not show translation if call startTranslation after pauseTranslation" into sc-qpr1-dev am: e82a38a8 am: d8b714a0 am: 804a1c3c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16001112

Change-Id: Ic67b20c8d27e1ac8ed1c84e9ddb3a081f92ec0af
parents 1d3d77ec 804a1c3c
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -428,15 +428,19 @@ public class UiTranslationController {
                    continue;
                }
                mActivity.runOnUiThread(() -> {
                    ViewTranslationCallback callback = view.getViewTranslationCallback();
                    if (view.getViewTranslationResponse() != null
                            && view.getViewTranslationResponse().equals(response)) {
                        if (callback instanceof TextViewTranslationCallback) {
                            if (((TextViewTranslationCallback) callback).isShowingTranslation()) {
                                if (DEBUG) {
                                    Log.d(TAG, "Duplicate ViewTranslationResponse for " + autofillId
                                            + ". Ignoring.");
                                }
                                return;
                            }
                    ViewTranslationCallback callback = view.getViewTranslationCallback();
                        }
                    }
                    if (callback == null) {
                        if (view instanceof TextView) {
                            // developer doesn't provide their override, we set the default TextView
+7 −1
Original line number Diff line number Diff line
@@ -64,6 +64,12 @@ public class TextViewTranslationCallback implements ViewTranslationCallback {
     */
    @Override
    public boolean onShowTranslation(@NonNull View view) {
        if (mIsShowingTranslation) {
            if (DEBUG) {
                Log.d(TAG, view + " is already showing translated text.");
            }
            return false;
        }
        ViewTranslationResponse response = view.getViewTranslationResponse();
        if (response == null) {
            Log.e(TAG, "onShowTranslation() shouldn't be called before "
@@ -152,7 +158,7 @@ public class TextViewTranslationCallback implements ViewTranslationCallback {
        return true;
    }

    boolean isShowingTranslation() {
    public boolean isShowingTranslation() {
        return mIsShowingTranslation;
    }