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

Commit ed2ce76b authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Preventing crash when there is not enough width to show the pending...

Merge "Preventing crash when there is not enough width to show the pending text" into ub-launcher3-burnaby-polish
parents 81131edc 5845bea5
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);