具有 DayNight 主题的 BiometricPrompt

Akb*_*bar 5 android android-biometric-prompt theme-daynight

DayNight 主题有四种情况:

  1. 设备 - DARK模式,应用程序 - DARK模式
  2. 设备 - LIGHT模式,应用 - LIGHT模式
  3. 设备 - DARK模式,应用程序 - LIGHT模式
  4. 设备 - LIGHT模式,应用 - DARK模式

第一种和第二种情况是正常的。不幸的是,第三和第四种情况并不如预期。BiometricPrompt 对话框获取设备的 ui 模式。我想为 BiometricPrompt 对话框应用应用程序 UI 模式。您可以在下面看到问题:

设备 - DARK模式,应用程序 - LIGHT模式 设备 - **DARK** 模式,应用程序 - **LIGHT** 模式

设备 - LIGHT模式,应用 - DARK模式 设备 - **LIGHT** 模式,应用程序 - **DARK** 模式

小智 0

Interesting question!

From your question it is clear that device and application roles are switched throughout all 4 scenarios (but only apparent when there is a difference in colors)

Some resources to check out and that form basis of my answer: https://developer.android.com/guide/topics/ui/look-and-feel/darktheme

https://cs.android.com/androidx/platform/frameworks/support/+/androidx-master-dev:biometric/biometric/src/main/java/androidx/biometric/

Some background:

  1. The authentication layout is built with soft-coded colors (theme attributed) which allow for night-theme to function (as shown in your pictures)

  2. The layout is not set up to inherit from night-theme (the activity's job)

  3. 显示身份验证对话框的方法使用片段(而不是活动),这可能是它在 uiMode 下无法正常工作的原因。必须在清单中设置活动才能支持 uiMode。不确定这如何与片段一起使用

  4. uiMode 配置更改自动重建活动

我的答案:

由于用户身份验证的优先级较高,因此身份验证对话框的优先级高于“设备”活动,而对话框背后的活动则被委托为“应用程序”角色。目前尚不清楚为什么或如何发生这种情况。我会尝试在 DayNight 主题的实现过程中切换设备和应用程序的角色。