diff options
| author | 2020-05-04 20:44:08 +0000 | |
|---|---|---|
| committer | 2020-05-04 20:44:08 +0000 | |
| commit | 98f012c3044b7c3c674da91bca80a123005ce998 (patch) | |
| tree | 8b1a0da1326441a806bfcd09c68b06040b75d030 | |
| parent | 98367aef1180ab2d98e7abf3b0ff1d7de539db07 (diff) | |
| parent | 653828d09e76e67b20896890db81c41791c94984 (diff) | |
Merge "Restore force relayout logic for apps targeting < R" into rvc-dev
| -rw-r--r-- | core/java/android/view/View.java | 10 | ||||
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 5 |
2 files changed, 15 insertions, 0 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index facf8619111c..1226202dfdf9 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -981,6 +981,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ protected static boolean sBrokenWindowBackground; + /** + * Prior to R, we were always forcing a layout of the entire hierarchy when insets changed from + * the server. This is inefficient and not all apps use it. Instead, we want to rely on apps + * calling {@link #requestLayout} when they need to relayout based on an insets change. + */ + static boolean sForceLayoutWhenInsetsChanged; + /** @hide */ @IntDef({NOT_FOCUSABLE, FOCUSABLE, FOCUSABLE_AUTO}) @Retention(RetentionPolicy.SOURCE) @@ -5375,6 +5382,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback, GradientDrawable.sWrapNegativeAngleMeasurements = targetSdkVersion >= Build.VERSION_CODES.Q; + + sForceLayoutWhenInsetsChanged = targetSdkVersion < Build.VERSION_CODES.R; + sCompatibilityDone = true; } } diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index b74c8f641a76..42f11c162473 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -1584,6 +1584,11 @@ public final class ViewRootImpl implements ViewParent, mApplyInsetsRequested = true; requestLayout(); + // See comment for View.sForceLayoutWhenInsetsChanged + if (View.sForceLayoutWhenInsetsChanged && mView != null) { + forceLayout(mView); + } + // If this changes during traversal, no need to schedule another one as it will dispatch it // during the current traversal. if (!mIsInTraversal) { |