|
@@ -46,11 +46,29 @@ import androidx.compose.ui.text.style.TextAlign
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
import com.fastest.pass.R
|
|
|
+import com.fastest.pass.helpers.BasePreferenceHelper
|
|
|
+import com.fastest.pass.home.data.model.NewItemFormField
|
|
|
|
|
|
@Composable
|
|
|
-fun AddWifiPasswordFormScreen() {
|
|
|
+fun AddWifiPasswordFormScreen(
|
|
|
+ basePreferenceHelper: BasePreferenceHelper,
|
|
|
+ onWifiPasswordFormList: (ArrayList<NewItemFormField>, Boolean) -> Unit
|
|
|
+) {
|
|
|
val keyboardController = LocalSoftwareKeyboardController.current
|
|
|
val focusManager = LocalFocusManager.current
|
|
|
+ var wifi_password_title by remember { mutableStateOf("") }
|
|
|
+ var wifi_password_ssid by remember { mutableStateOf("") }
|
|
|
+ var wifi_password_password by remember { mutableStateOf("") }
|
|
|
+ var wifi_password_connection_type by remember { mutableStateOf("") }
|
|
|
+ var wifi_password_connection_mode by remember { mutableStateOf("") }
|
|
|
+ var wifi_password_authentication by remember { mutableStateOf("") }
|
|
|
+ var wifi_password_encryption by remember { mutableStateOf("") }
|
|
|
+ var wifi_password_use_802_1X by remember { mutableStateOf("") }
|
|
|
+ var wifi_password_fips_mode by remember { mutableStateOf("") }
|
|
|
+ var wifi_password_key_type by remember { mutableStateOf("") }
|
|
|
+ var wifi_password_protected by remember { mutableStateOf("") }
|
|
|
+ var wifi_password_key_index by remember { mutableStateOf("") }
|
|
|
+ var wifi_password_notes by remember { mutableStateOf("") }
|
|
|
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
@@ -60,7 +78,46 @@ fun AddWifiPasswordFormScreen() {
|
|
|
.background(Color.Transparent)
|
|
|
.imePadding()
|
|
|
) {
|
|
|
- SaveButtonAWPFS(buttonText = R.string.save)
|
|
|
+ SaveButtonAWPFS(
|
|
|
+ buttonText = R.string.save,
|
|
|
+ onSaveButtonClick = {
|
|
|
+ val wifiPasswordFormList = ArrayList<NewItemFormField>()
|
|
|
+ val saltKey = basePreferenceHelper.getCustomSaltKey()
|
|
|
+ val secretKey = basePreferenceHelper.getCustomSecretKey()
|
|
|
+
|
|
|
+ val isTitleEmpty = wifi_password_title.isEmpty()
|
|
|
+
|
|
|
+ wifi_password_title = encryptIfNotEmpty(wifi_password_title, secretKey, saltKey)
|
|
|
+ wifi_password_ssid = encryptIfNotEmpty(wifi_password_ssid, secretKey, saltKey)
|
|
|
+ wifi_password_password = encryptIfNotEmpty(wifi_password_password, secretKey, saltKey)
|
|
|
+ wifi_password_connection_type = encryptIfNotEmpty(wifi_password_connection_type, secretKey, saltKey)
|
|
|
+ wifi_password_connection_mode = encryptIfNotEmpty(wifi_password_connection_mode, secretKey, saltKey)
|
|
|
+ wifi_password_authentication = encryptIfNotEmpty(wifi_password_authentication, secretKey, saltKey)
|
|
|
+ wifi_password_encryption = encryptIfNotEmpty(wifi_password_encryption, secretKey, saltKey)
|
|
|
+ wifi_password_use_802_1X = encryptIfNotEmpty(wifi_password_use_802_1X, secretKey, saltKey)
|
|
|
+ wifi_password_fips_mode = encryptIfNotEmpty(wifi_password_fips_mode, secretKey, saltKey)
|
|
|
+ wifi_password_key_type = encryptIfNotEmpty(wifi_password_key_type, secretKey, saltKey)
|
|
|
+ wifi_password_protected = encryptIfNotEmpty(wifi_password_protected, secretKey, saltKey)
|
|
|
+ wifi_password_key_index = encryptIfNotEmpty(wifi_password_key_index, secretKey, saltKey)
|
|
|
+ wifi_password_notes = encryptIfNotEmpty(wifi_password_notes, secretKey, saltKey)
|
|
|
+
|
|
|
+ wifiPasswordFormList.add(NewItemFormField("wifi-password_title", wifi_password_title))
|
|
|
+ wifiPasswordFormList.add(NewItemFormField("wifi-password_ssid", wifi_password_ssid))
|
|
|
+ wifiPasswordFormList.add(NewItemFormField("wifi-password_password", wifi_password_password))
|
|
|
+ wifiPasswordFormList.add(NewItemFormField("wifi-password_connection_type", wifi_password_connection_type))
|
|
|
+ wifiPasswordFormList.add(NewItemFormField("wifi-password_connection_mode", wifi_password_connection_mode))
|
|
|
+ wifiPasswordFormList.add(NewItemFormField("wifi-password_authentication", wifi_password_authentication))
|
|
|
+ wifiPasswordFormList.add(NewItemFormField("wifi-password_encryption", wifi_password_encryption))
|
|
|
+ wifiPasswordFormList.add(NewItemFormField("wifi-password_use_802.1X", wifi_password_use_802_1X))
|
|
|
+ wifiPasswordFormList.add(NewItemFormField("wifi-password_fips_mode", wifi_password_fips_mode))
|
|
|
+ wifiPasswordFormList.add(NewItemFormField("wifi-password_key_type", wifi_password_key_type))
|
|
|
+ wifiPasswordFormList.add(NewItemFormField("wifi-password_protected", wifi_password_protected))
|
|
|
+ wifiPasswordFormList.add(NewItemFormField("wifi-password_key_index", wifi_password_key_index))
|
|
|
+ wifiPasswordFormList.add(NewItemFormField("wifi-password_notes", wifi_password_notes))
|
|
|
+
|
|
|
+ onWifiPasswordFormList.invoke(wifiPasswordFormList, isTitleEmpty)
|
|
|
+ }
|
|
|
+ )
|
|
|
|
|
|
Column(
|
|
|
modifier = Modifier
|
|
@@ -71,31 +128,95 @@ fun AddWifiPasswordFormScreen() {
|
|
|
.verticalScroll(rememberScrollState())
|
|
|
) {
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldAWPFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.title)
|
|
|
+ NameTextFieldAWPFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ labelText = R.string.title,
|
|
|
+ onText = { wifi_password_title = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldAWPFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.ssid)
|
|
|
+ NameTextFieldAWPFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ labelText = R.string.ssid,
|
|
|
+ onText = { wifi_password_ssid = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldAWPFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.password)
|
|
|
+ NameTextFieldAWPFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ labelText = R.string.password,
|
|
|
+ onText = { wifi_password_password = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldAWPFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.connection_type)
|
|
|
+ NameTextFieldAWPFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ labelText = R.string.connection_type,
|
|
|
+ onText = { wifi_password_connection_type = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldAWPFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.connection_mode)
|
|
|
+ NameTextFieldAWPFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ labelText = R.string.connection_mode,
|
|
|
+ onText = { wifi_password_connection_mode = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldAWPFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.authentication)
|
|
|
+ NameTextFieldAWPFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ labelText = R.string.authentication,
|
|
|
+ onText = { wifi_password_authentication = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldAWPFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.encryption)
|
|
|
+ NameTextFieldAWPFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ labelText = R.string.encryption,
|
|
|
+ onText = { wifi_password_encryption = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldAWPFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.use_802_1x)
|
|
|
+ NameTextFieldAWPFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ labelText = R.string.use_802_1x,
|
|
|
+ onText = { wifi_password_use_802_1X = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldAWPFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.fips_mode)
|
|
|
+ NameTextFieldAWPFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ labelText = R.string.fips_mode,
|
|
|
+ onText = { wifi_password_fips_mode = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldAWPFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.key_type)
|
|
|
+ NameTextFieldAWPFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ labelText = R.string.key_type,
|
|
|
+ onText = { wifi_password_key_type = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldAWPFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.protected_text)
|
|
|
+ NameTextFieldAWPFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ labelText = R.string.protected_text,
|
|
|
+ onText = { wifi_password_protected = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NameTextFieldAWPFS(keyboardController = keyboardController, focusManager = focusManager, labelText = R.string.key_index)
|
|
|
+ NameTextFieldAWPFS(
|
|
|
+ keyboardController = keyboardController,
|
|
|
+ focusManager = focusManager,
|
|
|
+ labelText = R.string.key_index,
|
|
|
+ onText = { wifi_password_key_index = it }
|
|
|
+ )
|
|
|
Spacer(modifier = Modifier.height(20.dp))
|
|
|
- NotesTextFieldAWFFS(keyboardController, focusManager)
|
|
|
+ NotesTextFieldAWFFS(
|
|
|
+ keyboardController,
|
|
|
+ focusManager,
|
|
|
+ onText = { wifi_password_notes = it }
|
|
|
+ )
|
|
|
// Spacer(modifier = Modifier.height(25.dp))
|
|
|
// SaveButtonAWPFS(buttonText = R.string.save)
|
|
|
}
|
|
@@ -106,7 +227,8 @@ fun AddWifiPasswordFormScreen() {
|
|
|
fun ColumnScope.NameTextFieldAWPFS(
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
focusManager: FocusManager,
|
|
|
- labelText: Int
|
|
|
+ labelText: Int,
|
|
|
+ onText: (String) -> Unit
|
|
|
) {
|
|
|
var text by remember { mutableStateOf("") }
|
|
|
|
|
@@ -114,6 +236,7 @@ fun ColumnScope.NameTextFieldAWPFS(
|
|
|
value = text,
|
|
|
onValueChange = {
|
|
|
text = it
|
|
|
+ onText.invoke(text)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
@@ -175,7 +298,8 @@ fun ColumnScope.NameTextFieldAWPFS(
|
|
|
@Composable
|
|
|
fun ColumnScope.NotesTextFieldAWFFS(
|
|
|
keyboardController: SoftwareKeyboardController?,
|
|
|
- focusManager: FocusManager
|
|
|
+ focusManager: FocusManager,
|
|
|
+ onText: (String) -> Unit
|
|
|
) {
|
|
|
var notesText by remember { mutableStateOf("") }
|
|
|
|
|
@@ -183,6 +307,7 @@ fun ColumnScope.NotesTextFieldAWFFS(
|
|
|
value = notesText,
|
|
|
onValueChange = {
|
|
|
notesText = it
|
|
|
+ onText.invoke(notesText)
|
|
|
},
|
|
|
textStyle = MaterialTheme.typography.displayMedium,
|
|
|
modifier = Modifier
|
|
@@ -243,7 +368,10 @@ fun ColumnScope.NotesTextFieldAWFFS(
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
-fun BoxScope.SaveButtonAWPFS(buttonText: Int) {
|
|
|
+fun BoxScope.SaveButtonAWPFS(
|
|
|
+ buttonText: Int,
|
|
|
+ onSaveButtonClick: () -> Unit
|
|
|
+) {
|
|
|
Button(
|
|
|
modifier = Modifier
|
|
|
.background(colorResource(id = R.color.transparent))
|
|
@@ -251,7 +379,9 @@ fun BoxScope.SaveButtonAWPFS(buttonText: Int) {
|
|
|
.height(60.dp)
|
|
|
.align(Alignment.BottomCenter)
|
|
|
.clickable() { },
|
|
|
- onClick = {},
|
|
|
+ onClick = {
|
|
|
+ onSaveButtonClick.invoke()
|
|
|
+ },
|
|
|
shape = RoundedCornerShape(15.dp),
|
|
|
// border = BorderStroke(25.dp, colorResource(id = R.color.black)),
|
|
|
colors = ButtonDefaults.buttonColors(
|