diff --git a/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/screens/FinalShareScreen.java b/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/screens/FinalShareScreen.java index bf8e7eeea..fe938ae43 100644 --- a/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/screens/FinalShareScreen.java +++ b/ui/echo/src/main/java/de/danoeh/antennapod/ui/echo/screens/FinalShareScreen.java @@ -82,7 +82,8 @@ public class FinalShareScreen extends BubbleScreen { paintTextMain.setTextSize(fontSizePods); canvas.drawText((i + 1) + ".", innerBoxX, textY, paintTextMain); - canvas.drawText(favoritePodNames.get(i), innerBoxX + 0.055f * innerBoxSize, textY, paintTextMain); + String ellipsizedTitle = ellipsize(favoritePodNames.get(i), paintTextMain, (1.0f - 0.055f) * innerBoxSize); + canvas.drawText(ellipsizedTitle, innerBoxX + 0.055f * innerBoxSize, textY, paintTextMain); fontSizePods = innerBoxSize / 24; // Starting with second text is smaller textY += 1.3f * fontSizePods; paintTextMain.setTypeface(typefaceNormal); @@ -95,4 +96,14 @@ public class FinalShareScreen extends BubbleScreen { (int) (innerBoxY + innerBoxSize)); logo.draw(canvas); } + + String ellipsize(String string, Paint paint, float maxWidth) { + if (paint.measureText(string) <= maxWidth) { + return string; + } + while (paint.measureText(string + "…") > maxWidth || string.endsWith(" ")) { + string = string.substring(0, string.length() - 1); + } + return string + "…"; + } }