diff --git a/yoti-sdk-api/src/main/java/com/yoti/api/client/docs/DocScanConstants.java b/yoti-sdk-api/src/main/java/com/yoti/api/client/docs/DocScanConstants.java index 4a1e33fc..b41ad95a 100644 --- a/yoti-sdk-api/src/main/java/com/yoti/api/client/docs/DocScanConstants.java +++ b/yoti-sdk-api/src/main/java/com/yoti/api/client/docs/DocScanConstants.java @@ -86,4 +86,8 @@ private DocScanConstants() { } public static final String EAGER = "EAGER"; public static final String JUST_IN_TIME = "JUST_IN_TIME"; + public static final String ON = "ON"; + public static final String OFF = "OFF"; + public static final String AUTO = "AUTO"; + } diff --git a/yoti-sdk-api/src/main/java/com/yoti/api/client/docs/session/create/SdkConfig.java b/yoti-sdk-api/src/main/java/com/yoti/api/client/docs/session/create/SdkConfig.java index 9a5b8791..d7ad1541 100644 --- a/yoti-sdk-api/src/main/java/com/yoti/api/client/docs/session/create/SdkConfig.java +++ b/yoti-sdk-api/src/main/java/com/yoti/api/client/docs/session/create/SdkConfig.java @@ -15,12 +15,18 @@ public class SdkConfig { @JsonProperty(Property.PRIMARY_COLOUR) private final String primaryColour; + @JsonProperty(Property.PRIMARY_COLOUR_DARK_MODE) + private final String primaryColourDarkMode; + @JsonProperty(Property.SECONDARY_COLOUR) private final String secondaryColour; @JsonProperty(Property.FONT_COLOUR) private final String fontColour; + @JsonProperty(Property.DARK_MODE) + private final String darkMode; + @JsonProperty(Property.LOCALE) private final String locale; @@ -50,9 +56,11 @@ public class SdkConfig { SdkConfig(String allowedCaptureMethods, String primaryColour, + String primaryColourDarkMode, String secondaryColour, String fontColour, String locale, + String darkMode, String presetIssuingCountry, String successUrl, String errorUrl, @@ -63,9 +71,11 @@ public class SdkConfig { String biometricConsentFlow) { this.allowedCaptureMethods = allowedCaptureMethods; this.primaryColour = primaryColour; + this.primaryColourDarkMode = primaryColourDarkMode; this.secondaryColour = secondaryColour; this.fontColour = fontColour; this.locale = locale; + this.darkMode = darkMode; this.presetIssuingCountry = presetIssuingCountry; this.successUrl = successUrl; this.errorUrl = errorUrl; @@ -98,6 +108,15 @@ public String getPrimaryColour() { return primaryColour; } + /** + * The primary colour to use when in dark mode + * + * @return the primary colour + */ + public String getPrimaryColourDarkMode() { + return primaryColourDarkMode; + } + /** * The secondary colour * @@ -125,6 +144,15 @@ public String getLocale() { return locale; } + /** + * Whether to use dark mode - may be 'ON', 'OFF', or 'AUTO' + * + * @return the dark mode + */ + public String getDarkMode() { + return darkMode; + } + /** * The preset issuing country * @@ -204,9 +232,11 @@ public static class Builder { private String allowedCaptureMethods; private String primaryColour; + private String primaryColourDarkMode; private String secondaryColour; private String fontColour; private String locale; + private String darkMode; private String presetIssuingCountry; private String successUrl; private String errorUrl; @@ -258,6 +288,17 @@ public Builder withPrimaryColour(String primaryColour) { return this; } + /** + * Sets the primary colour to be used by the web/native client when in dark mode + * + * @param primaryColourDarkMode the primary colour for the dark mode, hexadecimal value e.g. #ff0000 + * @return the builder + */ + public Builder withPrimaryColourDarkMode(String primaryColourDarkMode) { + this.primaryColourDarkMode = primaryColourDarkMode; + return this; + } + /** * Sets the secondary colour to be used by the web/native client (used on the button) * @@ -291,6 +332,44 @@ public Builder withLocale(String locale) { return this; } + /** + * Whether to use dark mode on the web/native client - may be 'ON', 'OFF', or 'AUTO' + * + * @param darkMode the dark mode, e.g. "ON" + * @return the builder + */ + public Builder withDarkMode(String darkMode) { + this.darkMode = darkMode; + return this; + } + + /** + * Sets the dark mode to 'ON' to be used by the web/native client + * + * @return the builder + */ + public Builder withDarkModeOn() { + return withDarkMode(DocScanConstants.ON); + } + + /** + * Sets the dark mode to 'OFF' to be used by the web/native client + * + * @return the builder + */ + public Builder withDarkModeOff() { + return withDarkMode(DocScanConstants.OFF); + } + + /** + * Sets the dark mode to 'AUTO' to be used by the web/native client + * + * @return the builder + */ + public Builder withDarkModeAuto() { + return withDarkMode(DocScanConstants.AUTO); + } + /** * Sets the preset issuing country used by the web/native client * @@ -406,9 +485,11 @@ public SdkConfig build() { return new SdkConfig( allowedCaptureMethods, primaryColour, + primaryColourDarkMode, secondaryColour, fontColour, locale, + darkMode, presetIssuingCountry, successUrl, errorUrl, @@ -425,8 +506,10 @@ private static final class Property { private static final String ALLOWED_CAPTURE_METHODS = "allowed_capture_methods"; private static final String PRIMARY_COLOUR = "primary_colour"; + private static final String PRIMARY_COLOUR_DARK_MODE = "primary_colour_dark_mode"; private static final String SECONDARY_COLOUR = "secondary_colour"; private static final String FONT_COLOUR = "font_colour"; + private static final String DARK_MODE = "dark_mode"; private static final String LOCALE = "locale"; private static final String PRESET_ISSUING_COUNTRY = "preset_issuing_country"; private static final String SUCCESS_URL = "success_url"; diff --git a/yoti-sdk-api/src/test/java/com/yoti/api/client/docs/session/create/SdkConfigTest.java b/yoti-sdk-api/src/test/java/com/yoti/api/client/docs/session/create/SdkConfigTest.java index 57ab3e0c..24dba45d 100644 --- a/yoti-sdk-api/src/test/java/com/yoti/api/client/docs/session/create/SdkConfigTest.java +++ b/yoti-sdk-api/src/test/java/com/yoti/api/client/docs/session/create/SdkConfigTest.java @@ -13,9 +13,11 @@ public class SdkConfigTest { private static final String SOME_PRIMARY_COLOUR = "#FFFFFF"; + private static final String SOME_PRIMARY_COLOUR_DARK_MODE = "#3b706f"; private static final String SOME_SECONDARY_COLOUR = "#679bdd"; private static final String SOME_FONT_COLOUR = "#b40c12"; private static final String SOME_LOCALE = "en"; + private static final String SOME_DARK_MODE = "ON"; private static final String SOME_PRESET_ISSUING_COUNTRY = "USA"; private static final String SOME_BRAND_ID = "someBrandId"; @@ -30,9 +32,11 @@ public void shouldBuildSimpleSdkConfigWithAllOptions() { SdkConfig result = SdkConfig.builder() .withAllowsCamera() .withPrimaryColour(SOME_PRIMARY_COLOUR) + .withPrimaryColourDarkMode(SOME_PRIMARY_COLOUR_DARK_MODE) .withSecondaryColour(SOME_SECONDARY_COLOUR) .withFontColour(SOME_FONT_COLOUR) .withLocale(SOME_LOCALE) + .withDarkMode(SOME_DARK_MODE) .withPresetIssuingCountry(SOME_PRESET_ISSUING_COUNTRY) .withSuccessUrl(SOME_SUCCESS_URL) .withErrorUrl(SOME_ERROR_URL) @@ -46,9 +50,11 @@ public void shouldBuildSimpleSdkConfigWithAllOptions() { assertThat(result.getAllowedCaptureMethods(), is("CAMERA")); assertThat(result.getPrimaryColour(), is(SOME_PRIMARY_COLOUR)); + assertThat(result.getPrimaryColourDarkMode(), is(SOME_PRIMARY_COLOUR_DARK_MODE)); assertThat(result.getSecondaryColour(), is(SOME_SECONDARY_COLOUR)); assertThat(result.getFontColour(), is(SOME_FONT_COLOUR)); assertThat(result.getLocale(), is(SOME_LOCALE)); + assertThat(result.getDarkMode(), is(SOME_DARK_MODE)); assertThat(result.getPresetIssuingCountry(), is(SOME_PRESET_ISSUING_COUNTRY)); assertThat(result.getSuccessUrl(), is(SOME_SUCCESS_URL)); assertThat(result.getErrorUrl(), is(SOME_ERROR_URL)); @@ -112,5 +118,31 @@ public void shouldOverridePreviousAllowedCaptureMethods() { assertThat(result.getAllowedCaptureMethods(), is("CAMERA")); } + @Test + public void shouldSetDarkModeToOn() { + SdkConfig result = SdkConfig.builder() + .withDarkModeOn() + .build(); + + assertThat(result.getDarkMode(), is("ON")); + } + + @Test + public void shouldSetDarkModeToOff() { + SdkConfig result = SdkConfig.builder() + .withDarkModeOff() + .build(); + + assertThat(result.getDarkMode(), is("OFF")); + } + + @Test + public void shouldSetDarkModeToAuto() { + SdkConfig result = SdkConfig.builder() + .withDarkModeAuto() + .build(); + + assertThat(result.getDarkMode(), is("AUTO")); + } }