Moves LoginType to sdk api package

This commit is contained in:
ericdecanini 2022-05-18 11:23:34 +02:00
parent 6a3044cb2e
commit 61b8053b9b
18 changed files with 33 additions and 32 deletions

View file

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.matrix.android.sdk.internal.auth.login package org.matrix.android.sdk.api.auth
enum class LoginType { enum class LoginType {
PASSWORD, PASSWORD,

View file

@ -16,7 +16,7 @@
package org.matrix.android.sdk.api.auth.data 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. * This data class holds necessary data to open a session.

View file

@ -22,6 +22,7 @@ import okhttp3.OkHttpClient
import org.matrix.android.sdk.api.MatrixPatterns import org.matrix.android.sdk.api.MatrixPatterns
import org.matrix.android.sdk.api.MatrixPatterns.getDomain import org.matrix.android.sdk.api.MatrixPatterns.getDomain
import org.matrix.android.sdk.api.auth.AuthenticationService 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.Credentials
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
import org.matrix.android.sdk.api.auth.data.LoginFlowResult 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.db.PendingSessionData
import org.matrix.android.sdk.internal.auth.login.DefaultLoginWizard 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.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.registration.DefaultRegistrationWizard
import org.matrix.android.sdk.internal.auth.version.Versions import org.matrix.android.sdk.internal.auth.version.Versions
import org.matrix.android.sdk.internal.auth.version.isLoginAndRegistrationSupportedBySdk import org.matrix.android.sdk.internal.auth.version.isLoginAndRegistrationSupportedBySdk

View file

@ -16,11 +16,11 @@
package org.matrix.android.sdk.internal.auth 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.Credentials
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.internal.SessionManager import org.matrix.android.sdk.internal.SessionManager
import org.matrix.android.sdk.internal.auth.login.LoginType
import javax.inject.Inject import javax.inject.Inject
internal interface SessionCreator { internal interface SessionCreator {

View file

@ -17,11 +17,11 @@
package org.matrix.android.sdk.internal.auth package org.matrix.android.sdk.internal.auth
import android.net.Uri 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.Credentials
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig 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.SessionParams
import org.matrix.android.sdk.api.extensions.tryOrNull import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.internal.auth.login.LoginType
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject

View file

@ -17,11 +17,11 @@
package org.matrix.android.sdk.internal.auth.db package org.matrix.android.sdk.internal.auth.db
import com.squareup.moshi.Moshi 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.Credentials
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig 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.SessionParams
import org.matrix.android.sdk.api.auth.data.sessionId import org.matrix.android.sdk.api.auth.data.sessionId
import org.matrix.android.sdk.internal.auth.login.LoginType
import javax.inject.Inject import javax.inject.Inject
internal class SessionParamsMapper @Inject constructor(moshi: Moshi) { internal class SessionParamsMapper @Inject constructor(moshi: Moshi) {

View file

@ -17,8 +17,8 @@
package org.matrix.android.sdk.internal.auth.db.migration package org.matrix.android.sdk.internal.auth.db.migration
import io.realm.DynamicRealm 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.db.SessionParamsEntityFields
import org.matrix.android.sdk.internal.auth.login.LoginType
import org.matrix.android.sdk.internal.util.database.RealmMigrator import org.matrix.android.sdk.internal.util.database.RealmMigrator
import timber.log.Timber import timber.log.Timber

View file

@ -17,6 +17,7 @@
package org.matrix.android.sdk.internal.auth.login package org.matrix.android.sdk.internal.auth.login
import android.util.Patterns 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.LoginProfileInfo
import org.matrix.android.sdk.api.auth.login.LoginWizard import org.matrix.android.sdk.api.auth.login.LoginWizard
import org.matrix.android.sdk.api.auth.registration.RegisterThreePid import org.matrix.android.sdk.api.auth.registration.RegisterThreePid

View file

@ -18,6 +18,7 @@ package org.matrix.android.sdk.internal.auth.login
import dagger.Lazy import dagger.Lazy
import okhttp3.OkHttpClient 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.auth.data.HomeServerConnectionConfig
import org.matrix.android.sdk.api.failure.Failure import org.matrix.android.sdk.api.failure.Failure
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session

View file

@ -17,6 +17,7 @@
package org.matrix.android.sdk.internal.auth.registration package org.matrix.android.sdk.internal.auth.registration
import kotlinx.coroutines.delay 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.Credentials
import org.matrix.android.sdk.api.auth.data.LoginFlowTypes import org.matrix.android.sdk.api.auth.data.LoginFlowTypes
import org.matrix.android.sdk.api.auth.registration.RegisterThreePid 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.PendingSessionStore
import org.matrix.android.sdk.internal.auth.SessionCreator import org.matrix.android.sdk.internal.auth.SessionCreator
import org.matrix.android.sdk.internal.auth.db.PendingSessionData 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. * This class execute the registration request and is responsible to keep the session of interactive authentication.

View file

@ -20,6 +20,7 @@ import android.content.Context
import io.realm.Realm import io.realm.Realm
import io.realm.RealmConfiguration import io.realm.RealmConfiguration
import kotlinx.coroutines.runBlocking 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.Credentials
import org.matrix.android.sdk.api.auth.data.DiscoveryInformation import org.matrix.android.sdk.api.auth.data.DiscoveryInformation
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig 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.network.ssl.Fingerprint
import org.matrix.android.sdk.api.util.md5 import org.matrix.android.sdk.api.util.md5
import org.matrix.android.sdk.internal.auth.SessionParamsStore 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.RealmCryptoStoreMigration
import org.matrix.android.sdk.internal.crypto.store.db.RealmCryptoStoreModule import org.matrix.android.sdk.internal.crypto.store.db.RealmCryptoStoreModule
import org.matrix.android.sdk.internal.database.RealmKeysUtils import org.matrix.android.sdk.internal.database.RealmKeysUtils

View file

@ -19,6 +19,7 @@ package org.matrix.android.sdk.internal.auth.login
import org.amshove.kluent.shouldBeEqualTo import org.amshove.kluent.shouldBeEqualTo
import org.amshove.kluent.shouldNotBeEqualTo import org.amshove.kluent.shouldNotBeEqualTo
import org.junit.Test import org.junit.Test
import org.matrix.android.sdk.api.auth.LoginType
class LoginTypeTest { class LoginTypeTest {

View file

@ -21,10 +21,10 @@ import io.mockk.coVerify
import io.mockk.every import io.mockk.every
import io.mockk.mockk import io.mockk.mockk
import io.mockk.mockkStatic 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.Credentials
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig
import org.matrix.android.sdk.internal.auth.SessionParamsCreator 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 import org.matrix.android.sdk.test.fixtures.SessionParamsFixture.aSessionParams
internal class FakeSessionParamsCreator { internal class FakeSessionParamsCreator {

View file

@ -23,12 +23,12 @@ import io.mockk.mockk
import io.mockk.mockkStatic import io.mockk.mockkStatic
import org.amshove.kluent.shouldBeEqualTo import org.amshove.kluent.shouldBeEqualTo
import org.amshove.kluent.shouldBeNull 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.Credentials
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig 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.SessionParams
import org.matrix.android.sdk.api.auth.data.sessionId 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.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_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.FakeCredentialsJsonAdapter.Companion.credentials
import org.matrix.android.sdk.test.fakes.internal.auth.db.sessionparams.FakeHomeServerConnectionConfigJsonAdapter.Companion.HOME_SERVER_CONNECTION_CONFIG_JSON 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 { internal class FakeSessionParamsMapperMoshi {
val instance: Moshi = mockk() val instance: Moshi = mockk()
val credentialsJsonAdapter = FakeCredentialsJsonAdapter() private val credentialsJsonAdapter = FakeCredentialsJsonAdapter()
val homeServerConnectionConfigAdapter = FakeHomeServerConnectionConfigJsonAdapter() private val homeServerConnectionConfigAdapter = FakeHomeServerConnectionConfigJsonAdapter()
init { init {
mockkStatic(Uri::class) mockkStatic(Uri::class)

View file

@ -16,10 +16,10 @@
package org.matrix.android.sdk.test.fixtures 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.Credentials
import org.matrix.android.sdk.api.auth.data.HomeServerConnectionConfig 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.SessionParams
import org.matrix.android.sdk.internal.auth.login.LoginType
import org.matrix.android.sdk.test.fixtures.CredentialsFixture.aCredentials import org.matrix.android.sdk.test.fixtures.CredentialsFixture.aCredentials
object SessionParamsFixture { object SessionParamsFixture {

View file

@ -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.loginTextItem
import im.vector.app.features.signout.soft.epoxy.loginTitleItem import im.vector.app.features.signout.soft.epoxy.loginTitleItem
import im.vector.app.features.signout.soft.epoxy.loginTitleSmallItem 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 import javax.inject.Inject
class SoftLogoutController @Inject constructor( class SoftLogoutController @Inject constructor(
private val stringProvider: StringProvider, private val stringProvider: StringProvider,
private val errorFormatter: ErrorFormatter private val errorFormatter: ErrorFormatter
) : EpoxyController() { ) : EpoxyController() {
var listener: Listener? = null var listener: Listener? = null
@ -94,10 +94,10 @@ class SoftLogoutController @Inject constructor(
} }
private fun buildForm(state: SoftLogoutViewState) = when (state.asyncHomeServerLoginFlowRequest) { private fun buildForm(state: SoftLogoutViewState) = when (state.asyncHomeServerLoginFlowRequest) {
is Fail -> buildLoginErrorWithRetryItem(state.asyncHomeServerLoginFlowRequest.error) is Fail -> buildLoginErrorWithRetryItem(state.asyncHomeServerLoginFlowRequest.error)
is Success -> buildLoginSuccessItem(state) is Success -> buildLoginSuccessItem(state)
is Loading, Uninitialized -> buildLoadingItem() is Loading, Uninitialized -> buildLoadingItem()
is Incomplete -> Unit is Incomplete -> Unit
} }
private fun buildLoadingItem() { private fun buildLoadingItem() {
@ -116,11 +116,11 @@ class SoftLogoutController @Inject constructor(
} }
private fun buildLoginSuccessItem(state: SoftLogoutViewState) = when (state.asyncHomeServerLoginFlowRequest.invoke()) { private fun buildLoginSuccessItem(state: SoftLogoutViewState) = when (state.asyncHomeServerLoginFlowRequest.invoke()) {
LoginMode.Password -> buildLoginPasswordForm(state) LoginMode.Password -> buildLoginPasswordForm(state)
is LoginMode.Sso -> buildLoginSSOForm() is LoginMode.Sso -> buildLoginSSOForm()
is LoginMode.SsoAndPassword -> disambiguateLoginSSOAndPasswordForm(state) is LoginMode.SsoAndPassword -> disambiguateLoginSSOAndPasswordForm(state)
LoginMode.Unsupported -> buildLoginUnsupportedForm() LoginMode.Unsupported -> buildLoginUnsupportedForm()
LoginMode.Unknown, null -> Unit // Should not happen LoginMode.Unknown, null -> Unit // Should not happen
} }
private fun buildLoginPasswordForm(state: SoftLogoutViewState) { private fun buildLoginPasswordForm(state: SoftLogoutViewState) {
@ -148,12 +148,12 @@ class SoftLogoutController @Inject constructor(
private fun disambiguateLoginSSOAndPasswordForm(state: SoftLogoutViewState) { private fun disambiguateLoginSSOAndPasswordForm(state: SoftLogoutViewState) {
when (state.loginType) { when (state.loginType) {
LoginType.PASSWORD -> buildLoginPasswordForm(state) LoginType.PASSWORD -> buildLoginPasswordForm(state)
LoginType.SSO -> buildLoginSSOForm() LoginType.SSO -> buildLoginSSOForm()
LoginType.DIRECT, LoginType.DIRECT,
LoginType.CUSTOM, LoginType.CUSTOM,
LoginType.UNSUPPORTED -> buildLoginUnsupportedForm() LoginType.UNSUPPORTED -> buildLoginUnsupportedForm()
LoginType.UNKNOWN -> Unit LoginType.UNKNOWN -> Unit
} }
} }

View file

@ -35,15 +35,13 @@ import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.login.LoginMode import im.vector.app.features.login.LoginMode
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.auth.AuthenticationService 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.auth.data.LoginFlowTypes
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.getUser import org.matrix.android.sdk.api.session.getUser
import org.matrix.android.sdk.internal.auth.login.LoginType
import timber.log.Timber import timber.log.Timber
/**
* TODO Test push: disable the pushers?
*/
class SoftLogoutViewModel @AssistedInject constructor( class SoftLogoutViewModel @AssistedInject constructor(
@Assisted initialState: SoftLogoutViewState, @Assisted initialState: SoftLogoutViewState,
private val session: Session, private val session: Session,

View file

@ -22,7 +22,7 @@ import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.Success import com.airbnb.mvrx.Success
import com.airbnb.mvrx.Uninitialized import com.airbnb.mvrx.Uninitialized
import im.vector.app.features.login.LoginMode 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( data class SoftLogoutViewState(
val asyncHomeServerLoginFlowRequest: Async<LoginMode> = Uninitialized, val asyncHomeServerLoginFlowRequest: Async<LoginMode> = Uninitialized,