Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d5edc772 authored by Adam Powell's avatar Adam Powell
Browse files

Fix adjustViewBounds handling for ImageView

When computing the adjusted view bounds, don't constrain the
dimensions by the original estimate if the opposite dimension has a
fixed size. This can result in the view never getting properly
enlarged.

Also fix a long-standing bug in MeasureSpec.makeMeasureSpec where
oversized or negative values could result in broken packed values.

Bug 72402519

Change-Id: I359d108ff52b6f3b5c4bf393d2271d28999c0127
parent 59adf04a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -17208,7 +17208,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
         * @return the measure specification based on size and mode
         */
        public static int makeMeasureSpec(int size, int mode) {
            return size + mode;
            return (size & ~MODE_MASK) | (mode & MODE_MASK);
        }
        /**
+13 −0
Original line number Diff line number Diff line
@@ -789,6 +789,12 @@ public class ImageView extends View {
                    if (resizeWidth) {
                        int newWidth = (int)(desiredAspect * (heightSize - ptop - pbottom)) +
                                pleft + pright;

                        // Allow the width to outgrow its original estimate if height is fixed.
                        if (!resizeHeight) {
                            widthSize = resolveAdjustedSize(newWidth, mMaxWidth, widthMeasureSpec);
                        }

                        if (newWidth <= widthSize) {
                            widthSize = newWidth;
                            done = true;
@@ -799,6 +805,13 @@ public class ImageView extends View {
                    if (!done && resizeHeight) {
                        int newHeight = (int)((widthSize - pleft - pright) / desiredAspect) +
                                ptop + pbottom;

                        // Allow the height to outgrow its original estimate if width is fixed.
                        if (!resizeWidth) {
                            heightSize = resolveAdjustedSize(newHeight, mMaxHeight,
                                    heightMeasureSpec);
                        }

                        if (newHeight <= heightSize) {
                            heightSize = newHeight;
                        }