Snap for 7809314 from e82a38a8ee to sc-qpr1-release
Change-Id: I5f73590196fcdf776944ca606fd1d9a5676a4fe6
This commit is contained in:
@@ -431,15 +431,19 @@ public class UiTranslationController {
|
||||
continue;
|
||||
}
|
||||
mActivity.runOnUiThread(() -> {
|
||||
ViewTranslationCallback callback = view.getViewTranslationCallback();
|
||||
if (view.getViewTranslationResponse() != null
|
||||
&& view.getViewTranslationResponse().equals(response)) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Duplicate ViewTranslationResponse for " + autofillId
|
||||
+ ". Ignoring.");
|
||||
if (callback instanceof TextViewTranslationCallback) {
|
||||
if (((TextViewTranslationCallback) callback).isShowingTranslation()) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "Duplicate ViewTranslationResponse for " + autofillId
|
||||
+ ". Ignoring.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
ViewTranslationCallback callback = view.getViewTranslationCallback();
|
||||
if (callback == null) {
|
||||
if (view instanceof TextView) {
|
||||
// developer doesn't provide their override, we set the default TextView
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user