From fe745c557f75a19608f6807129379d6fe8180ff3 Mon Sep 17 00:00:00 2001 From: Joe Bolinger Date: Fri, 2 Jun 2023 04:10:34 +0000 Subject: Fix margins and positioning for the small (implicit) face view. This temporary workaround only impacts the new prompt, but should be simplified once the shared code is decoupled. The existing layout logic is too tightly coupled with UDFPS and additional changes/replacements to the legacy panel controller are still needed. Bug: 272510026 Test: manual (use BP test app with coex, uncheck require confirmation and check 0, 90, 270 rotations) Change-Id: I9fe9692dc8008549f9dad7932e07b0fa16503afd --- .../systemui/biometrics/AuthContainerView.java | 6 ++++- .../ui/binder/BiometricViewSizeBinder.kt | 29 +++++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java index f86e2ed6eb91..7f706859abb3 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java @@ -614,7 +614,11 @@ public class AuthContainerView extends LinearLayout return ((AuthBiometricFingerprintView) view).isUdfps(); } if (view instanceof BiometricPromptLayout) { - return ((BiometricPromptLayout) view).isUdfps(); + // this will force the prompt to align itself on the edge of the screen + // instead of centering (temporary workaround to prevent small implicit view + // from breaking due to the way gravity / margins are set in the legacy + // AuthPanelController + return true; } return false; diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt index e4c4e9aedb56..1dffa80a084f 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt @@ -19,8 +19,11 @@ package com.android.systemui.biometrics.ui.binder import android.animation.Animator import android.animation.AnimatorSet import android.animation.ValueAnimator +import android.view.Surface import android.view.View import android.view.ViewGroup +import android.view.WindowInsets +import android.view.WindowManager import android.view.accessibility.AccessibilityManager import android.widget.TextView import androidx.core.animation.addListener @@ -52,7 +55,9 @@ object BiometricViewSizeBinder { panelViewController: AuthPanelController, jankListener: BiometricJankListener, ) { - val accessibilityManager = view.context.getSystemService(AccessibilityManager::class.java)!! + val windowManager = requireNotNull(view.context.getSystemService(WindowManager::class.java)) + val accessibilityManager = + requireNotNull(view.context.getSystemService(AccessibilityManager::class.java)) fun notifyAccessibilityChanged() { Utils.notifyAccessibilityContentChanged(accessibilityManager, view) } @@ -102,15 +107,26 @@ object BiometricViewSizeBinder { when { size.isSmall -> { iconHolderView.alpha = 1f + val bottomInset = + windowManager.maximumWindowMetrics.windowInsets + .getInsets(WindowInsets.Type.navigationBars()) + .bottom iconHolderView.y = - view.height - iconHolderView.height - iconPadding + if (view.isLandscape()) { + (view.height - iconHolderView.height - bottomInset) / 2f + } else { + view.height - + iconHolderView.height - + iconPadding - + bottomInset + } val newHeight = - iconHolderView.height + 2 * iconPadding.toInt() - + iconHolderView.height + (2 * iconPadding.toInt()) - iconHolderView.paddingTop - iconHolderView.paddingBottom panelViewController.updateForContentDimensions( width, - newHeight, + newHeight + bottomInset, 0, /* animateDurationMs */ ) } @@ -181,6 +197,11 @@ object BiometricViewSizeBinder { } } +private fun View.isLandscape(): Boolean { + val r = context.display.rotation + return r == Surface.ROTATION_90 || r == Surface.ROTATION_270 +} + private fun TextView.showTextOrHide(forceHide: Boolean = false) { visibility = if (forceHide || text.isBlank()) View.GONE else View.VISIBLE } -- cgit v1.2.3-59-g8ed1b