forked from github/szkolny
[Login] Reformat LoginInfo.
This commit is contained in:
parent
2b3a7f6b41
commit
481af64137
@ -16,443 +16,446 @@ import pl.szczodrzynski.fslogin.realm.RealmData
|
|||||||
object LoginInfo {
|
object LoginInfo {
|
||||||
|
|
||||||
private fun getEmailCredential(keyName: String) = FormField(
|
private fun getEmailCredential(keyName: String) = FormField(
|
||||||
keyName = keyName,
|
keyName = keyName,
|
||||||
name = R.string.login_hint_email,
|
name = R.string.login_hint_email,
|
||||||
icon = CommunityMaterial.Icon.cmd_at,
|
icon = CommunityMaterial.Icon.cmd_at,
|
||||||
emptyText = R.string.login_error_no_email,
|
emptyText = R.string.login_error_no_email,
|
||||||
invalidText = R.string.login_error_incorrect_email,
|
invalidText = R.string.login_error_incorrect_email,
|
||||||
errorCodes = mapOf(),
|
errorCodes = mapOf(),
|
||||||
isRequired = true,
|
isRequired = true,
|
||||||
validationRegex = "([\\w.\\-_+]+)?\\w+@[\\w-_]+(\\.\\w+)+",
|
validationRegex = "([\\w.\\-_+]+)?\\w+@[\\w-_]+(\\.\\w+)+",
|
||||||
caseMode = FormField.CaseMode.LOWER_CASE
|
caseMode = FormField.CaseMode.LOWER_CASE
|
||||||
)
|
|
||||||
private fun getPasswordCredential(keyName: String) = FormField(
|
|
||||||
keyName = keyName,
|
|
||||||
name = R.string.login_hint_password,
|
|
||||||
icon = CommunityMaterial.Icon2.cmd_lock_outline,
|
|
||||||
emptyText = R.string.login_error_no_password,
|
|
||||||
invalidText = R.string.login_error_incorrect_login_or_password,
|
|
||||||
errorCodes = mapOf(),
|
|
||||||
isRequired = true,
|
|
||||||
validationRegex = ".*",
|
|
||||||
hideText = true
|
|
||||||
)
|
)
|
||||||
|
|
||||||
val list by lazy { listOf(
|
private fun getPasswordCredential(keyName: String) = FormField(
|
||||||
|
keyName = keyName,
|
||||||
|
name = R.string.login_hint_password,
|
||||||
|
icon = CommunityMaterial.Icon2.cmd_lock_outline,
|
||||||
|
emptyText = R.string.login_error_no_password,
|
||||||
|
invalidText = R.string.login_error_incorrect_login_or_password,
|
||||||
|
errorCodes = mapOf(),
|
||||||
|
isRequired = true,
|
||||||
|
validationRegex = ".*",
|
||||||
|
hideText = true
|
||||||
|
)
|
||||||
|
|
||||||
|
val list by lazy {
|
||||||
|
listOf(
|
||||||
Register(
|
Register(
|
||||||
loginType = LOGIN_TYPE_LIBRUS,
|
loginType = LOGIN_TYPE_LIBRUS,
|
||||||
internalName = "librus",
|
internalName = "librus",
|
||||||
registerName = R.string.login_register_librus,
|
registerName = R.string.login_register_librus,
|
||||||
registerLogo = R.drawable.login_logo_librus,
|
registerLogo = R.drawable.login_logo_librus,
|
||||||
loginModes = listOf(
|
loginModes = listOf(
|
||||||
Mode(
|
Mode(
|
||||||
loginMode = LOGIN_MODE_LIBRUS_EMAIL,
|
loginMode = LOGIN_MODE_LIBRUS_EMAIL,
|
||||||
name = R.string.login_mode_librus_email,
|
name = R.string.login_mode_librus_email,
|
||||||
icon = R.drawable.login_mode_librus_email,
|
icon = R.drawable.login_mode_librus_email,
|
||||||
hintText = R.string.login_mode_librus_email_hint,
|
hintText = R.string.login_mode_librus_email_hint,
|
||||||
guideText = R.string.login_mode_librus_email_guide,
|
guideText = R.string.login_mode_librus_email_guide,
|
||||||
isRecommended = true,
|
isRecommended = true,
|
||||||
credentials = listOf(
|
credentials = listOf(
|
||||||
getEmailCredential("email"),
|
getEmailCredential("email"),
|
||||||
getPasswordCredential("password")
|
getPasswordCredential("password")
|
||||||
|
),
|
||||||
|
errorCodes = mapOf(
|
||||||
|
ERROR_LOGIN_LIBRUS_PORTAL_NOT_ACTIVATED to R.string.login_error_account_not_activated,
|
||||||
|
ERROR_LOGIN_LIBRUS_PORTAL_INVALID_LOGIN to R.string.login_error_incorrect_login_or_password,
|
||||||
|
ERROR_CAPTCHA_LIBRUS_PORTAL to R.string.error_3001_reason
|
||||||
|
)
|
||||||
|
),
|
||||||
|
/*Mode(
|
||||||
|
loginMode = LOGIN_MODE_LIBRUS_SYNERGIA,
|
||||||
|
name = R.string.login_mode_librus_synergia,
|
||||||
|
icon = R.drawable.login_mode_librus_synergia,
|
||||||
|
hintText = R.string.login_mode_librus_synergia_hint,
|
||||||
|
guideText = R.string.login_mode_librus_synergia_guide,
|
||||||
|
credentials = listOf(
|
||||||
|
Credential(
|
||||||
|
keyName = "accountLogin",
|
||||||
|
name = R.string.login_hint_login,
|
||||||
|
icon = CommunityMaterial.Icon.cmd_account_outline,
|
||||||
|
emptyText = R.string.login_error_no_login,
|
||||||
|
invalidText = R.string.login_error_incorrect_login,
|
||||||
|
errorCodes = mapOf(),
|
||||||
|
isRequired = true,
|
||||||
|
validationRegex = "[A-z0-9._\\-+]+",
|
||||||
|
caseMode = Credential.CaseMode.LOWER_CASE
|
||||||
),
|
),
|
||||||
errorCodes = mapOf(
|
getPasswordCredential("accountPassword")
|
||||||
ERROR_LOGIN_LIBRUS_PORTAL_NOT_ACTIVATED to R.string.login_error_account_not_activated,
|
|
||||||
ERROR_LOGIN_LIBRUS_PORTAL_INVALID_LOGIN to R.string.login_error_incorrect_login_or_password,
|
|
||||||
ERROR_CAPTCHA_LIBRUS_PORTAL to R.string.error_3001_reason
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
/*Mode(
|
errorCodes = mapOf(
|
||||||
loginMode = LOGIN_MODE_LIBRUS_SYNERGIA,
|
ERROR_LOGIN_LIBRUS_API_INVALID_LOGIN to R.string.login_error_incorrect_login_or_password,
|
||||||
name = R.string.login_mode_librus_synergia,
|
ERROR_LOGIN_LIBRUS_API_INVALID_REQUEST to R.string.login_error_incorrect_login_or_password
|
||||||
icon = R.drawable.login_mode_librus_synergia,
|
|
||||||
hintText = R.string.login_mode_librus_synergia_hint,
|
|
||||||
guideText = R.string.login_mode_librus_synergia_guide,
|
|
||||||
credentials = listOf(
|
|
||||||
Credential(
|
|
||||||
keyName = "accountLogin",
|
|
||||||
name = R.string.login_hint_login,
|
|
||||||
icon = CommunityMaterial.Icon.cmd_account_outline,
|
|
||||||
emptyText = R.string.login_error_no_login,
|
|
||||||
invalidText = R.string.login_error_incorrect_login,
|
|
||||||
errorCodes = mapOf(),
|
|
||||||
isRequired = true,
|
|
||||||
validationRegex = "[A-z0-9._\\-+]+",
|
|
||||||
caseMode = Credential.CaseMode.LOWER_CASE
|
|
||||||
),
|
|
||||||
getPasswordCredential("accountPassword")
|
|
||||||
),
|
|
||||||
errorCodes = mapOf(
|
|
||||||
ERROR_LOGIN_LIBRUS_API_INVALID_LOGIN to R.string.login_error_incorrect_login_or_password,
|
|
||||||
ERROR_LOGIN_LIBRUS_API_INVALID_REQUEST to R.string.login_error_incorrect_login_or_password
|
|
||||||
)
|
|
||||||
),*/
|
|
||||||
Mode(
|
|
||||||
loginMode = LOGIN_MODE_LIBRUS_JST,
|
|
||||||
name = R.string.login_mode_librus_jst,
|
|
||||||
icon = R.drawable.login_mode_librus_jst,
|
|
||||||
hintText = R.string.login_mode_librus_jst_hint,
|
|
||||||
guideText = R.string.login_mode_librus_jst_guide,
|
|
||||||
credentials = listOf(
|
|
||||||
FormField(
|
|
||||||
keyName = "accountCode",
|
|
||||||
name = R.string.login_hint_token,
|
|
||||||
icon = CommunityMaterial.Icon.cmd_code_braces,
|
|
||||||
emptyText = R.string.login_error_no_token,
|
|
||||||
invalidText = R.string.login_error_incorrect_token,
|
|
||||||
errorCodes = mapOf(),
|
|
||||||
isRequired = true,
|
|
||||||
validationRegex = "[A-Z0-9_]+",
|
|
||||||
caseMode = FormField.CaseMode.UPPER_CASE
|
|
||||||
),
|
|
||||||
FormField(
|
|
||||||
keyName = "accountPin",
|
|
||||||
name = R.string.login_hint_pin,
|
|
||||||
icon = CommunityMaterial.Icon2.cmd_lock,
|
|
||||||
emptyText = R.string.login_error_no_pin,
|
|
||||||
invalidText = R.string.login_error_incorrect_pin,
|
|
||||||
errorCodes = mapOf(),
|
|
||||||
isRequired = true,
|
|
||||||
validationRegex = "[a-z0-9_]+",
|
|
||||||
caseMode = FormField.CaseMode.LOWER_CASE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
errorCodes = mapOf(
|
|
||||||
ERROR_LOGIN_LIBRUS_API_INVALID_LOGIN to R.string.login_error_incorrect_code_or_pin,
|
|
||||||
ERROR_LOGIN_LIBRUS_API_INVALID_REQUEST to R.string.login_error_incorrect_code_or_pin
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
),*/
|
||||||
),
|
Mode(
|
||||||
Register(
|
loginMode = LOGIN_MODE_LIBRUS_JST,
|
||||||
loginType = LOGIN_TYPE_VULCAN,
|
name = R.string.login_mode_librus_jst,
|
||||||
internalName = "vulcan",
|
icon = R.drawable.login_mode_librus_jst,
|
||||||
registerName = R.string.login_type_vulcan,
|
hintText = R.string.login_mode_librus_jst_hint,
|
||||||
registerLogo = R.drawable.login_logo_vulcan,
|
guideText = R.string.login_mode_librus_jst_guide,
|
||||||
loginModes = listOf(
|
credentials = listOf(
|
||||||
Mode(
|
FormField(
|
||||||
loginMode = LOGIN_MODE_VULCAN_HEBE,
|
keyName = "accountCode",
|
||||||
name = R.string.login_mode_vulcan_api,
|
name = R.string.login_hint_token,
|
||||||
icon = R.drawable.login_mode_vulcan_hebe,
|
icon = CommunityMaterial.Icon.cmd_code_braces,
|
||||||
hintText = R.string.login_mode_vulcan_api_hint,
|
emptyText = R.string.login_error_no_token,
|
||||||
guideText = R.string.login_mode_vulcan_api_guide,
|
invalidText = R.string.login_error_incorrect_token,
|
||||||
isRecommended = true,
|
errorCodes = mapOf(),
|
||||||
credentials = listOf(
|
isRequired = true,
|
||||||
FormField(
|
validationRegex = "[A-Z0-9_]+",
|
||||||
keyName = "deviceToken",
|
caseMode = FormField.CaseMode.UPPER_CASE
|
||||||
name = R.string.login_hint_token,
|
|
||||||
icon = CommunityMaterial.Icon.cmd_code_braces,
|
|
||||||
emptyText = R.string.login_error_no_token,
|
|
||||||
invalidText = R.string.login_error_incorrect_token,
|
|
||||||
errorCodes = mapOf(
|
|
||||||
ERROR_LOGIN_VULCAN_INVALID_TOKEN to R.string.login_error_incorrect_token
|
|
||||||
),
|
|
||||||
isRequired = true,
|
|
||||||
validationRegex = "[A-Z0-9]{5,12}",
|
|
||||||
caseMode = FormField.CaseMode.UPPER_CASE
|
|
||||||
),
|
|
||||||
FormField(
|
|
||||||
keyName = "symbol",
|
|
||||||
name = R.string.login_hint_symbol,
|
|
||||||
icon = CommunityMaterial.Icon2.cmd_school,
|
|
||||||
emptyText = R.string.login_error_no_symbol,
|
|
||||||
invalidText = R.string.login_error_incorrect_symbol,
|
|
||||||
errorCodes = mapOf(
|
|
||||||
ERROR_LOGIN_VULCAN_INVALID_SYMBOL to R.string.login_error_incorrect_symbol
|
|
||||||
),
|
|
||||||
isRequired = true,
|
|
||||||
validationRegex = "[a-z0-9_-]+",
|
|
||||||
caseMode = FormField.CaseMode.LOWER_CASE
|
|
||||||
),
|
|
||||||
FormField(
|
|
||||||
keyName = "devicePin",
|
|
||||||
name = R.string.login_hint_pin,
|
|
||||||
icon = CommunityMaterial.Icon2.cmd_lock,
|
|
||||||
emptyText = R.string.login_error_no_pin,
|
|
||||||
invalidText = R.string.login_error_incorrect_pin,
|
|
||||||
errorCodes = mapOf(
|
|
||||||
ERROR_LOGIN_VULCAN_INVALID_PIN to R.string.login_error_incorrect_pin
|
|
||||||
),
|
|
||||||
isRequired = true,
|
|
||||||
validationRegex = "[0-9]+",
|
|
||||||
caseMode = FormField.CaseMode.LOWER_CASE
|
|
||||||
)
|
|
||||||
),
|
|
||||||
errorCodes = mapOf(
|
|
||||||
ERROR_LOGIN_VULCAN_EXPIRED_TOKEN to R.string.login_error_expired_token
|
|
||||||
)
|
|
||||||
),
|
),
|
||||||
Mode(
|
FormField(
|
||||||
loginMode = LOGIN_MODE_VULCAN_WEB,
|
keyName = "accountPin",
|
||||||
name = R.string.login_mode_vulcan_web,
|
name = R.string.login_hint_pin,
|
||||||
icon = R.drawable.login_mode_vulcan_web,
|
icon = CommunityMaterial.Icon2.cmd_lock,
|
||||||
hintText = R.string.login_mode_vulcan_web_hint,
|
emptyText = R.string.login_error_no_pin,
|
||||||
guideText = R.string.login_mode_vulcan_web_guide,
|
invalidText = R.string.login_error_incorrect_pin,
|
||||||
isTesting = true,
|
errorCodes = mapOf(),
|
||||||
isPlatformSelection = true,
|
isRequired = true,
|
||||||
credentials = listOf(
|
validationRegex = "[a-z0-9_]+",
|
||||||
getEmailCredential("email"),
|
caseMode = FormField.CaseMode.LOWER_CASE
|
||||||
FormField(
|
|
||||||
keyName = "username",
|
|
||||||
name = R.string.login_hint_username,
|
|
||||||
icon = CommunityMaterial.Icon.cmd_account_outline,
|
|
||||||
emptyText = R.string.login_error_no_username,
|
|
||||||
invalidText = R.string.login_error_incorrect_username,
|
|
||||||
errorCodes = mapOf(),
|
|
||||||
isRequired = true,
|
|
||||||
validationRegex = "[A-Z]{7}[0-9]+",
|
|
||||||
caseMode = FormField.CaseMode.UPPER_CASE
|
|
||||||
),
|
|
||||||
getPasswordCredential("password")
|
|
||||||
),
|
|
||||||
errorCodes = mapOf()
|
|
||||||
)
|
)
|
||||||
|
),
|
||||||
|
errorCodes = mapOf(
|
||||||
|
ERROR_LOGIN_LIBRUS_API_INVALID_LOGIN to R.string.login_error_incorrect_code_or_pin,
|
||||||
|
ERROR_LOGIN_LIBRUS_API_INVALID_REQUEST to R.string.login_error_incorrect_code_or_pin
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Register(
|
Register(
|
||||||
loginType = LOGIN_TYPE_MOBIDZIENNIK,
|
loginType = LOGIN_TYPE_VULCAN,
|
||||||
internalName = "mobidziennik",
|
internalName = "vulcan",
|
||||||
registerName = R.string.login_type_mobidziennik,
|
registerName = R.string.login_type_vulcan,
|
||||||
registerLogo = R.drawable.login_logo_mobidziennik,
|
registerLogo = R.drawable.login_logo_vulcan,
|
||||||
loginModes = listOf(
|
loginModes = listOf(
|
||||||
Mode(
|
Mode(
|
||||||
loginMode = LOGIN_MODE_MOBIDZIENNIK_WEB,
|
loginMode = LOGIN_MODE_VULCAN_HEBE,
|
||||||
name = R.string.login_mode_mobidziennik_web,
|
name = R.string.login_mode_vulcan_api,
|
||||||
icon = R.drawable.login_mode_mobidziennik_web,
|
icon = R.drawable.login_mode_vulcan_hebe,
|
||||||
hintText = R.string.login_mode_mobidziennik_web_hint,
|
hintText = R.string.login_mode_vulcan_api_hint,
|
||||||
guideText = R.string.login_mode_mobidziennik_web_guide,
|
guideText = R.string.login_mode_vulcan_api_guide,
|
||||||
credentials = listOf(
|
isRecommended = true,
|
||||||
FormField(
|
credentials = listOf(
|
||||||
keyName = "username",
|
FormField(
|
||||||
name = R.string.login_hint_login_email,
|
keyName = "deviceToken",
|
||||||
icon = CommunityMaterial.Icon.cmd_account_outline,
|
name = R.string.login_hint_token,
|
||||||
emptyText = R.string.login_error_no_login,
|
icon = CommunityMaterial.Icon.cmd_code_braces,
|
||||||
invalidText = R.string.login_error_incorrect_login,
|
emptyText = R.string.login_error_no_token,
|
||||||
errorCodes = mapOf(),
|
invalidText = R.string.login_error_incorrect_token,
|
||||||
isRequired = true,
|
errorCodes = mapOf(
|
||||||
validationRegex = "^[a-z0-9_\\-@+.]+$",
|
ERROR_LOGIN_VULCAN_INVALID_TOKEN to R.string.login_error_incorrect_token
|
||||||
caseMode = FormField.CaseMode.LOWER_CASE
|
),
|
||||||
),
|
isRequired = true,
|
||||||
FormField(
|
validationRegex = "[A-Z0-9]{5,12}",
|
||||||
keyName = "password",
|
caseMode = FormField.CaseMode.UPPER_CASE
|
||||||
name = R.string.login_hint_password,
|
),
|
||||||
icon = CommunityMaterial.Icon2.cmd_lock_outline,
|
FormField(
|
||||||
emptyText = R.string.login_error_no_password,
|
keyName = "symbol",
|
||||||
invalidText = R.string.login_error_incorrect_login_or_password,
|
name = R.string.login_hint_symbol,
|
||||||
errorCodes = mapOf(
|
icon = CommunityMaterial.Icon2.cmd_school,
|
||||||
ERROR_LOGIN_MOBIDZIENNIK_WEB_OLD_PASSWORD to R.string.login_error_old_password
|
emptyText = R.string.login_error_no_symbol,
|
||||||
),
|
invalidText = R.string.login_error_incorrect_symbol,
|
||||||
isRequired = true,
|
errorCodes = mapOf(
|
||||||
validationRegex = ".*",
|
ERROR_LOGIN_VULCAN_INVALID_SYMBOL to R.string.login_error_incorrect_symbol
|
||||||
hideText = true
|
),
|
||||||
),
|
isRequired = true,
|
||||||
FormField(
|
validationRegex = "[a-z0-9_-]+",
|
||||||
keyName = "serverName",
|
caseMode = FormField.CaseMode.LOWER_CASE
|
||||||
name = R.string.login_hint_address,
|
),
|
||||||
icon = CommunityMaterial.Icon2.cmd_web,
|
FormField(
|
||||||
emptyText = R.string.login_error_no_address,
|
keyName = "devicePin",
|
||||||
invalidText = R.string.login_error_incorrect_address,
|
name = R.string.login_hint_pin,
|
||||||
errorCodes = mapOf(
|
icon = CommunityMaterial.Icon2.cmd_lock,
|
||||||
ERROR_LOGIN_MOBIDZIENNIK_WEB_INVALID_ADDRESS to R.string.login_error_incorrect_address
|
emptyText = R.string.login_error_no_pin,
|
||||||
),
|
invalidText = R.string.login_error_incorrect_pin,
|
||||||
isRequired = true,
|
errorCodes = mapOf(
|
||||||
validationRegex = "^[a-z0-9_\\-]+\$",
|
ERROR_LOGIN_VULCAN_INVALID_PIN to R.string.login_error_incorrect_pin
|
||||||
caseMode = FormField.CaseMode.LOWER_CASE
|
),
|
||||||
)
|
isRequired = true,
|
||||||
),
|
validationRegex = "[0-9]+",
|
||||||
errorCodes = mapOf(
|
caseMode = FormField.CaseMode.LOWER_CASE
|
||||||
ERROR_LOGIN_MOBIDZIENNIK_WEB_INVALID_LOGIN to R.string.login_error_incorrect_login_or_password,
|
|
||||||
ERROR_LOGIN_MOBIDZIENNIK_WEB_ARCHIVED to R.string.sync_error_archived
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
),
|
||||||
|
errorCodes = mapOf(
|
||||||
|
ERROR_LOGIN_VULCAN_EXPIRED_TOKEN to R.string.login_error_expired_token
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Mode(
|
||||||
|
loginMode = LOGIN_MODE_VULCAN_WEB,
|
||||||
|
name = R.string.login_mode_vulcan_web,
|
||||||
|
icon = R.drawable.login_mode_vulcan_web,
|
||||||
|
hintText = R.string.login_mode_vulcan_web_hint,
|
||||||
|
guideText = R.string.login_mode_vulcan_web_guide,
|
||||||
|
isTesting = true,
|
||||||
|
isPlatformSelection = true,
|
||||||
|
credentials = listOf(
|
||||||
|
getEmailCredential("email"),
|
||||||
|
FormField(
|
||||||
|
keyName = "username",
|
||||||
|
name = R.string.login_hint_username,
|
||||||
|
icon = CommunityMaterial.Icon.cmd_account_outline,
|
||||||
|
emptyText = R.string.login_error_no_username,
|
||||||
|
invalidText = R.string.login_error_incorrect_username,
|
||||||
|
errorCodes = mapOf(),
|
||||||
|
isRequired = true,
|
||||||
|
validationRegex = "[A-Z]{7}[0-9]+",
|
||||||
|
caseMode = FormField.CaseMode.UPPER_CASE
|
||||||
|
),
|
||||||
|
getPasswordCredential("password")
|
||||||
|
),
|
||||||
|
errorCodes = mapOf()
|
||||||
)
|
)
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Register(
|
Register(
|
||||||
loginType = LOGIN_TYPE_IDZIENNIK,
|
loginType = LOGIN_TYPE_MOBIDZIENNIK,
|
||||||
internalName = "idziennik",
|
internalName = "mobidziennik",
|
||||||
registerName = R.string.login_type_idziennik,
|
registerName = R.string.login_type_mobidziennik,
|
||||||
registerLogo = R.drawable.login_logo_iuczniowie,
|
registerLogo = R.drawable.login_logo_mobidziennik,
|
||||||
loginModes = listOf(
|
loginModes = listOf(
|
||||||
Mode(
|
Mode(
|
||||||
loginMode = LOGIN_MODE_IDZIENNIK_WEB,
|
loginMode = LOGIN_MODE_MOBIDZIENNIK_WEB,
|
||||||
name = R.string.login_mode_idziennik_web,
|
name = R.string.login_mode_mobidziennik_web,
|
||||||
icon = R.drawable.login_mode_idziennik_web,
|
icon = R.drawable.login_mode_mobidziennik_web,
|
||||||
hintText = R.string.login_mode_idziennik_web_hint,
|
hintText = R.string.login_mode_mobidziennik_web_hint,
|
||||||
guideText = R.string.login_mode_idziennik_web_guide,
|
guideText = R.string.login_mode_mobidziennik_web_guide,
|
||||||
credentials = listOf(
|
credentials = listOf(
|
||||||
FormField(
|
FormField(
|
||||||
keyName = "schoolName",
|
keyName = "username",
|
||||||
name = R.string.login_hint_school_name,
|
name = R.string.login_hint_login_email,
|
||||||
icon = CommunityMaterial.Icon2.cmd_school,
|
icon = CommunityMaterial.Icon.cmd_account_outline,
|
||||||
emptyText = R.string.login_error_no_school_name,
|
emptyText = R.string.login_error_no_login,
|
||||||
invalidText = R.string.login_error_incorrect_school_name,
|
invalidText = R.string.login_error_incorrect_login,
|
||||||
errorCodes = mapOf(
|
errorCodes = mapOf(),
|
||||||
ERROR_LOGIN_IDZIENNIK_WEB_INVALID_SCHOOL_NAME to R.string.login_error_incorrect_school_name
|
isRequired = true,
|
||||||
),
|
validationRegex = "^[a-z0-9_\\-@+.]+$",
|
||||||
isRequired = true,
|
caseMode = FormField.CaseMode.LOWER_CASE
|
||||||
validationRegex = "^[a-z0-9_\\-.]+$",
|
),
|
||||||
caseMode = FormField.CaseMode.LOWER_CASE
|
FormField(
|
||||||
),
|
keyName = "password",
|
||||||
FormField(
|
name = R.string.login_hint_password,
|
||||||
keyName = "username",
|
icon = CommunityMaterial.Icon2.cmd_lock_outline,
|
||||||
name = R.string.login_hint_username,
|
emptyText = R.string.login_error_no_password,
|
||||||
icon = CommunityMaterial.Icon.cmd_account_outline,
|
invalidText = R.string.login_error_incorrect_login_or_password,
|
||||||
emptyText = R.string.login_error_no_username,
|
errorCodes = mapOf(
|
||||||
invalidText = R.string.login_error_incorrect_username,
|
ERROR_LOGIN_MOBIDZIENNIK_WEB_OLD_PASSWORD to R.string.login_error_old_password
|
||||||
errorCodes = mapOf(),
|
),
|
||||||
isRequired = true,
|
isRequired = true,
|
||||||
validationRegex = "^[a-z0-9_\\-.]+$",
|
validationRegex = ".*",
|
||||||
caseMode = FormField.CaseMode.LOWER_CASE
|
hideText = true
|
||||||
),
|
),
|
||||||
getPasswordCredential("password")
|
FormField(
|
||||||
),
|
keyName = "serverName",
|
||||||
errorCodes = mapOf(
|
name = R.string.login_hint_address,
|
||||||
ERROR_LOGIN_IDZIENNIK_WEB_INVALID_LOGIN to R.string.login_error_incorrect_login_or_password
|
icon = CommunityMaterial.Icon2.cmd_web,
|
||||||
)
|
emptyText = R.string.login_error_no_address,
|
||||||
|
invalidText = R.string.login_error_incorrect_address,
|
||||||
|
errorCodes = mapOf(
|
||||||
|
ERROR_LOGIN_MOBIDZIENNIK_WEB_INVALID_ADDRESS to R.string.login_error_incorrect_address
|
||||||
|
),
|
||||||
|
isRequired = true,
|
||||||
|
validationRegex = "^[a-z0-9_\\-]+\$",
|
||||||
|
caseMode = FormField.CaseMode.LOWER_CASE
|
||||||
)
|
)
|
||||||
|
),
|
||||||
|
errorCodes = mapOf(
|
||||||
|
ERROR_LOGIN_MOBIDZIENNIK_WEB_INVALID_LOGIN to R.string.login_error_incorrect_login_or_password,
|
||||||
|
ERROR_LOGIN_MOBIDZIENNIK_WEB_ARCHIVED to R.string.sync_error_archived
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Register(
|
Register(
|
||||||
loginType = LOGIN_TYPE_EDUDZIENNIK,
|
loginType = LOGIN_TYPE_IDZIENNIK,
|
||||||
internalName = "edudziennik",
|
internalName = "idziennik",
|
||||||
registerName = R.string.login_type_edudziennik,
|
registerName = R.string.login_type_idziennik,
|
||||||
registerLogo = R.drawable.login_logo_edudziennik,
|
registerLogo = R.drawable.login_logo_iuczniowie,
|
||||||
loginModes = listOf(
|
loginModes = listOf(
|
||||||
Mode(
|
Mode(
|
||||||
loginMode = LOGIN_MODE_EDUDZIENNIK_WEB,
|
loginMode = LOGIN_MODE_IDZIENNIK_WEB,
|
||||||
name = R.string.login_mode_edudziennik_web,
|
name = R.string.login_mode_idziennik_web,
|
||||||
icon = R.drawable.login_mode_edudziennik_web,
|
icon = R.drawable.login_mode_idziennik_web,
|
||||||
hintText = R.string.login_mode_edudziennik_web_hint,
|
hintText = R.string.login_mode_idziennik_web_hint,
|
||||||
guideText = R.string.login_mode_edudziennik_web_guide,
|
guideText = R.string.login_mode_idziennik_web_guide,
|
||||||
credentials = listOf(
|
credentials = listOf(
|
||||||
getEmailCredential("email"),
|
FormField(
|
||||||
getPasswordCredential("password")
|
keyName = "schoolName",
|
||||||
),
|
name = R.string.login_hint_school_name,
|
||||||
errorCodes = mapOf(
|
icon = CommunityMaterial.Icon2.cmd_school,
|
||||||
ERROR_LOGIN_EDUDZIENNIK_WEB_INVALID_LOGIN to R.string.login_error_incorrect_login_or_password
|
emptyText = R.string.login_error_no_school_name,
|
||||||
)
|
invalidText = R.string.login_error_incorrect_school_name,
|
||||||
)
|
errorCodes = mapOf(
|
||||||
|
ERROR_LOGIN_IDZIENNIK_WEB_INVALID_SCHOOL_NAME to R.string.login_error_incorrect_school_name
|
||||||
|
),
|
||||||
|
isRequired = true,
|
||||||
|
validationRegex = "^[a-z0-9_\\-.]+$",
|
||||||
|
caseMode = FormField.CaseMode.LOWER_CASE
|
||||||
|
),
|
||||||
|
FormField(
|
||||||
|
keyName = "username",
|
||||||
|
name = R.string.login_hint_username,
|
||||||
|
icon = CommunityMaterial.Icon.cmd_account_outline,
|
||||||
|
emptyText = R.string.login_error_no_username,
|
||||||
|
invalidText = R.string.login_error_incorrect_username,
|
||||||
|
errorCodes = mapOf(),
|
||||||
|
isRequired = true,
|
||||||
|
validationRegex = "^[a-z0-9_\\-.]+$",
|
||||||
|
caseMode = FormField.CaseMode.LOWER_CASE
|
||||||
|
),
|
||||||
|
getPasswordCredential("password")
|
||||||
|
),
|
||||||
|
errorCodes = mapOf(
|
||||||
|
ERROR_LOGIN_IDZIENNIK_WEB_INVALID_LOGIN to R.string.login_error_incorrect_login_or_password
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
),
|
),
|
||||||
Register(
|
Register(
|
||||||
loginType = LOGIN_TYPE_PODLASIE,
|
loginType = LOGIN_TYPE_EDUDZIENNIK,
|
||||||
internalName = "podlasie",
|
internalName = "edudziennik",
|
||||||
registerName = R.string.login_type_podlasie,
|
registerName = R.string.login_type_edudziennik,
|
||||||
registerLogo = R.drawable.login_logo_podlasie,
|
registerLogo = R.drawable.login_logo_edudziennik,
|
||||||
loginModes = listOf(
|
loginModes = listOf(
|
||||||
Mode(
|
Mode(
|
||||||
loginMode = LOGIN_MODE_PODLASIE_API,
|
loginMode = LOGIN_MODE_EDUDZIENNIK_WEB,
|
||||||
name = R.string.login_mode_podlasie_api,
|
name = R.string.login_mode_edudziennik_web,
|
||||||
icon = R.drawable.login_mode_podlasie_api,
|
icon = R.drawable.login_mode_edudziennik_web,
|
||||||
guideText = R.string.login_mode_podlasie_api_guide,
|
hintText = R.string.login_mode_edudziennik_web_hint,
|
||||||
credentials = listOf(
|
guideText = R.string.login_mode_edudziennik_web_guide,
|
||||||
FormField(
|
credentials = listOf(
|
||||||
keyName = "apiToken",
|
getEmailCredential("email"),
|
||||||
name = R.string.login_hint_token,
|
getPasswordCredential("password")
|
||||||
icon = CommunityMaterial.Icon2.cmd_lock_outline,
|
),
|
||||||
emptyText = R.string.login_error_no_token,
|
errorCodes = mapOf(
|
||||||
invalidText = R.string.login_error_incorrect_token,
|
ERROR_LOGIN_EDUDZIENNIK_WEB_INVALID_LOGIN to R.string.login_error_incorrect_login_or_password
|
||||||
errorCodes = mapOf(),
|
)
|
||||||
isRequired = true,
|
|
||||||
validationRegex = "[a-zA-Z0-9]{10}",
|
|
||||||
caseMode = FormField.CaseMode.UNCHANGED
|
|
||||||
),
|
|
||||||
FormCheckbox(
|
|
||||||
keyName = "logoutDevices",
|
|
||||||
name = R.string.login_podlasie_logout_devices,
|
|
||||||
checked = false,
|
|
||||||
errorCodes = mapOf(
|
|
||||||
ERROR_LOGIN_PODLASIE_API_DEVICE_LIMIT to R.string.error_602_reason
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
errorCodes = mapOf()
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Register(
|
||||||
|
loginType = LOGIN_TYPE_PODLASIE,
|
||||||
|
internalName = "podlasie",
|
||||||
|
registerName = R.string.login_type_podlasie,
|
||||||
|
registerLogo = R.drawable.login_logo_podlasie,
|
||||||
|
loginModes = listOf(
|
||||||
|
Mode(
|
||||||
|
loginMode = LOGIN_MODE_PODLASIE_API,
|
||||||
|
name = R.string.login_mode_podlasie_api,
|
||||||
|
icon = R.drawable.login_mode_podlasie_api,
|
||||||
|
guideText = R.string.login_mode_podlasie_api_guide,
|
||||||
|
credentials = listOf(
|
||||||
|
FormField(
|
||||||
|
keyName = "apiToken",
|
||||||
|
name = R.string.login_hint_token,
|
||||||
|
icon = CommunityMaterial.Icon2.cmd_lock_outline,
|
||||||
|
emptyText = R.string.login_error_no_token,
|
||||||
|
invalidText = R.string.login_error_incorrect_token,
|
||||||
|
errorCodes = mapOf(),
|
||||||
|
isRequired = true,
|
||||||
|
validationRegex = "[a-zA-Z0-9]{10}",
|
||||||
|
caseMode = FormField.CaseMode.UNCHANGED
|
||||||
|
),
|
||||||
|
FormCheckbox(
|
||||||
|
keyName = "logoutDevices",
|
||||||
|
name = R.string.login_podlasie_logout_devices,
|
||||||
|
checked = false,
|
||||||
|
errorCodes = mapOf(
|
||||||
|
ERROR_LOGIN_PODLASIE_API_DEVICE_LIMIT to R.string.error_602_reason
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
errorCodes = mapOf()
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
) }
|
)
|
||||||
|
}
|
||||||
|
|
||||||
data class Register(
|
data class Register(
|
||||||
val loginType: Int,
|
val loginType: Int,
|
||||||
val internalName: String,
|
val internalName: String,
|
||||||
val registerName: Int,
|
val registerName: Int,
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
val registerLogo: Int,
|
val registerLogo: Int,
|
||||||
|
|
||||||
val loginModes: List<Mode>
|
val loginModes: List<Mode>
|
||||||
) : ExpandableItemModel<Mode>(loginModes.toMutableList()) {
|
) : ExpandableItemModel<Mode>(loginModes.toMutableList()) {
|
||||||
override var level = 1
|
override var level = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
data class Mode(
|
data class Mode(
|
||||||
val loginMode: Int,
|
val loginMode: Int,
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
val name: Int,
|
val name: Int,
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
val icon: Int,
|
val icon: Int,
|
||||||
@StringRes
|
@StringRes
|
||||||
val hintText: Int? = null,
|
val hintText: Int? = null,
|
||||||
@StringRes
|
@StringRes
|
||||||
val guideText: Int,
|
val guideText: Int,
|
||||||
|
|
||||||
val isRecommended: Boolean = false,
|
val isRecommended: Boolean = false,
|
||||||
val isTesting: Boolean = false,
|
val isTesting: Boolean = false,
|
||||||
val isDevOnly: Boolean = false,
|
val isDevOnly: Boolean = false,
|
||||||
val isPlatformSelection: Boolean = false,
|
val isPlatformSelection: Boolean = false,
|
||||||
|
|
||||||
val credentials: List<BaseCredential>,
|
val credentials: List<BaseCredential>,
|
||||||
val errorCodes: Map<Int, Int>
|
val errorCodes: Map<Int, Int>
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Platform(
|
data class Platform(
|
||||||
val id: Int,
|
val id: Int,
|
||||||
val name: String,
|
val name: String,
|
||||||
val description: String?,
|
val description: String?,
|
||||||
val icon: String,
|
val icon: String,
|
||||||
val screenshot: String?,
|
val screenshot: String?,
|
||||||
val formFields: List<String>,
|
val formFields: List<String>,
|
||||||
val realmData: RealmData
|
val realmData: RealmData
|
||||||
)
|
)
|
||||||
|
|
||||||
open class BaseCredential(
|
open class BaseCredential(
|
||||||
open val keyName: String,
|
open val keyName: String,
|
||||||
@StringRes
|
@StringRes
|
||||||
open val name: Int,
|
open val name: Int,
|
||||||
open val errorCodes: Map<Int, Int>
|
open val errorCodes: Map<Int, Int>
|
||||||
)
|
)
|
||||||
|
|
||||||
data class FormField(
|
data class FormField(
|
||||||
override val keyName: String,
|
override val keyName: String,
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
override val name: Int,
|
override val name: Int,
|
||||||
val icon: IIcon,
|
val icon: IIcon,
|
||||||
@StringRes
|
@StringRes
|
||||||
val placeholder: Int? = null,
|
val placeholder: Int? = null,
|
||||||
@StringRes
|
@StringRes
|
||||||
val emptyText: Int,
|
val emptyText: Int,
|
||||||
@StringRes
|
@StringRes
|
||||||
val invalidText: Int,
|
val invalidText: Int,
|
||||||
override val errorCodes: Map<Int, Int>,
|
override val errorCodes: Map<Int, Int>,
|
||||||
@StringRes
|
@StringRes
|
||||||
val hintText: Int? = null,
|
val hintText: Int? = null,
|
||||||
|
|
||||||
val isRequired: Boolean = true,
|
val isRequired: Boolean = true,
|
||||||
val validationRegex: String,
|
val validationRegex: String,
|
||||||
val caseMode: CaseMode = CaseMode.UNCHANGED,
|
val caseMode: CaseMode = CaseMode.UNCHANGED,
|
||||||
val hideText: Boolean = false,
|
val hideText: Boolean = false,
|
||||||
val stripTextRegex: String? = null
|
val stripTextRegex: String? = null
|
||||||
) : BaseCredential(keyName, name, errorCodes) {
|
) : BaseCredential(keyName, name, errorCodes) {
|
||||||
enum class CaseMode { UNCHANGED, UPPER_CASE, LOWER_CASE }
|
enum class CaseMode { UNCHANGED, UPPER_CASE, LOWER_CASE }
|
||||||
}
|
}
|
||||||
|
|
||||||
data class FormCheckbox(
|
data class FormCheckbox(
|
||||||
override val keyName: String,
|
override val keyName: String,
|
||||||
@StringRes
|
@StringRes
|
||||||
override val name: Int,
|
override val name: Int,
|
||||||
val checked: Boolean = false,
|
val checked: Boolean = false,
|
||||||
override val errorCodes: Map<Int, Int> = mapOf()
|
override val errorCodes: Map<Int, Int> = mapOf()
|
||||||
) : BaseCredential(keyName, name, errorCodes)
|
) : BaseCredential(keyName, name, errorCodes)
|
||||||
|
|
||||||
var chooserList: MutableList<Any>? = null
|
var chooserList: MutableList<Any>? = null
|
||||||
|
Loading…
x
Reference in New Issue
Block a user