Merge "Update layout direction if ViewRoot is preserved" into tm-qpr-dev am: 3c282790e4

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

Change-Id: I4c4f0a12f317219b86c57218eba9c87725ce91fb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-10-12 14:15:42 +00:00
committed by Automerger Merge Worker

View File

@@ -1102,7 +1102,7 @@ public final class ViewRootImpl implements ViewParent,
// Update the last resource config in case the resource configuration was changed while
// activity relaunched.
mLastConfigurationFromResources.setTo(getConfiguration());
updateLastConfigurationFromResources(getConfiguration());
}
private Configuration getConfiguration() {
@@ -5398,13 +5398,7 @@ public final class ViewRootImpl implements ViewParent,
// Update the display with new DisplayAdjustments.
updateInternalDisplay(mDisplay.getDisplayId(), localResources);
final int lastLayoutDirection = mLastConfigurationFromResources.getLayoutDirection();
final int currentLayoutDirection = config.getLayoutDirection();
mLastConfigurationFromResources.setTo(config);
if (lastLayoutDirection != currentLayoutDirection
&& mViewLayoutDirectionInitial == View.LAYOUT_DIRECTION_INHERIT) {
mView.setLayoutDirection(currentLayoutDirection);
}
updateLastConfigurationFromResources(config);
mView.dispatchConfigurationChanged(config);
// We could have gotten this {@link Configuration} update after we called
@@ -5418,6 +5412,17 @@ public final class ViewRootImpl implements ViewParent,
updateForceDarkMode();
}
private void updateLastConfigurationFromResources(Configuration resConfig) {
final int lastLayoutDirection = mLastConfigurationFromResources.getLayoutDirection();
final int currentLayoutDirection = resConfig.getLayoutDirection();
mLastConfigurationFromResources.setTo(resConfig);
// Update layout direction in case the language or screen layout is changed.
if (lastLayoutDirection != currentLayoutDirection && mView != null
&& mViewLayoutDirectionInitial == View.LAYOUT_DIRECTION_INHERIT) {
mView.setLayoutDirection(currentLayoutDirection);
}
}
/**
* Return true if child is an ancestor of parent, (or equal to the parent).
*/