Moar cleanup

This commit is contained in:
Benoit Marty 2021-11-19 17:35:02 +01:00
parent 4af2780ad9
commit 35ee555252

View File

@ -38,6 +38,7 @@ import im.vector.app.R
import im.vector.app.core.extensions.commitTransaction import im.vector.app.core.extensions.commitTransaction
import im.vector.app.core.extensions.exhaustive import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.extensions.registerStartForActivityResult import im.vector.app.core.extensions.registerStartForActivityResult
import im.vector.app.core.extensions.toMvRxBundle
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
import im.vector.app.databinding.BottomSheetBootstrapBinding import im.vector.app.databinding.BottomSheetBootstrapBinding
import im.vector.app.features.auth.ReAuthActivity import im.vector.app.features.auth.ReAuthActivity
@ -154,48 +155,48 @@ class BootstrapBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetBoot
is BootstrapStep.CheckingMigration -> { is BootstrapStep.CheckingMigration -> {
views.bootstrapIcon.isVisible = false views.bootstrapIcon.isVisible = false
views.bootstrapTitleText.text = getString(R.string.bottom_sheet_setup_secure_backup_title) views.bootstrapTitleText.text = getString(R.string.bottom_sheet_setup_secure_backup_title)
showFragment(BootstrapWaitingFragment::class, Bundle()) showFragment(BootstrapWaitingFragment::class)
} }
is BootstrapStep.FirstForm -> { is BootstrapStep.FirstForm -> {
views.bootstrapIcon.isVisible = false views.bootstrapIcon.isVisible = false
views.bootstrapTitleText.text = getString(R.string.bottom_sheet_setup_secure_backup_title) views.bootstrapTitleText.text = getString(R.string.bottom_sheet_setup_secure_backup_title)
showFragment(BootstrapSetupRecoveryKeyFragment::class, Bundle()) showFragment(BootstrapSetupRecoveryKeyFragment::class)
} }
is BootstrapStep.SetupPassphrase -> { is BootstrapStep.SetupPassphrase -> {
views.bootstrapIcon.isVisible = true views.bootstrapIcon.isVisible = true
views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_phrase_24dp)) views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_phrase_24dp))
views.bootstrapTitleText.text = getString(R.string.set_a_security_phrase_title) views.bootstrapTitleText.text = getString(R.string.set_a_security_phrase_title)
showFragment(BootstrapEnterPassphraseFragment::class, Bundle()) showFragment(BootstrapEnterPassphraseFragment::class)
} }
is BootstrapStep.ConfirmPassphrase -> { is BootstrapStep.ConfirmPassphrase -> {
views.bootstrapIcon.isVisible = true views.bootstrapIcon.isVisible = true
views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_phrase_24dp)) views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_phrase_24dp))
views.bootstrapTitleText.text = getString(R.string.set_a_security_phrase_title) views.bootstrapTitleText.text = getString(R.string.set_a_security_phrase_title)
showFragment(BootstrapConfirmPassphraseFragment::class, Bundle()) showFragment(BootstrapConfirmPassphraseFragment::class)
} }
is BootstrapStep.AccountReAuth -> { is BootstrapStep.AccountReAuth -> {
views.bootstrapIcon.isVisible = true views.bootstrapIcon.isVisible = true
views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_user)) views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_user))
views.bootstrapTitleText.text = getString(R.string.re_authentication_activity_title) views.bootstrapTitleText.text = getString(R.string.re_authentication_activity_title)
showFragment(BootstrapReAuthFragment::class, Bundle()) showFragment(BootstrapReAuthFragment::class)
} }
is BootstrapStep.Initializing -> { is BootstrapStep.Initializing -> {
views.bootstrapIcon.isVisible = true views.bootstrapIcon.isVisible = true
views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_key_24dp)) views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_key_24dp))
views.bootstrapTitleText.text = getString(R.string.bootstrap_loading_title) views.bootstrapTitleText.text = getString(R.string.bootstrap_loading_title)
showFragment(BootstrapWaitingFragment::class, Bundle()) showFragment(BootstrapWaitingFragment::class)
} }
is BootstrapStep.SaveRecoveryKey -> { is BootstrapStep.SaveRecoveryKey -> {
views.bootstrapIcon.isVisible = true views.bootstrapIcon.isVisible = true
views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_key_24dp)) views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_key_24dp))
views.bootstrapTitleText.text = getString(R.string.bottom_sheet_save_your_recovery_key_title) views.bootstrapTitleText.text = getString(R.string.bottom_sheet_save_your_recovery_key_title)
showFragment(BootstrapSaveRecoveryKeyFragment::class, Bundle()) showFragment(BootstrapSaveRecoveryKeyFragment::class)
} }
is BootstrapStep.DoneSuccess -> { is BootstrapStep.DoneSuccess -> {
views.bootstrapIcon.isVisible = true views.bootstrapIcon.isVisible = true
views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_key_24dp)) views.bootstrapIcon.setImageDrawable(ContextCompat.getDrawable(requireContext(), R.drawable.ic_security_key_24dp))
views.bootstrapTitleText.text = getString(R.string.bootstrap_finish_title) views.bootstrapTitleText.text = getString(R.string.bootstrap_finish_title)
showFragment(BootstrapConclusionFragment::class, Bundle()) showFragment(BootstrapConclusionFragment::class)
} }
is BootstrapStep.GetBackupSecretForMigration -> { is BootstrapStep.GetBackupSecretForMigration -> {
val isKey = state.step.useKey() val isKey = state.step.useKey()
@ -206,7 +207,7 @@ class BootstrapBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetBoot
drawableRes) drawableRes)
) )
views.bootstrapTitleText.text = getString(R.string.upgrade_security) views.bootstrapTitleText.text = getString(R.string.upgrade_security)
showFragment(BootstrapMigrateBackupFragment::class, Bundle()) showFragment(BootstrapMigrateBackupFragment::class)
} }
}.exhaustive }.exhaustive
super.invalidate() super.invalidate()
@ -224,12 +225,12 @@ class BootstrapBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetBoot
} }
} }
private fun showFragment(fragmentClass: KClass<out Fragment>, bundle: Bundle) { private fun showFragment(fragmentClass: KClass<out Fragment>, argsParcelable: Parcelable? = null) {
if (childFragmentManager.findFragmentByTag(fragmentClass.simpleName) == null) { if (childFragmentManager.findFragmentByTag(fragmentClass.simpleName) == null) {
childFragmentManager.commitTransaction { childFragmentManager.commitTransaction {
replace(R.id.bottomSheetFragmentContainer, replace(R.id.bottomSheetFragmentContainer,
fragmentClass.java, fragmentClass.java,
bundle, argsParcelable?.toMvRxBundle(),
fragmentClass.simpleName fragmentClass.simpleName
) )
} }