Merge "Preventing crash when there is not enough width to show the pending text" into ub-launcher3-burnaby-polish
This commit is contained in:
commit
ed2ce76bfe
1 file changed
+21
-17
@@ -231,26 +231,30 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView implemen
|
|||||||
|
|
||||||
int actualIconSize = (int) Math.min(iconSize, grid.iconSizePx);
|
int actualIconSize = (int) Math.min(iconSize, grid.iconSizePx);
|
||||||
|
|
||||||
// Recreate the setup text.
|
// Icon top when we do not draw the text
|
||||||
mSetupTextLayout = new StaticLayout(
|
int iconTop = (getHeight() - actualIconSize) / 2;
|
||||||
getResources().getText(R.string.gadget_setup_text), mPaint, availableWidth,
|
mSetupTextLayout = null;
|
||||||
Layout.Alignment.ALIGN_CENTER, 1, 0, true);
|
|
||||||
int textHeight = mSetupTextLayout.getHeight();
|
|
||||||
|
|
||||||
// Extra icon size due to the setting icon
|
if (availableWidth > 0) {
|
||||||
float minHeightWithText = textHeight + actualIconSize * settingIconScaleFactor
|
// Recreate the setup text.
|
||||||
+ grid.iconDrawablePaddingPx;
|
mSetupTextLayout = new StaticLayout(
|
||||||
|
getResources().getText(R.string.gadget_setup_text), mPaint, availableWidth,
|
||||||
|
Layout.Alignment.ALIGN_CENTER, 1, 0, true);
|
||||||
|
int textHeight = mSetupTextLayout.getHeight();
|
||||||
|
|
||||||
int iconTop;
|
// Extra icon size due to the setting icon
|
||||||
if (minHeightWithText < availableHeight) {
|
float minHeightWithText = textHeight + actualIconSize * settingIconScaleFactor
|
||||||
// We can draw the text as well
|
+ grid.iconDrawablePaddingPx;
|
||||||
iconTop = (getHeight() - textHeight -
|
|
||||||
grid.iconDrawablePaddingPx - actualIconSize) / 2;
|
|
||||||
|
|
||||||
} else {
|
if (minHeightWithText < availableHeight) {
|
||||||
// The text will not fit. Only draw the icons.
|
// We can draw the text as well
|
||||||
iconTop = (getHeight() - actualIconSize) / 2;
|
iconTop = (getHeight() - textHeight -
|
||||||
mSetupTextLayout = null;
|
grid.iconDrawablePaddingPx - actualIconSize) / 2;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// We can't draw the text. Let the iconTop be same as before.
|
||||||
|
mSetupTextLayout = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mRect.set(0, 0, actualIconSize, actualIconSize);
|
mRect.set(0, 0, actualIconSize, actualIconSize);
|
||||||
|
|||||||
Reference in new issue
Block a user