diff --git a/vector/src/main/java/im/vector/app/features/login/LoginFragment.kt b/vector/src/main/java/im/vector/app/features/login/LoginFragment.kt index cf799681ac..016e4ca0c7 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginFragment.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginFragment.kt @@ -174,7 +174,7 @@ class LoginFragment @Inject constructor() : AbstractSSOLoginFragment { views.loginServerIcon.isVisible = true views.loginServerIcon.setImageResource(R.drawable.ic_logo_matrix_org) - views.loginTitle.text = getString(resId, state.homeServerUrl.toReducedUrl()) + views.loginTitle.text = getString(resId, state.homeServerUrlFromUser.toReducedUrl()) views.loginNotice.text = getString(R.string.login_server_matrix_org_text) } ServerType.EMS -> { @@ -185,7 +185,7 @@ class LoginFragment @Inject constructor() : AbstractSSOLoginFragment { views.loginServerIcon.isVisible = false - views.loginTitle.text = getString(resId, state.homeServerUrl.toReducedUrl()) + views.loginTitle.text = getString(resId, state.homeServerUrlFromUser.toReducedUrl()) views.loginNotice.text = getString(R.string.login_server_other_text) } ServerType.Unknown -> Unit /* Should not happen */ diff --git a/vector/src/main/java/im/vector/app/features/login/LoginResetPasswordFragment.kt b/vector/src/main/java/im/vector/app/features/login/LoginResetPasswordFragment.kt index d08d81d98a..07c27ab296 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginResetPasswordFragment.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginResetPasswordFragment.kt @@ -55,7 +55,7 @@ class LoginResetPasswordFragment @Inject constructor() : AbstractLoginFragment { views.loginSignupSigninServerIcon.setImageResource(R.drawable.ic_logo_matrix_org) views.loginSignupSigninServerIcon.isVisible = true - views.loginSignupSigninTitle.text = getString(R.string.login_connect_to, state.homeServerUrl.toReducedUrl()) + views.loginSignupSigninTitle.text = getString(R.string.login_connect_to, state.homeServerUrlFromUser.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.homeServerUrl.toReducedUrl() + views.loginSignupSigninText.text = state.homeServerUrlFromUser.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.homeServerUrl.toReducedUrl()) + views.loginSignupSigninText.text = getString(R.string.login_connect_to, state.homeServerUrlFromUser.toReducedUrl()) } ServerType.Unknown -> Unit /* Should not happen */ } diff --git a/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt b/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt index 440220882a..8d4e600980 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginViewModel.kt @@ -214,6 +214,7 @@ class LoginViewModel @AssistedInject constructor( copy( signMode = SignMode.SignIn, loginMode = LoginMode.Sso(action.ssoIdentityProviders), + homeServerUrlFromUser = action.homeServerUrl, homeServerUrl = action.homeServerUrl, deviceId = action.deviceId ) @@ -365,6 +366,7 @@ class LoginViewModel @AssistedInject constructor( setState { copy( asyncHomeServerLoginFlowRequest = Uninitialized, + homeServerUrlFromUser = null, homeServerUrl = null, loginMode = LoginMode.Unknown, serverType = ServerType.Unknown, @@ -788,6 +790,7 @@ class LoginViewModel @AssistedInject constructor( setState { copy( asyncHomeServerLoginFlowRequest = Uninitialized, + homeServerUrlFromUser = homeServerConnectionConfig.homeServerUri.toString(), homeServerUrl = data.homeServerUrl, loginMode = loginMode, loginModeSupportedTypes = data.supportedLoginTypes.toList() diff --git a/vector/src/main/java/im/vector/app/features/login/LoginViewState.kt b/vector/src/main/java/im/vector/app/features/login/LoginViewState.kt index 37ac89794f..187d39d9eb 100644 --- a/vector/src/main/java/im/vector/app/features/login/LoginViewState.kt +++ b/vector/src/main/java/im/vector/app/features/login/LoginViewState.kt @@ -38,7 +38,12 @@ data class LoginViewState( @PersistState val resetPasswordEmail: String? = null, @PersistState + val homeServerUrlFromUser: String? = null, + + // Can be modified after a Wellknown request + @PersistState val homeServerUrl: String? = null, + // For SSO session recovery @PersistState val deviceId: String? = null, diff --git a/vector/src/main/java/im/vector/app/features/login/terms/LoginTermsFragment.kt b/vector/src/main/java/im/vector/app/features/login/terms/LoginTermsFragment.kt index 3227bb7371..6f033b0294 100755 --- a/vector/src/main/java/im/vector/app/features/login/terms/LoginTermsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/login/terms/LoginTermsFragment.kt @@ -112,7 +112,7 @@ class LoginTermsFragment @Inject constructor( } override fun updateWithState(state: LoginViewState) { - policyController.homeServer = state.homeServerUrl.toReducedUrl() + policyController.homeServer = state.homeServerUrlFromUser.toReducedUrl() renderState() }