mirror of
https://github.com/twofas/2fas-android.git
synced 2024-11-22 02:09:58 +01:00
Fix no password when backup
This commit is contained in:
parent
3d6d376840
commit
a2987d888f
@ -13,6 +13,7 @@ import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.Shape
|
||||
@ -24,6 +25,7 @@ import androidx.compose.ui.window.DialogProperties
|
||||
import com.twofasapp.designsystem.TwTheme
|
||||
import com.twofasapp.designsystem.common.TwTextButton
|
||||
import com.twofasapp.locale.TwLocale
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
internal val DialogPadding = 24.dp
|
||||
private val IconPadding = PaddingValues(bottom = 16.dp)
|
||||
@ -51,6 +53,7 @@ fun BaseDialog(
|
||||
properties: DialogProperties = DialogProperties(),
|
||||
content: @Composable () -> Unit = {},
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val showActions = positive != null || negative != null
|
||||
|
||||
Dialog(
|
||||
@ -92,12 +95,16 @@ fun BaseDialog(
|
||||
positive = positive,
|
||||
negative = negative,
|
||||
onPositiveClick = {
|
||||
onPositiveClick?.invoke()
|
||||
onDismissRequest()
|
||||
scope.launch {
|
||||
onPositiveClick?.invoke()
|
||||
onDismissRequest()
|
||||
}
|
||||
},
|
||||
onNegativeClick = {
|
||||
onNegativeClick?.invoke()
|
||||
onDismissRequest()
|
||||
scope.launch {
|
||||
onNegativeClick?.invoke()
|
||||
onDismissRequest()
|
||||
}
|
||||
},
|
||||
positiveEnabled = positiveEnabled,
|
||||
negativeEnabled = negativeEnabled,
|
||||
|
@ -16,6 +16,7 @@ import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import com.twofasapp.designsystem.common.TwOutlinedTextFieldPassword
|
||||
import com.twofasapp.locale.TwLocale
|
||||
import kotlinx.coroutines.android.awaitFrame
|
||||
@ -36,6 +37,7 @@ fun PasswordDialog(
|
||||
minLength: Int = 3,
|
||||
maxLength: Int = Int.MAX_VALUE,
|
||||
confirmRequired: Boolean = true,
|
||||
properties: DialogProperties = DialogProperties(),
|
||||
) {
|
||||
var password by remember { mutableStateOf("") }
|
||||
var passwordConfirm by remember { mutableStateOf("") }
|
||||
@ -61,6 +63,7 @@ fun PasswordDialog(
|
||||
onNegativeClick = onNegative,
|
||||
positiveEnabled = positiveEnabledState,
|
||||
negativeEnabled = true,
|
||||
properties = properties,
|
||||
) {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
|
@ -23,6 +23,7 @@ import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.twofasapp.data.services.domain.CloudSyncError
|
||||
import com.twofasapp.data.services.domain.CloudSyncStatus
|
||||
@ -249,7 +250,9 @@ private fun ScreenContent(
|
||||
body = strings.backupEnterCloudPasswordMsg,
|
||||
error = if (showPasswordError) strings.backupIncorrectPassword else null,
|
||||
positive = strings.commonContinue,
|
||||
onPositive = { onEnterPassword(it) }
|
||||
onPositive = { onEnterPassword(it) },
|
||||
onNegative = { onTurnOffSync() },
|
||||
properties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ internal class BackupViewModel(
|
||||
)
|
||||
}
|
||||
|
||||
if (isPasswordError && cloudSyncStatus.trigger == CloudSyncTrigger.FirstConnect) {
|
||||
if (isPasswordError && cloudSyncStatus.trigger == CloudSyncTrigger.FirstConnect && cloudBackupStatus.active) {
|
||||
publishEvent(BackupUiEvent.ShowPasswordDialog)
|
||||
}
|
||||
}
|
||||
@ -116,7 +116,19 @@ internal class BackupViewModel(
|
||||
launchScoped {
|
||||
googleAuth.signOut()
|
||||
backupRepository.setCloudSyncNotConfigured()
|
||||
backupRepository.publishCloudSyncStatus(CloudSyncStatus.Default)
|
||||
sessionRepository.resetBackupReminder()
|
||||
uiState.update { state ->
|
||||
state.copy(
|
||||
syncChecked = false,
|
||||
syncEnabled = true,
|
||||
showSyncMsg = true,
|
||||
showError = false,
|
||||
error = null,
|
||||
cloudBackupStatus = null,
|
||||
cloudSyncStatus = CloudSyncStatus.Default
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user