Make sure glowpad is centered when gravity is centered.

+----------------+
|      ----      |
|    -      -    |
|   -        -   |
|    -      -    |
|      ----      |
+----------------+
| h |              from square edge to circle edge
    |   d    |     diameter of circle
|       w        | width of square

Those are the three values involved in the calculation that we are
changing.  The formula calculated the center of the circle (glowpad).

When setting the x position of the glowpad we should always grab the
radius of the  circle (d/2) then set h to a proper value depending on
the gravity setting:
left)   h = 0               // do not shift at all
center) h = (w - d) / 2     // half the diff. between box and circle widths
right)  h = (w - d)         // total diff. between box and circle widths

This is what the code does after this change.  The flaw that I saw was
that instead of using the radius and adding to h, we used the maximum
between the radius or w/2 (half the width of the box).

The result was that in rare occassion (possibly for the first time in the
associated bug) where the circle is smaller than the box, we would shift
too far to the right because w/2 is always larger than the more
appropriate d/2.  I don't know why this was done, but I have added
jaggies@ who originally wrote the code.

I consulted with christinech@ and both determined that this is the
correct mathematical formula.

I verified that the old code did not work correctly for left, right, or
center and that all three work as expected with the new code.

bug:10958942
Change-Id: I781dc25601382d7a43408cbce0badf8a0a90d663
2 files changed
tree: 1260c4c095f05f1f59014b7f8a22098b38cba69d
  1. InCallUI/