Make the text for the drop target buttons fit if it's too long.

The text "Don't suggest app" is too long when the device language
is GE or JA, or if you make the text bigger in settings.

Before truncating the text completely we are going to try to make
the text smaller until it gets to a predefined value
(button_drop_target_min_text_size).

Test: Change the language to German (Deutch) and install a new app and drag it to the workspace to see the button "App nicht vorschlagen"
Test: Also, a nice way to test is to go to SecondaryDropTarget#setupUi and hardcode the option to always show "Don't suggest app"
Fix: 221480721
Change-Id: I99def4e23cd17109a297aecaa620cef7a0d137e7
This commit is contained in:
Sebastian Franco
2022-04-04 14:51:53 -07:00
committed by Sebastián Franco
parent b9879a0b85
commit d2d8e97a65
4 changed files with 60 additions and 4 deletions

View File

@@ -140,9 +140,22 @@ public class DropTargetBar extends FrameLayout
if (visibleCount > 0) {
int availableWidth = width / visibleCount;
boolean textVisible = true;
for (ButtonDropTarget buttons : mDropTargets) {
if (buttons.getVisibility() != GONE) {
textVisible = textVisible && !buttons.isTextTruncated(availableWidth);
boolean textResized = false;
float textSize = mDropTargets[0].getTextSize();
for (ButtonDropTarget button : mDropTargets) {
if (button.getVisibility() == GONE) {
continue;
}
if (button.isTextTruncated(availableWidth)) {
textSize = Math.min(textSize, button.resizeTextToFit(availableWidth));
textResized = true;
}
textVisible = textVisible && !button.isTextTruncated(availableWidth);
}
if (textResized) {
for (ButtonDropTarget button : mDropTargets) {
button.setTextSize(textSize);
}
}