mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-10 06:14:10 +01:00
Add change password dialog
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
381804c892
commit
31c0d74356
@ -445,7 +445,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM
|
|||||||
val isOpenForGuestAppUsers = conversationCreationViewModel.openForGuestAppUsers.value
|
val isOpenForGuestAppUsers = conversationCreationViewModel.openForGuestAppUsers.value
|
||||||
|
|
||||||
val isPasswordSet = conversationCreationViewModel.isPasswordEnabled.value
|
val isPasswordSet = conversationCreationViewModel.isPasswordEnabled.value
|
||||||
val isPasswordChanged = conversationCreationViewModel.isPasswordChanged.value
|
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(id = R.string.nc_new_conversation_visibility).uppercase(),
|
text = stringResource(id = R.string.nc_new_conversation_visibility).uppercase(),
|
||||||
@ -463,7 +462,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
showDialog = false,
|
|
||||||
conversationCreationViewModel = conversationCreationViewModel
|
conversationCreationViewModel = conversationCreationViewModel
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -471,7 +469,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM
|
|||||||
ConversationOptions(
|
ConversationOptions(
|
||||||
icon = R.drawable.ic_lock_grey600_24px,
|
icon = R.drawable.ic_lock_grey600_24px,
|
||||||
text = R.string.nc_set_password,
|
text = R.string.nc_set_password,
|
||||||
showDialog = true,
|
|
||||||
conversationCreationViewModel = conversationCreationViewModel
|
conversationCreationViewModel = conversationCreationViewModel
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -480,7 +477,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM
|
|||||||
ConversationOptions(
|
ConversationOptions(
|
||||||
icon = R.drawable.ic_lock_grey600_24px,
|
icon = R.drawable.ic_lock_grey600_24px,
|
||||||
text = R.string.nc_change_password,
|
text = R.string.nc_change_password,
|
||||||
showDialog = false,
|
|
||||||
conversationCreationViewModel = conversationCreationViewModel
|
conversationCreationViewModel = conversationCreationViewModel
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -496,7 +492,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
showDialog = false,
|
|
||||||
conversationCreationViewModel = conversationCreationViewModel
|
conversationCreationViewModel = conversationCreationViewModel
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -511,7 +506,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
showDialog = false,
|
|
||||||
conversationCreationViewModel = conversationCreationViewModel
|
conversationCreationViewModel = conversationCreationViewModel
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -522,19 +516,23 @@ fun ConversationOptions(
|
|||||||
icon: Int? = null,
|
icon: Int? = null,
|
||||||
text: Int,
|
text: Int,
|
||||||
switch: @Composable (() -> Unit)? = null,
|
switch: @Composable (() -> Unit)? = null,
|
||||||
showDialog: Boolean,
|
|
||||||
conversationCreationViewModel: ConversationCreationViewModel
|
conversationCreationViewModel: ConversationCreationViewModel
|
||||||
) {
|
) {
|
||||||
var showPasswordDialog by rememberSaveable { mutableStateOf(false) }
|
var showPasswordDialog by rememberSaveable { mutableStateOf(false) }
|
||||||
|
var showPasswordChangeDialog by rememberSaveable { mutableStateOf(false) }
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(start = 16.dp, end = 16.dp, bottom = 8.dp)
|
.padding(start = 16.dp, end = 16.dp, bottom = 8.dp)
|
||||||
.then(
|
.then(
|
||||||
if (showDialog) {
|
if (!conversationCreationViewModel.isPasswordEnabled.value) {
|
||||||
Modifier.clickable {
|
Modifier.clickable {
|
||||||
showPasswordDialog = true
|
showPasswordDialog = true
|
||||||
}
|
}
|
||||||
|
} else if (conversationCreationViewModel.isPasswordEnabled.value) {
|
||||||
|
Modifier.clickable {
|
||||||
|
showPasswordChangeDialog = true
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Modifier
|
Modifier
|
||||||
}
|
}
|
||||||
@ -565,9 +563,10 @@ fun ConversationOptions(
|
|||||||
conversationCreationViewModel = conversationCreationViewModel
|
conversationCreationViewModel = conversationCreationViewModel
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (conversationCreationViewModel.isPasswordChanged.value) {
|
if (showPasswordChangeDialog) {
|
||||||
ShowChangePassword(
|
ShowChangePassword(
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
|
showPasswordChangeDialog = false
|
||||||
},
|
},
|
||||||
conversationCreationViewModel = conversationCreationViewModel
|
conversationCreationViewModel = conversationCreationViewModel
|
||||||
)
|
)
|
||||||
@ -578,17 +577,15 @@ fun ConversationOptions(
|
|||||||
@Composable
|
@Composable
|
||||||
fun ShowChangePassword(onDismiss: () -> Unit, conversationCreationViewModel: ConversationCreationViewModel) {
|
fun ShowChangePassword(onDismiss: () -> Unit, conversationCreationViewModel: ConversationCreationViewModel) {
|
||||||
var changedPassword by rememberSaveable { mutableStateOf("") }
|
var changedPassword by rememberSaveable { mutableStateOf("") }
|
||||||
Dialog(onDismissRequest = { }) {
|
Dialog(onDismissRequest = {
|
||||||
|
onDismiss()
|
||||||
|
}) {
|
||||||
Card(
|
Card(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(375.dp)
|
.height(375.dp)
|
||||||
.padding(16.dp)
|
.padding(16.dp)
|
||||||
.background(color = colorResource(id = R.color.appbar))
|
.background(color = colorResource(id = R.color.appbar)),
|
||||||
.clickable {
|
|
||||||
if (conversationCreationViewModel.isPasswordEnabled.value) {
|
|
||||||
}
|
|
||||||
},
|
|
||||||
shape = RoundedCornerShape(16.dp)
|
shape = RoundedCornerShape(16.dp)
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
@ -606,21 +603,32 @@ fun ShowChangePassword(onDismiss: () -> Unit, conversationCreationViewModel: Con
|
|||||||
label = { Text(text = stringResource(id = R.string.nc_set_new_password)) },
|
label = { Text(text = stringResource(id = R.string.nc_set_new_password)) },
|
||||||
singleLine = true
|
singleLine = true
|
||||||
)
|
)
|
||||||
|
if (changedPassword.isNotEmpty() && changedPassword.isNotBlank()) {
|
||||||
TextButton(
|
TextButton(
|
||||||
onClick = { },
|
onClick = {
|
||||||
modifier = Modifier.padding(8.dp)
|
conversationCreationViewModel.updatePassword(changedPassword)
|
||||||
) {
|
conversationCreationViewModel.isPasswordEnabled.value = true
|
||||||
Text(text = stringResource(id = R.string.nc_change_password))
|
onDismiss()
|
||||||
|
},
|
||||||
|
modifier = Modifier.padding(8.dp)
|
||||||
|
) {
|
||||||
|
Text(text = stringResource(id = R.string.nc_change_password))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TextButton(
|
TextButton(
|
||||||
onClick = { },
|
onClick = {
|
||||||
|
conversationCreationViewModel.isPasswordEnabled.value = true
|
||||||
|
onDismiss()
|
||||||
|
},
|
||||||
modifier = Modifier.padding(8.dp)
|
modifier = Modifier.padding(8.dp)
|
||||||
) {
|
) {
|
||||||
Text(text = stringResource(id = R.string.nc_remove_password))
|
Text(text = stringResource(id = R.string.nc_remove_password))
|
||||||
}
|
}
|
||||||
TextButton(
|
TextButton(
|
||||||
onClick = { },
|
onClick = {
|
||||||
|
conversationCreationViewModel.isPasswordEnabled.value = true
|
||||||
|
onDismiss()
|
||||||
|
},
|
||||||
modifier = Modifier.padding(8.dp)
|
modifier = Modifier.padding(8.dp)
|
||||||
) {
|
) {
|
||||||
Text(text = stringResource(id = R.string.nc_cancel))
|
Text(text = stringResource(id = R.string.nc_cancel))
|
||||||
@ -633,18 +641,18 @@ fun ShowChangePassword(onDismiss: () -> Unit, conversationCreationViewModel: Con
|
|||||||
@Composable
|
@Composable
|
||||||
fun ShowPasswordDialog(onDismiss: () -> Unit, conversationCreationViewModel: ConversationCreationViewModel) {
|
fun ShowPasswordDialog(onDismiss: () -> Unit, conversationCreationViewModel: ConversationCreationViewModel) {
|
||||||
var password by rememberSaveable { mutableStateOf("") }
|
var password by rememberSaveable { mutableStateOf("") }
|
||||||
|
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
containerColor = colorResource(id = R.color.dialog_background),
|
containerColor = colorResource(id = R.color.dialog_background),
|
||||||
onDismissRequest = onDismiss,
|
onDismissRequest = onDismiss,
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
Button(onClick = {
|
Button(
|
||||||
if (password.isNotEmpty()) {
|
onClick = {
|
||||||
conversationCreationViewModel.updatePassword(password)
|
if (password.isNotEmpty() && password.isNotBlank()) {
|
||||||
conversationCreationViewModel.isPasswordEnabled(true)
|
conversationCreationViewModel.updatePassword(password)
|
||||||
|
conversationCreationViewModel.isPasswordEnabled(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onDismiss()
|
) {
|
||||||
}) {
|
|
||||||
Text(text = stringResource(id = R.string.save))
|
Text(text = stringResource(id = R.string.save))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -41,17 +41,15 @@ class ConversationCreationViewModel @Inject constructor(
|
|||||||
private val _isPasswordEnabled = mutableStateOf(false)
|
private val _isPasswordEnabled = mutableStateOf(false)
|
||||||
val isPasswordEnabled = _isPasswordEnabled
|
val isPasswordEnabled = _isPasswordEnabled
|
||||||
|
|
||||||
private val _isPasswordChanged = mutableStateOf(false)
|
|
||||||
val isPasswordChanged = _isPasswordChanged
|
|
||||||
|
|
||||||
fun updateSelectedParticipants(participants: List<AutocompleteUser>) {
|
fun updateSelectedParticipants(participants: List<AutocompleteUser>) {
|
||||||
_selectedParticipants.value = participants
|
_selectedParticipants.value = participants
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isPasswordEnabled(value: Boolean) {
|
||||||
|
isPasswordEnabled.value = value
|
||||||
fun updateSelectedImageUri(uri: Uri?) {
|
fun updateSelectedImageUri(uri: Uri?) {
|
||||||
_selectedImageUri.value = uri
|
_selectedImageUri.value = uri
|
||||||
}
|
}
|
||||||
|
|
||||||
private val _roomName = MutableStateFlow("")
|
private val _roomName = MutableStateFlow("")
|
||||||
val roomName: StateFlow<String> = _roomName
|
val roomName: StateFlow<String> = _roomName
|
||||||
private val _password = MutableStateFlow("")
|
private val _password = MutableStateFlow("")
|
||||||
|
Loading…
Reference in New Issue
Block a user