Change val to fun on the SDK interfaces.

Dokka will generate a better documentation (`Functions` and `Properties` are 2 distinct tab), and for Service it's better to have only `fun`
This commit is contained in:
Benoit Marty 2022-05-05 18:07:31 +02:00 committed by Benoit Marty
parent cfd6456614
commit e6c8ffd1b8
7 changed files with 24 additions and 27 deletions

View File

@ -66,7 +66,7 @@ interface AuthenticationService {
/** /**
* True when login and password has been sent with success to the homeserver. * True when login and password has been sent with success to the homeserver.
*/ */
val isRegistrationStarted: Boolean fun isRegistrationStarted(): Boolean
/** /**
* Cancel pending login or pending registration. * Cancel pending login or pending registration.

View File

@ -109,14 +109,14 @@ interface RegistrationWizard {
suspend fun checkIfEmailHasBeenValidated(delayMillis: Long): RegistrationResult suspend fun checkIfEmailHasBeenValidated(delayMillis: Long): RegistrationResult
/** /**
* This is the current ThreePid, waiting for validation. The SDK will store it in database, so it can be * Returns the current ThreePid, waiting for validation. The SDK will store it in database, so it can be
* restored even if the app has been killed during the registration * restored even if the app has been killed during the registration
*/ */
val currentThreePid: String? fun currentThreePid(): String?
/** /**
* True when login and password have been sent with success to the homeserver, i.e. [createAccount] has been * Return true when login and password have been sent with success to the homeserver, i.e. [createAccount] has been
* called successfully. * called successfully.
*/ */
val isRegistrationStarted: Boolean fun isRegistrationStarted(): Boolean
} }

View File

