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

Commit 4da1ee45 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou
Browse files

Fix velocity reporting for negative values > -1

Currently, a velocity with a magnitude of (for example) 0.1 and a
negative sign will be displayed as positive 0.1 by the
FasterStringBuilder. This is because casting a float to an int makes it
zero, and the sign gets lost: (int)-0.1f = 0.
Add this sign here.

Bug: 112705257
Test: enabled pointer location, and manually generated some flings that
have negative direction and magnitude less than 1. Confirmed that the
velocity sign is displayed correctly.

Change-Id: I0d777e790d324739ce248d3e6b8e04692400d832
parent f8c92820
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -841,6 +841,10 @@ public class PointerLocationView extends View implements InputDeviceListener,
            }
            value = (float) (Math.rint(value * scale) / scale);

            // Corner case: (int)-0.1 will become zero, so the negative sign gets lost
            if ((int) value == 0 && value < 0) {
                append("-");
            }
            append((int) value);

            if (precision != 0) {