Fix BiometricPrompt can scroll / overflow on long text
1. Make title & subtitle in single line
2. Make prompt dialog can't grow than 3/4 display height
3. Make description view scrollable
BUG: 226643887
Test: 1. Download test app from bug 226643887
2. Check prompt ui
Change-Id: Ib95d090729b1561a70a853b17a4e17cdcbb71fbd
This commit is contained in:
@@ -21,6 +21,9 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="@integer/biometric_dialog_text_gravity"
|
||||
android:singleLine="true"
|
||||
android:marqueeRepeatLimit="1"
|
||||
android:ellipsize="marquee"
|
||||
style="@style/TextAppearance.AuthCredential.Title"/>
|
||||
|
||||
<TextView
|
||||
@@ -28,13 +31,16 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="@integer/biometric_dialog_text_gravity"
|
||||
android:singleLine="true"
|
||||
android:marqueeRepeatLimit="1"
|
||||
android:ellipsize="marquee"
|
||||
style="@style/TextAppearance.AuthCredential.Subtitle"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="@integer/biometric_dialog_text_gravity"
|
||||
android:scrollbars ="vertical"
|
||||
style="@style/TextAppearance.AuthCredential.Description"/>
|
||||
|
||||
<Space android:id="@+id/space_above_icon"
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@@ -706,6 +707,12 @@ public class AuthBiometricView extends LinearLayout {
|
||||
|
||||
mTitleView.setText(mPromptInfo.getTitle());
|
||||
|
||||
//setSelected could make marguee work
|
||||
mTitleView.setSelected(true);
|
||||
mSubtitleView.setSelected(true);
|
||||
//make description view become scrollable
|
||||
mDescriptionView.setMovementMethod(new ScrollingMovementMethod());
|
||||
|
||||
if (isDeviceCredentialAllowed()) {
|
||||
final CharSequence credentialButtonText;
|
||||
@Utils.CredentialType final int credentialType =
|
||||
|
||||
@@ -139,6 +139,9 @@ public class UdfpsDialogMeasureAdapter {
|
||||
child.measure(
|
||||
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
||||
MeasureSpec.makeMeasureSpec(clampedSpacerHeight, MeasureSpec.EXACTLY));
|
||||
} else if (child.getId() == R.id.description) {
|
||||
//skip description view and compute later
|
||||
continue;
|
||||
} else {
|
||||
child.measure(
|
||||
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
||||
@@ -150,9 +153,27 @@ public class UdfpsDialogMeasureAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
//re-calculate the height of description
|
||||
View description = mView.findViewById(R.id.description);
|
||||
totalHeight += measureDescription(description, displayHeight, width, totalHeight);
|
||||
|
||||
return new AuthDialog.LayoutParams(width, totalHeight);
|
||||
}
|
||||
|
||||
private int measureDescription(View description, int displayHeight, int currWidth,
|
||||
int currHeight) {
|
||||
//description view should be measured in AuthBiometricFingerprintView#onMeasureInternal
|
||||
//so we could getMeasuredHeight in onMeasureInternalPortrait directly.
|
||||
int newHeight = description.getMeasuredHeight() + currHeight;
|
||||
int limit = (int) (displayHeight * 0.75);
|
||||
if (newHeight > limit) {
|
||||
description.measure(
|
||||
MeasureSpec.makeMeasureSpec(currWidth, MeasureSpec.EXACTLY),
|
||||
MeasureSpec.makeMeasureSpec(limit - currHeight, MeasureSpec.EXACTLY));
|
||||
}
|
||||
return description.getMeasuredHeight();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private AuthDialog.LayoutParams onMeasureInternalLandscape(int width, int height) {
|
||||
final WindowMetrics windowMetrics = mWindowManager.getMaximumWindowMetrics();
|
||||
|
||||
Reference in New Issue
Block a user