From ae96cb181a9a431ff111b69de984c9a5b49432ba Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Mon, 20 Apr 2020 19:44:17 -0700 Subject: [PATCH] Right align pwd field when space is tight When the text field is center aligned, it's not possible to see what's being typed after N characters. To workaround the issue, we should right align the text, otherwise characters will be clipped. Test: visual Fixes: 144509592 Change-Id: I30cbedbb7f50bc9aca4bb7c322b8c764eaabd6f5 --- .../SystemUI/src/com/android/keyguard/PasswordTextView.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java b/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java index 409ae3f3c7d60..c92174a0d8af5 100644 --- a/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java +++ b/packages/SystemUI/src/com/android/keyguard/PasswordTextView.java @@ -164,7 +164,9 @@ public class PasswordTextView extends View { currentDrawPosition = getPaddingLeft(); } } else { - currentDrawPosition = getWidth() / 2 - totalDrawingWidth / 2; + float maxRight = getWidth() - getPaddingRight() - totalDrawingWidth; + float center = getWidth() / 2f - totalDrawingWidth / 2f; + currentDrawPosition = center > 0 ? center : maxRight; } int length = mTextChars.size(); Rect bounds = getCharBounds();