From d336d1921b09cfe48d197b3e2a5b9bea0be4529f Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Fri, 19 Aug 2022 13:35:15 +0300 Subject: [PATCH] Observe view events. --- .../v2/VectorSettingsDevicesFragment.kt | 48 +++++++++++++++++++ .../res/layout/fragment_settings_devices.xml | 4 ++ 2 files changed, 52 insertions(+) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt index 6b60e9b020..35fd92023f 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt @@ -23,10 +23,18 @@ import android.view.View import android.view.ViewGroup import android.widget.Toast import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.isVisible +import com.airbnb.mvrx.fragmentViewModel import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R +import im.vector.app.core.dialogs.ManuallyVerifyDialog import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.databinding.FragmentSettingsDevicesBinding +import im.vector.app.features.crypto.recover.SetupMode +import im.vector.app.features.crypto.verification.VerificationBottomSheet +import im.vector.app.features.settings.devices.DevicesAction +import im.vector.app.features.settings.devices.DevicesViewEvents +import im.vector.app.features.settings.devices.DevicesViewModel import javax.inject.Inject /** @@ -35,6 +43,8 @@ import javax.inject.Inject @AndroidEntryPoint class VectorSettingsDevicesFragment @Inject constructor() : VectorBaseFragment() { + private val viewModel: DevicesViewModel by fragmentViewModel() + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentSettingsDevicesBinding { return FragmentSettingsDevicesBinding.inflate(inflater, container, false) } @@ -52,7 +62,45 @@ class VectorSettingsDevicesFragment @Inject constructor() : VectorBaseFragment showLoading(it.message) + is DevicesViewEvents.Failure -> showFailure(it.throwable) + is DevicesViewEvents.RequestReAuth -> Unit // TODO. Next PR + is DevicesViewEvents.PromptRenameDevice -> Unit // TODO. Next PR + is DevicesViewEvents.ShowVerifyDevice -> { + VerificationBottomSheet.withArgs( + roomId = null, + otherUserId = it.userId, + transactionId = it.transactionId + ).show(childFragmentManager, "REQPOP") + } + is DevicesViewEvents.SelfVerification -> { + VerificationBottomSheet.forSelfVerification(it.session) + .show(childFragmentManager, "REQPOP") + } + is DevicesViewEvents.ShowManuallyVerify -> { + ManuallyVerifyDialog.show(requireActivity(), it.cryptoDeviceInfo) { + viewModel.handle(DevicesAction.MarkAsManuallyVerified(it.cryptoDeviceInfo)) + } + } + is DevicesViewEvents.PromptResetSecrets -> { + navigator.open4SSetup(requireContext(), SetupMode.PASSPHRASE_AND_NEEDED_SECRETS_RESET) + } + } + } + } + + private fun initWaitingView() { + views.waitingView.waitingStatusText.setText(R.string.please_wait) + views.waitingView.waitingStatusText.isVisible = true } override fun onDestroyView() { diff --git a/vector/src/main/res/layout/fragment_settings_devices.xml b/vector/src/main/res/layout/fragment_settings_devices.xml index a1f2717159..586082b99e 100644 --- a/vector/src/main/res/layout/fragment_settings_devices.xml +++ b/vector/src/main/res/layout/fragment_settings_devices.xml @@ -34,4 +34,8 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/deviceListCurrentSession" /> + +