mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
Moves LoginType to sdk api package
This commit is contained in:
parent
6a3044cb2e
commit
61b8053b9b
18 changed files with 33 additions and 32 deletions
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.matrix.android.sdk.internal.auth.login
|
||||
package org.matrix.android.sdk.api.auth
|
||||
|
||||
enum class LoginType {
|
||||
PASSWORD,
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.matrix.android.sdk.api.auth.data
|
||||
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
|
||||
/**
|
||||
* This data class holds necessary data to open a session.
|
||||
|
|
|
@ -22,6 +22,7 @@ import okhttp3.OkHttpClient
|
|||
import org.matrix.android.sdk.api.MatrixPatterns
|
||||
import org.matrix.android.sdk.api.MatrixPatterns.getDomain
|
||||
import org.matrix.android.sdk.api.auth.AuthenticationService
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.api.auth.data.LoginFlowResult
|
||||
|
@ -38,7 +39,6 @@ import org.matrix.android.sdk.internal.auth.data.WebClientConfig
|
|||
import org.matrix.android.sdk.internal.auth.db.PendingSessionData
|
||||
import org.matrix.android.sdk.internal.auth.login.DefaultLoginWizard
|
||||
import org.matrix.android.sdk.internal.auth.login.DirectLoginTask
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import org.matrix.android.sdk.internal.auth.registration.DefaultRegistrationWizard
|
||||
import org.matrix.android.sdk.internal.auth.version.Versions
|
||||
import org.matrix.android.sdk.internal.auth.version.isLoginAndRegistrationSupportedBySdk
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
package org.matrix.android.sdk.internal.auth
|
||||
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.internal.SessionManager
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import javax.inject.Inject
|
||||
|
||||
internal interface SessionCreator {
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
package org.matrix.android.sdk.internal.auth
|
||||
|
||||
import android.net.Uri
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.api.auth.data.SessionParams
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
package org.matrix.android.sdk.internal.auth.db
|
||||
|
||||
import com.squareup.moshi.Moshi
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.api.auth.data.SessionParams
|
||||
import org.matrix.android.sdk.api.auth.data.sessionId
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import javax.inject.Inject
|
||||
|
||||
internal class SessionParamsMapper @Inject constructor(moshi: Moshi) {
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
package org.matrix.android.sdk.internal.auth.db.migration
|
||||
|
||||
import io.realm.DynamicRealm
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
import org.matrix.android.sdk.internal.auth.db.SessionParamsEntityFields
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import org.matrix.android.sdk.internal.util.database.RealmMigrator
|
||||
import timber.log.Timber
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.matrix.android.sdk.internal.auth.login
|
||||
|
||||
import android.util.Patterns
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
import org.matrix.android.sdk.api.auth.login.LoginProfileInfo
|
||||
import org.matrix.android.sdk.api.auth.login.LoginWizard
|
||||
import org.matrix.android.sdk.api.auth.registration.RegisterThreePid
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.auth.login
|
|||
|
||||
import dagger.Lazy
|
||||
import okhttp3.OkHttpClient
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.api.failure.Failure
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.matrix.android.sdk.internal.auth.registration
|
||||
|
||||
import kotlinx.coroutines.delay
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||
import org.matrix.android.sdk.api.auth.data.LoginFlowTypes
|
||||
import org.matrix.android.sdk.api.auth.registration.RegisterThreePid
|
||||
|
@ -31,7 +32,6 @@ import org.matrix.android.sdk.internal.auth.AuthAPI
|
|||
import org.matrix.android.sdk.internal.auth.PendingSessionStore
|
||||
import org.matrix.android.sdk.internal.auth.SessionCreator
|
||||
import org.matrix.android.sdk.internal.auth.db.PendingSessionData
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
|
||||
/**
|
||||
* This class execute the registration request and is responsible to keep the session of interactive authentication.
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.content.Context
|
|||
import io.realm.Realm
|
||||
import io.realm.RealmConfiguration
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||
import org.matrix.android.sdk.api.auth.data.DiscoveryInformation
|
||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
|
@ -29,7 +30,6 @@ import org.matrix.android.sdk.api.legacy.LegacySessionImporter
|
|||
import org.matrix.android.sdk.api.network.ssl.Fingerprint
|
||||
import org.matrix.android.sdk.api.util.md5
|
||||
import org.matrix.android.sdk.internal.auth.SessionParamsStore
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import org.matrix.android.sdk.internal.crypto.store.db.RealmCryptoStoreMigration
|
||||
import org.matrix.android.sdk.internal.crypto.store.db.RealmCryptoStoreModule
|
||||
import org.matrix.android.sdk.internal.database.RealmKeysUtils
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.auth.login
|
|||
import org.amshove.kluent.shouldBeEqualTo
|
||||
import org.amshove.kluent.shouldNotBeEqualTo
|
||||
import org.junit.Test
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
|
||||
class LoginTypeTest {
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@ import io.mockk.coVerify
|
|||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.mockkStatic
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.internal.auth.SessionParamsCreator
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import org.matrix.android.sdk.test.fixtures.SessionParamsFixture.aSessionParams
|
||||
|
||||
internal class FakeSessionParamsCreator {
|
||||
|
|
|
@ -23,12 +23,12 @@ import io.mockk.mockk
|
|||
import io.mockk.mockkStatic
|
||||
import org.amshove.kluent.shouldBeEqualTo
|
||||
import org.amshove.kluent.shouldBeNull
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.api.auth.data.SessionParams
|
||||
import org.matrix.android.sdk.api.auth.data.sessionId
|
||||
import org.matrix.android.sdk.internal.auth.db.SessionParamsEntity
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import org.matrix.android.sdk.test.fakes.internal.auth.db.sessionparams.FakeCredentialsJsonAdapter.Companion.CREDENTIALS_JSON
|
||||
import org.matrix.android.sdk.test.fakes.internal.auth.db.sessionparams.FakeCredentialsJsonAdapter.Companion.credentials
|
||||
import org.matrix.android.sdk.test.fakes.internal.auth.db.sessionparams.FakeHomeServerConnectionConfigJsonAdapter.Companion.HOME_SERVER_CONNECTION_CONFIG_JSON
|
||||
|
@ -39,8 +39,8 @@ import org.matrix.android.sdk.test.fixtures.SessionParamsFixture.aSessionParams
|
|||
internal class FakeSessionParamsMapperMoshi {
|
||||
|
||||
val instance: Moshi = mockk()
|
||||
val credentialsJsonAdapter = FakeCredentialsJsonAdapter()
|
||||
val homeServerConnectionConfigAdapter = FakeHomeServerConnectionConfigJsonAdapter()
|
||||
private val credentialsJsonAdapter = FakeCredentialsJsonAdapter()
|
||||
private val homeServerConnectionConfigAdapter = FakeHomeServerConnectionConfigJsonAdapter()
|
||||
|
||||
init {
|
||||
mockkStatic(Uri::class)
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
|
||||
package org.matrix.android.sdk.test.fixtures
|
||||
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
import org.matrix.android.sdk.api.auth.data.Credentials
|
||||
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
|
||||
import org.matrix.android.sdk.api.auth.data.SessionParams
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import org.matrix.android.sdk.test.fixtures.CredentialsFixture.aCredentials
|
||||
|
||||
object SessionParamsFixture {
|
||||
|
|
|
@ -36,12 +36,12 @@ import im.vector.app.features.signout.soft.epoxy.loginRedButtonItem
|
|||
import im.vector.app.features.signout.soft.epoxy.loginTextItem
|
||||
import im.vector.app.features.signout.soft.epoxy.loginTitleItem
|
||||
import im.vector.app.features.signout.soft.epoxy.loginTitleSmallItem
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
import javax.inject.Inject
|
||||
|
||||
class SoftLogoutController @Inject constructor(
|
||||
private val stringProvider: StringProvider,
|
||||
private val errorFormatter: ErrorFormatter
|
||||
private val stringProvider: StringProvider,
|
||||
private val errorFormatter: ErrorFormatter
|
||||
) : EpoxyController() {
|
||||
|
||||
var listener: Listener? = null
|
||||
|
@ -94,10 +94,10 @@ class SoftLogoutController @Inject constructor(
|
|||
}
|
||||
|
||||
private fun buildForm(state: SoftLogoutViewState) = when (state.asyncHomeServerLoginFlowRequest) {
|
||||
is Fail -> buildLoginErrorWithRetryItem(state.asyncHomeServerLoginFlowRequest.error)
|
||||
is Success -> buildLoginSuccessItem(state)
|
||||
is Fail -> buildLoginErrorWithRetryItem(state.asyncHomeServerLoginFlowRequest.error)
|
||||
is Success -> buildLoginSuccessItem(state)
|
||||
is Loading, Uninitialized -> buildLoadingItem()
|
||||
is Incomplete -> Unit
|
||||
is Incomplete -> Unit
|
||||
}
|
||||
|
||||
private fun buildLoadingItem() {
|
||||
|
@ -116,11 +116,11 @@ class SoftLogoutController @Inject constructor(
|
|||
}
|
||||
|
||||
private fun buildLoginSuccessItem(state: SoftLogoutViewState) = when (state.asyncHomeServerLoginFlowRequest.invoke()) {
|
||||
LoginMode.Password -> buildLoginPasswordForm(state)
|
||||
is LoginMode.Sso -> buildLoginSSOForm()
|
||||
LoginMode.Password -> buildLoginPasswordForm(state)
|
||||
is LoginMode.Sso -> buildLoginSSOForm()
|
||||
is LoginMode.SsoAndPassword -> disambiguateLoginSSOAndPasswordForm(state)
|
||||
LoginMode.Unsupported -> buildLoginUnsupportedForm()
|
||||
LoginMode.Unknown, null -> Unit // Should not happen
|
||||
LoginMode.Unsupported -> buildLoginUnsupportedForm()
|
||||
LoginMode.Unknown, null -> Unit // Should not happen
|
||||
}
|
||||
|
||||
private fun buildLoginPasswordForm(state: SoftLogoutViewState) {
|
||||
|
@ -148,12 +148,12 @@ class SoftLogoutController @Inject constructor(
|
|||
|
||||
private fun disambiguateLoginSSOAndPasswordForm(state: SoftLogoutViewState) {
|
||||
when (state.loginType) {
|
||||
LoginType.PASSWORD -> buildLoginPasswordForm(state)
|
||||
LoginType.SSO -> buildLoginSSOForm()
|
||||
LoginType.PASSWORD -> buildLoginPasswordForm(state)
|
||||
LoginType.SSO -> buildLoginSSOForm()
|
||||
LoginType.DIRECT,
|
||||
LoginType.CUSTOM,
|
||||
LoginType.UNSUPPORTED -> buildLoginUnsupportedForm()
|
||||
LoginType.UNKNOWN -> Unit
|
||||
LoginType.UNKNOWN -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,15 +35,13 @@ import im.vector.app.core.platform.VectorViewModel
|
|||
import im.vector.app.features.login.LoginMode
|
||||
import kotlinx.coroutines.launch
|
||||
import org.matrix.android.sdk.api.auth.AuthenticationService
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
import org.matrix.android.sdk.api.auth.data.LoginFlowTypes
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.getUser
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* TODO Test push: disable the pushers?
|
||||
*/
|
||||
|
||||
class SoftLogoutViewModel @AssistedInject constructor(
|
||||
@Assisted initialState: SoftLogoutViewState,
|
||||
private val session: Session,
|
||||
|
|
|
@ -22,7 +22,7 @@ import com.airbnb.mvrx.MavericksState
|
|||
import com.airbnb.mvrx.Success
|
||||
import com.airbnb.mvrx.Uninitialized
|
||||
import im.vector.app.features.login.LoginMode
|
||||
import org.matrix.android.sdk.internal.auth.login.LoginType
|
||||
import org.matrix.android.sdk.api.auth.LoginType
|
||||
|
||||
data class SoftLogoutViewState(
|
||||
val asyncHomeServerLoginFlowRequest: Async<LoginMode> = Uninitialized,
|
||||
|
|
Loading…
Reference in a new issue