Merge "Restore force relayout logic for apps targeting < R" into rvc-dev am: 98f012c304 am: 5706a132ab

Change-Id: I4b8cf67320eb57955415d49397b5a115c50a0c00
This commit is contained in:
Jorim Jaggi
2020-05-04 21:00:32 +00:00
committed by Automerger Merge Worker
2 changed files with 15 additions and 0 deletions

View File

@@ -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;
}
}

View File

@@ -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) {