Code review fixes.
This commit is contained in:
parent
8547fee562
commit
91bb86d3c6
@ -3385,7 +3385,7 @@
|
|||||||
<string name="qr_code_login_header_failed_denied_description">The request was denied on the other device.</string>
|
<string name="qr_code_login_header_failed_denied_description">The request was denied on the other device.</string>
|
||||||
<string name="qr_code_login_new_device_instruction_1">Open ${app_name} on your other device</string>
|
<string name="qr_code_login_new_device_instruction_1">Open ${app_name} on your other device</string>
|
||||||
<string name="qr_code_login_new_device_instruction_2">Go to Settings -> Security & Privacy -> Show All Sessions</string>
|
<string name="qr_code_login_new_device_instruction_2">Go to Settings -> Security & Privacy -> Show All Sessions</string>
|
||||||
<string name="qr_code_login_new_device_instruction_3">Select \'Show QR code\'</string>
|
<string name="qr_code_login_new_device_instruction_3">Select \'Show QR code in this device\'</string>
|
||||||
<string name="qr_code_login_link_a_device_scan_qr_code_instruction_1">Start at the sign in screen</string>
|
<string name="qr_code_login_link_a_device_scan_qr_code_instruction_1">Start at the sign in screen</string>
|
||||||
<string name="qr_code_login_link_a_device_scan_qr_code_instruction_2">Select \'Sign in with QR code\'</string>
|
<string name="qr_code_login_link_a_device_scan_qr_code_instruction_2">Select \'Sign in with QR code\'</string>
|
||||||
<string name="qr_code_login_link_a_device_show_qr_code_instruction_1">Start at the sign in screen</string>
|
<string name="qr_code_login_link_a_device_show_qr_code_instruction_1">Start at the sign in screen</string>
|
||||||
|
@ -20,7 +20,6 @@ import com.zhuinden.monarchy.Monarchy
|
|||||||
import org.matrix.android.sdk.api.MatrixPatterns.getServerName
|
import org.matrix.android.sdk.api.MatrixPatterns.getServerName
|
||||||
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.wellknown.WellknownResult
|
import org.matrix.android.sdk.api.auth.wellknown.WellknownResult
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
|
||||||
import org.matrix.android.sdk.api.extensions.orTrue
|
import org.matrix.android.sdk.api.extensions.orTrue
|
||||||
import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilities
|
import org.matrix.android.sdk.api.session.homeserver.HomeServerCapabilities
|
||||||
import org.matrix.android.sdk.internal.auth.version.Versions
|
import org.matrix.android.sdk.internal.auth.version.Versions
|
||||||
@ -144,8 +143,8 @@ internal class DefaultGetHomeServerCapabilitiesTask @Inject constructor(
|
|||||||
homeServerCapabilitiesEntity.lastVersionIdentityServerSupported = getVersionResult.isLoginAndRegistrationSupportedBySdk()
|
homeServerCapabilitiesEntity.lastVersionIdentityServerSupported = getVersionResult.isLoginAndRegistrationSupportedBySdk()
|
||||||
homeServerCapabilitiesEntity.canControlLogoutDevices = getVersionResult.doesServerSupportLogoutDevices()
|
homeServerCapabilitiesEntity.canControlLogoutDevices = getVersionResult.doesServerSupportLogoutDevices()
|
||||||
homeServerCapabilitiesEntity.canUseThreading = /* capabilities?.threads?.enabled.orFalse() || */
|
homeServerCapabilitiesEntity.canUseThreading = /* capabilities?.threads?.enabled.orFalse() || */
|
||||||
getVersionResult.doesServerSupportThreads().orFalse()
|
getVersionResult.doesServerSupportThreads()
|
||||||
homeServerCapabilitiesEntity.canLoginWithQrCode = getVersionResult.doesServerSupportQrCodeLogin().orFalse()
|
homeServerCapabilitiesEntity.canLoginWithQrCode = getVersionResult.doesServerSupportQrCodeLogin()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getWellknownResult != null && getWellknownResult is WellknownResult.Prompt) {
|
if (getWellknownResult != null && getWellknownResult is WellknownResult.Prompt) {
|
||||||
|
@ -20,6 +20,6 @@ import im.vector.app.core.platform.VectorViewModelAction
|
|||||||
|
|
||||||
sealed class QrCodeLoginAction : VectorViewModelAction {
|
sealed class QrCodeLoginAction : VectorViewModelAction {
|
||||||
data class OnQrCodeScanned(val qrCode: String) : QrCodeLoginAction()
|
data class OnQrCodeScanned(val qrCode: String) : QrCodeLoginAction()
|
||||||
object QrCodeViewStarted : QrCodeLoginAction()
|
object GenerateQrCode : QrCodeLoginAction()
|
||||||
object ShowQrCode : QrCodeLoginAction()
|
object ShowQrCode : QrCodeLoginAction()
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import dagger.hilt.android.AndroidEntryPoint
|
|||||||
import im.vector.app.core.extensions.addFragment
|
import im.vector.app.core.extensions.addFragment
|
||||||
import im.vector.app.core.platform.SimpleFragmentActivity
|
import im.vector.app.core.platform.SimpleFragmentActivity
|
||||||
import im.vector.lib.core.utils.compat.getParcelableCompat
|
import im.vector.lib.core.utils.compat.getParcelableCompat
|
||||||
import org.matrix.android.sdk.api.extensions.orFalse
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
@ -45,7 +44,7 @@ class QrCodeLoginActivity : SimpleFragmentActivity() {
|
|||||||
showInstructionsFragment(qrCodeLoginArgs)
|
showInstructionsFragment(qrCodeLoginArgs)
|
||||||
}
|
}
|
||||||
QrCodeLoginType.LINK_A_DEVICE -> {
|
QrCodeLoginType.LINK_A_DEVICE -> {
|
||||||
if (qrCodeLoginArgs.showQrCodeByDefault.orFalse()) {
|
if (qrCodeLoginArgs.showQrCodeImmediately) {
|
||||||
handleNavigateToShowQrCodeScreen()
|
handleNavigateToShowQrCodeScreen()
|
||||||
} else {
|
} else {
|
||||||
showInstructionsFragment(qrCodeLoginArgs)
|
showInstructionsFragment(qrCodeLoginArgs)
|
||||||
@ -54,6 +53,7 @@ class QrCodeLoginActivity : SimpleFragmentActivity() {
|
|||||||
null -> {
|
null -> {
|
||||||
Timber.i("QrCodeLoginArgs is null. This is not expected.")
|
Timber.i("QrCodeLoginArgs is null. This is not expected.")
|
||||||
finish()
|
finish()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,5 +22,5 @@ import kotlinx.parcelize.Parcelize
|
|||||||
@Parcelize
|
@Parcelize
|
||||||
data class QrCodeLoginArgs(
|
data class QrCodeLoginArgs(
|
||||||
val loginType: QrCodeLoginType,
|
val loginType: QrCodeLoginType,
|
||||||
val showQrCodeByDefault: Boolean,
|
val showQrCodeImmediately: Boolean,
|
||||||
) : Parcelable
|
) : Parcelable
|
||||||
|
@ -24,6 +24,7 @@ import android.view.LayoutInflater
|
|||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.core.content.res.use
|
import androidx.core.content.res.use
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
|
import im.vector.app.core.extensions.setTextOrHide
|
||||||
import im.vector.app.databinding.ViewQrCodeLoginHeaderBinding
|
import im.vector.app.databinding.ViewQrCodeLoginHeaderBinding
|
||||||
|
|
||||||
class QrCodeLoginHeaderView @JvmOverloads constructor(
|
class QrCodeLoginHeaderView @JvmOverloads constructor(
|
||||||
@ -52,27 +53,26 @@ class QrCodeLoginHeaderView @JvmOverloads constructor(
|
|||||||
|
|
||||||
private fun setTitle(typedArray: TypedArray) {
|
private fun setTitle(typedArray: TypedArray) {
|
||||||
val title = typedArray.getString(R.styleable.QrCodeLoginHeaderView_qrCodeLoginHeaderTitle)
|
val title = typedArray.getString(R.styleable.QrCodeLoginHeaderView_qrCodeLoginHeaderTitle)
|
||||||
binding.qrCodeLoginHeaderTitleTextView.text = title
|
setTitle(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setDescription(typedArray: TypedArray) {
|
private fun setDescription(typedArray: TypedArray) {
|
||||||
val description = typedArray.getString(R.styleable.QrCodeLoginHeaderView_qrCodeLoginHeaderDescription)
|
val description = typedArray.getString(R.styleable.QrCodeLoginHeaderView_qrCodeLoginHeaderDescription)
|
||||||
binding.qrCodeLoginHeaderDescriptionTextView.text = description
|
setDescription(description)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setImage(typedArray: TypedArray) {
|
private fun setImage(typedArray: TypedArray) {
|
||||||
val imageResource = typedArray.getResourceId(R.styleable.QrCodeLoginHeaderView_qrCodeLoginHeaderImageResource, 0)
|
val imageResource = typedArray.getResourceId(R.styleable.QrCodeLoginHeaderView_qrCodeLoginHeaderImageResource, 0)
|
||||||
val backgroundTint = typedArray.getColor(R.styleable.QrCodeLoginHeaderView_qrCodeLoginHeaderImageBackgroundTint, 0)
|
val backgroundTint = typedArray.getColor(R.styleable.QrCodeLoginHeaderView_qrCodeLoginHeaderImageBackgroundTint, 0)
|
||||||
binding.qrCodeLoginHeaderImageView.setImageResource(imageResource)
|
setImage(imageResource, backgroundTint)
|
||||||
binding.qrCodeLoginHeaderImageView.backgroundTintList = ColorStateList.valueOf(backgroundTint)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setTitle(title: String) {
|
fun setTitle(title: String?) {
|
||||||
binding.qrCodeLoginHeaderTitleTextView.text = title
|
binding.qrCodeLoginHeaderTitleTextView.setTextOrHide(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setDescription(description: String) {
|
fun setDescription(description: String?) {
|
||||||
binding.qrCodeLoginHeaderDescriptionTextView.text = description
|
binding.qrCodeLoginHeaderDescriptionTextView.setTextOrHide(description)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setImage(imageResource: Int, backgroundTintColor: Int) {
|
fun setImage(imageResource: Int, backgroundTintColor: Int) {
|
||||||
|
@ -22,6 +22,7 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.airbnb.mvrx.activityViewModel
|
import com.airbnb.mvrx.activityViewModel
|
||||||
|
import com.airbnb.mvrx.withState
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.extensions.registerStartForActivityResult
|
import im.vector.app.core.extensions.registerStartForActivityResult
|
||||||
@ -41,32 +42,10 @@ class QrCodeLoginInstructionsFragment : VectorBaseFragment<FragmentQrCodeLoginIn
|
|||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
observeViewState()
|
|
||||||
initScanQrCodeButton()
|
initScanQrCodeButton()
|
||||||
initShowQrCodeButton()
|
initShowQrCodeButton()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeViewState() {
|
|
||||||
viewModel.onEach {
|
|
||||||
if (it.loginType == QrCodeLoginType.LOGIN) {
|
|
||||||
views.qrCodeLoginInstructionsView.setInstructions(
|
|
||||||
listOf(
|
|
||||||
getString(R.string.qr_code_login_new_device_instruction_1),
|
|
||||||
getString(R.string.qr_code_login_new_device_instruction_2),
|
|
||||||
getString(R.string.qr_code_login_new_device_instruction_3),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
views.qrCodeLoginInstructionsView.setInstructions(
|
|
||||||
listOf(
|
|
||||||
getString(R.string.qr_code_login_link_a_device_scan_qr_code_instruction_1),
|
|
||||||
getString(R.string.qr_code_login_link_a_device_scan_qr_code_instruction_2),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initShowQrCodeButton() {
|
private fun initShowQrCodeButton() {
|
||||||
views.qrCodeLoginInstructionsShowQrCodeButton.debouncedClicks {
|
views.qrCodeLoginInstructionsShowQrCodeButton.debouncedClicks {
|
||||||
viewModel.handle(QrCodeLoginAction.ShowQrCode)
|
viewModel.handle(QrCodeLoginAction.ShowQrCode)
|
||||||
@ -99,4 +78,23 @@ class QrCodeLoginInstructionsFragment : VectorBaseFragment<FragmentQrCodeLoginIn
|
|||||||
private fun onQrCodeScannerFailed() {
|
private fun onQrCodeScannerFailed() {
|
||||||
Timber.d("QrCodeLoginInstructionsFragment.onQrCodeScannerFailed")
|
Timber.d("QrCodeLoginInstructionsFragment.onQrCodeScannerFailed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun invalidate() = withState(viewModel) { state ->
|
||||||
|
if (state.loginType == QrCodeLoginType.LOGIN) {
|
||||||
|
views.qrCodeLoginInstructionsView.setInstructions(
|
||||||
|
listOf(
|
||||||
|
getString(R.string.qr_code_login_new_device_instruction_1),
|
||||||
|
getString(R.string.qr_code_login_new_device_instruction_2),
|
||||||
|
getString(R.string.qr_code_login_new_device_instruction_3),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
views.qrCodeLoginInstructionsView.setInstructions(
|
||||||
|
listOf(
|
||||||
|
getString(R.string.qr_code_login_link_a_device_scan_qr_code_instruction_1),
|
||||||
|
getString(R.string.qr_code_login_link_a_device_scan_qr_code_instruction_2),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,18 +54,19 @@ class QrCodeLoginInstructionsView @JvmOverloads constructor(
|
|||||||
val instruction1 = typedArray.getString(R.styleable.QrCodeLoginInstructionsView_qrCodeLoginInstruction1)
|
val instruction1 = typedArray.getString(R.styleable.QrCodeLoginInstructionsView_qrCodeLoginInstruction1)
|
||||||
val instruction2 = typedArray.getString(R.styleable.QrCodeLoginInstructionsView_qrCodeLoginInstruction2)
|
val instruction2 = typedArray.getString(R.styleable.QrCodeLoginInstructionsView_qrCodeLoginInstruction2)
|
||||||
val instruction3 = typedArray.getString(R.styleable.QrCodeLoginInstructionsView_qrCodeLoginInstruction3)
|
val instruction3 = typedArray.getString(R.styleable.QrCodeLoginInstructionsView_qrCodeLoginInstruction3)
|
||||||
binding.instructions1Layout.isVisible = instruction1 != null
|
setInstructions(
|
||||||
binding.instructions2Layout.isVisible = instruction2 != null
|
listOf(
|
||||||
binding.instructions3Layout.isVisible = instruction3 != null
|
instruction1,
|
||||||
binding.instruction1TextView.text = instruction1
|
instruction2,
|
||||||
binding.instruction2TextView.text = instruction2
|
instruction3,
|
||||||
binding.instruction3TextView.text = instruction3
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setInstructions(instructions: List<String>) {
|
fun setInstructions(instructions: List<String?>?) {
|
||||||
setInstruction(binding.instructions1Layout, binding.instruction1TextView, instructions.getOrNull(0))
|
setInstruction(binding.instructions1Layout, binding.instruction1TextView, instructions?.getOrNull(0))
|
||||||
setInstruction(binding.instructions2Layout, binding.instruction2TextView, instructions.getOrNull(1))
|
setInstruction(binding.instructions2Layout, binding.instruction2TextView, instructions?.getOrNull(1))
|
||||||
setInstruction(binding.instructions3Layout, binding.instruction3TextView, instructions.getOrNull(2))
|
setInstruction(binding.instructions3Layout, binding.instruction3TextView, instructions?.getOrNull(2))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setInstruction(instructionLayout: LinearLayout, instructionTextView: TextView, instruction: String?) {
|
private fun setInstruction(instructionLayout: LinearLayout, instructionTextView: TextView, instruction: String?) {
|
||||||
|
@ -21,6 +21,7 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.airbnb.mvrx.activityViewModel
|
import com.airbnb.mvrx.activityViewModel
|
||||||
|
import com.airbnb.mvrx.withState
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.platform.VectorBaseFragment
|
import im.vector.app.core.platform.VectorBaseFragment
|
||||||
@ -38,8 +39,7 @@ class QrCodeLoginShowQrCodeFragment : VectorBaseFragment<FragmentQrCodeLoginShow
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
initCancelButton()
|
initCancelButton()
|
||||||
observeViewState()
|
viewModel.handle(QrCodeLoginAction.GenerateQrCode)
|
||||||
viewModel.handle(QrCodeLoginAction.QrCodeViewStarted)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initCancelButton() {
|
private fun initCancelButton() {
|
||||||
@ -48,15 +48,6 @@ class QrCodeLoginShowQrCodeFragment : VectorBaseFragment<FragmentQrCodeLoginShow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeViewState() {
|
|
||||||
viewModel.onEach {
|
|
||||||
setInstructions(it.loginType)
|
|
||||||
it.generatedQrCodeData?.let { qrCodeData ->
|
|
||||||
showQrCode(qrCodeData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setInstructions(loginType: QrCodeLoginType) {
|
private fun setInstructions(loginType: QrCodeLoginType) {
|
||||||
if (loginType == QrCodeLoginType.LOGIN) {
|
if (loginType == QrCodeLoginType.LOGIN) {
|
||||||
views.qrCodeLoginShowQrCodeHeaderView.setDescription(getString(R.string.qr_code_login_header_show_qr_code_new_device_description))
|
views.qrCodeLoginShowQrCodeHeaderView.setDescription(getString(R.string.qr_code_login_header_show_qr_code_new_device_description))
|
||||||
@ -81,4 +72,11 @@ class QrCodeLoginShowQrCodeFragment : VectorBaseFragment<FragmentQrCodeLoginShow
|
|||||||
private fun showQrCode(qrCodeData: String) {
|
private fun showQrCode(qrCodeData: String) {
|
||||||
views.qrCodeLoginSHowQrCodeImageView.setData(qrCodeData)
|
views.qrCodeLoginSHowQrCodeImageView.setData(qrCodeData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun invalidate() = withState(viewModel) { state ->
|
||||||
|
state.generatedQrCodeData?.let { qrCodeData ->
|
||||||
|
showQrCode(qrCodeData)
|
||||||
|
}
|
||||||
|
setInstructions(state.loginType)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import com.airbnb.mvrx.activityViewModel
|
import com.airbnb.mvrx.activityViewModel
|
||||||
|
import com.airbnb.mvrx.withState
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.platform.VectorBaseFragment
|
import im.vector.app.core.platform.VectorBaseFragment
|
||||||
@ -40,7 +41,6 @@ class QrCodeLoginStatusFragment : VectorBaseFragment<FragmentQrCodeLoginStatusBi
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
initCancelButton()
|
initCancelButton()
|
||||||
observeViewState()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initCancelButton() {
|
private fun initCancelButton() {
|
||||||
@ -49,18 +49,6 @@ class QrCodeLoginStatusFragment : VectorBaseFragment<FragmentQrCodeLoginStatusBi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeViewState() {
|
|
||||||
viewModel.onEach {
|
|
||||||
when (it.connectionStatus) {
|
|
||||||
is QrCodeLoginConnectionStatus.Connected -> handleConnectionEstablished(it.connectionStatus, it.loginType)
|
|
||||||
QrCodeLoginConnectionStatus.ConnectingToDevice -> handleConnectingToDevice()
|
|
||||||
QrCodeLoginConnectionStatus.SigningIn -> handleSigningIn()
|
|
||||||
is QrCodeLoginConnectionStatus.Failed -> handleFailed(it.connectionStatus)
|
|
||||||
null -> { /* NOOP */ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleFailed(connectionStatus: QrCodeLoginConnectionStatus.Failed) {
|
private fun handleFailed(connectionStatus: QrCodeLoginConnectionStatus.Failed) {
|
||||||
views.qrCodeLoginConfirmSecurityCodeLayout.isVisible = false
|
views.qrCodeLoginConfirmSecurityCodeLayout.isVisible = false
|
||||||
views.qrCodeLoginStatusLoadingLayout.isVisible = false
|
views.qrCodeLoginStatusLoadingLayout.isVisible = false
|
||||||
@ -128,4 +116,14 @@ class QrCodeLoginStatusFragment : VectorBaseFragment<FragmentQrCodeLoginStatusBi
|
|||||||
backgroundTintColor = ThemeUtils.getColor(requireContext(), R.attr.colorPrimary)
|
backgroundTintColor = ThemeUtils.getColor(requireContext(), R.attr.colorPrimary)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun invalidate() = withState(viewModel) { state ->
|
||||||
|
when (state.connectionStatus) {
|
||||||
|
is QrCodeLoginConnectionStatus.Connected -> handleConnectionEstablished(state.connectionStatus, state.loginType)
|
||||||
|
QrCodeLoginConnectionStatus.ConnectingToDevice -> handleConnectingToDevice()
|
||||||
|
QrCodeLoginConnectionStatus.SigningIn -> handleSigningIn()
|
||||||
|
is QrCodeLoginConnectionStatus.Failed -> handleFailed(state.connectionStatus)
|
||||||
|
null -> { /* NOOP */ }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,7 @@ import dagger.assisted.AssistedInject
|
|||||||
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||||
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||||
import im.vector.app.core.platform.VectorViewModel
|
import im.vector.app.core.platform.VectorViewModel
|
||||||
import kotlinx.coroutines.delay
|
import timber.log.Timber
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
|
|
||||||
class QrCodeLoginViewModel @AssistedInject constructor(
|
class QrCodeLoginViewModel @AssistedInject constructor(
|
||||||
@Assisted private val initialState: QrCodeLoginViewState,
|
@Assisted private val initialState: QrCodeLoginViewState,
|
||||||
@ -40,7 +39,7 @@ class QrCodeLoginViewModel @AssistedInject constructor(
|
|||||||
override fun handle(action: QrCodeLoginAction) {
|
override fun handle(action: QrCodeLoginAction) {
|
||||||
when (action) {
|
when (action) {
|
||||||
is QrCodeLoginAction.OnQrCodeScanned -> handleOnQrCodeScanned(action)
|
is QrCodeLoginAction.OnQrCodeScanned -> handleOnQrCodeScanned(action)
|
||||||
QrCodeLoginAction.QrCodeViewStarted -> handleQrCodeViewStarted()
|
QrCodeLoginAction.GenerateQrCode -> handleQrCodeViewStarted()
|
||||||
QrCodeLoginAction.ShowQrCode -> handleShowQrCode()
|
QrCodeLoginAction.ShowQrCode -> handleShowQrCode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,18 +66,6 @@ class QrCodeLoginViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
_viewEvents.post(QrCodeLoginViewEvents.NavigateToStatusScreen)
|
_viewEvents.post(QrCodeLoginViewEvents.NavigateToStatusScreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO. UI test purpose. Fixme remove!
|
|
||||||
viewModelScope.launch {
|
|
||||||
delay(3000)
|
|
||||||
onFailed(QrCodeLoginErrorType.TIMEOUT, true)
|
|
||||||
delay(3000)
|
|
||||||
onConnectionEstablished("1234-ABCD-5678-EFGH")
|
|
||||||
delay(3000)
|
|
||||||
onSigningIn()
|
|
||||||
delay(3000)
|
|
||||||
onFailed(QrCodeLoginErrorType.DEVICE_IS_NOT_SUPPORTED, false)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onFailed(errorType: QrCodeLoginErrorType, canTryAgain: Boolean) {
|
private fun onFailed(errorType: QrCodeLoginErrorType, canTryAgain: Boolean) {
|
||||||
@ -106,17 +93,14 @@ class QrCodeLoginViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// TODO. Implement in the logic related PR.
|
||||||
* TODO. UI test purpose. Fixme accordingly.
|
|
||||||
*/
|
|
||||||
private fun isValidQrCode(qrCode: String): Boolean {
|
private fun isValidQrCode(qrCode: String): Boolean {
|
||||||
return qrCode.startsWith("http")
|
Timber.d("isValidQrCode: $qrCode")
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// TODO. Implement in the logic related PR.
|
||||||
* TODO. UI test purpose. Fixme accordingly.
|
|
||||||
*/
|
|
||||||
private fun generateQrCodeData(): String {
|
private fun generateQrCodeData(): String {
|
||||||
return "https://element.io"
|
return "TODO"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeQrCodeLoginCapability(homeServerUrl: String) = viewModelScope.launch {
|
private fun checkQrCodeLoginCapability(homeServerUrl: String) {
|
||||||
if (!vectorFeatures.isQrCodeLoginEnabled()) {
|
if (!vectorFeatures.isQrCodeLoginEnabled()) {
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
@ -133,6 +133,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
viewModelScope.launch {
|
||||||
// check if selected server supports MSC3882 first
|
// check if selected server supports MSC3882 first
|
||||||
homeServerConnectionConfigFactory.create(homeServerUrl)?.let {
|
homeServerConnectionConfigFactory.create(homeServerUrl)?.let {
|
||||||
val canLoginWithQrCode = authenticationService.isQrLoginSupported(it)
|
val canLoginWithQrCode = authenticationService.isQrLoginSupported(it)
|
||||||
@ -144,6 +145,7 @@ class OnboardingViewModel @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()
|
||||||
private val defaultHomeserverUrl = matrixOrgUrl
|
private val defaultHomeserverUrl = matrixOrgUrl
|
||||||
@ -707,7 +709,7 @@ class OnboardingViewModel @AssistedInject constructor(
|
|||||||
_viewEvents.post(OnboardingViewEvents.Failure(Throwable("Unable to create a HomeServerConnectionConfig")))
|
_viewEvents.post(OnboardingViewEvents.Failure(Throwable("Unable to create a HomeServerConnectionConfig")))
|
||||||
} else {
|
} else {
|
||||||
startAuthenticationFlow(action, homeServerConnectionConfig, serverTypeOverride, postAction)
|
startAuthenticationFlow(action, homeServerConnectionConfig, serverTypeOverride, postAction)
|
||||||
observeQrCodeLoginCapability(homeServerConnectionConfig.homeServerUri.toString())
|
checkQrCodeLoginCapability(homeServerConnectionConfig.homeServerUri.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,20 +81,18 @@ class FtueAuthCombinedLoginFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun configureQrCodeLoginButtonVisibility(canLoginWithQrCode: Boolean) {
|
private fun configureQrCodeLoginButtonVisibility(canLoginWithQrCode: Boolean) {
|
||||||
|
views.loginWithQrCode.isVisible = canLoginWithQrCode
|
||||||
if (canLoginWithQrCode) {
|
if (canLoginWithQrCode) {
|
||||||
views.loginWithQrCode.isVisible = true
|
|
||||||
views.loginWithQrCode.debouncedClicks {
|
views.loginWithQrCode.debouncedClicks {
|
||||||
navigator
|
navigator
|
||||||
.openLoginWithQrCode(
|
.openLoginWithQrCode(
|
||||||
requireActivity(),
|
requireActivity(),
|
||||||
QrCodeLoginArgs(
|
QrCodeLoginArgs(
|
||||||
loginType = QrCodeLoginType.LOGIN,
|
loginType = QrCodeLoginType.LOGIN,
|
||||||
showQrCodeByDefault = false,
|
showQrCodeImmediately = false,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
views.loginWithQrCode.isVisible = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,27 +170,24 @@ class VectorSettingsDevicesFragment :
|
|||||||
views.deviceListHeaderShowQrCodeButton.isVisible = true
|
views.deviceListHeaderShowQrCodeButton.isVisible = true
|
||||||
|
|
||||||
views.deviceListHeaderScanQrCodeButton.debouncedClicks {
|
views.deviceListHeaderScanQrCodeButton.debouncedClicks {
|
||||||
navigator
|
navigateToQrCodeScreen(showQrCodeImmediately = false)
|
||||||
.openLoginWithQrCode(
|
|
||||||
requireActivity(),
|
|
||||||
QrCodeLoginArgs(
|
|
||||||
loginType = QrCodeLoginType.LINK_A_DEVICE,
|
|
||||||
showQrCodeByDefault = false,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
views.deviceListHeaderShowQrCodeButton.debouncedClicks {
|
views.deviceListHeaderShowQrCodeButton.debouncedClicks {
|
||||||
|
navigateToQrCodeScreen(showQrCodeImmediately = true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun navigateToQrCodeScreen(showQrCodeImmediately: Boolean) {
|
||||||
navigator
|
navigator
|
||||||
.openLoginWithQrCode(
|
.openLoginWithQrCode(
|
||||||
requireActivity(),
|
requireActivity(),
|
||||||
QrCodeLoginArgs(
|
QrCodeLoginArgs(
|
||||||
loginType = QrCodeLoginType.LINK_A_DEVICE,
|
loginType = QrCodeLoginType.LINK_A_DEVICE,
|
||||||
showQrCodeByDefault = true,
|
showQrCodeImmediately = showQrCodeImmediately,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
cleanUpLearnMoreButtonsListeners()
|
cleanUpLearnMoreButtonsListeners()
|
||||||
|
@ -251,10 +251,12 @@
|
|||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:text="@string/login_scan_qr_code"
|
android:text="@string/login_scan_qr_code"
|
||||||
|
android:visibility="gone"
|
||||||
app:drawableLeftCompat="@drawable/ic_qr_code"
|
app:drawableLeftCompat="@drawable/ic_qr_code"
|
||||||
app:layout_constraintEnd_toEndOf="@id/loginGutterEnd"
|
app:layout_constraintEnd_toEndOf="@id/loginGutterEnd"
|
||||||
app:layout_constraintStart_toStartOf="@id/loginGutterStart"
|
app:layout_constraintStart_toStartOf="@id/loginGutterStart"
|
||||||
app:layout_constraintTop_toBottomOf="@id/ssoButtonsHeader" />
|
app:layout_constraintTop_toBottomOf="@id/ssoButtonsHeader"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<im.vector.app.features.login.SocialLoginButtonsView
|
<im.vector.app.features.login.SocialLoginButtonsView
|
||||||
android:id="@+id/ssoButtons"
|
android:id="@+id/ssoButtons"
|
||||||
|
@ -98,26 +98,4 @@
|
|||||||
tools:text="@string/qr_code_login_new_device_instruction_3" />
|
tools:text="@string/qr_code_login_new_device_instruction_3" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/instructions4Layout"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="12dp"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:visibility="gone"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/instructions3Layout"
|
|
||||||
tools:visibility="visible">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
style="@style/TextAppearance.Vector.Caption"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="@drawable/circle_qr_code_login_instruction_with_border"
|
|
||||||
android:padding="6dp"
|
|
||||||
android:text="@string/four"
|
|
||||||
android:textColor="?colorPrimary" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</merge>
|
</merge>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user