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
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 972a2e4..8192057 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -483,6 +483,11 @@
return res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
+ /** Converts a pixel value (px) to scale pixel value (SP) for the current device. */
+ public static float pxToSp(float size) {
+ return size / Resources.getSystem().getDisplayMetrics().scaledDensity;
+ }
+
public static float dpiFromPx(float size, int densityDpi) {
float densityRatio = (float) densityDpi / DisplayMetrics.DENSITY_DEFAULT;
return (size / densityRatio);