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

Commit 7515f1b4 authored by Sunny Goyal's avatar Sunny Goyal Committed by android-build-merger
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
am: ed2ce76b

* commit 'ed2ce76b':
  Preventing crash when there is not enough width to show the pending text
parents bc545eef ed2ce76b
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);