Moar cleanup

This commit is contained in:
Benoit Marty 2021-11-19 17:35:02 +01:00
parent 4af2780ad9
commit 35ee555252
1 changed files with 12 additions and 11 deletions

View File

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