Monday, November 26, 2018

Android fingerprint sensor dialog translations

Date : 27 / 11 / 2018

HI,

As part of my project I was assigned to implement fingerprint authentication to android app. Since this app should support different countries I had to add the translations text to this dialog also. That's where I encountered a problem which took me more time than I expected. Although Setting title, subtitle and few other messages were easy, setting few strings were not easy as I thought.

This is the easy part.

 val biometricPromptInfo = BiometricPrompt.PromptInfo.Builder()  
         .setTitle("Main Title")  
         .setSubtitle("Here is subtitle")  
         .setDescription("This is the description")  
         .setNegativeButtonText(getString(R.string.cancel))  
         .build()  

Which gives us following dialog prompt.


We can surely add the translations for all the gives setters. But I couldn't get a setter for "Touch the fingerprint sensor". This is where I began to search how could I change this text and add translation for that text. Since there was no search result for this particular problem in internet, I searched in the android files. I found the string value for this TextView which is highlighted, in a generated file located in
C:\Users\yourName\AppName\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\androidx\biometric.



so the rest was easy. I have added string with same id with desired values  in mu strings.xml files.

Later I also found this link on github which could be useful.

Hope this is useful to someone.

Happy coding :) ......




No comments:

Post a Comment