mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-18 04:08:44 +03:00
renaming homeserver url properties to better define their content
This commit is contained in:
parent
0ce2012b83
commit
21102a2f9f
11 changed files with 32 additions and 33 deletions
|
@ -560,7 +560,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
}
|
||||
|
||||
private fun handleWebLoginSuccess(action: OnboardingAction.WebLoginSuccess) = withState { state ->
|
||||
val homeServerConnectionConfigFinal = homeServerConnectionConfigFactory.create(state.selectedHomeserver.declaredUrl)
|
||||
val homeServerConnectionConfigFinal = homeServerConnectionConfigFactory.create(state.selectedHomeserver.upstreamUrl)
|
||||
|
||||
if (homeServerConnectionConfigFinal == null) {
|
||||
// Should not happen
|
||||
|
@ -603,7 +603,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||
setState {
|
||||
copy(
|
||||
serverType = alignServerTypeAfterSubmission(homeServerConnectionConfig, serverTypeOverride),
|
||||
selectedHomeserver = it.selectedHomeserverState,
|
||||
selectedHomeserver = it.selectedHomeserver,
|
||||
isLoading = false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -64,8 +64,8 @@ enum class OnboardingFlow {
|
|||
@Parcelize
|
||||
data class SelectedHomeserverState(
|
||||
val description: String? = null,
|
||||
val sourceUrl: String? = null,
|
||||
val declaredUrl: String? = null,
|
||||
val userFacingUrl: String? = null,
|
||||
val upstreamUrl: String? = null,
|
||||
val preferredLoginMode: LoginMode = LoginMode.Unknown,
|
||||
val supportedLoginTypes: List<String> = emptyList(),
|
||||
) : Parcelable
|
||||
|
|
|
@ -36,28 +36,27 @@ class StartAuthenticationFlowUseCase @Inject constructor(
|
|||
authenticationService.cancelPendingLoginOrRegistration()
|
||||
val authFlow = authenticationService.getLoginFlow(config)
|
||||
val preferredLoginMode = authFlow.findPreferredLoginMode()
|
||||
val selection = createSelectedHomeserverState(authFlow, config, preferredLoginMode)
|
||||
val selection = createSelectedHomeserver(authFlow, config, preferredLoginMode)
|
||||
val isOutdated = (preferredLoginMode == LoginMode.Password && !authFlow.isLoginAndRegistrationSupported) || authFlow.isOutdatedHomeserver
|
||||
return StartAuthenticationResult(isOutdated, selection)
|
||||
}
|
||||
|
||||
private fun createSelectedHomeserverState(
|
||||
private fun createSelectedHomeserver(
|
||||
authFlow: LoginFlowResult,
|
||||
config: HomeServerConnectionConfig,
|
||||
preferredLoginMode: LoginMode
|
||||
): SelectedHomeserverState {
|
||||
val matrixOrgUrl = stringProvider.getString(R.string.matrix_org_server_url).ensureTrailingSlash()
|
||||
return SelectedHomeserverState(
|
||||
description = when (config.homeServerUri.toString()) {
|
||||
matrixOrgUrl -> stringProvider.getString(R.string.ftue_auth_create_account_matrix_dot_org_server_description)
|
||||
else -> null
|
||||
},
|
||||
sourceUrl = config.homeServerUri.toString(),
|
||||
declaredUrl = authFlow.homeServerUrl,
|
||||
preferredLoginMode = preferredLoginMode,
|
||||
supportedLoginTypes = authFlow.supportedLoginTypes
|
||||
)
|
||||
}
|
||||
) = SelectedHomeserverState(
|
||||
description = when (config.homeServerUri.toString()) {
|
||||
matrixOrgUrl() -> stringProvider.getString(R.string.ftue_auth_create_account_matrix_dot_org_server_description)
|
||||
else -> null
|
||||
},
|
||||
userFacingUrl = config.homeServerUri.toString(),
|
||||
upstreamUrl = authFlow.homeServerUrl,
|
||||
preferredLoginMode = preferredLoginMode,
|
||||
supportedLoginTypes = authFlow.supportedLoginTypes
|
||||
)
|
||||
|
||||
private fun matrixOrgUrl() = stringProvider.getString(R.string.matrix_org_server_url).ensureTrailingSlash()
|
||||
|
||||
private fun LoginFlowResult.findPreferredLoginMode() = when {
|
||||
supportedLoginTypes.containsAll(LoginFlowTypes.SSO, LoginFlowTypes.PASSWORD) -> LoginMode.SsoAndPassword(ssoIdentityProviders)
|
||||
|
@ -68,6 +67,6 @@ class StartAuthenticationFlowUseCase @Inject constructor(
|
|||
|
||||
data class StartAuthenticationResult(
|
||||
val isHomeserverOutdated: Boolean,
|
||||
val selectedHomeserverState: SelectedHomeserverState
|
||||
val selectedHomeserver: SelectedHomeserverState
|
||||
)
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ class FtueAuthCaptchaFragment @Inject constructor(
|
|||
val mime = "text/html"
|
||||
val encoding = "utf-8"
|
||||
|
||||
val homeServerUrl = state.selectedHomeserver.declaredUrl ?: error("missing url of homeserver")
|
||||
val homeServerUrl = state.selectedHomeserver.upstreamUrl ?: error("missing url of homeserver")
|
||||
views.loginCaptchaWevView.loadDataWithBaseURL(homeServerUrl, html, mime, encoding, null)
|
||||
views.loginCaptchaWevView.requestLayout()
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ class FtueAuthCombinedRegisterFragment @Inject constructor() : AbstractSSOFtueAu
|
|||
setupUi(state)
|
||||
setupAutoFill()
|
||||
|
||||
views.selectedServerName.text = state.selectedHomeserver.sourceUrl.toReducedUrl()
|
||||
views.selectedServerName.text = state.selectedHomeserver.userFacingUrl.toReducedUrl()
|
||||
views.selectedServerDescription.text = state.selectedHomeserver.description
|
||||
|
||||
if (state.isLoading) {
|
||||
|
@ -208,5 +208,5 @@ class FtueAuthCombinedRegisterFragment @Inject constructor() : AbstractSSOFtueAu
|
|||
}
|
||||
}
|
||||
|
||||
private fun OnboardingViewState.isNumericOnlyUserIdForbidden() = selectedHomeserver.sourceUrl == getString(R.string.matrix_org_server_url)
|
||||
private fun OnboardingViewState.isNumericOnlyUserIdForbidden() = selectedHomeserver.userFacingUrl == getString(R.string.matrix_org_server_url)
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ class FtueAuthCombinedServerSelectionFragment @Inject constructor() : AbstractFt
|
|||
|
||||
override fun updateWithState(state: OnboardingViewState) {
|
||||
if (views.chooseServerInput.content().isEmpty()) {
|
||||
val userUrlInput = state.selectedHomeserver.sourceUrl?.toReducedUrlKeepingSchemaIfInsecure()
|
||||
val userUrlInput = state.selectedHomeserver.userFacingUrl?.toReducedUrlKeepingSchemaIfInsecure()
|
||||
views.chooseServerInput.editText().setText(userUrlInput)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ class FtueAuthLoginFragment @Inject constructor() : AbstractSSOFtueAuthFragment<
|
|||
ServerType.MatrixOrg -> {
|
||||
views.loginServerIcon.isVisible = true
|
||||
views.loginServerIcon.setImageResource(R.drawable.ic_logo_matrix_org)
|
||||
views.loginTitle.text = getString(resId, state.selectedHomeserver.sourceUrl.toReducedUrl())
|
||||
views.loginTitle.text = getString(resId, state.selectedHomeserver.userFacingUrl.toReducedUrl())
|
||||
views.loginNotice.text = getString(R.string.login_server_matrix_org_text)
|
||||
}
|
||||
ServerType.EMS -> {
|
||||
|
@ -195,7 +195,7 @@ class FtueAuthLoginFragment @Inject constructor() : AbstractSSOFtueAuthFragment<
|
|||
}
|
||||
ServerType.Other -> {
|
||||
views.loginServerIcon.isVisible = false
|
||||
views.loginTitle.text = getString(resId, state.selectedHomeserver.sourceUrl.toReducedUrl())
|
||||
views.loginTitle.text = getString(resId, state.selectedHomeserver.userFacingUrl.toReducedUrl())
|
||||
views.loginNotice.text = getString(R.string.login_server_other_text)
|
||||
}
|
||||
ServerType.Unknown -> Unit /* Should not happen */
|
||||
|
|
|
@ -59,7 +59,7 @@ class FtueAuthResetPasswordFragment @Inject constructor() : AbstractFtueAuthFrag
|
|||
}
|
||||
|
||||
private fun setupUi(state: OnboardingViewState) {
|
||||
views.resetPasswordTitle.text = getString(R.string.login_reset_password_on, state.selectedHomeserver.sourceUrl.toReducedUrl())
|
||||
views.resetPasswordTitle.text = getString(R.string.login_reset_password_on, state.selectedHomeserver.userFacingUrl.toReducedUrl())
|
||||
}
|
||||
|
||||
private fun setupSubmitButton() {
|
||||
|
|
|
@ -60,19 +60,19 @@ class FtueAuthSignUpSignInSelectionFragment @Inject constructor() : AbstractSSOF
|
|||
ServerType.MatrixOrg -> {
|
||||
views.loginSignupSigninServerIcon.setImageResource(R.drawable.ic_logo_matrix_org)
|
||||
views.loginSignupSigninServerIcon.isVisible = true
|
||||
views.loginSignupSigninTitle.text = getString(R.string.login_connect_to, state.selectedHomeserver.sourceUrl.toReducedUrl())
|
||||
views.loginSignupSigninTitle.text = getString(R.string.login_connect_to, state.selectedHomeserver.userFacingUrl.toReducedUrl())
|
||||
views.loginSignupSigninText.text = getString(R.string.login_server_matrix_org_text)
|
||||
}
|
||||
ServerType.EMS -> {
|
||||
views.loginSignupSigninServerIcon.setImageResource(R.drawable.ic_logo_element_matrix_services)
|
||||
views.loginSignupSigninServerIcon.isVisible = true
|
||||
views.loginSignupSigninTitle.text = getString(R.string.login_connect_to_modular)
|
||||
views.loginSignupSigninText.text = state.selectedHomeserver.sourceUrl.toReducedUrl()
|
||||
views.loginSignupSigninText.text = state.selectedHomeserver.userFacingUrl.toReducedUrl()
|
||||
}
|
||||
ServerType.Other -> {
|
||||
views.loginSignupSigninServerIcon.isVisible = false
|
||||
views.loginSignupSigninTitle.text = getString(R.string.login_server_other_title)
|
||||
views.loginSignupSigninText.text = getString(R.string.login_connect_to, state.selectedHomeserver.sourceUrl.toReducedUrl())
|
||||
views.loginSignupSigninText.text = getString(R.string.login_connect_to, state.selectedHomeserver.userFacingUrl.toReducedUrl())
|
||||
}
|
||||
ServerType.Unknown -> Unit /* Should not happen */
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ class FtueAuthTermsFragment @Inject constructor(
|
|||
}
|
||||
|
||||
override fun updateWithState(state: OnboardingViewState) {
|
||||
policyController.homeServer = state.selectedHomeserver.sourceUrl.toReducedUrl()
|
||||
policyController.homeServer = state.selectedHomeserver.userFacingUrl.toReducedUrl()
|
||||
renderState()
|
||||
}
|
||||
|
||||
|
|
|
@ -141,8 +141,8 @@ class StartAuthenticationFlowUseCaseTest {
|
|||
isHomeserverOutdated,
|
||||
SelectedHomeserverState(
|
||||
description = description,
|
||||
sourceUrl = homeserverSourceUrl,
|
||||
declaredUrl = A_DECLARED_HOMESERVER_URL,
|
||||
userFacingUrl = homeserverSourceUrl,
|
||||
upstreamUrl = A_DECLARED_HOMESERVER_URL,
|
||||
preferredLoginMode = preferredLoginMode,
|
||||
supportedLoginTypes = supportedLoginTypes
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue