diff --git a/android/src/main/java/com/onfido/reactnative/sdk/OnfidoSdkModule.java b/android/src/main/java/com/onfido/reactnative/sdk/OnfidoSdkModule.java index 3f8e1a0..ee13622 100644 --- a/android/src/main/java/com/onfido/reactnative/sdk/OnfidoSdkModule.java +++ b/android/src/main/java/com/onfido/reactnative/sdk/OnfidoSdkModule.java @@ -57,7 +57,9 @@ public String getName() { return "OnfidoSdk"; } - /** NOTE: This indirection is used to allow unit tests to mock this method */ + /** + * NOTE: This indirection is used to allow unit tests to mock this method + */ protected Activity getCurrentActivityInParentClass() { return super.getCurrentActivity(); } @@ -86,20 +88,27 @@ public void start(final ReadableMap config, final Promise promise) { return; } - try { - final OnfidoConfig onfidoConfig = OnfidoConfig.builder(currentActivity) - .withSDKToken(sdkToken) - .withCustomFlow(flowStepsWithOptions) - .withLocale(Locale.GERMAN) - .build(); - client.startActivityForResult(currentActivity, 1, onfidoConfig); - } - catch (final Exception e) { - currentPromise.reject("error", new Exception("Failed to show Onfido page", e)); - currentPromise = null; - return; + Locale locale = Locale.ENGLISH; // default language + String language = config.getString("language"); // from js thread + if (language.equals("ger")) { + locale = Locale.GERMAN; + } else if (language.equals("ita")) { + locale = Locale.ITALIAN; } + try { + final OnfidoConfig onfidoConfig = OnfidoConfig.builder(currentActivity) + .withSDKToken(sdkToken) + .withCustomFlow(flowStepsWithOptions) + .withLocale(locale) + .build(); + client.startActivityForResult(currentActivity, 1, onfidoConfig); + } catch (final Exception e) { + currentPromise.reject("error", new Exception("Failed to show Onfido page", e)); + currentPromise = null; + return; + } + } catch (final Exception e) { e.printStackTrace(); // Wrap all unexpected exceptions. @@ -166,7 +175,7 @@ public static FlowStep[] getFlowStepsFromConfig(final ReadableMap config) throws String countryCodeString = captureDocument.getString("countryCode"); CountryCode countryCodeEnum = findCountryCodeByAlpha3(countryCodeString); - if (countryCodeEnum ==null) { + if (countryCodeEnum == null) { System.err.println("Unexpected countryCode value: [" + countryCodeString + "]"); throw new Exception("Unexpected countryCode value."); }