mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 02:05:06 +08:00
Fix issue on SignOutBottomSheet (Sign out action displayed by mistake)
Also improve code clarity by reordering lines and removing private method, which lead to bug (ex: duplicate action on `setupMegolmBackupButton` in `hideViews(setupMegolmBackupButton, setupMegolmBackupButton, signOutButton, exportManuallyButton)`)
This commit is contained in:
parent
85c8092e65
commit
015678ca20
@ -35,8 +35,6 @@ import com.airbnb.mvrx.fragmentViewModel
|
||||
import com.airbnb.mvrx.withState
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import org.matrix.android.sdk.api.MatrixCallback
|
||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupState
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ScreenComponent
|
||||
import im.vector.app.core.dialogs.ExportKeysDialog
|
||||
@ -45,6 +43,9 @@ import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
|
||||
import im.vector.app.features.crypto.keysbackup.setup.KeysBackupSetupActivity
|
||||
import im.vector.app.features.crypto.recover.BootstrapBottomSheet
|
||||
import im.vector.app.features.crypto.recover.SetupMode
|
||||
import kotlinx.android.synthetic.main.bottom_sheet_logout_and_backup.*
|
||||
import org.matrix.android.sdk.api.MatrixCallback
|
||||
import org.matrix.android.sdk.api.session.crypto.keysbackup.KeysBackupState
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -57,21 +58,6 @@ class SignOutBottomSheetDialogFragment : VectorBaseBottomSheetDialogFragment(),
|
||||
@BindView(R.id.bottom_sheet_signout_backingup_status_group)
|
||||
lateinit var backingUpStatusGroup: ViewGroup
|
||||
|
||||
@BindView(R.id.setupRecoveryButton)
|
||||
lateinit var setupRecoveryButton: SignoutBottomSheetActionButton
|
||||
|
||||
@BindView(R.id.setupMegolmBackupButton)
|
||||
lateinit var setupMegolmBackupButton: SignoutBottomSheetActionButton
|
||||
|
||||
@BindView(R.id.exportManuallyButton)
|
||||
lateinit var exportManuallyButton: SignoutBottomSheetActionButton
|
||||
|
||||
@BindView(R.id.exitAnywayButton)
|
||||
lateinit var exitAnywayButton: SignoutBottomSheetActionButton
|
||||
|
||||
@BindView(R.id.signOutButton)
|
||||
lateinit var signOutButton: SignoutBottomSheetActionButton
|
||||
|
||||
@BindView(R.id.bottom_sheet_signout_icon_progress_bar)
|
||||
lateinit var backupProgress: ProgressBar
|
||||
|
||||
@ -186,10 +172,10 @@ class SignOutBottomSheetDialogFragment : VectorBaseBottomSheetDialogFragment(),
|
||||
// we should show option to setup 4S
|
||||
setupRecoveryButton.isVisible = true
|
||||
setupMegolmBackupButton.isVisible = false
|
||||
signOutButton.isVisible = false
|
||||
// We let the option to ignore and quit
|
||||
exportManuallyButton.isVisible = true
|
||||
exitAnywayButton.isVisible = true
|
||||
signOutButton.isVisible = false
|
||||
} else if (state.keysBackupState == KeysBackupState.Unknown || state.keysBackupState == KeysBackupState.Disabled) {
|
||||
sheetTitle.text = getString(R.string.sign_out_bottom_sheet_warning_no_backup)
|
||||
backingUpStatusGroup.isVisible = false
|
||||
@ -198,10 +184,10 @@ class SignOutBottomSheetDialogFragment : VectorBaseBottomSheetDialogFragment(),
|
||||
// we should show option to setup 4S
|
||||
setupRecoveryButton.isVisible = false
|
||||
setupMegolmBackupButton.isVisible = true
|
||||
signOutButton.isVisible = false
|
||||
// We let the option to ignore and quit
|
||||
exportManuallyButton.isVisible = true
|
||||
exitAnywayButton.isVisible = true
|
||||
signOutButton.isVisible = false
|
||||
} else {
|
||||
// so keybackup is setup
|
||||
// You should wait until all are uploaded
|
||||
@ -217,11 +203,12 @@ class SignOutBottomSheetDialogFragment : VectorBaseBottomSheetDialogFragment(),
|
||||
backupCompleteImage.isVisible = true
|
||||
backupStatusTex.text = getString(R.string.keys_backup_info_keys_all_backup_up)
|
||||
|
||||
hideViews(setupMegolmBackupButton, exportManuallyButton, exitAnywayButton)
|
||||
setupMegolmBackupButton.isVisible = false
|
||||
exportManuallyButton.isVisible = false
|
||||
exitAnywayButton.isVisible = false
|
||||
// You can signout
|
||||
signOutButton.isVisible = true
|
||||
}
|
||||
|
||||
KeysBackupState.WillBackUp,
|
||||
KeysBackupState.BackingUp -> {
|
||||
sheetTitle.text = getString(R.string.sign_out_bottom_sheet_warning_backing_up)
|
||||
@ -232,18 +219,21 @@ class SignOutBottomSheetDialogFragment : VectorBaseBottomSheetDialogFragment(),
|
||||
backupCompleteImage.isVisible = false
|
||||
backupStatusTex.text = getString(R.string.sign_out_bottom_sheet_backing_up_keys)
|
||||
|
||||
hideViews(setupMegolmBackupButton, setupMegolmBackupButton, signOutButton, exportManuallyButton)
|
||||
setupMegolmBackupButton.isVisible = false
|
||||
exportManuallyButton.isVisible = false
|
||||
exitAnywayButton.isVisible = true
|
||||
signOutButton.isVisible = false
|
||||
}
|
||||
KeysBackupState.NotTrusted -> {
|
||||
sheetTitle.text = getString(R.string.sign_out_bottom_sheet_warning_backup_not_active)
|
||||
// It's not trusted and we know there are unsaved keys..
|
||||
backingUpStatusGroup.isVisible = false
|
||||
|
||||
exportManuallyButton.isVisible = true
|
||||
// option to enter pass/key
|
||||
setupMegolmBackupButton.isVisible = true
|
||||
exportManuallyButton.isVisible = true
|
||||
exitAnywayButton.isVisible = true
|
||||
signOutButton.isVisible = false
|
||||
}
|
||||
else -> {
|
||||
// mmm.. strange state
|
||||
@ -257,21 +247,23 @@ class SignOutBottomSheetDialogFragment : VectorBaseBottomSheetDialogFragment(),
|
||||
when (state.hasBeenExportedToFile) {
|
||||
is Loading -> {
|
||||
signoutExportingLoading.isVisible = true
|
||||
hideViews(setupRecoveryButton,
|
||||
setupMegolmBackupButton,
|
||||
exportManuallyButton,
|
||||
backingUpStatusGroup,
|
||||
signOutButton)
|
||||
backingUpStatusGroup.isVisible = false
|
||||
|
||||
setupRecoveryButton.isVisible = false
|
||||
setupMegolmBackupButton.isVisible = false
|
||||
exportManuallyButton.isVisible = false
|
||||
exitAnywayButton.isVisible = true
|
||||
signOutButton.isVisible = false
|
||||
}
|
||||
is Success -> {
|
||||
if (state.hasBeenExportedToFile.invoke()) {
|
||||
sheetTitle.text = getString(R.string.action_sign_out_confirmation_simple)
|
||||
hideViews(setupRecoveryButton,
|
||||
setupMegolmBackupButton,
|
||||
exportManuallyButton,
|
||||
backingUpStatusGroup,
|
||||
exitAnywayButton)
|
||||
backingUpStatusGroup.isVisible = false
|
||||
|
||||
setupRecoveryButton.isVisible = false
|
||||
setupMegolmBackupButton.isVisible = false
|
||||
exportManuallyButton.isVisible = false
|
||||
exitAnywayButton.isVisible = false
|
||||
signOutButton.isVisible = true
|
||||
}
|
||||
}
|
||||
@ -319,8 +311,4 @@ class SignOutBottomSheetDialogFragment : VectorBaseBottomSheetDialogFragment(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun hideViews(vararg views: View) {
|
||||
views.forEach { it.isVisible = false }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user