@ -323,8 +323,7 @@ internal class DefaultAuthenticationService @Inject constructor(
} }
} }
override val isRegistrationStarted: Boolean override fun isRegistrationStarted() = currentRegistrationWizard?.isRegistrationStarted() == true
get() = currentRegistrationWizard?.isRegistrationStarted == true
override fun getLoginWizard(): LoginWizard { override fun getLoginWizard(): LoginWizard {
return currentLoginWizard return currentLoginWizard

View File

@ -49,20 +49,18 @@ internal class DefaultRegistrationWizard(
private val validateCodeTask: ValidateCodeTask = DefaultValidateCodeTask(authAPI) private val validateCodeTask: ValidateCodeTask = DefaultValidateCodeTask(authAPI)
private val registerCustomTask: RegisterCustomTask = DefaultRegisterCustomTask(authAPI) private val registerCustomTask: RegisterCustomTask = DefaultRegisterCustomTask(authAPI)
override val currentThreePid: String? override fun currentThreePid(): String? {
get() { return when (val threePid = pendingSessionData.currentThreePidData?.threePid) {
return when (val threePid = pendingSessionData.currentThreePidData?.threePid) { is RegisterThreePid.Email -> threePid.email
is RegisterThreePid.Email -> threePid.email is RegisterThreePid.Msisdn -> {
is RegisterThreePid.Msisdn -> { // Take formatted msisdn if provided by the server
// Take formatted msisdn if provided by the server pendingSessionData.currentThreePidData?.addThreePidRegistrationResponse?.formattedMsisdn?.takeIf { it.isNotBlank() } ?: threePid.msisdn
pendingSessionData.currentThreePidData?.addThreePidRegistrationResponse?.formattedMsisdn?.takeIf { it.isNotBlank() } ?: threePid.msisdn
}
null -> null
} }
null -> null
} }
}
override val isRegistrationStarted: Boolean override fun isRegistrationStarted() = pendingSessionData.isRegistrationStarted
get() = pendingSessionData.isRegistrationStarted
override suspend fun getRegistrationFlow(): RegistrationResult { override suspend fun getRegistrationFlow(): RegistrationResult {
val params = RegistrationParams() val params = RegistrationParams()

View File

@ -91,11 +91,11 @@ class LoginViewModel @AssistedInject constructor(
private val matrixOrgUrl = stringProvider.getString(R.string.matrix_org_server_url).ensureTrailingSlash() private val matrixOrgUrl = stringProvider.getString(R.string.matrix_org_server_url).ensureTrailingSlash()
val currentThreePid: String? val currentThreePid: String?
get() = registrationWizard?.currentThreePid get() = registrationWizard?.currentThreePid()
// True when login and password has been sent with success to the homeserver // True when login and password has been sent with success to the homeserver
val isRegistrationStarted: Boolean val isRegistrationStarted: Boolean
get() = authenticationService.isRegistrationStarted get() = authenticationService.isRegistrationStarted()
private val registrationWizard: RegistrationWizard? private val registrationWizard: RegistrationWizard?
get() = authenticationService.getRegistrationWizard() get() = authenticationService.getRegistrationWizard()
@ -455,7 +455,7 @@ class LoginViewModel @AssistedInject constructor(
// If there is a pending email validation continue on this step // If there is a pending email validation continue on this step
try { try {
if (registrationWizard?.isRegistrationStarted == true) { if (registrationWizard?.isRegistrationStarted() == true) {
currentThreePid?.let { currentThreePid?.let {
handle(LoginAction.PostViewEvent(LoginViewEvents.OnSendEmailSuccess(it))) handle(LoginAction.PostViewEvent(LoginViewEvents.OnSendEmailSuccess(it)))
} }

View File

@ -92,11 +92,11 @@ class LoginViewModel2 @AssistedInject constructor(
private val matrixOrgUrl = stringProvider.getString(R.string.matrix_org_server_url).ensureTrailingSlash() private val matrixOrgUrl = stringProvider.getString(R.string.matrix_org_server_url).ensureTrailingSlash()
val currentThreePid: String? val currentThreePid: String?
get() = registrationWizard?.currentThreePid get() = registrationWizard?.currentThreePid()
// True when login and password has been sent with success to the homeserver // True when login and password has been sent with success to the homeserver
val isRegistrationStarted: Boolean val isRegistrationStarted: Boolean
get() = authenticationService.isRegistrationStarted get() = authenticationService.isRegistrationStarted()
private val registrationWizard: RegistrationWizard? private val registrationWizard: RegistrationWizard?
get() = authenticationService.getRegistrationWizard() get() = authenticationService.getRegistrationWizard()
@ -420,7 +420,7 @@ class LoginViewModel2 @AssistedInject constructor(
// If there is a pending email validation continue on this step // If there is a pending email validation continue on this step
try { try {
if (registrationWizard?.isRegistrationStarted == true) { if (registrationWizard?.isRegistrationStarted() == true) {
currentThreePid?.let { currentThreePid?.let {
handle(LoginAction2.PostViewEvent(LoginViewEvents2.OnSendEmailSuccess(it))) handle(LoginAction2.PostViewEvent(LoginViewEvents2.OnSendEmailSuccess(it)))
} }

View File

@ -114,11 +114,11 @@ class OnboardingViewModel @AssistedInject constructor(
get() = authenticationService.getRegistrationWizard() get() = authenticationService.getRegistrationWizard()
val currentThreePid: String? val currentThreePid: String?
get() = registrationWizard.currentThreePid get() = registrationWizard.currentThreePid()
// True when login and password has been sent with success to the homeserver // True when login and password has been sent with success to the homeserver
val isRegistrationStarted: Boolean val isRegistrationStarted: Boolean
get() = authenticationService.isRegistrationStarted get() = authenticationService.isRegistrationStarted()
private val loginWizard: LoginWizard? private val loginWizard: LoginWizard?
get() = authenticationService.getLoginWizard() get() = authenticationService.getLoginWizard()
@ -396,7 +396,7 @@ class OnboardingViewModel @AssistedInject constructor(
// If there is a pending email validation continue on this step // If there is a pending email validation continue on this step
try { try {
if (registrationWizard.isRegistrationStarted) { if (registrationWizard.isRegistrationStarted()) {
currentThreePid?.let { currentThreePid?.let {
handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnSendEmailSuccess(it))) handle(OnboardingAction.PostViewEvent(OnboardingViewEvents.OnSendEmailSuccess(it)))
} }