Loading core/java/android/view/View.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -820,6 +820,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ */ static boolean sTextureViewIgnoresDrawableSetters = false; static boolean sTextureViewIgnoresDrawableSetters = false; /** * Prior to N, some ViewGroups would not convert LayoutParams properly even though both extend * MarginLayoutParams. For instance, converting LinearLayout.LayoutParams to * RelativeLayout.LayoutParams would lose margin information. This is fixed on N but target API * check is implemented for backwards compatibility. * * {@hide} */ protected static boolean sPreserveMarginParamsInLayoutParamConversion; /** /** * This view does not want keystrokes. Use with TAKES_FOCUS_MASK when * This view does not want keystrokes. Use with TAKES_FOCUS_MASK when * calling setFlags. * calling setFlags. Loading Loading @@ -4054,6 +4065,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // On N+, we throw, but that breaks compatibility with apps that use these methods. // On N+, we throw, but that breaks compatibility with apps that use these methods. sTextureViewIgnoresDrawableSetters = targetSdkVersion <= M; sTextureViewIgnoresDrawableSetters = targetSdkVersion <= M; // Prior to N, we would drop margins in LayoutParam conversions. The fix triggers bugs // in apps so we target check it to avoid breaking existing apps. sPreserveMarginParamsInLayoutParamConversion = targetSdkVersion >= N; sCompatibilityDone = true; sCompatibilityDone = true; } } } } Loading core/java/android/widget/FrameLayout.java +7 −6 Original line number Original line Diff line number Diff line Loading @@ -382,14 +382,15 @@ public class FrameLayout extends ViewGroup { @Override @Override protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { if (sPreserveMarginParamsInLayoutParamConversion) { if (lp instanceof LayoutParams) { if (lp instanceof LayoutParams) { return new LayoutParams((LayoutParams) lp); return new LayoutParams((LayoutParams) lp); } else if (lp instanceof MarginLayoutParams) { } else if (lp instanceof MarginLayoutParams) { return new LayoutParams((MarginLayoutParams) lp); return new LayoutParams((MarginLayoutParams) lp); } else { return new LayoutParams(lp); } } } } return new LayoutParams(lp); } @Override @Override public CharSequence getAccessibilityClassName() { public CharSequence getAccessibilityClassName() { Loading core/java/android/widget/GridLayout.java +7 −6 Original line number Original line Diff line number Diff line Loading @@ -868,14 +868,15 @@ public class GridLayout extends ViewGroup { @Override @Override protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { if (sPreserveMarginParamsInLayoutParamConversion) { if (lp instanceof LayoutParams) { if (lp instanceof LayoutParams) { return new LayoutParams((LayoutParams) lp); return new LayoutParams((LayoutParams) lp); } else if (lp instanceof MarginLayoutParams) { } else if (lp instanceof MarginLayoutParams) { return new LayoutParams((MarginLayoutParams) lp); return new LayoutParams((MarginLayoutParams) lp); } else { return new LayoutParams(lp); } } } } return new LayoutParams(lp); } // Draw grid // Draw grid Loading core/java/android/widget/LinearLayout.java +7 −6 Original line number Original line Diff line number Diff line Loading @@ -1871,14 +1871,15 @@ public class LinearLayout extends ViewGroup { @Override @Override protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { if (sPreserveMarginParamsInLayoutParamConversion) { if (lp instanceof LayoutParams) { if (lp instanceof LayoutParams) { return new LayoutParams((LayoutParams) lp); return new LayoutParams((LayoutParams) lp); } else if (lp instanceof MarginLayoutParams) { } else if (lp instanceof MarginLayoutParams) { return new LayoutParams((MarginLayoutParams) lp); return new LayoutParams((MarginLayoutParams) lp); } else { return new LayoutParams(lp); } } } } return new LayoutParams(lp); } // Override to allow type-checking of LayoutParams. // Override to allow type-checking of LayoutParams. Loading core/java/android/widget/RelativeLayout.java +7 −6 Original line number Original line Diff line number Diff line Loading @@ -1104,14 +1104,15 @@ public class RelativeLayout extends ViewGroup { @Override @Override protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { if (sPreserveMarginParamsInLayoutParamConversion) { if (lp instanceof LayoutParams) { if (lp instanceof LayoutParams) { return new LayoutParams((LayoutParams) lp); return new LayoutParams((LayoutParams) lp); } else if (lp instanceof MarginLayoutParams) { } else if (lp instanceof MarginLayoutParams) { return new LayoutParams((MarginLayoutParams) lp); return new LayoutParams((MarginLayoutParams) lp); } else { return new LayoutParams(lp); } } } } return new LayoutParams(lp); } /** @hide */ /** @hide */ @Override @Override Loading Loading
core/java/android/view/View.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -820,6 +820,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ */ static boolean sTextureViewIgnoresDrawableSetters = false; static boolean sTextureViewIgnoresDrawableSetters = false; /** * Prior to N, some ViewGroups would not convert LayoutParams properly even though both extend * MarginLayoutParams. For instance, converting LinearLayout.LayoutParams to * RelativeLayout.LayoutParams would lose margin information. This is fixed on N but target API * check is implemented for backwards compatibility. * * {@hide} */ protected static boolean sPreserveMarginParamsInLayoutParamConversion; /** /** * This view does not want keystrokes. Use with TAKES_FOCUS_MASK when * This view does not want keystrokes. Use with TAKES_FOCUS_MASK when * calling setFlags. * calling setFlags. Loading Loading @@ -4054,6 +4065,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, // On N+, we throw, but that breaks compatibility with apps that use these methods. // On N+, we throw, but that breaks compatibility with apps that use these methods. sTextureViewIgnoresDrawableSetters = targetSdkVersion <= M; sTextureViewIgnoresDrawableSetters = targetSdkVersion <= M; // Prior to N, we would drop margins in LayoutParam conversions. The fix triggers bugs // in apps so we target check it to avoid breaking existing apps. sPreserveMarginParamsInLayoutParamConversion = targetSdkVersion >= N; sCompatibilityDone = true; sCompatibilityDone = true; } } } } Loading
core/java/android/widget/FrameLayout.java +7 −6 Original line number Original line Diff line number Diff line Loading @@ -382,14 +382,15 @@ public class FrameLayout extends ViewGroup { @Override @Override protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { if (sPreserveMarginParamsInLayoutParamConversion) { if (lp instanceof LayoutParams) { if (lp instanceof LayoutParams) { return new LayoutParams((LayoutParams) lp); return new LayoutParams((LayoutParams) lp); } else if (lp instanceof MarginLayoutParams) { } else if (lp instanceof MarginLayoutParams) { return new LayoutParams((MarginLayoutParams) lp); return new LayoutParams((MarginLayoutParams) lp); } else { return new LayoutParams(lp); } } } } return new LayoutParams(lp); } @Override @Override public CharSequence getAccessibilityClassName() { public CharSequence getAccessibilityClassName() { Loading
core/java/android/widget/GridLayout.java +7 −6 Original line number Original line Diff line number Diff line Loading @@ -868,14 +868,15 @@ public class GridLayout extends ViewGroup { @Override @Override protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { if (sPreserveMarginParamsInLayoutParamConversion) { if (lp instanceof LayoutParams) { if (lp instanceof LayoutParams) { return new LayoutParams((LayoutParams) lp); return new LayoutParams((LayoutParams) lp); } else if (lp instanceof MarginLayoutParams) { } else if (lp instanceof MarginLayoutParams) { return new LayoutParams((MarginLayoutParams) lp); return new LayoutParams((MarginLayoutParams) lp); } else { return new LayoutParams(lp); } } } } return new LayoutParams(lp); } // Draw grid // Draw grid Loading
core/java/android/widget/LinearLayout.java +7 −6 Original line number Original line Diff line number Diff line Loading @@ -1871,14 +1871,15 @@ public class LinearLayout extends ViewGroup { @Override @Override protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { if (sPreserveMarginParamsInLayoutParamConversion) { if (lp instanceof LayoutParams) { if (lp instanceof LayoutParams) { return new LayoutParams((LayoutParams) lp); return new LayoutParams((LayoutParams) lp); } else if (lp instanceof MarginLayoutParams) { } else if (lp instanceof MarginLayoutParams) { return new LayoutParams((MarginLayoutParams) lp); return new LayoutParams((MarginLayoutParams) lp); } else { return new LayoutParams(lp); } } } } return new LayoutParams(lp); } // Override to allow type-checking of LayoutParams. // Override to allow type-checking of LayoutParams. Loading
core/java/android/widget/RelativeLayout.java +7 −6 Original line number Original line Diff line number Diff line Loading @@ -1104,14 +1104,15 @@ public class RelativeLayout extends ViewGroup { @Override @Override protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) { if (sPreserveMarginParamsInLayoutParamConversion) { if (lp instanceof LayoutParams) { if (lp instanceof LayoutParams) { return new LayoutParams((LayoutParams) lp); return new LayoutParams((LayoutParams) lp); } else if (lp instanceof MarginLayoutParams) { } else if (lp instanceof MarginLayoutParams) { return new LayoutParams((MarginLayoutParams) lp); return new LayoutParams((MarginLayoutParams) lp); } else { return new LayoutParams(lp); } } } } return new LayoutParams(lp); } /** @hide */ /** @hide */ @Override @Override Loading