Add digit grouping to display

Bug: 27461988

Add digit grouping separators to formula and result.

The result display piece of this is an annoyingly complex change,
since it interacts with our already subtle calculations of the
number of digits to display, our initial evaluation precision,
etc.

We display grouping separators in the result only when the entire
whole part of the number, with grouping separators, fits into
the display.  If it fits into the display without, but not with,
grouping separators, we force scientific notation. This may require
the result to be scrollable when it otherwise would not be, and
leads to an interesting set of corner cases, which we claim to
handle reasonably.

Some cleanups were applied to make this easier, more useful, and
more debuggable.  These included:

More accurate bookkeeping about different character widths. Otherwise
scrolling with grouping separators was not smooth.

Ignore grouping separators and spaces on input, as we should have
been doing all along.

Only redisplay the result if the character (as opposed to pixel)
position changed. This makes up for some extra computation and
facilitates debugging.

Introduce StringUtils.java to hold digit string operations that really
don't fit anywhere else.  Move the duplicated repeat() function there.

Change-Id: I00502b9906b184671cd3379cd68b0447939b2394
9 files changed