infinum / Android-Goldfinger

Android library to simplify Biometric authentication implementation.
Apache License 2.0
653 stars 73 forks source link

Biometric prompt localisation #52

Closed zplesac closed 4 years ago

zplesac commented 4 years ago

We should check the Biometric prompt localisation - it seems that title, description and subtitle are localised using the app context, while the info message get's localised using the phone language. You can see here that prompt is packed with localisation support for all languages.

This is resulting in a strange behaviour where half of the prompt is using one language, while other half is using something else.

domagojkorman commented 4 years ago

@zplesac I just tested this behavior inside Example activity and it seems like everything is working OK. Are you sure that the localization is correctly implemented inside your implementation?

This is what I used and everything worked smooth.

    private Context updateLocale(Context context) {
        Configuration config = new Configuration(context.getResources().getConfiguration());
        Locale locale = Locale.FRENCH;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            config.setLocale(locale);
        } else {
            config.locale = locale;
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            return context.createConfigurationContext(config);
        } else {
            context.getResources().updateConfiguration(config, context.getResources().getDisplayMetrics());
            return context;
        }
    }

    @Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(updateLocale(newBase));
    }
zplesac commented 4 years ago

@davidvinf will check this with sample activity on his Huawei device and report back.

domagojkorman commented 4 years ago

I investigated this and it seems that it is device specific issue because localization correctly worked on 2, 3 different devices that I tested it on. Closing this issue as there is nothing that can be done, Goldfinger uses correct Context, and the reported string that is not controlled by Goldfinger.

igortepavac commented 4 years ago

@zplesac I see that you are using appcompat 1.1.0 which has introduced an issue with applying locale on devices from API 21 to 25. Try downgrading to 1.0.2 and see if it works.