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.airbnb.mvrx.withState
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
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.R
|
||||||
import im.vector.app.core.di.ScreenComponent
|
import im.vector.app.core.di.ScreenComponent
|
||||||
import im.vector.app.core.dialogs.ExportKeysDialog
|
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.keysbackup.setup.KeysBackupSetupActivity
|
||||||
import im.vector.app.features.crypto.recover.BootstrapBottomSheet
|
import im.vector.app.features.crypto.recover.BootstrapBottomSheet
|
||||||
import im.vector.app.features.crypto.recover.SetupMode
|
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 timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -57,21 +58,6 @@ class SignOutBottomSheetDialogFragment : VectorBaseBottomSheetDialogFragment(),
|
|||||||
@BindView(R.id.bottom_sheet_signout_backingup_status_group)
|
@BindView(R.id.bottom_sheet_signout_backingup_status_group)
|
||||||
lateinit var backingUpStatusGroup: ViewGroup
|
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)
|
@BindView(R.id.bottom_sheet_signout_icon_progress_bar)
|
||||||
lateinit var backupProgress: ProgressBar
|
lateinit var backupProgress: ProgressBar
|
||||||
|
|
||||||
@ -186,10 +172,10 @@ class SignOutBottomSheetDialogFragment : VectorBaseBottomSheetDialogFragment(),
|
|||||||
// we should show option to setup 4S
|
// we should show option to setup 4S
|
||||||
setupRecoveryButton.isVisible = true
|
setupRecoveryButton.isVisible = true
|
||||||
setupMegolmBackupButton.isVisible = false
|
setupMegolmBackupButton.isVisible = false
|
||||||
signOutButton.isVisible = false
|
|
||||||
// We let the option to ignore and quit
|
// We let the option to ignore and quit
|
||||||
exportManuallyButton.isVisible = true
|
exportManuallyButton.isVisible = true
|
||||||
exitAnywayButton.isVisible = true
|
exitAnywayButton.isVisible = true
|
||||||
|
signOutButton.isVisible = false
|
||||||
} else if (state.keysBackupState == KeysBackupState.Unknown || state.keysBackupState == KeysBackupState.Disabled) {
|
} else if (state.keysBackupState == KeysBackupState.Unknown || state.keysBackupState == KeysBackupState.Disabled) {
|
||||||
sheetTitle.text = getString(R.string.sign_out_bottom_sheet_warning_no_backup)
|
sheetTitle.text = getString(R.string.sign_out_bottom_sheet_warning_no_backup)
|
||||||
backingUpStatusGroup.isVisible = false
|
backingUpStatusGroup.isVisible = false
|
||||||
@ -198,10 +184,10 @@ class SignOutBottomSheetDialogFragment : VectorBaseBottomSheetDialogFragment(),
|
|||||||
// we should show option to setup 4S
|
// we should show option to setup 4S
|
||||||
setupRecoveryButton.isVisible = false
|
setupRecoveryButton.isVisible = false
|
||||||
setupMegolmBackupButton.isVisible = true
|
setupMegolmBackupButton.isVisible = true
|
||||||
signOutButton.isVisible = false
|
|
||||||
// We let the option to ignore and quit
|
// We let the option to ignore and quit
|
||||||
exportManuallyButton.isVisible = true
|
exportManuallyButton.isVisible = true
|
||||||
exitAnywayButton.isVisible = true
|
exitAnywayButton.isVisible = true
|
||||||
|
signOutButton.isVisible = false
|
||||||
} else {
|
} else {
|
||||||
// so keybackup is setup
|
// so keybackup is setup
|
||||||
// You should wait until all are uploaded
|
// You should wait until all are uploaded
|
||||||
@ -217,13 +203,14 @@ class SignOutBottomSheetDialogFragment : VectorBaseBottomSheetDialogFragment(),
|
|||||||
backupCompleteImage.isVisible = true
|
backupCompleteImage.isVisible = true
|
||||||
backupStatusTex.text = getString(R.string.keys_backup_info_keys_all_backup_up)
|
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
|
// You can signout
|
||||||
signOutButton.isVisible = true
|
signOutButton.isVisible = true
|
||||||
}
|
}
|
||||||
|
|
||||||
KeysBackupState.WillBackUp,
|
KeysBackupState.WillBackUp,
|
||||||
KeysBackupState.BackingUp -> {
|
KeysBackupState.BackingUp -> {
|
||||||
sheetTitle.text = getString(R.string.sign_out_bottom_sheet_warning_backing_up)
|
sheetTitle.text = getString(R.string.sign_out_bottom_sheet_warning_backing_up)
|
||||||
|
|
||||||
// save in progress
|
// save in progress
|
||||||
@ -232,18 +219,21 @@ class SignOutBottomSheetDialogFragment : VectorBaseBottomSheetDialogFragment(),
|
|||||||
backupCompleteImage.isVisible = false
|
backupCompleteImage.isVisible = false
|
||||||
backupStatusTex.text = getString(R.string.sign_out_bottom_sheet_backing_up_keys)
|
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
|
exitAnywayButton.isVisible = true
|
||||||
|
signOutButton.isVisible = false
|
||||||
}
|
}
|
||||||
KeysBackupState.NotTrusted -> {
|
KeysBackupState.NotTrusted -> {
|
||||||
sheetTitle.text = getString(R.string.sign_out_bottom_sheet_warning_backup_not_active)
|
sheetTitle.text = getString(R.string.sign_out_bottom_sheet_warning_backup_not_active)
|
||||||
// It's not trusted and we know there are unsaved keys..
|
// It's not trusted and we know there are unsaved keys..
|
||||||
backingUpStatusGroup.isVisible = false
|
backingUpStatusGroup.isVisible = false
|
||||||
|
|
||||||
exportManuallyButton.isVisible = true
|
|
||||||
// option to enter pass/key
|
// option to enter pass/key
|
||||||
setupMegolmBackupButton.isVisible = true
|
setupMegolmBackupButton.isVisible = true
|
||||||
|
exportManuallyButton.isVisible = true
|
||||||
exitAnywayButton.isVisible = true
|
exitAnywayButton.isVisible = true
|
||||||
|
signOutButton.isVisible = false
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
// mmm.. strange state
|
// mmm.. strange state
|
||||||
@ -257,21 +247,23 @@ class SignOutBottomSheetDialogFragment : VectorBaseBottomSheetDialogFragment(),
|
|||||||
when (state.hasBeenExportedToFile) {
|
when (state.hasBeenExportedToFile) {
|
||||||
is Loading -> {
|
is Loading -> {
|
||||||
signoutExportingLoading.isVisible = true
|
signoutExportingLoading.isVisible = true
|
||||||
hideViews(setupRecoveryButton,
|
backingUpStatusGroup.isVisible = false
|
||||||
setupMegolmBackupButton,
|
|
||||||
exportManuallyButton,
|
setupRecoveryButton.isVisible = false
|
||||||
backingUpStatusGroup,
|
setupMegolmBackupButton.isVisible = false
|
||||||
signOutButton)
|
exportManuallyButton.isVisible = false
|
||||||
exitAnywayButton.isVisible = true
|
exitAnywayButton.isVisible = true
|
||||||
|
signOutButton.isVisible = false
|
||||||
}
|
}
|
||||||
is Success -> {
|
is Success -> {
|
||||||
if (state.hasBeenExportedToFile.invoke()) {
|
if (state.hasBeenExportedToFile.invoke()) {
|
||||||
sheetTitle.text = getString(R.string.action_sign_out_confirmation_simple)
|
sheetTitle.text = getString(R.string.action_sign_out_confirmation_simple)
|
||||||
hideViews(setupRecoveryButton,
|
backingUpStatusGroup.isVisible = false
|
||||||
setupMegolmBackupButton,
|
|
||||||
exportManuallyButton,
|
setupRecoveryButton.isVisible = false
|
||||||
backingUpStatusGroup,
|
setupMegolmBackupButton.isVisible = false
|
||||||
exitAnywayButton)
|
exportManuallyButton.isVisible = false
|
||||||
|
exitAnywayButton.isVisible = false
|
||||||
signOutButton.isVisible = true
|
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