diff --git a/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsAction.kt b/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsAction.kt new file mode 100644 index 0000000000..a8c509292c --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsAction.kt @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotx.features.discovery + +import im.vector.matrix.android.api.session.identity.ThreePid +import im.vector.riotx.core.platform.VectorViewModelAction + +sealed class DiscoverySettingsAction : VectorViewModelAction { + object RetrieveBinding : DiscoverySettingsAction() + object Refresh : DiscoverySettingsAction() + + data class ChangeIdentityServer(val url: String?) : DiscoverySettingsAction() + data class RevokeThreePid(val threePid: ThreePid) : DiscoverySettingsAction() + data class ShareThreePid(val threePid: ThreePid) : DiscoverySettingsAction() + data class FinalizeBind3pid(val threePid: ThreePid) : DiscoverySettingsAction() + data class SubmitMsisdnToken(val threePid: ThreePid.Msisdn, val code: String) : DiscoverySettingsAction() + data class CancelBinding(val threePid: ThreePid) : DiscoverySettingsAction() +} diff --git a/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsState.kt b/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsState.kt new file mode 100644 index 0000000000..5dc4b2354a --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsState.kt @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotx.features.discovery + +import com.airbnb.mvrx.Async +import com.airbnb.mvrx.MvRxState +import com.airbnb.mvrx.Uninitialized + +data class DiscoverySettingsState( + val identityServer: Async = Uninitialized, + val emailList: Async> = Uninitialized, + val phoneNumbersList: Async> = Uninitialized, + // Can be true if terms are updated + val termsNotSigned: Boolean = false +) : MvRxState diff --git a/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsViewEvents.kt b/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsViewEvents.kt new file mode 100644 index 0000000000..6fd45394a2 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsViewEvents.kt @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotx.features.discovery + +import im.vector.riotx.core.platform.VectorViewEvents + +sealed class DiscoverySettingsViewEvents : VectorViewEvents { + data class Failure(val throwable: Throwable) : DiscoverySettingsViewEvents() +} diff --git a/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsViewModel.kt b/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsViewModel.kt index 547c74fe2e..84b6c84614 100644 --- a/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySettingsViewModel.kt @@ -19,7 +19,6 @@ import com.airbnb.mvrx.Async import com.airbnb.mvrx.Fail import com.airbnb.mvrx.FragmentViewModelContext import com.airbnb.mvrx.Loading -import com.airbnb.mvrx.MvRxState import com.airbnb.mvrx.MvRxViewModelFactory import com.airbnb.mvrx.Success import com.airbnb.mvrx.Uninitialized @@ -34,43 +33,7 @@ import im.vector.matrix.android.api.session.identity.SharedState import im.vector.matrix.android.api.session.identity.ThreePid import im.vector.matrix.rx.rx import im.vector.riotx.core.extensions.exhaustive -import im.vector.riotx.core.platform.VectorViewEvents import im.vector.riotx.core.platform.VectorViewModel -import im.vector.riotx.core.platform.VectorViewModelAction - -data class PidInfo( - // Retrieved from the homeserver - val threePid: ThreePid, - // Retrieved from IdentityServer, or transient state - val isShared: Async, - // Contains information about a current request to submit the token (for instance SMS code received by SMS) - // Or a current binding finalization, for email - val finalRequest: Async = Uninitialized -) - -data class DiscoverySettingsState( - val identityServer: Async = Uninitialized, - val emailList: Async> = Uninitialized, - val phoneNumbersList: Async> = Uninitialized, - // Can be true if terms are updated - val termsNotSigned: Boolean = false -) : MvRxState - -sealed class DiscoverySettingsAction : VectorViewModelAction { - object RetrieveBinding : DiscoverySettingsAction() - object Refresh : DiscoverySettingsAction() - - data class ChangeIdentityServer(val url: String?) : DiscoverySettingsAction() - data class RevokeThreePid(val threePid: ThreePid) : DiscoverySettingsAction() - data class ShareThreePid(val threePid: ThreePid) : DiscoverySettingsAction() - data class FinalizeBind3pid(val threePid: ThreePid) : DiscoverySettingsAction() - data class SubmitMsisdnToken(val threePid: ThreePid.Msisdn, val code: String) : DiscoverySettingsAction() - data class CancelBinding(val threePid: ThreePid) : DiscoverySettingsAction() -} - -sealed class DiscoverySettingsViewEvents : VectorViewEvents { - data class Failure(val throwable: Throwable) : DiscoverySettingsViewEvents() -} class DiscoverySettingsViewModel @AssistedInject constructor( @Assisted initialState: DiscoverySettingsState, diff --git a/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySharedViewModel.kt b/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySharedViewModel.kt index e6ebed577b..cde326d824 100644 --- a/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySharedViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySharedViewModel.kt @@ -21,10 +21,6 @@ import im.vector.riotx.core.extensions.postLiveEvent import im.vector.riotx.core.utils.LiveEvent import javax.inject.Inject -sealed class DiscoverySharedViewModelAction { - data class ChangeIdentityServer(val newUrl: String) : DiscoverySharedViewModelAction() -} - class DiscoverySharedViewModel @Inject constructor() : ViewModel() { var navigateEvent = MutableLiveData>() diff --git a/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySharedViewModelAction.kt b/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySharedViewModelAction.kt new file mode 100644 index 0000000000..5889ce4a63 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/discovery/DiscoverySharedViewModelAction.kt @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotx.features.discovery + +sealed class DiscoverySharedViewModelAction { + data class ChangeIdentityServer(val newUrl: String) : DiscoverySharedViewModelAction() +} diff --git a/vector/src/main/java/im/vector/riotx/features/discovery/PidInfo.kt b/vector/src/main/java/im/vector/riotx/features/discovery/PidInfo.kt new file mode 100644 index 0000000000..67739c48ce --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/discovery/PidInfo.kt @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotx.features.discovery + +import com.airbnb.mvrx.Async +import com.airbnb.mvrx.Uninitialized +import im.vector.matrix.android.api.session.identity.SharedState +import im.vector.matrix.android.api.session.identity.ThreePid + +data class PidInfo( + // Retrieved from the homeserver + val threePid: ThreePid, + // Retrieved from IdentityServer, or transient state + val isShared: Async, + // Contains information about a current request to submit the token (for instance SMS code received by SMS) + // Or a current binding finalization, for email + val finalRequest: Async = Uninitialized +) diff --git a/vector/src/main/java/im/vector/riotx/features/discovery/change/SetIdentityServerAction.kt b/vector/src/main/java/im/vector/riotx/features/discovery/change/SetIdentityServerAction.kt new file mode 100644 index 0000000000..6f3a56e3e6 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/discovery/change/SetIdentityServerAction.kt @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotx.features.discovery.change + +import im.vector.riotx.core.platform.VectorViewModelAction + +sealed class SetIdentityServerAction : VectorViewModelAction { + data class UpdateServerName(val url: String) : SetIdentityServerAction() + object DoChangeServerName : SetIdentityServerAction() +} diff --git a/vector/src/main/java/im/vector/riotx/features/discovery/change/SetIdentityServerState.kt b/vector/src/main/java/im/vector/riotx/features/discovery/change/SetIdentityServerState.kt new file mode 100644 index 0000000000..f3cc81dc95 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/discovery/change/SetIdentityServerState.kt @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotx.features.discovery.change + +import androidx.annotation.StringRes +import com.airbnb.mvrx.MvRxState + +data class SetIdentityServerState( + val existingIdentityServer: String? = null, + val newIdentityServer: String? = null, + @StringRes val errorMessageId: Int? = null, + val isVerifyingServer: Boolean = false +) : MvRxState diff --git a/vector/src/main/java/im/vector/riotx/features/discovery/change/SetIdentityServerViewEvents.kt b/vector/src/main/java/im/vector/riotx/features/discovery/change/SetIdentityServerViewEvents.kt new file mode 100644 index 0000000000..1addf92d72 --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/features/discovery/change/SetIdentityServerViewEvents.kt @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2020 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotx.features.discovery.change + +import im.vector.riotx.core.platform.VectorViewEvents + +sealed class SetIdentityServerViewEvents : VectorViewEvents { + data class ShowTerms(val newIdentityServer: String) : SetIdentityServerViewEvents() + object NoTerms : SetIdentityServerViewEvents() + object TermsAccepted : SetIdentityServerViewEvents() +} diff --git a/vector/src/main/java/im/vector/riotx/features/discovery/change/SetIdentityServerViewModel.kt b/vector/src/main/java/im/vector/riotx/features/discovery/change/SetIdentityServerViewModel.kt index 2037a5629c..db5f28b36f 100644 --- a/vector/src/main/java/im/vector/riotx/features/discovery/change/SetIdentityServerViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/discovery/change/SetIdentityServerViewModel.kt @@ -15,9 +15,7 @@ */ package im.vector.riotx.features.discovery.change -import androidx.annotation.StringRes import com.airbnb.mvrx.FragmentViewModelContext -import com.airbnb.mvrx.MvRxState import com.airbnb.mvrx.MvRxViewModelFactory import com.airbnb.mvrx.ViewModelContext import com.squareup.inject.assisted.Assisted @@ -29,29 +27,9 @@ import im.vector.matrix.android.api.session.terms.GetTermsResponse import im.vector.matrix.android.api.session.terms.TermsService import im.vector.riotx.R import im.vector.riotx.core.extensions.exhaustive -import im.vector.riotx.core.platform.VectorViewEvents import im.vector.riotx.core.platform.VectorViewModel -import im.vector.riotx.core.platform.VectorViewModelAction import im.vector.riotx.core.resources.StringProvider -data class SetIdentityServerState( - val existingIdentityServer: String? = null, - val newIdentityServer: String? = null, - @StringRes val errorMessageId: Int? = null, - val isVerifyingServer: Boolean = false -) : MvRxState - -sealed class SetIdentityServerAction : VectorViewModelAction { - data class UpdateServerName(val url: String) : SetIdentityServerAction() - object DoChangeServerName : SetIdentityServerAction() -} - -sealed class SetIdentityServerViewEvents : VectorViewEvents { - data class ShowTerms(val newIdentityServer: String) : SetIdentityServerViewEvents() - object NoTerms : SetIdentityServerViewEvents() - object TermsAccepted : SetIdentityServerViewEvents() -} - class SetIdentityServerViewModel @AssistedInject constructor( @Assisted initialState: SetIdentityServerState, private val mxSession: Session,