|
@@ -64,12 +64,13 @@ import androidx.compose.ui.unit.sp
|
|
|
import com.fastest.pass.R
|
|
|
import com.fastest.pass.app.Utils
|
|
|
import com.fastest.pass.helpers.BasePreferenceHelper
|
|
|
+import com.fastest.pass.home.data.model.NewItemFormField
|
|
|
import com.fastest.pass.home.domain.model.PasswordFormData
|
|
|
import javax.inject.Inject
|
|
|
|
|
|
@Composable
|
|
|
fun AddPasswordFormScreen(
|
|
|
- onPasswordsFormList: (ArrayList<PasswordFormData>) -> Unit,
|
|
|
+ onPasswordsFormList: (ArrayList<NewItemFormField>, Boolean) -> Unit,
|
|
|
basePreferenceHelper: BasePreferenceHelper
|
|
|
) {
|
|
|
val keyboardController = LocalSoftwareKeyboardController.current
|
|
@@ -91,29 +92,38 @@ fun AddPasswordFormScreen(
|
|
|
SaveButtonAPWFS(
|
|
|
buttonText = R.string.save,
|
|
|
onSaveButtonCLick = {
|
|
|
- val passwordsFormList = ArrayList<PasswordFormData>()
|
|
|
+ val passwordsFormList = ArrayList<NewItemFormField>()
|
|
|
val saltKey = basePreferenceHelper.getCustomSaltKey()
|
|
|
- val userPassword = basePreferenceHelper.getPassword()
|
|
|
+ val secretKey = basePreferenceHelper.getCustomSecretKey()
|
|
|
|
|
|
- Log.d("saltKey", "saltKey = $saltKey, password = $userPassword")
|
|
|
-// val passwords_title_enc = Utils.encryptData(
|
|
|
-// passwords_title, userPassword ?: "", saltKey ?: "")
|
|
|
-// passwords_url = Utils.encryptData(
|
|
|
-// passwords_url, userPassword ?: "", saltKey ?: "")
|
|
|
-// passwords_username = Utils.encryptData(
|
|
|
-// passwords_username, userPassword ?: "", saltKey ?: "")
|
|
|
-// passwords_password = Utils.encryptData(
|
|
|
-// passwords_password, userPassword ?: "", saltKey ?: "")
|
|
|
-// passwords_notes = Utils.encryptData(
|
|
|
-// passwords_notes, userPassword ?: "", saltKey ?: "")
|
|
|
+ val isTitleEmpty = passwords_title.isEmpty()
|
|
|
|
|
|
- passwordsFormList.add(PasswordFormData("passwords_title", passwords_title))
|
|
|
- passwordsFormList.add(PasswordFormData("passwords_url", passwords_url))
|
|
|
- passwordsFormList.add(PasswordFormData("passwords_username", passwords_username))
|
|
|
- passwordsFormList.add(PasswordFormData("passwords_password", passwords_password))
|
|
|
- passwordsFormList.add(PasswordFormData("passwords_notes", passwords_notes))
|
|
|
+ if (passwords_title.isNotEmpty()) {
|
|
|
+ passwords_title = Utils.encryptData(passwords_title, secretKey ?: "", saltKey ?: "")
|
|
|
+ }
|
|
|
+ if (passwords_url.isNotEmpty()) {
|
|
|
+ passwords_url = Utils.encryptData(passwords_url, secretKey ?: "", saltKey ?: "")
|
|
|
+ }
|
|
|
+ if (passwords_username.isNotEmpty()) {
|
|
|
+ passwords_username =
|
|
|
+ Utils.encryptData(passwords_username, secretKey ?: "", saltKey ?: "")
|
|
|
+ }
|
|
|
+ if (passwords_password.isNotEmpty()) {
|
|
|
+ passwords_password =
|
|
|
+ Utils.encryptData(passwords_password, secretKey ?: "", saltKey ?: "")
|
|
|
+ }
|
|
|
+ if (passwords_notes.isNotEmpty()) {
|
|
|
+ passwords_notes =
|
|
|
+ Utils.encryptData(passwords_notes, secretKey ?: "", saltKey ?: "")
|
|
|
+ }
|
|
|
+
|
|
|
+ passwordsFormList.add(NewItemFormField("passwords_title", passwords_title))
|
|
|
+ passwordsFormList.add(NewItemFormField("passwords_url", passwords_url))
|
|
|
+ passwordsFormList.add(NewItemFormField("passwords_username", passwords_username))
|
|
|
+ passwordsFormList.add(NewItemFormField("passwords_password", passwords_password))
|
|
|
+ passwordsFormList.add(NewItemFormField("passwords_notes", passwords_notes))
|
|
|
|
|
|
- onPasswordsFormList.invoke(passwordsFormList)
|
|
|
+ onPasswordsFormList.invoke(passwordsFormList, isTitleEmpty)
|
|
|
}
|
|
|
)
|
|
|
|