diff options
author | Adam Powell <adamp@google.com> | 2012-12-07 15:28:33 -0800 |
---|---|---|
committer | Adam Powell <adamp@google.com> | 2012-12-07 16:30:35 -0800 |
commit | 7da4b73a236b7c72d1337696949df7a00776dd06 (patch) | |
tree | 3ec31388ab1bd2b7e401438ff60e74b00f783975 /core/java/android/widget/ImageView.java | |
parent | ab6376b068b9d01b13951e09db21a7a9c128a1b8 (diff) | |
download | frameworks_base-7da4b73a236b7c72d1337696949df7a00776dd06.zip frameworks_base-7da4b73a236b7c72d1337696949df7a00776dd06.tar.gz frameworks_base-7da4b73a236b7c72d1337696949df7a00776dd06.tar.bz2 |
Compatibility measurement hacks when targetSdkVersion <= JB-MR1
All three of these are interrelated!
* Allow broken MeasureSpec values. The long-standing implementation
of MeasureSpec.makeMeasureSpec has been to add both values rather
than masking/or-ing the values together. Some old code relied on
this, such as if it mixed up size/mode params.
* Disable ImageView adjustViewBounds allowing the view to grow beyond
its initial size. A bug in RelativeLayout in the presence of the
above MeasureSpec fix causes this not to work properly in apps.
* Allow RelativeLayout to send overflowed/bogus MeasureSpec values
when measured with MeasureSpec.UNSPECIFIED mode. Some apps have
custom child views that do not properly handle UNSPECIFIED
measurements, but the exact overflow semantics caused this to
generate AT_MOST $REALLYBIG MeasureSpecs for those views instead if
they were placed inside a RelativeLayout in a scrolling container.
Change-Id: I977a5f1ba5637f0cba3d26a70139e2bcd021fc9c
Diffstat (limited to 'core/java/android/widget/ImageView.java')
-rw-r--r-- | core/java/android/widget/ImageView.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index e3f0960..aa977a1 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -30,6 +30,7 @@ import android.graphics.RectF; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.os.Build; import android.text.TextUtils; import android.util.AttributeSet; import android.util.Log; @@ -93,6 +94,9 @@ public class ImageView extends View { private int mBaseline = -1; private boolean mBaselineAlignBottom = false; + // AdjustViewBounds behavior will be in compatibility mode for older apps. + private boolean mAdjustViewBoundsCompat = false; + private static final ScaleType[] sScaleTypeArray = { ScaleType.MATRIX, ScaleType.FIT_XY, @@ -167,6 +171,8 @@ public class ImageView extends View { private void initImageView() { mMatrix = new Matrix(); mScaleType = ScaleType.FIT_CENTER; + mAdjustViewBoundsCompat = mContext.getApplicationInfo().targetSdkVersion <= + Build.VERSION_CODES.JELLY_BEAN_MR1; } @Override @@ -801,7 +807,7 @@ public class ImageView extends View { pleft + pright; // Allow the width to outgrow its original estimate if height is fixed. - if (!resizeHeight) { + if (!resizeHeight && !mAdjustViewBoundsCompat) { widthSize = resolveAdjustedSize(newWidth, mMaxWidth, widthMeasureSpec); } @@ -817,7 +823,7 @@ public class ImageView extends View { ptop + pbottom; // Allow the height to outgrow its original estimate if width is fixed. - if (!resizeWidth) { + if (!resizeWidth && !mAdjustViewBoundsCompat) { heightSize = resolveAdjustedSize(newHeight, mMaxHeight, heightMeasureSpec); } |