Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08c570a8 authored by Vincent Wang's avatar Vincent Wang Committed by Android (Google) Code Review
Browse files

Merge "Fix BiometricPrompt can scroll / overflow on long text" into tm-dev

parents dc7c91de f53ec27a
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -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"
+7 −0
Original line number Diff line number Diff line
@@ -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 =
+21 −0
Original line number Diff line number Diff line
@@ -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();