Кастомизация SDK для Android
КриптоПро Ключ SDK предусматривает возможность настройки внешнего вида (кастомизации) пользовательского интерфейса (UI) в соответствии с выбранным цветовым решением для приложения, куда будет встроен SDK.
Для кастомизации используется метод setDssKidMainTheme. В данный метод требуется добавить класс данных DssKidMainTheme, описывающий цветовую тему SDK.
Возможны следующие варианты использования:
- частичная модицикация: в этом случае возможно не заполнять класс
DssKidMainTheme
полностью, а использоватьdefaultDssKidMainTheme
и при помощи методаcopy
изменить нужные параметры; - полная модификация.
Пример частичной модификации темы
1. Вызываем метод defaultDssKidMainTheme()
: он вернет заполненный класс DssKidMainTheme
.
2. Вызываем метод .copy
и вносим правки. В данном случае изменяются цвета и размеры кнопок SDK.
3. Результат метода .copy
передается в CryptoProDss.getInstance().setDssKidMainTheme()
.
val originalTheme: DssKidMainTheme = defaultDssKidMainTheme()
val updatedTheme = originalTheme.copy(
colors = originalTheme.colors.copy(
light = originalTheme.colors.light.copy(
// Обновляем цветовую схему кнопок
buttonColorSchemes = originalTheme.colors.light.buttonColorSchemes.copy(
primaryButtonsColors = originalTheme.colors.light.buttonColorSchemes.primaryButtonsColors.copy(
btnBgColor = originalTheme.colors.light.buttonColorSchemes.primaryButtonsColors.btnBgColor.copy(
normal = Color(0xFF6200EE), // Цвет кнопки в нормальном состоянии
pressed = Color(0xFF3700B3), // При нажатии
disabled = Color(0xFFBDBDBD) // В неактивном состоянии
),
textColor = originalTheme.colors.light.buttonColorSchemes.primaryButtonsColors.textColor.copy(
normal = Color.White,
pressed = Color.White,
disabled = Color.LightGray
)
)
)
)
),
// Обновляем размеры
sizes = originalTheme.sizes.copy(
buttonMinHeight = 64.dp // Увеличиваем высоту кнопки
)
)
Пример полной модификации темы
val customTheme = DssKidMainTheme(
colors = DssKidDayNightColors(
light = DssKidColors(
textColors = DssKidTextColors(
textPrimaryColor = Color.Black,
textDescriptionColor = Color.DarkGray,
textLinksColor = Color.Blue,
textErrorPrimaryColor = Color.Red,
textErrorLightColor = Color(0xFFFFCDD2),
textWarningColor = Color(0xFFFFEB3B)
),
statusColors = DssKidStatuses(
statusYellow = DssKidStatusColorSchemes(Color(0xFFFFC107), Color(0xFFFFF8E1)),
statusGreen = DssKidStatusColorSchemes(Color(0xFF4CAF50), Color(0xFFE8F5E9)),
statusRed = DssKidStatusColorSchemes(Color(0xFFF44336), Color(0xFFFFEBEE)),
statusBlue = DssKidStatusColorSchemes(Color(0xFF2196F3), Color(0xFFE3F2FD)),
statusGray = DssKidStatusColorSchemes(Color.Gray, Color(0xFFF5F5F5))
),
appBackgroundColors = DssKidAppBgColors(
primaryBackground = Color.White,
cardBackground = Color(0xFFF0F0F0),
modalBackground = Color.White,
tabbarBackground = Color(0xFFE0E0E0),
topMenuBackground = Color.White,
systemStatusBarBackground = Color.White,
listLayoutBackgroundColor = Color(0xFFF7F7F7),
qrScannerBackgroundColor = Color.Black
),
keyboardBgColor = Color(0xFFECECEC),
buttonColorSchemes = DssKidButtonColorSchemes(
primaryButtonsColors = DssKidBtnColor(
btnBgColor = DssKidViewStateColors(
normal = Color(0xFF6200EE),
pressed = Color(0xFF3700B3),
disabled = Color(0xFFBDBDBD)
),
btnBorderColor = null,
textColor = DssKidViewStateColors(
normal = Color.White,
pressed = Color.White,
disabled = Color.LightGray
)
),
secondaryButtonsColors = DssKidBtnColor(
btnBgColor = DssKidViewStateColors(
normal = Color.LightGray,
pressed = Color.Gray,
disabled = Color(0xFFE0E0E0)
),
btnBorderColor = DssKidViewStateColors(
normal = Color.Gray,
pressed = Color.DarkGray,
disabled = Color.LightGray
),
textColor = DssKidViewStateColors(
normal = Color.Black,
pressed = Color.DarkGray,
disabled = Color.Gray
)
),
attentionButtonsColors = DssKidBtnColor(
btnBgColor = DssKidViewStateColors(
normal = Color.Red,
pressed = Color(0xFFB71C1C),
disabled = Color(0xFFFFCDD2)
),
btnBorderColor = DssKidViewStateColors(
normal = Color.DarkGray,
pressed = Color.Gray,
disabled = Color.Gray
),
textColor = DssKidViewStateColors(
normal = Color.White,
pressed = Color.White,
disabled = Color.LightGray
)
),
outlineButtonsColors = DssKidBtnColor(
btnBgColor = DssKidViewStateColors(
normal = Color.Transparent,
pressed = Color(0xFFE3F2FD),
disabled = Color.Transparent
),
btnBorderColor = DssKidViewStateColors(
normal = Color.Blue,
pressed = Color(0xFF1565C0),
disabled = Color.LightGray
),
textColor = DssKidViewStateColors(
normal = Color.Blue,
pressed = Color(0xFF1565C0),
disabled = Color.Gray
)
),
forgotPassButtonsColors = DssKidBtnColor(
btnBgColor = DssKidViewStateColors(
normal = Color.Transparent,
pressed = Color.Transparent,
disabled = Color.Transparent
),
btnBorderColor = null,
textColor = DssKidViewStateColors(
normal = Color(0xFF2962FF),
pressed = Color(0xFF0039CB),
disabled = Color.LightGray
)
),
linkButtonsColors = DssKidBtnColor(
btnBgColor = DssKidViewStateColors(
normal = Color.Transparent,
pressed = Color.Transparent,
disabled = Color.Transparent
),
btnBorderColor = null,
textColor = DssKidViewStateColors(
normal = Color.Blue,
pressed = Color(0xFF0D47A1),
disabled = Color.Gray
)
)
),
checkedViewColorSchemes = DssKidCheckViewColorSchemes(
checkedBgColor = Color.Green,
uncheckedBgColor = Color.White,
borderColor = Color.Gray,
iconColor = Color.White
),
inputSchemes = DssKidInputColorSchemes(
backgroundColor = Color.White,
backgroundColorDisabled = Color(0xFFF0F0F0),
borderNormalColor = Color.Gray,
borderFocusedColor = Color.Blue,
borderErrorColor = Color.Red,
borderDisableColor = Color.LightGray,
borderSuccessColor = Color.Green
),
iconColorSchemes = DssKidIconColorSchemes(
primaryIconColor = Color.Black,
secondaryIconColor = Color.Gray
)
),
dark = DssKidColors(
textColors = DssKidTextColors(
textPrimaryColor = Color.White,
textDescriptionColor = Color.LightGray,
textLinksColor = Color.Cyan,
textErrorPrimaryColor = Color(0xFFFF8A80),
textErrorLightColor = Color(0xFFFF5252),
textWarningColor = Color(0xFFFFF176)
),
statusColors = DssKidStatuses(
statusYellow = DssKidStatusColorSchemes(Color.Yellow, Color(0xFF424200)),
statusGreen = DssKidStatusColorSchemes(Color.Green, Color(0xFF003300)),
statusRed = DssKidStatusColorSchemes(Color.Red, Color(0xFF330000)),
statusBlue = DssKidStatusColorSchemes(Color.Blue, Color(0xFF001F3F)),
statusGray = DssKidStatusColorSchemes(Color.Gray, Color(0xFF212121))
),
appBackgroundColors = DssKidAppBgColors(
primaryBackground = Color(0xFF121212),
cardBackground = Color(0xFF1E1E1E),
modalBackground = Color(0xFF2C2C2C),
tabbarBackground = Color(0xFF1A1A1A),
topMenuBackground = Color(0xFF121212),
systemStatusBarBackground = Color(0xFF000000),
listLayoutBackgroundColor = Color(0xFF1F1F1F),
qrScannerBackgroundColor = Color.Black
),
keyboardBgColor = Color(0xFF2B2B2B),
buttonColorSchemes = DssKidButtonColorSchemes(
primaryButtonsColors = DssKidBtnColor(
btnBgColor = DssKidViewStateColors(
normal = Color.DarkGray,
pressed = Color.Gray,
disabled = Color(0xFF757575)
),
btnBorderColor = null,
textColor = DssKidViewStateColors(
normal = Color.White,
pressed = Color.White,
disabled = Color.LightGray
)
),
secondaryButtonsColors = DssKidBtnColor(
btnBgColor = DssKidViewStateColors(
Color.Gray,
Color.DarkGray,
Color(0xFF616161)
),
btnBorderColor = DssKidViewStateColors(
Color.LightGray,
Color.Gray,
Color.DarkGray
),
textColor = DssKidViewStateColors(Color.White, Color.White, Color.Gray)
),
attentionButtonsColors = DssKidBtnColor(
btnBgColor = DssKidViewStateColors(
Color.Red,
Color(0xFFB71C1C),
Color(0xFFEF9A9A)
),
btnBorderColor = DssKidViewStateColors(Color.DarkGray, Color.Gray, Color.Gray),
textColor = DssKidViewStateColors(Color.White, Color.White, Color.LightGray)
),
outlineButtonsColors = DssKidBtnColor(
btnBgColor = DssKidViewStateColors(
Color.Transparent,
Color.Transparent,
Color.Transparent
),
btnBorderColor = DssKidViewStateColors(
Color.Cyan,
Color(0xFF00ACC1),
Color.Gray
),
textColor = DssKidViewStateColors(Color.Cyan, Color(0xFF00ACC1), Color.Gray)
),
forgotPassButtonsColors = DssKidBtnColor(
btnBgColor = DssKidViewStateColors(
Color.Transparent,
Color.Transparent,
Color.Transparent
),
btnBorderColor = null,
textColor = DssKidViewStateColors(
Color(0xFF82B1FF),
Color(0xFF448AFF),
Color.Gray
)
),
linkButtonsColors = DssKidBtnColor(
btnBgColor = DssKidViewStateColors(
Color.Transparent,
Color.Transparent,
Color.Transparent
),
btnBorderColor = null,
textColor = DssKidViewStateColors(Color.Cyan, Color(0xFF00BCD4), Color.Gray)
)
),
checkedViewColorSchemes = DssKidCheckViewColorSchemes(
checkedBgColor = Color(0xFF00E676),
uncheckedBgColor = Color(0xFF424242),
borderColor = Color.LightGray,
iconColor = Color.Black
),
inputSchemes = DssKidInputColorSchemes(
backgroundColor = Color(0xFF1C1C1C),
backgroundColorDisabled = Color(0xFF2C2C2C),
borderNormalColor = Color.DarkGray,
borderFocusedColor = Color.Cyan,
borderErrorColor = Color.Red,
borderDisableColor = Color.Gray,
borderSuccessColor = Color.Green
),
iconColorSchemes = DssKidIconColorSchemes(
primaryIconColor = Color.White,
secondaryIconColor = Color.LightGray
)
)
),
typography = DssKidTypography(
headline1 = TextStyle(fontSize = 24.sp, fontWeight = FontWeight.Bold),
headline2 = TextStyle(fontSize = 22.sp, fontWeight = FontWeight.Medium),
outlinedButton = TextStyle(fontSize = 16.sp, fontWeight = FontWeight.Medium),
description = TextStyle(fontSize = 14.sp, fontWeight = FontWeight.Normal),
body = TextStyle(fontSize = 16.sp, fontWeight = FontWeight.Normal),
footnoteRegular = TextStyle(fontSize = 12.sp, fontWeight = FontWeight.Normal),
footnoteMedium = TextStyle(fontSize = 12.sp, fontWeight = FontWeight.Medium)
),
shapes = DssKidShape(
padding = 16.dp,
cornersStyle = RoundedCornerShape(8.dp)
),
sizes = DssKidSizes(
textInputMinHeight = 56.dp,
buttonMinHeight = 48.dp,
dropDownMinHeight = 40.dp
),
icons = DssKidDayNightIcons(
light = DssKidIcons(
smartCardIcons = DssKidSmartCardIcons(
waitIcon = R.drawable.ic_wait,
nfcIcon = R.drawable.ic_nfc,
usbIcon = R.drawable.ic_usb,
errorIcon = R.drawable.ic_error
)
),
dark = DssKidIcons(
smartCardIcons = DssKidSmartCardIcons(
waitIcon = R.drawable.ic_wait_dark,
nfcIcon = R.drawable.ic_nfc_dark,
usbIcon = R.drawable.ic_usb_dark,
errorIcon = R.drawable.ic_error_dark
)
)
)
)