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

Commit 5845bea5 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Preventing crash when there is not enough width to show the pending text

Bug: 26901856
Change-Id: I03c9631ce224cce76b2c896a5e6ce6b0ee741782
parent d31dcbcc
Loading
Loading
Loading
Loading
+24 −20
Original line number Diff line number Diff line
@@ -231,6 +231,11 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView implemen

            int actualIconSize = (int) Math.min(iconSize, grid.iconSizePx);

            // Icon top when we do not draw the text
            int iconTop = (getHeight() - actualIconSize) / 2;
            mSetupTextLayout = null;

            if (availableWidth > 0) {
                // Recreate the setup text.
                mSetupTextLayout = new StaticLayout(
                        getResources().getText(R.string.gadget_setup_text), mPaint, availableWidth,
@@ -241,17 +246,16 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView implemen
                float minHeightWithText = textHeight + actualIconSize * settingIconScaleFactor
                        + grid.iconDrawablePaddingPx;

            int iconTop;
                if (minHeightWithText < availableHeight) {
                    // We can draw the text as well
                    iconTop = (getHeight() - textHeight -
                            grid.iconDrawablePaddingPx - actualIconSize) / 2;

                } else {
                // The text will not fit. Only draw the icons.
                iconTop = (getHeight() - actualIconSize) / 2;
                    // We can't draw the text. Let the iconTop be same as before.
                    mSetupTextLayout = null;
                }
            }

            mRect.set(0, 0, actualIconSize, actualIconSize);
            mRect.offset((getWidth() - actualIconSize) / 2, iconTop);