From eab392086cb1d2d8061566b60805354765b4513f Mon Sep 17 00:00:00 2001 From: lbill Date: Fri, 7 Oct 2022 08:18:04 +0000 Subject: [PATCH] Fix AuthCredentialPasswordView inputfield overlap issue 1. SubTitle or descriptionView may not set by 3P app, so we should check visibility of subTitle and descriptionView only count it's position when view is visible. 2. Adjust landscape layout margin to ensure IME pop-up the auth header container can show title & description expectedly. 3. Set Title view with marquee when device in landscape mode and IME pop-up(mBottomInset > 0). Note:select to enable marquee unless a screen reader is enabled. Bug: 243115550 Test: atest AuthContainerViewTests Test: manual check visual, set display & font scale > largest check the PIN/Password inputfield should not overlap desc Change-Id: I5f3798b31749a1184bcbd9895b1b0820a1029d81 --- .../auth_credential_password_view.xml | 6 +-- .../layout/auth_credential_password_view.xml | 6 +-- .../AuthCredentialPasswordView.java | 50 +++++++++++++++---- .../biometrics/AuthCredentialPatternView.java | 4 +- .../biometrics/AuthCredentialView.java | 8 +-- 5 files changed, 52 insertions(+), 22 deletions(-) diff --git a/packages/SystemUI/res/layout-land/auth_credential_password_view.xml b/packages/SystemUI/res/layout-land/auth_credential_password_view.xml index a4d4025f2d101..3bcc37a478c98 100644 --- a/packages/SystemUI/res/layout-land/auth_credential_password_view.xml +++ b/packages/SystemUI/res/layout-land/auth_credential_password_view.xml @@ -40,7 +40,7 @@ android:id="@+id/title" style="?titleTextAppearance" android:layout_below="@id/icon" - android:layout_width="wrap_content" + android:layout_width="match_parent" android:layout_height="wrap_content" /> diff --git a/packages/SystemUI/res/layout/auth_credential_password_view.xml b/packages/SystemUI/res/layout/auth_credential_password_view.xml index d9abaf2c7eac5..774b335f913ed 100644 --- a/packages/SystemUI/res/layout/auth_credential_password_view.xml +++ b/packages/SystemUI/res/layout/auth_credential_password_view.xml @@ -40,21 +40,21 @@ android:id="@+id/title" style="?titleTextAppearance" android:layout_below="@id/icon" - android:layout_width="wrap_content" + android:layout_width="match_parent" android:layout_height="wrap_content"/> diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPasswordView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPasswordView.java index 5ed898682883f..76cd3f4c4f1d5 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPasswordView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPasswordView.java @@ -24,6 +24,7 @@ import android.content.Context; import android.graphics.Insets; import android.os.UserHandle; import android.text.InputType; +import android.text.TextUtils; import android.util.AttributeSet; import android.view.KeyEvent; import android.view.View; @@ -151,39 +152,52 @@ public class AuthCredentialPasswordView extends AuthCredentialView protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); - if (mAuthCredentialInput == null || mAuthCredentialHeader == null - || mSubtitleView == null || mPasswordField == null || mErrorView == null) { + if (mAuthCredentialInput == null || mAuthCredentialHeader == null || mSubtitleView == null + || mDescriptionView == null || mPasswordField == null || mErrorView == null) { return; } - // b/157910732 In AuthContainerView#getLayoutParams() we used to prevent jank risk when - // resizing by IME show or hide, we used to setFitInsetsTypes `~WindowInsets.Type.ime()` to - // LP. As a result this view needs to listen onApplyWindowInsets() and handle onLayout. int inputLeftBound; int inputTopBound; int headerRightBound = right; + int headerTopBounds = top; + final int subTitleBottom = (mSubtitleView.getVisibility() == GONE) ? mTitleView.getBottom() + : mSubtitleView.getBottom(); + final int descBottom = (mDescriptionView.getVisibility() == GONE) ? subTitleBottom + : mDescriptionView.getBottom(); if (getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE) { - inputTopBound = (bottom - (mPasswordField.getHeight() + mErrorView.getHeight())) / 2; + inputTopBound = (bottom - mAuthCredentialInput.getHeight()) / 2; inputLeftBound = (right - left) / 2; headerRightBound = inputLeftBound; + headerTopBounds -= Math.min(mIconView.getBottom(), mBottomInset); } else { - inputTopBound = mSubtitleView.getBottom() + (bottom - mSubtitleView.getBottom()) / 2; + inputTopBound = + descBottom + (bottom - descBottom - mAuthCredentialInput.getHeight()) / 2; inputLeftBound = (right - left - mAuthCredentialInput.getWidth()) / 2; } - mAuthCredentialHeader.layout(left, top, headerRightBound, bottom); + if (mDescriptionView.getBottom() > mBottomInset) { + mAuthCredentialHeader.layout(left, headerTopBounds, headerRightBound, bottom); + } mAuthCredentialInput.layout(inputLeftBound, inputTopBound, right, bottom); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); + final int newWidth = MeasureSpec.getSize(widthMeasureSpec); final int newHeight = MeasureSpec.getSize(heightMeasureSpec) - mBottomInset; - setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), newHeight); + setMeasuredDimension(newWidth, newHeight); - measureChildren(widthMeasureSpec, - MeasureSpec.makeMeasureSpec(newHeight, MeasureSpec.AT_MOST)); + final int halfWidthSpec = MeasureSpec.makeMeasureSpec(getWidth() / 2, + MeasureSpec.AT_MOST); + final int fullHeightSpec = MeasureSpec.makeMeasureSpec(newHeight, MeasureSpec.UNSPECIFIED); + if (getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE) { + measureChildren(halfWidthSpec, fullHeightSpec); + } else { + measureChildren(widthMeasureSpec, fullHeightSpec); + } } @NonNull @@ -193,6 +207,20 @@ public class AuthCredentialPasswordView extends AuthCredentialView final Insets bottomInset = insets.getInsets(ime()); if (v instanceof AuthCredentialPasswordView && mBottomInset != bottomInset.bottom) { mBottomInset = bottomInset.bottom; + if (mBottomInset > 0 + && getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE) { + mTitleView.setSingleLine(true); + mTitleView.setEllipsize(TextUtils.TruncateAt.MARQUEE); + mTitleView.setMarqueeRepeatLimit(-1); + // select to enable marquee unless a screen reader is enabled + mTitleView.setSelected(!mAccessibilityManager.isEnabled() + || !mAccessibilityManager.isTouchExplorationEnabled()); + } else { + mTitleView.setSingleLine(false); + mTitleView.setEllipsize(null); + // select to enable marquee unless a screen reader is enabled + mTitleView.setSelected(false); + } requestLayout(); } return insets; diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPatternView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPatternView.java index 11498dbc0b830..f9e44a0c17243 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPatternView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialPatternView.java @@ -93,7 +93,9 @@ public class AuthCredentialPatternView extends AuthCredentialView { @Override protected void onErrorTimeoutFinish() { super.onErrorTimeoutFinish(); - mLockPatternView.setEnabled(true); + // select to enable marquee unless a screen reader is enabled + mLockPatternView.setEnabled(!mAccessibilityManager.isEnabled() + || !mAccessibilityManager.isTouchExplorationEnabled()); } public AuthCredentialPatternView(Context context, AttributeSet attrs) { diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialView.java index baa8090328abe..5958e6a436f1f 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthCredentialView.java @@ -76,7 +76,7 @@ public abstract class AuthCredentialView extends LinearLayout { protected final Handler mHandler; protected final LockPatternUtils mLockPatternUtils; - private final AccessibilityManager mAccessibilityManager; + protected final AccessibilityManager mAccessibilityManager; private final UserManager mUserManager; private final DevicePolicyManager mDevicePolicyManager; @@ -85,10 +85,10 @@ public abstract class AuthCredentialView extends LinearLayout { private boolean mShouldAnimatePanel; private boolean mShouldAnimateContents; - private TextView mTitleView; + protected TextView mTitleView; protected TextView mSubtitleView; - private TextView mDescriptionView; - private ImageView mIconView; + protected TextView mDescriptionView; + protected ImageView mIconView; protected TextView mErrorView; protected @Utils.CredentialType int mCredentialType;