| commit | 139e82cd68dff3d3518d7ddfb038d4f01310bef3 | [log] [tgz] |
|---|---|---|
| author | Jerome Gaillard <jgaillard@google.com> | Wed May 28 12:14:16 2025 +0100 |
| committer | Jerome Gaillard <jgaillard@google.com> | Wed May 28 04:17:47 2025 -0700 |
| tree | c68e5eb12bb35ff0359aa4ad2510645c2de4a49b | |
| parent | 05acbb406c60946e60d8f503eec9a121a715ad5b [diff] |
Call dispatchConfigurationChanged if configuration changed When updating the configuration within an existing render session, exisiting views need to be informed of that change. This is done through calling dispatchConfigurationChanged on the root view. Flag: NONE host-only change Bug: 405954650 Test: test updated Change-Id: If55b2d1dc2b1f25e07618d46725af5446ff03f30
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java b/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java index 5470a54..ad03988 100644 --- a/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java +++ b/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
@@ -101,6 +101,8 @@ private final T mParams; + protected boolean mConfigurationUpdated; + private BridgeContext mContext; private static final Object sContextLock = new Object(); @@ -187,6 +189,7 @@ public void updateHardwareConfiguration(HardwareConfig hardwareConfig) { mParams.setHardwareConfig(hardwareConfig); mContext.getConfiguration().setTo(getConfiguration(mParams)); + mConfigurationUpdated = true; } /**
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java index b805e33..ab2164e 100644 --- a/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +++ b/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
@@ -483,6 +483,11 @@ return ERROR_NOT_INFLATED.createResult(); } + if (mConfigurationUpdated) { + mViewRoot.dispatchConfigurationChanged(getContext().getConfiguration()); + mConfigurationUpdated = false; + } + measureLayout(params); float scaleX = 1.0f;
diff --git a/bridge/tests/res/testApp/MyApplication/golden/allwidgets_resized.png b/bridge/tests/res/testApp/MyApplication/golden/allwidgets_resized.png index 7337711..28cc3da 100644 --- a/bridge/tests/res/testApp/MyApplication/golden/allwidgets_resized.png +++ b/bridge/tests/res/testApp/MyApplication/golden/allwidgets_resized.png Binary files differ