Merge "Fix BiometricPrompt can scroll / overflow on long text" into tm-dev
This commit is contained in:
@@ -21,6 +21,9 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="@integer/biometric_dialog_text_gravity"
|
android:gravity="@integer/biometric_dialog_text_gravity"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:marqueeRepeatLimit="1"
|
||||||
|
android:ellipsize="marquee"
|
||||||
style="@style/TextAppearance.AuthCredential.Title"/>
|
style="@style/TextAppearance.AuthCredential.Title"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -28,13 +31,16 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="@integer/biometric_dialog_text_gravity"
|
android:gravity="@integer/biometric_dialog_text_gravity"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:marqueeRepeatLimit="1"
|
||||||
|
android:ellipsize="marquee"
|
||||||
style="@style/TextAppearance.AuthCredential.Subtitle"/>
|
style="@style/TextAppearance.AuthCredential.Subtitle"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/description"
|
android:id="@+id/description"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="@integer/biometric_dialog_text_gravity"
|
android:scrollbars ="vertical"
|
||||||
style="@style/TextAppearance.AuthCredential.Description"/>
|
style="@style/TextAppearance.AuthCredential.Description"/>
|
||||||
|
|
||||||
<Space android:id="@+id/space_above_icon"
|
<Space android:id="@+id/space_above_icon"
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.text.method.ScrollingMovementMethod;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -706,6 +707,12 @@ public class AuthBiometricView extends LinearLayout {
|
|||||||
|
|
||||||
mTitleView.setText(mPromptInfo.getTitle());
|
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()) {
|
if (isDeviceCredentialAllowed()) {
|
||||||
final CharSequence credentialButtonText;
|
final CharSequence credentialButtonText;
|
||||||
@Utils.CredentialType final int credentialType =
|
@Utils.CredentialType final int credentialType =
|
||||||
|
|||||||
@@ -139,6 +139,9 @@ public class UdfpsDialogMeasureAdapter {
|
|||||||
child.measure(
|
child.measure(
|
||||||
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
||||||
MeasureSpec.makeMeasureSpec(clampedSpacerHeight, MeasureSpec.EXACTLY));
|
MeasureSpec.makeMeasureSpec(clampedSpacerHeight, MeasureSpec.EXACTLY));
|
||||||
|
} else if (child.getId() == R.id.description) {
|
||||||
|
//skip description view and compute later
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
child.measure(
|
child.measure(
|
||||||
MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
|
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);
|
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
|
@NonNull
|
||||||
private AuthDialog.LayoutParams onMeasureInternalLandscape(int width, int height) {
|
private AuthDialog.LayoutParams onMeasureInternalLandscape(int width, int height) {
|
||||||
final WindowMetrics windowMetrics = mWindowManager.getMaximumWindowMetrics();
|
final WindowMetrics windowMetrics = mWindowManager.getMaximumWindowMetrics();
|
||||||
|
|||||||
Reference in New Issue
Block a user