SoftLogout: start handling SSO

This commit is contained in:
Benoit Marty 2019-12-13 00:20:14 +01:00
parent 14562f7285
commit 183d6b53bd
3 changed files with 27 additions and 18 deletions

View File

@ -115,6 +115,7 @@ class SoftLogoutController @Inject constructor(
LoginMode.Sso -> {
loginCenterButtonItem {
id("sso")
text(stringProvider.getString(R.string.login_signin_sso))
listener { listener?.ssoSubmit() }
}
}

View File

@ -24,6 +24,7 @@ import com.airbnb.mvrx.activityViewModel
import com.airbnb.mvrx.withState
import im.vector.riotx.R
import im.vector.riotx.core.dialogs.withColoredButton
import im.vector.riotx.core.error.ErrorFormatter
import im.vector.riotx.core.extensions.cleanup
import im.vector.riotx.core.extensions.configureWith
import im.vector.riotx.core.extensions.hideKeyboard
@ -31,7 +32,6 @@ import im.vector.riotx.features.MainActivity
import im.vector.riotx.features.MainActivityArgs
import im.vector.riotx.features.login.AbstractLoginFragment
import im.vector.riotx.features.login.LoginNavigation
import im.vector.riotx.features.login.LoginViewState
import kotlinx.android.synthetic.main.fragment_generic_recycler.*
import javax.inject.Inject
@ -41,7 +41,8 @@ import javax.inject.Inject
* - or to cleanup all the data
*/
class SoftLogoutFragment @Inject constructor(
private val softLogoutController: SoftLogoutController
private val softLogoutController: SoftLogoutController,
private val errorFormatter: ErrorFormatter
) : AbstractLoginFragment(), SoftLogoutController.Listener {
private val softLogoutViewModel: SoftLogoutViewModel by activityViewModel()
@ -52,6 +53,10 @@ class SoftLogoutFragment @Inject constructor(
super.onViewCreated(view, savedInstanceState)
setupRecyclerView()
softLogoutViewModel.subscribe(this) { softLogoutViewState ->
softLogoutController.update(softLogoutViewState)
}
}
private fun setupRecyclerView() {
@ -120,15 +125,12 @@ class SoftLogoutFragment @Inject constructor(
softLogoutViewModel.handle(SoftLogoutAction.TogglePassword)
}
override fun updateWithState(state: LoginViewState) {
super.updateWithState(state)
withState(softLogoutViewModel) { state2 ->
softLogoutController.update(state2)
}
}
override fun onError(throwable: Throwable) {
AlertDialog.Builder(requireActivity())
.setTitle(R.string.dialog_title_error)
.setMessage(errorFormatter.toHumanReadable(throwable))
.setPositiveButton(R.string.ok, null)
.show()
}
override fun resetViewModel() {

View File

@ -1,10 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.button.MaterialButton xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/itemLoginCenteredButton"
style="@style/Style.Vector.Login.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
tools:text="@string/login_signin_sso" />
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.button.MaterialButton
android:id="@+id/itemLoginCenteredButton"
style="@style/Style.Vector.Login.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
tools:text="@string/login_signin_sso" />
</FrameLayout>