BiometricPrompt 提示未本地化
BiometricPrompt hints are not localized
问题
我们正在更改应用内的区域设置,除了指纹对话框中的提示外,一切正常。无论我们设置什么语言,我们总是有英文提示:
- 触摸指纹传感器
- 无法识别
- 等...
环境
- 使用的组件:androidx.biometric.BiometricPrompt
- 使用的版本:1.0.0.0-alpha04
- Devices/Android 版本复制于:模拟器 API 28
如何设置语言环境:
private fun setNewLocaleAndRestart(language: String) {
LocaleManager(this).setNewLocale(language)
//restarting app
val i = Intent(this, SplashScreenActivity::class.java)
startActivity(i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK))
finish()
System.exit(0)
}
class LocaleManager(val context: Context) {
val sharedPreferenceManager = createSharedPreferenceManager(context)
fun setLocale(): Context = updateResources()
fun setNewLocale(language: String): Context {
return updateResources(language)
}
private fun updateResources(l: String? = null): Context {
val language = l ?: sharedPreferenceManager.language
if (language.isBlank()) return context
val locale = Locale(language)
Locale.setDefault(locale)
val res = context.resources
val config = Configuration(res.configuration)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
config.setLocale(locale)
return context.createConfigurationContext(config)
} else @Suppress("DEPRECATION") {
config.locale = locale
res.updateConfiguration(config, res.displayMetrics)
return context
}
}
}
everything works except the hints in the fingerprint dialog
所有系统对话框都将使用用户为设备设置的语言。这包括生物识别系统对话框。
它已在 BiometricPrompt 版本 androidx.biometric:biometric:1.0.0-alpha04
中修复。
您只需更改您的 phone 区域设置即可反映更改。
这里是 commit 如果你感兴趣的话
我 implementation 'androidx.biometric:biometric:1.0.1@aar'
也遇到了这个问题。我将系统语言更改为英语以外的其他语言,但它仍然显示 "Touch the fingerprint sensor"。有人对此有解决方案或解释吗?
它looks好像Android生物识别库已经支持所有语言,但它似乎不起作用。我什至可以在 Android 构建文件夹中看到生成的 merger.xml
中的翻译。
在我的 OnePlus 5T 上测试 Android 9/Oxygen 9.0.10。
我刚刚实现了 BiometricManager androidx.biometric:biometric:1.0.1
并且能够更改和本地化提示文本以及使用错误指纹时的文本。
您只需在 strings.xml 中定义这些字符串即可覆盖 API:
中的字符串
fingerprint_not_recognized
更改使用错误指纹时的错误消息。这是在 FingerprintHelperFragment.java
中定义的
fingerprint_dialog_touch_sensor
更改提示。这在 FingerprintDialogFragment.java
中定义
问题
我们正在更改应用内的区域设置,除了指纹对话框中的提示外,一切正常。无论我们设置什么语言,我们总是有英文提示:
- 触摸指纹传感器
- 无法识别
- 等...
环境
- 使用的组件:androidx.biometric.BiometricPrompt
- 使用的版本:1.0.0.0-alpha04
- Devices/Android 版本复制于:模拟器 API 28
如何设置语言环境:
private fun setNewLocaleAndRestart(language: String) {
LocaleManager(this).setNewLocale(language)
//restarting app
val i = Intent(this, SplashScreenActivity::class.java)
startActivity(i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK))
finish()
System.exit(0)
}
class LocaleManager(val context: Context) {
val sharedPreferenceManager = createSharedPreferenceManager(context)
fun setLocale(): Context = updateResources()
fun setNewLocale(language: String): Context {
return updateResources(language)
}
private fun updateResources(l: String? = null): Context {
val language = l ?: sharedPreferenceManager.language
if (language.isBlank()) return context
val locale = Locale(language)
Locale.setDefault(locale)
val res = context.resources
val config = Configuration(res.configuration)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
config.setLocale(locale)
return context.createConfigurationContext(config)
} else @Suppress("DEPRECATION") {
config.locale = locale
res.updateConfiguration(config, res.displayMetrics)
return context
}
}
}
everything works except the hints in the fingerprint dialog
所有系统对话框都将使用用户为设备设置的语言。这包括生物识别系统对话框。
它已在 BiometricPrompt 版本 androidx.biometric:biometric:1.0.0-alpha04
中修复。
您只需更改您的 phone 区域设置即可反映更改。
这里是 commit 如果你感兴趣的话
我 implementation 'androidx.biometric:biometric:1.0.1@aar'
也遇到了这个问题。我将系统语言更改为英语以外的其他语言,但它仍然显示 "Touch the fingerprint sensor"。有人对此有解决方案或解释吗?
它looks好像Android生物识别库已经支持所有语言,但它似乎不起作用。我什至可以在 Android 构建文件夹中看到生成的 merger.xml
中的翻译。
在我的 OnePlus 5T 上测试 Android 9/Oxygen 9.0.10。
我刚刚实现了 BiometricManager androidx.biometric:biometric:1.0.1
并且能够更改和本地化提示文本以及使用错误指纹时的文本。
您只需在 strings.xml 中定义这些字符串即可覆盖 API:
中的字符串fingerprint_not_recognized
更改使用错误指纹时的错误消息。这是在 FingerprintHelperFragment.java
fingerprint_dialog_touch_sensor
更改提示。这在 FingerprintDialogFragment.java