Loading core/java/android/view/View.java +14 −73 Original line number Diff line number Diff line Loading @@ -204,7 +204,6 @@ import android.view.translation.ViewTranslationCallback; import android.view.translation.ViewTranslationRequest; import android.view.translation.ViewTranslationResponse; import android.widget.Checkable; import android.widget.FrameLayout; import android.widget.ScrollBarDrawable; import android.window.OnBackInvokedDispatcher; Loading Loading @@ -961,21 +960,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** @hide */ public HapticScrollFeedbackProvider mScrollFeedbackProvider = null; /** * Use the old (broken) way of building MeasureSpecs. */ private static boolean sUseBrokenMakeMeasureSpec = false; /** * Always return a size of 0 for MeasureSpec values with a mode of UNSPECIFIED */ static boolean sUseZeroUnspecifiedMeasureSpec = false; /** * Ignore any optimizations using the measure cache. */ private static boolean sIgnoreMeasureCache = false; /** * Ignore an optimization that skips unnecessary EXACTLY layout passes. */ Loading Loading @@ -5845,20 +5829,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (!sCompatibilityDone && context != null) { final int targetSdkVersion = context.getApplicationInfo().targetSdkVersion; // Older apps may need this compatibility hack for measurement. sUseBrokenMakeMeasureSpec = targetSdkVersion <= Build.VERSION_CODES.JELLY_BEAN_MR1; // Older apps expect onMeasure() to always be called on a layout pass, regardless // of whether a layout was requested on that View. sIgnoreMeasureCache = targetSdkVersion < Build.VERSION_CODES.KITKAT; // In M and newer, our widgets can pass a "hint" value in the size // for UNSPECIFIED MeasureSpecs. This lets child views of scrolling containers // know what the expected parent size is going to be, so e.g. list items can size // themselves at 1/3 the size of their container. It breaks older apps though, // specifically apps that use some popular open source libraries. sUseZeroUnspecifiedMeasureSpec = targetSdkVersion < Build.VERSION_CODES.M; // Old versions of the platform would give different results from // LinearLayout measurement passes using EXACTLY and non-EXACTLY // modes, so we always need to run an additional EXACTLY pass. Loading Loading @@ -6035,8 +6005,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, boolean leftPaddingDefined = false; boolean rightPaddingDefined = false; final int targetSdkVersion = context.getApplicationInfo().targetSdkVersion; // Set default values. viewFlagValues |= FOCUSABLE_AUTO; viewFlagMasks |= FOCUSABLE_AUTO; Loading Loading @@ -6257,11 +6225,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, break; //noinspection deprecation case R.styleable.View_fadingEdge: if (targetSdkVersion >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // Ignore the attribute starting with ICS break; } // With builds < ICS, fall through and apply fading edges case R.styleable.View_requiresFadingEdge: final int fadingEdge = a.getInt(attr, FADING_EDGE_NONE); if (fadingEdge != FADING_EDGE_NONE) { Loading Loading @@ -6399,35 +6363,25 @@ public class View implements Drawable.Callback, KeyEvent.Callback, PROVIDER_BACKGROUND)); break; case R.styleable.View_foreground: if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) { setForeground(a.getDrawable(attr)); } break; case R.styleable.View_foregroundGravity: if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) { setForegroundGravity(a.getInt(attr, Gravity.NO_GRAVITY)); } break; case R.styleable.View_foregroundTintMode: if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) { setForegroundTintBlendMode( Drawable.parseBlendMode(a.getInt(attr, -1), null)); } break; case R.styleable.View_foregroundTint: if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) { setForegroundTintList(a.getColorStateList(attr)); } break; case R.styleable.View_foregroundInsidePadding: if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) { if (mForegroundInfo == null) { mForegroundInfo = new ForegroundInfo(); } mForegroundInfo.mInsidePadding = a.getBoolean(attr, mForegroundInfo.mInsidePadding); } break; case R.styleable.View_scrollIndicators: final int scrollIndicators = Loading Loading @@ -13905,11 +13859,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, }) @ResolvedLayoutDir public int getLayoutDirection() { final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion; if (targetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR1) { mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED; return LAYOUT_DIRECTION_RESOLVED_DEFAULT; } return ((mPrivateFlags2 & PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL) == PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL) ? LAYOUT_DIRECTION_RTL : LAYOUT_DIRECTION_LTR; } Loading Loading @@ -22480,8 +22429,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * RTL not supported) */ private boolean isRtlCompatibilityMode() { final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion; return targetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR1 || !hasRtlSupport(); return !hasRtlSupport(); } /** Loading Loading @@ -28149,7 +28097,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, cacheIndex = forceLayout ? -1 : mMeasureCache.indexOfKey(key); } if (cacheIndex < 0 || sIgnoreMeasureCache) { if (cacheIndex < 0) { if (isTraversalTracingEnabled()) { Trace.beginSection(mTracingStrings.onMeasure); } Loading Loading @@ -31135,12 +31083,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ public static int makeMeasureSpec(@IntRange(from = 0, to = (1 << MeasureSpec.MODE_SHIFT) - 1) int size, @MeasureSpecMode int mode) { if (sUseBrokenMakeMeasureSpec) { return size + mode; } else { return (size & ~MODE_MASK) | (mode & MODE_MASK); } } /** * Like {@link #makeMeasureSpec(int, int)}, but any spec with a mode of UNSPECIFIED Loading @@ -31150,9 +31094,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ @UnsupportedAppUsage public static int makeSafeMeasureSpec(int size, int mode) { if (sUseZeroUnspecifiedMeasureSpec && mode == UNSPECIFIED) { return 0; } return makeMeasureSpec(size, mode); } core/java/android/view/ViewGroup.java +5 −52 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package android.view; import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; import static android.view.WindowInsetsAnimation.Callback.DISPATCH_MODE_CONTINUE_ON_SUBTREE; import static android.view.WindowInsetsAnimation.Callback.DISPATCH_MODE_STOP; Loading Loading @@ -55,7 +54,6 @@ import android.util.Log; import android.util.Pools; import android.util.Pools.SynchronizedPool; import android.util.SparseArray; import android.util.SparseBooleanArray; import android.view.WindowInsetsAnimation.Bounds; import android.view.WindowInsetsAnimation.Callback.DispatchMode; import android.view.accessibility.AccessibilityEvent; Loading Loading @@ -718,10 +716,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager mGroupFlags |= FLAG_ANIMATION_DONE; mGroupFlags |= FLAG_ANIMATION_CACHE; mGroupFlags |= FLAG_ALWAYS_DRAWN_WITH_CACHE; if (mContext.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB) { mGroupFlags |= FLAG_SPLIT_MOTION_EVENTS; } setDescendantFocusability(FOCUS_BEFORE_DESCENDANTS); Loading Loading @@ -3599,49 +3594,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager childIndex = getAndVerifyPreorderedIndex(childrenCount, i, customOrder); } catch (IndexOutOfBoundsException e) { childIndex = i; if (mContext.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.M) { Log.w(TAG, "Bad getChildDrawingOrder while collecting assist @ " + i + " of " + childrenCount, e); // At least one app is failing when we call getChildDrawingOrder // at this point, so deal semi-gracefully with it by falling back // on the basic order. customOrder = false; if (i > 0) { // If we failed at the first index, there really isn't // anything to do -- we will just proceed with the simple // sequence order. // Otherwise, we failed in the middle, so need to come up // with an order for the remaining indices and use that. // Failed at the first one, easy peasy. int[] permutation = new int[childrenCount]; SparseBooleanArray usedIndices = new SparseBooleanArray(); // Go back and collected the indices we have done so far. for (int j = 0; j < i; j++) { permutation[j] = getChildDrawingOrder(childrenCount, j); usedIndices.put(permutation[j], true); } // Fill in the remaining indices with indices that have not // yet been used. int nextIndex = 0; for (int j = i; j < childrenCount; j++) { while (usedIndices.get(nextIndex, false)) { nextIndex++; } permutation[j] = nextIndex; nextIndex++; } // Build the final view list. preorderedList = new ArrayList<>(childrenCount); for (int j = 0; j < childrenCount; j++) { final int index = permutation[j]; final View child = mChildren[index]; preorderedList.add(child); } } } else { throw e; } } final View child = getAndVerifyPreorderedView(preorderedList, mChildren, childIndex); final ViewStructure cstructure = structure.newChild(i); Loading Loading @@ -7109,12 +7063,12 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } else if (childDimension == LayoutParams.MATCH_PARENT) { // Child wants to be our size... find out how big it should // be resultSize = View.sUseZeroUnspecifiedMeasureSpec ? 0 : size; resultSize = size; resultMode = MeasureSpec.UNSPECIFIED; } else if (childDimension == LayoutParams.WRAP_CONTENT) { // Child wants to determine its own size.... find out how // big it should be resultSize = View.sUseZeroUnspecifiedMeasureSpec ? 0 : size; resultSize = size; resultMode = MeasureSpec.UNSPECIFIED; } break; Loading Loading @@ -8662,8 +8616,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } final boolean hasRtlSupport = c.getApplicationInfo().hasRtlSupport(); final int targetSdkVersion = c.getApplicationInfo().targetSdkVersion; if (targetSdkVersion < JELLY_BEAN_MR1 || !hasRtlSupport) { if (!hasRtlSupport) { mMarginFlags |= RTL_COMPATIBILITY_MODE_MASK; } Loading Loading
core/java/android/view/View.java +14 −73 Original line number Diff line number Diff line Loading @@ -204,7 +204,6 @@ import android.view.translation.ViewTranslationCallback; import android.view.translation.ViewTranslationRequest; import android.view.translation.ViewTranslationResponse; import android.widget.Checkable; import android.widget.FrameLayout; import android.widget.ScrollBarDrawable; import android.window.OnBackInvokedDispatcher; Loading Loading @@ -961,21 +960,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** @hide */ public HapticScrollFeedbackProvider mScrollFeedbackProvider = null; /** * Use the old (broken) way of building MeasureSpecs. */ private static boolean sUseBrokenMakeMeasureSpec = false; /** * Always return a size of 0 for MeasureSpec values with a mode of UNSPECIFIED */ static boolean sUseZeroUnspecifiedMeasureSpec = false; /** * Ignore any optimizations using the measure cache. */ private static boolean sIgnoreMeasureCache = false; /** * Ignore an optimization that skips unnecessary EXACTLY layout passes. */ Loading Loading @@ -5845,20 +5829,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (!sCompatibilityDone && context != null) { final int targetSdkVersion = context.getApplicationInfo().targetSdkVersion; // Older apps may need this compatibility hack for measurement. sUseBrokenMakeMeasureSpec = targetSdkVersion <= Build.VERSION_CODES.JELLY_BEAN_MR1; // Older apps expect onMeasure() to always be called on a layout pass, regardless // of whether a layout was requested on that View. sIgnoreMeasureCache = targetSdkVersion < Build.VERSION_CODES.KITKAT; // In M and newer, our widgets can pass a "hint" value in the size // for UNSPECIFIED MeasureSpecs. This lets child views of scrolling containers // know what the expected parent size is going to be, so e.g. list items can size // themselves at 1/3 the size of their container. It breaks older apps though, // specifically apps that use some popular open source libraries. sUseZeroUnspecifiedMeasureSpec = targetSdkVersion < Build.VERSION_CODES.M; // Old versions of the platform would give different results from // LinearLayout measurement passes using EXACTLY and non-EXACTLY // modes, so we always need to run an additional EXACTLY pass. Loading Loading @@ -6035,8 +6005,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, boolean leftPaddingDefined = false; boolean rightPaddingDefined = false; final int targetSdkVersion = context.getApplicationInfo().targetSdkVersion; // Set default values. viewFlagValues |= FOCUSABLE_AUTO; viewFlagMasks |= FOCUSABLE_AUTO; Loading Loading @@ -6257,11 +6225,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, break; //noinspection deprecation case R.styleable.View_fadingEdge: if (targetSdkVersion >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // Ignore the attribute starting with ICS break; } // With builds < ICS, fall through and apply fading edges case R.styleable.View_requiresFadingEdge: final int fadingEdge = a.getInt(attr, FADING_EDGE_NONE); if (fadingEdge != FADING_EDGE_NONE) { Loading Loading @@ -6399,35 +6363,25 @@ public class View implements Drawable.Callback, KeyEvent.Callback, PROVIDER_BACKGROUND)); break; case R.styleable.View_foreground: if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) { setForeground(a.getDrawable(attr)); } break; case R.styleable.View_foregroundGravity: if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) { setForegroundGravity(a.getInt(attr, Gravity.NO_GRAVITY)); } break; case R.styleable.View_foregroundTintMode: if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) { setForegroundTintBlendMode( Drawable.parseBlendMode(a.getInt(attr, -1), null)); } break; case R.styleable.View_foregroundTint: if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) { setForegroundTintList(a.getColorStateList(attr)); } break; case R.styleable.View_foregroundInsidePadding: if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) { if (mForegroundInfo == null) { mForegroundInfo = new ForegroundInfo(); } mForegroundInfo.mInsidePadding = a.getBoolean(attr, mForegroundInfo.mInsidePadding); } break; case R.styleable.View_scrollIndicators: final int scrollIndicators = Loading Loading @@ -13905,11 +13859,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, }) @ResolvedLayoutDir public int getLayoutDirection() { final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion; if (targetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR1) { mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED; return LAYOUT_DIRECTION_RESOLVED_DEFAULT; } return ((mPrivateFlags2 & PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL) == PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL) ? LAYOUT_DIRECTION_RTL : LAYOUT_DIRECTION_LTR; } Loading Loading @@ -22480,8 +22429,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * RTL not supported) */ private boolean isRtlCompatibilityMode() { final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion; return targetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR1 || !hasRtlSupport(); return !hasRtlSupport(); } /** Loading Loading @@ -28149,7 +28097,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, cacheIndex = forceLayout ? -1 : mMeasureCache.indexOfKey(key); } if (cacheIndex < 0 || sIgnoreMeasureCache) { if (cacheIndex < 0) { if (isTraversalTracingEnabled()) { Trace.beginSection(mTracingStrings.onMeasure); } Loading Loading @@ -31135,12 +31083,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ public static int makeMeasureSpec(@IntRange(from = 0, to = (1 << MeasureSpec.MODE_SHIFT) - 1) int size, @MeasureSpecMode int mode) { if (sUseBrokenMakeMeasureSpec) { return size + mode; } else { return (size & ~MODE_MASK) | (mode & MODE_MASK); } } /** * Like {@link #makeMeasureSpec(int, int)}, but any spec with a mode of UNSPECIFIED Loading @@ -31150,9 +31094,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ @UnsupportedAppUsage public static int makeSafeMeasureSpec(int size, int mode) { if (sUseZeroUnspecifiedMeasureSpec && mode == UNSPECIFIED) { return 0; } return makeMeasureSpec(size, mode); }
core/java/android/view/ViewGroup.java +5 −52 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package android.view; import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; import static android.view.WindowInsetsAnimation.Callback.DISPATCH_MODE_CONTINUE_ON_SUBTREE; import static android.view.WindowInsetsAnimation.Callback.DISPATCH_MODE_STOP; Loading Loading @@ -55,7 +54,6 @@ import android.util.Log; import android.util.Pools; import android.util.Pools.SynchronizedPool; import android.util.SparseArray; import android.util.SparseBooleanArray; import android.view.WindowInsetsAnimation.Bounds; import android.view.WindowInsetsAnimation.Callback.DispatchMode; import android.view.accessibility.AccessibilityEvent; Loading Loading @@ -718,10 +716,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager mGroupFlags |= FLAG_ANIMATION_DONE; mGroupFlags |= FLAG_ANIMATION_CACHE; mGroupFlags |= FLAG_ALWAYS_DRAWN_WITH_CACHE; if (mContext.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB) { mGroupFlags |= FLAG_SPLIT_MOTION_EVENTS; } setDescendantFocusability(FOCUS_BEFORE_DESCENDANTS); Loading Loading @@ -3599,49 +3594,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager childIndex = getAndVerifyPreorderedIndex(childrenCount, i, customOrder); } catch (IndexOutOfBoundsException e) { childIndex = i; if (mContext.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.M) { Log.w(TAG, "Bad getChildDrawingOrder while collecting assist @ " + i + " of " + childrenCount, e); // At least one app is failing when we call getChildDrawingOrder // at this point, so deal semi-gracefully with it by falling back // on the basic order. customOrder = false; if (i > 0) { // If we failed at the first index, there really isn't // anything to do -- we will just proceed with the simple // sequence order. // Otherwise, we failed in the middle, so need to come up // with an order for the remaining indices and use that. // Failed at the first one, easy peasy. int[] permutation = new int[childrenCount]; SparseBooleanArray usedIndices = new SparseBooleanArray(); // Go back and collected the indices we have done so far. for (int j = 0; j < i; j++) { permutation[j] = getChildDrawingOrder(childrenCount, j); usedIndices.put(permutation[j], true); } // Fill in the remaining indices with indices that have not // yet been used. int nextIndex = 0; for (int j = i; j < childrenCount; j++) { while (usedIndices.get(nextIndex, false)) { nextIndex++; } permutation[j] = nextIndex; nextIndex++; } // Build the final view list. preorderedList = new ArrayList<>(childrenCount); for (int j = 0; j < childrenCount; j++) { final int index = permutation[j]; final View child = mChildren[index]; preorderedList.add(child); } } } else { throw e; } } final View child = getAndVerifyPreorderedView(preorderedList, mChildren, childIndex); final ViewStructure cstructure = structure.newChild(i); Loading Loading @@ -7109,12 +7063,12 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } else if (childDimension == LayoutParams.MATCH_PARENT) { // Child wants to be our size... find out how big it should // be resultSize = View.sUseZeroUnspecifiedMeasureSpec ? 0 : size; resultSize = size; resultMode = MeasureSpec.UNSPECIFIED; } else if (childDimension == LayoutParams.WRAP_CONTENT) { // Child wants to determine its own size.... find out how // big it should be resultSize = View.sUseZeroUnspecifiedMeasureSpec ? 0 : size; resultSize = size; resultMode = MeasureSpec.UNSPECIFIED; } break; Loading Loading @@ -8662,8 +8616,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } final boolean hasRtlSupport = c.getApplicationInfo().hasRtlSupport(); final int targetSdkVersion = c.getApplicationInfo().targetSdkVersion; if (targetSdkVersion < JELLY_BEAN_MR1 || !hasRtlSupport) { if (!hasRtlSupport) { mMarginFlags |= RTL_COMPATIBILITY_MODE_MASK; } Loading