PointerLocationView: Do not scale touch and tool axes when drawing

The touch and tool axes in MotionEvent use display pixels as their unit,
so it is incorrect to scale them when drawing.

Instead, to make the orientation arrow more visible in
PointerLocationView, make the minimum size for the arrow 24dp, instead
of the old minimum of 20 pixels.

Bug: 285045978
Test: manual
Change-Id: I0d30c7bf0ad8cd833434229a9f6fc03c80ada6fd
This commit is contained in:
Prabir Pradhan
2023-06-07 17:35:40 +00:00
parent 9ce13dd292
commit a6ae45c8a6

View File

@@ -359,20 +359,16 @@ public class PointerLocationView extends View implements InputDeviceListener,
// Draw current touch ellipse.
mPaint.setARGB(255, pressureLevel, 255 - pressureLevel, 128);
drawOval(canvas, ps.mCoords.x, ps.mCoords.y, ps.mCoords.touchMajor * mDensity,
ps.mCoords.touchMinor * mDensity, ps.mCoords.orientation, mPaint);
drawOval(canvas, ps.mCoords.x, ps.mCoords.y, ps.mCoords.touchMajor,
ps.mCoords.touchMinor, ps.mCoords.orientation, mPaint);
// Draw current tool ellipse.
mPaint.setARGB(255, pressureLevel, 128, 255 - pressureLevel);
drawOval(canvas, ps.mCoords.x, ps.mCoords.y, ps.mCoords.toolMajor * mDensity,
ps.mCoords.toolMinor * mDensity, ps.mCoords.orientation, mPaint);
drawOval(canvas, ps.mCoords.x, ps.mCoords.y, ps.mCoords.toolMajor,
ps.mCoords.toolMinor, ps.mCoords.orientation, mPaint);
// Draw the orientation arrow.
float arrowSize = ps.mCoords.toolMajor * 0.7f;
if (arrowSize < 20) {
arrowSize = 20;
}
arrowSize *= mDensity;
// Draw the orientation arrow, and ensure it has a minimum size of 24dp.
final float arrowSize = Math.max(ps.mCoords.toolMajor * 0.7f, 24 * mDensity);
mPaint.setARGB(255, pressureLevel, 255, 0);
float orientationVectorX = (float) (Math.sin(ps.mCoords.orientation)
* arrowSize);