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

Commit a4b7ea19 authored by LuK1337's avatar LuK1337 Committed by Łukasz Patron
Browse files

Remove navbar inset for UDFPS BiometricPrompt

This is not necessary because BiometricPrompt is not drawn above the
navigation bar.

Change-Id: I7a00a0d6f1b2b68d6c642be03e23849029f8faa1
parent 2e17dcc3
Loading
Loading
Loading
Loading
+9 −28
Original line number Diff line number Diff line
@@ -96,10 +96,9 @@ public class UdfpsDialogMeasureAdapter {
        // Navbar + dialogMargin + buttonBar + textIndicator + spacerHeight = sensorDistFromBottom
        final int dialogMargin = getDialogMarginPx();
        final int displayHeight = getWindowBounds().height();
        final Insets navbarInsets = getNavbarInsets();
        mBottomSpacerHeight = calculateBottomSpacerHeightForPortrait(
                mSensorProps, displayHeight, textIndicatorHeight, buttonBarHeight,
                dialogMargin, navbarInsets.bottom);
                dialogMargin);

        // Go through each of the children and do the custom measurement.
        int totalHeight = 0;
@@ -160,17 +159,15 @@ public class UdfpsDialogMeasureAdapter {
        final int topSpacerHeight = getViewHeightPx(R.id.space_above_icon);
        final int textIndicatorHeight = getViewHeightPx(R.id.indicator);
        final int buttonBarHeight = getViewHeightPx(R.id.button_bar);
        final Insets navbarInsets = getNavbarInsets();
        final int bottomSpacerHeight = calculateBottomSpacerHeightForLandscape(titleHeight,
                subtitleHeight, descriptionHeight, topSpacerHeight, textIndicatorHeight,
                buttonBarHeight, navbarInsets.bottom);
                buttonBarHeight);

        // Find the spacer width needed to horizontally align the icon with the sensor.
        final int displayWidth = getWindowBounds().width();
        final int dialogMargin = getDialogMarginPx();
        final int horizontalInset = navbarInsets.left + navbarInsets.right;
        final int horizontalSpacerWidth = calculateHorizontalSpacerWidthForLandscape(
                mSensorProps, displayWidth, dialogMargin, horizontalInset);
                mSensorProps, displayWidth, dialogMargin);

        final int sensorDiameter = mSensorProps.sensorRadius * 2;
        final int remeasuredWidth = sensorDiameter + 2 * horizontalSpacerWidth;
@@ -235,15 +232,6 @@ public class UdfpsDialogMeasureAdapter {
        return mView.getResources().getDimensionPixelSize(R.dimen.biometric_dialog_border_padding);
    }

    @NonNull
    private Insets getNavbarInsets() {
        final WindowManager windowManager = getWindowManager();
        return windowManager != null && windowManager.getCurrentWindowMetrics() != null
                ? windowManager.getCurrentWindowMetrics().getWindowInsets()
                .getInsets(WindowInsets.Type.navigationBars())
                : Insets.NONE;
    }

    @NonNull
    private Rect getWindowBounds() {
        final WindowManager windowManager = getWindowManager();
@@ -267,8 +255,7 @@ public class UdfpsDialogMeasureAdapter {
    @VisibleForTesting
    static int calculateBottomSpacerHeightForPortrait(
            @NonNull FingerprintSensorPropertiesInternal sensorProperties, int displayHeightPx,
            int textIndicatorHeightPx, int buttonBarHeightPx, int dialogMarginPx,
            int navbarBottomInsetPx) {
            int textIndicatorHeightPx, int buttonBarHeightPx, int dialogMarginPx) {

        final int sensorDistanceFromBottom = displayHeightPx
                - sensorProperties.sensorLocationY
@@ -277,13 +264,11 @@ public class UdfpsDialogMeasureAdapter {
        final int spacerHeight = sensorDistanceFromBottom
                - textIndicatorHeightPx
                - buttonBarHeightPx
                - dialogMarginPx
                - navbarBottomInsetPx;
                - dialogMarginPx;

        Log.d(TAG, "Display height: " + displayHeightPx
                + ", Distance from bottom: " + sensorDistanceFromBottom
                + ", Bottom margin: " + dialogMarginPx
                + ", Navbar bottom inset: " + navbarBottomInsetPx
                + ", Bottom spacer height (portrait): " + spacerHeight);

        return spacerHeight;
@@ -296,7 +281,7 @@ public class UdfpsDialogMeasureAdapter {
    @VisibleForTesting
    static int calculateBottomSpacerHeightForLandscape(int titleHeightPx, int subtitleHeightPx,
            int descriptionHeightPx, int topSpacerHeightPx, int textIndicatorHeightPx,
            int buttonBarHeightPx, int navbarBottomInsetPx) {
            int buttonBarHeightPx) {

        final int dialogHeightAboveIcon = titleHeightPx
                + subtitleHeightPx
@@ -306,8 +291,7 @@ public class UdfpsDialogMeasureAdapter {
        final int dialogHeightBelowIcon = textIndicatorHeightPx + buttonBarHeightPx;

        final int bottomSpacerHeight = dialogHeightAboveIcon
                - dialogHeightBelowIcon
                - navbarBottomInsetPx;
                - dialogHeightBelowIcon;

        Log.d(TAG, "Title height: " + titleHeightPx
                + ", Subtitle height: " + subtitleHeightPx
@@ -315,7 +299,6 @@ public class UdfpsDialogMeasureAdapter {
                + ", Top spacer height: " + topSpacerHeightPx
                + ", Text indicator height: " + textIndicatorHeightPx
                + ", Button bar height: " + buttonBarHeightPx
                + ", Navbar bottom inset: " + navbarBottomInsetPx
                + ", Bottom spacer height (landscape): " + bottomSpacerHeight);

        return bottomSpacerHeight;
@@ -329,20 +312,18 @@ public class UdfpsDialogMeasureAdapter {
    @VisibleForTesting
    static int calculateHorizontalSpacerWidthForLandscape(
            @NonNull FingerprintSensorPropertiesInternal sensorProperties, int displayWidthPx,
            int dialogMarginPx, int navbarHorizontalInsetPx) {
            int dialogMarginPx) {

        final int sensorDistanceFromEdge = displayWidthPx
                - sensorProperties.sensorLocationY
                - sensorProperties.sensorRadius;

        final int horizontalPadding = sensorDistanceFromEdge
                - dialogMarginPx
                - navbarHorizontalInsetPx;
                - dialogMarginPx;

        Log.d(TAG, "Display width: " + displayWidthPx
                + ", Distance from edge: " + sensorDistanceFromEdge
                + ", Dialog margin: " + dialogMarginPx
                + ", Navbar horizontal inset: " + navbarHorizontalInsetPx
                + ", Horizontal spacer width (landscape): " + horizontalPadding);

        return horizontalPadding;