Merge "Reset translation state when views disappear." into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4442058508
@@ -9922,7 +9922,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
|||||||
* <ol>
|
* <ol>
|
||||||
* <li>It should only be called when content capture is enabled for the view.
|
* <li>It should only be called when content capture is enabled for the view.
|
||||||
* <li>It must call viewAppeared() before viewDisappeared()
|
* <li>It must call viewAppeared() before viewDisappeared()
|
||||||
* <li>viewAppearead() can only be called when the view is visible and laidout
|
* <li>viewAppeared() can only be called when the view is visible and laid out
|
||||||
* <li>It should not call the same event twice.
|
* <li>It should not call the same event twice.
|
||||||
* </ol>
|
* </ol>
|
||||||
*/
|
*/
|
||||||
@@ -9999,6 +9999,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
|||||||
Log.v(CONTENT_CAPTURE_LOG_TAG, "no AttachInfo on disappeared for " + this);
|
Log.v(CONTENT_CAPTURE_LOG_TAG, "no AttachInfo on disappeared for " + this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We reset any translation state as views may be re-used (e.g., as in ListView and
|
||||||
|
// RecyclerView). We only need to do this for views important for content capture since
|
||||||
|
// views unimportant for content capture won't be translated anyway.
|
||||||
|
clearTranslationState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12718,6 +12723,21 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
|||||||
== PFLAG4_HAS_TRANSLATION_TRANSIENT_STATE;
|
== PFLAG4_HAS_TRANSLATION_TRANSIENT_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public void clearTranslationState() {
|
||||||
|
if (mViewTranslationCallback != null) {
|
||||||
|
mViewTranslationCallback.onClearTranslation(this);
|
||||||
|
}
|
||||||
|
clearViewTranslationCallback();
|
||||||
|
clearViewTranslationResponse();
|
||||||
|
if (hasTranslationTransientState()) {
|
||||||
|
setHasTransientState(false);
|
||||||
|
setHasTranslationTransientState(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this view is currently attached to a window.
|
* Returns true if this view is currently attached to a window.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -158,12 +158,7 @@ public class UiTranslationController implements Dumpable {
|
|||||||
case STATE_UI_TRANSLATION_FINISHED:
|
case STATE_UI_TRANSLATION_FINISHED:
|
||||||
destroyTranslators();
|
destroyTranslators();
|
||||||
runForEachView((view, callback) -> {
|
runForEachView((view, callback) -> {
|
||||||
callback.onClearTranslation(view);
|
view.clearTranslationState();
|
||||||
view.clearViewTranslationResponse();
|
|
||||||
if (view.hasTranslationTransientState()) {
|
|
||||||
view.setHasTransientState(false);
|
|
||||||
view.setHasTranslationTransientState(false);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
notifyTranslationFinished(/* activityDestroyed= */ false);
|
notifyTranslationFinished(/* activityDestroyed= */ false);
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
|
|||||||
Reference in New Issue
Block a user