From 381804c8922051543800ba4c4fdc6efe142e5470 Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Fri, 20 Sep 2024 15:41:02 +0200 Subject: [PATCH 1/5] Add Change Password dialogue Signed-off-by: sowjanyakch --- .../ConversationCreationActivity.kt | 93 ++++++++++++++++++- .../ConversationCreationViewModel.kt | 7 ++ app/src/main/res/values/strings.xml | 3 + 3 files changed, 99 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt index 74bf4d6150..1f68b2686f 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt @@ -20,6 +20,7 @@ import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.compose.setContent import androidx.activity.result.ActivityResult import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Arrangement @@ -28,17 +29,21 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button +import androidx.compose.material3.Card import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon @@ -48,6 +53,7 @@ import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold import androidx.compose.material3.Switch import androidx.compose.material3.Text +import androidx.compose.material3.TextButton import androidx.compose.material3.TextField import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable @@ -56,6 +62,7 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -70,6 +77,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.compose.ui.window.Dialog import androidx.core.view.WindowCompat import androidx.lifecycle.ViewModelProvider import autodagger.AutoInjector @@ -436,6 +444,9 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM .isConversationAvailableForRegisteredUsers.value val isOpenForGuestAppUsers = conversationCreationViewModel.openForGuestAppUsers.value + val isPasswordSet = conversationCreationViewModel.isPasswordEnabled.value + val isPasswordChanged = conversationCreationViewModel.isPasswordChanged.value + Text( text = stringResource(id = R.string.nc_new_conversation_visibility).uppercase(), fontSize = 14.sp, @@ -456,7 +467,7 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM conversationCreationViewModel = conversationCreationViewModel ) - if (isGuestsAllowed) { + if (isGuestsAllowed && !isPasswordSet) { ConversationOptions( icon = R.drawable.ic_lock_grey600_24px, text = R.string.nc_set_password, @@ -465,6 +476,15 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM ) } + if (isGuestsAllowed && isPasswordSet) { + ConversationOptions( + icon = R.drawable.ic_lock_grey600_24px, + text = R.string.nc_change_password, + showDialog = false, + conversationCreationViewModel = conversationCreationViewModel + ) + } + ConversationOptions( icon = R.drawable.baseline_format_list_bulleted_24, text = R.string.nc_open_conversation_to_registered_users, @@ -505,7 +525,7 @@ fun ConversationOptions( showDialog: Boolean, conversationCreationViewModel: ConversationCreationViewModel ) { - var showPasswordDialog by remember { mutableStateOf(false) } + var showPasswordDialog by rememberSaveable { mutableStateOf(false) } Row( modifier = Modifier .fillMaxWidth() @@ -545,19 +565,84 @@ fun ConversationOptions( conversationCreationViewModel = conversationCreationViewModel ) } + if (conversationCreationViewModel.isPasswordChanged.value) { + ShowChangePassword( + onDismiss = { + }, + conversationCreationViewModel = conversationCreationViewModel + ) + } + } +} + +@Composable +fun ShowChangePassword(onDismiss: () -> Unit, conversationCreationViewModel: ConversationCreationViewModel) { + var changedPassword by rememberSaveable { mutableStateOf("") } + Dialog(onDismissRequest = { }) { + Card( + modifier = Modifier + .fillMaxWidth() + .height(375.dp) + .padding(16.dp) + .background(color = colorResource(id = R.color.appbar)) + .clickable { + if (conversationCreationViewModel.isPasswordEnabled.value) { + } + }, + shape = RoundedCornerShape(16.dp) + ) { + Column( + modifier = Modifier + .fillMaxSize(), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + Text(text = stringResource(id = R.string.nc_change_password)) + OutlinedTextField( + value = changedPassword, + onValueChange = { + changedPassword = it + }, + label = { Text(text = stringResource(id = R.string.nc_set_new_password)) }, + singleLine = true + ) + + TextButton( + onClick = { }, + modifier = Modifier.padding(8.dp) + ) { + Text(text = stringResource(id = R.string.nc_change_password)) + } + TextButton( + onClick = { }, + modifier = Modifier.padding(8.dp) + ) { + Text(text = stringResource(id = R.string.nc_remove_password)) + } + TextButton( + onClick = { }, + modifier = Modifier.padding(8.dp) + ) { + Text(text = stringResource(id = R.string.nc_cancel)) + } + } + } } } @Composable fun ShowPasswordDialog(onDismiss: () -> Unit, conversationCreationViewModel: ConversationCreationViewModel) { - var password by remember { mutableStateOf("") } + var password by rememberSaveable { mutableStateOf("") } AlertDialog( containerColor = colorResource(id = R.color.dialog_background), onDismissRequest = onDismiss, confirmButton = { Button(onClick = { - conversationCreationViewModel.updatePassword(password) + if (password.isNotEmpty()) { + conversationCreationViewModel.updatePassword(password) + conversationCreationViewModel.isPasswordEnabled(true) + } onDismiss() }) { Text(text = stringResource(id = R.string.save)) diff --git a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt index 0fa663d889..33249c9ee6 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt @@ -38,6 +38,12 @@ class ConversationCreationViewModel @Inject constructor( private val _currentUser = userManager.currentUser.blockingGet() val currentUser: User = _currentUser + private val _isPasswordEnabled = mutableStateOf(false) + val isPasswordEnabled = _isPasswordEnabled + + private val _isPasswordChanged = mutableStateOf(false) + val isPasswordChanged = _isPasswordChanged + fun updateSelectedParticipants(participants: List) { _selectedParticipants.value = participants } @@ -73,6 +79,7 @@ class ConversationCreationViewModel @Inject constructor( roomType: String, conversationName: String, participants: Set, + selectedImageUri: Uri?, onRoomCreated: (String) -> Unit ) { val scope = when { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c23acb5fbe..858f3bb0d7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -434,6 +434,9 @@ How to translate with transifex: Allow guests to share a public link to join this conversation. Cannot enable/disable guest access. Set Password + Change Password + Remove Password + Set a new password Password protection Set a password to restrict who can use the public link. Guest access password From 31c0d74356c86a499a6e5b667f880cbea1309350 Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Mon, 23 Sep 2024 17:51:30 +0200 Subject: [PATCH 2/5] Add change password dialog Signed-off-by: sowjanyakch --- .../ConversationCreationActivity.kt | 68 +++++++++++-------- .../ConversationCreationViewModel.kt | 6 +- 2 files changed, 40 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt index 1f68b2686f..f732a1f838 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt @@ -445,7 +445,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM val isOpenForGuestAppUsers = conversationCreationViewModel.openForGuestAppUsers.value val isPasswordSet = conversationCreationViewModel.isPasswordEnabled.value - val isPasswordChanged = conversationCreationViewModel.isPasswordChanged.value Text( text = stringResource(id = R.string.nc_new_conversation_visibility).uppercase(), @@ -463,7 +462,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM } ) }, - showDialog = false, conversationCreationViewModel = conversationCreationViewModel ) @@ -471,7 +469,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM ConversationOptions( icon = R.drawable.ic_lock_grey600_24px, text = R.string.nc_set_password, - showDialog = true, conversationCreationViewModel = conversationCreationViewModel ) } @@ -480,7 +477,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM ConversationOptions( icon = R.drawable.ic_lock_grey600_24px, text = R.string.nc_change_password, - showDialog = false, conversationCreationViewModel = conversationCreationViewModel ) } @@ -496,7 +492,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM } ) }, - showDialog = false, conversationCreationViewModel = conversationCreationViewModel ) @@ -511,7 +506,6 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM } ) }, - showDialog = false, conversationCreationViewModel = conversationCreationViewModel ) } @@ -522,19 +516,23 @@ fun ConversationOptions( icon: Int? = null, text: Int, switch: @Composable (() -> Unit)? = null, - showDialog: Boolean, conversationCreationViewModel: ConversationCreationViewModel ) { var showPasswordDialog by rememberSaveable { mutableStateOf(false) } + var showPasswordChangeDialog by rememberSaveable { mutableStateOf(false) } Row( modifier = Modifier .fillMaxWidth() .padding(start = 16.dp, end = 16.dp, bottom = 8.dp) .then( - if (showDialog) { + if (!conversationCreationViewModel.isPasswordEnabled.value) { Modifier.clickable { showPasswordDialog = true } + } else if (conversationCreationViewModel.isPasswordEnabled.value) { + Modifier.clickable { + showPasswordChangeDialog = true + } } else { Modifier } @@ -565,9 +563,10 @@ fun ConversationOptions( conversationCreationViewModel = conversationCreationViewModel ) } - if (conversationCreationViewModel.isPasswordChanged.value) { + if (showPasswordChangeDialog) { ShowChangePassword( onDismiss = { + showPasswordChangeDialog = false }, conversationCreationViewModel = conversationCreationViewModel ) @@ -578,17 +577,15 @@ fun ConversationOptions( @Composable fun ShowChangePassword(onDismiss: () -> Unit, conversationCreationViewModel: ConversationCreationViewModel) { var changedPassword by rememberSaveable { mutableStateOf("") } - Dialog(onDismissRequest = { }) { + Dialog(onDismissRequest = { + onDismiss() + }) { Card( modifier = Modifier .fillMaxWidth() .height(375.dp) .padding(16.dp) - .background(color = colorResource(id = R.color.appbar)) - .clickable { - if (conversationCreationViewModel.isPasswordEnabled.value) { - } - }, + .background(color = colorResource(id = R.color.appbar)), shape = RoundedCornerShape(16.dp) ) { Column( @@ -606,21 +603,32 @@ fun ShowChangePassword(onDismiss: () -> Unit, conversationCreationViewModel: Con label = { Text(text = stringResource(id = R.string.nc_set_new_password)) }, singleLine = true ) - - TextButton( - onClick = { }, - modifier = Modifier.padding(8.dp) - ) { - Text(text = stringResource(id = R.string.nc_change_password)) + if (changedPassword.isNotEmpty() && changedPassword.isNotBlank()) { + TextButton( + onClick = { + conversationCreationViewModel.updatePassword(changedPassword) + conversationCreationViewModel.isPasswordEnabled.value = true + onDismiss() + }, + modifier = Modifier.padding(8.dp) + ) { + Text(text = stringResource(id = R.string.nc_change_password)) + } } TextButton( - onClick = { }, + onClick = { + conversationCreationViewModel.isPasswordEnabled.value = true + onDismiss() + }, modifier = Modifier.padding(8.dp) ) { Text(text = stringResource(id = R.string.nc_remove_password)) } TextButton( - onClick = { }, + onClick = { + conversationCreationViewModel.isPasswordEnabled.value = true + onDismiss() + }, modifier = Modifier.padding(8.dp) ) { Text(text = stringResource(id = R.string.nc_cancel)) @@ -633,18 +641,18 @@ fun ShowChangePassword(onDismiss: () -> Unit, conversationCreationViewModel: Con @Composable fun ShowPasswordDialog(onDismiss: () -> Unit, conversationCreationViewModel: ConversationCreationViewModel) { var password by rememberSaveable { mutableStateOf("") } - AlertDialog( containerColor = colorResource(id = R.color.dialog_background), onDismissRequest = onDismiss, confirmButton = { - Button(onClick = { - if (password.isNotEmpty()) { - conversationCreationViewModel.updatePassword(password) - conversationCreationViewModel.isPasswordEnabled(true) + Button( + onClick = { + if (password.isNotEmpty() && password.isNotBlank()) { + conversationCreationViewModel.updatePassword(password) + conversationCreationViewModel.isPasswordEnabled(true) + } } - onDismiss() - }) { + ) { Text(text = stringResource(id = R.string.save)) } }, diff --git a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt index 33249c9ee6..509bf4be31 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt @@ -41,17 +41,15 @@ class ConversationCreationViewModel @Inject constructor( private val _isPasswordEnabled = mutableStateOf(false) val isPasswordEnabled = _isPasswordEnabled - private val _isPasswordChanged = mutableStateOf(false) - val isPasswordChanged = _isPasswordChanged - fun updateSelectedParticipants(participants: List) { _selectedParticipants.value = participants } + fun isPasswordEnabled(value: Boolean) { + isPasswordEnabled.value = value fun updateSelectedImageUri(uri: Uri?) { _selectedImageUri.value = uri } - private val _roomName = MutableStateFlow("") val roomName: StateFlow = _roomName private val _password = MutableStateFlow("") From c165e9fe0c628fa60a81d1059908e818e5491321 Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Mon, 23 Sep 2024 18:35:38 +0200 Subject: [PATCH 3/5] UI improvements Signed-off-by: sowjanyakch --- .../ConversationCreationActivity.kt | 70 +++++++++++-------- app/src/main/res/values/strings.xml | 3 +- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt index f732a1f838..23eb61e87e 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt @@ -26,6 +26,7 @@ import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight @@ -37,13 +38,11 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button -import androidx.compose.material3.Card import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon @@ -51,6 +50,7 @@ import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold +import androidx.compose.material3.Surface import androidx.compose.material3.Switch import androidx.compose.material3.Text import androidx.compose.material3.TextButton @@ -74,6 +74,7 @@ import androidx.compose.ui.platform.LocalView import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -580,58 +581,69 @@ fun ShowChangePassword(onDismiss: () -> Unit, conversationCreationViewModel: Con Dialog(onDismissRequest = { onDismiss() }) { - Card( + Surface( modifier = Modifier .fillMaxWidth() .height(375.dp) - .padding(16.dp) - .background(color = colorResource(id = R.color.appbar)), - shape = RoundedCornerShape(16.dp) + .padding(32.dp) + .background(color = colorResource(id = R.color.appbar)) ) { Column( modifier = Modifier - .fillMaxSize(), + .fillMaxSize() + .padding(vertical = 16.dp, horizontal = 16.dp), verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.CenterHorizontally ) { - Text(text = stringResource(id = R.string.nc_change_password)) + Text(text = stringResource(id = R.string.nc_set_new_password), fontWeight = FontWeight.SemiBold) + Spacer(modifier = Modifier.height(16.dp)) OutlinedTextField( value = changedPassword, onValueChange = { changedPassword = it }, - label = { Text(text = stringResource(id = R.string.nc_set_new_password)) }, + label = { Text(text = stringResource(id = R.string.nc_password)) }, singleLine = true ) - if (changedPassword.isNotEmpty() && changedPassword.isNotBlank()) { + Spacer(modifier = Modifier.height(16.dp)) + + Column( + modifier = Modifier.fillMaxWidth() + .padding(vertical = 8.dp), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { TextButton( onClick = { conversationCreationViewModel.updatePassword(changedPassword) conversationCreationViewModel.isPasswordEnabled.value = true onDismiss() }, - modifier = Modifier.padding(8.dp) + enabled = changedPassword.isNotEmpty() && changedPassword.isNotBlank(), + contentPadding = PaddingValues(horizontal = 16.dp, vertical = 8.dp) ) { Text(text = stringResource(id = R.string.nc_change_password)) } - } - TextButton( - onClick = { - conversationCreationViewModel.isPasswordEnabled.value = true - onDismiss() - }, - modifier = Modifier.padding(8.dp) - ) { - Text(text = stringResource(id = R.string.nc_remove_password)) - } - TextButton( - onClick = { - conversationCreationViewModel.isPasswordEnabled.value = true - onDismiss() - }, - modifier = Modifier.padding(8.dp) - ) { - Text(text = stringResource(id = R.string.nc_cancel)) + Spacer(modifier = Modifier.height(4.dp)) + TextButton( + onClick = { + conversationCreationViewModel.isPasswordEnabled.value = false + onDismiss() + }, + contentPadding = PaddingValues(horizontal = 16.dp, vertical = 8.dp) + ) { + Text( + text = stringResource(id = R.string.nc_remove_password), + color = colorResource(id = R.color.nc_darkRed) + ) + } + Spacer(modifier = Modifier.height(4.dp)) + TextButton( + onClick = { onDismiss() }, + contentPadding = PaddingValues(horizontal = 16.dp, vertical = 8.dp) + ) { + Text(text = stringResource(id = R.string.nc_cancel)) + } } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 858f3bb0d7..b6d2d6469f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -434,9 +434,10 @@ How to translate with transifex: Allow guests to share a public link to join this conversation. Cannot enable/disable guest access. Set Password + Password Change Password Remove Password - Set a new password + Set new password Password protection Set a password to restrict who can use the public link. Guest access password From 8c967c4f5678305a0829d940ec975b910b469e33 Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Mon, 23 Sep 2024 19:14:16 +0200 Subject: [PATCH 4/5] use open lock icon for set password Signed-off-by: sowjanyakch --- .../ConversationCreationActivity.kt | 23 +++++++++---------- .../ConversationCreationViewModel.kt | 5 ++-- .../res/drawable/baseline_lock_open_24.xml | 18 +++++++++++++++ 3 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 app/src/main/res/drawable/baseline_lock_open_24.xml diff --git a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt index 23eb61e87e..4ead1257c2 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt @@ -61,7 +61,6 @@ import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment @@ -468,7 +467,7 @@ fun RoomCreationOptions(conversationCreationViewModel: ConversationCreationViewM if (isGuestsAllowed && !isPasswordSet) { ConversationOptions( - icon = R.drawable.ic_lock_grey600_24px, + icon = R.drawable.baseline_lock_open_24, text = R.string.nc_set_password, conversationCreationViewModel = conversationCreationViewModel ) @@ -656,6 +655,16 @@ fun ShowPasswordDialog(onDismiss: () -> Unit, conversationCreationViewModel: Con AlertDialog( containerColor = colorResource(id = R.color.dialog_background), onDismissRequest = onDismiss, + title = { Text(text = stringResource(id = R.string.nc_set_password)) }, + text = { + TextField( + value = password, + onValueChange = { + password = it + }, + label = { Text(text = stringResource(id = R.string.nc_guest_access_password_dialog_hint)) } + ) + }, confirmButton = { Button( onClick = { @@ -668,16 +677,6 @@ fun ShowPasswordDialog(onDismiss: () -> Unit, conversationCreationViewModel: Con Text(text = stringResource(id = R.string.save)) } }, - title = { Text(text = stringResource(id = R.string.nc_set_password)) }, - text = { - TextField( - value = password, - onValueChange = { - password = it - }, - label = { Text(text = stringResource(id = R.string.nc_guest_access_password_dialog_hint)) } - ) - }, dismissButton = { Button(onClick = { onDismiss() }) { Text(text = stringResource(id = R.string.nc_cancel)) diff --git a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt index 509bf4be31..66421bb540 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationViewModel.kt @@ -46,7 +46,9 @@ class ConversationCreationViewModel @Inject constructor( } fun isPasswordEnabled(value: Boolean) { - isPasswordEnabled.value = value + _isPasswordEnabled.value = value + } + fun updateSelectedImageUri(uri: Uri?) { _selectedImageUri.value = uri } @@ -77,7 +79,6 @@ class ConversationCreationViewModel @Inject constructor( roomType: String, conversationName: String, participants: Set, - selectedImageUri: Uri?, onRoomCreated: (String) -> Unit ) { val scope = when { diff --git a/app/src/main/res/drawable/baseline_lock_open_24.xml b/app/src/main/res/drawable/baseline_lock_open_24.xml new file mode 100644 index 0000000000..ed16256a53 --- /dev/null +++ b/app/src/main/res/drawable/baseline_lock_open_24.xml @@ -0,0 +1,18 @@ + + + + + + + From ebace8713afdc6e208dc09281880e406f2851c4f Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Wed, 25 Sep 2024 08:29:08 +0200 Subject: [PATCH 5/5] Rounded corners for change password dialog Signed-off-by: sowjanyakch --- .../ConversationCreationActivity.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt index 4ead1257c2..b45db2f035 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationcreation/ConversationCreationActivity.kt @@ -38,11 +38,13 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button +import androidx.compose.material3.Card import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Icon @@ -50,7 +52,6 @@ import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold -import androidx.compose.material3.Surface import androidx.compose.material3.Switch import androidx.compose.material3.Text import androidx.compose.material3.TextButton @@ -580,11 +581,12 @@ fun ShowChangePassword(onDismiss: () -> Unit, conversationCreationViewModel: Con Dialog(onDismissRequest = { onDismiss() }) { - Surface( + Card( modifier = Modifier .fillMaxWidth() .height(375.dp) .padding(32.dp) + .clip(RoundedCornerShape(16.dp)) .background(color = colorResource(id = R.color.appbar)) ) { Column( @@ -666,7 +668,7 @@ fun ShowPasswordDialog(onDismiss: () -> Unit, conversationCreationViewModel: Con ) }, confirmButton = { - Button( + TextButton( onClick = { if (password.isNotEmpty() && password.isNotBlank()) { conversationCreationViewModel.updatePassword(password) @@ -678,7 +680,7 @@ fun ShowPasswordDialog(onDismiss: () -> Unit, conversationCreationViewModel: Con } }, dismissButton = { - Button(onClick = { onDismiss() }) { + TextButton(onClick = { onDismiss() }) { Text(text = stringResource(id = R.string.nc_cancel)) } }