Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Remove navbar inset for UDFPS BiometricPrompt
Browse files Browse the repository at this point in the history
This is not necessary because BiometricPrompt is not drawn above the
navigation bar.

Change-Id: I7a00a0d6f1b2b68d6c642be03e23849029f8faa1
  • Loading branch information
luk1337 authored and jhenrique09 committed Mar 20, 2022
1 parent 721e90e commit b31fe69
Showing 1 changed file with 9 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ private AuthDialog.LayoutParams onMeasureInternalPortrait(int width, int height)
// 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;
Expand Down Expand Up @@ -161,17 +160,15 @@ private AuthDialog.LayoutParams onMeasureInternalLandscape(int width, int height
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.getLocation().sensorRadius * 2;
final int remeasuredWidth = sensorDiameter + 2 * horizontalSpacerWidth;
Expand Down Expand Up @@ -236,15 +233,6 @@ private int getDialogMarginPx() {
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();
Expand All @@ -268,8 +256,7 @@ private WindowManager getWindowManager() {
@VisibleForTesting
static int calculateBottomSpacerHeightForPortrait(
@NonNull FingerprintSensorPropertiesInternal sensorProperties, int displayHeightPx,
int textIndicatorHeightPx, int buttonBarHeightPx, int dialogMarginPx,
int navbarBottomInsetPx) {
int textIndicatorHeightPx, int buttonBarHeightPx, int dialogMarginPx) {
final SensorLocationInternal location = sensorProperties.getLocation();
final int sensorDistanceFromBottom = displayHeightPx
- location.sensorLocationY
Expand All @@ -278,13 +265,11 @@ static int calculateBottomSpacerHeightForPortrait(
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;
Expand All @@ -297,7 +282,7 @@ static int calculateBottomSpacerHeightForPortrait(
@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
Expand All @@ -307,16 +292,14 @@ static int calculateBottomSpacerHeightForLandscape(int titleHeightPx, int subtit
final int dialogHeightBelowIcon = textIndicatorHeightPx + buttonBarHeightPx;

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

Log.d(TAG, "Title height: " + titleHeightPx
+ ", Subtitle height: " + subtitleHeightPx
+ ", Description height: " + descriptionHeightPx
+ ", Top spacer height: " + topSpacerHeightPx
+ ", Text indicator height: " + textIndicatorHeightPx
+ ", Button bar height: " + buttonBarHeightPx
+ ", Navbar bottom inset: " + navbarBottomInsetPx
+ ", Bottom spacer height (landscape): " + bottomSpacerHeight);

return bottomSpacerHeight;
Expand All @@ -330,20 +313,18 @@ static int calculateBottomSpacerHeightForLandscape(int titleHeightPx, int subtit
@VisibleForTesting
static int calculateHorizontalSpacerWidthForLandscape(
@NonNull FingerprintSensorPropertiesInternal sensorProperties, int displayWidthPx,
int dialogMarginPx, int navbarHorizontalInsetPx) {
int dialogMarginPx) {
final SensorLocationInternal location = sensorProperties.getLocation();
final int sensorDistanceFromEdge = displayWidthPx
- location.sensorLocationY
- location.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;
Expand Down

0 comments on commit b31fe69

Please sign in to comment.