Allow empty backup/restore password
This commit is contained in:
@ -508,6 +508,7 @@ object CustomElements {
|
||||
ctx: Context,
|
||||
showPasswordDialog: MutableState<Boolean>,
|
||||
password: MutableState<String>,
|
||||
emptyOk: Boolean = false,
|
||||
keyboardController: SoftwareKeyboardController?,
|
||||
title: String,
|
||||
message: String = "",
|
||||
@ -614,7 +615,7 @@ object CustomElements {
|
||||
keyboardController?.hide()
|
||||
showPasswordDialog.value = false
|
||||
password.value = password.value.trim()
|
||||
if (!Account.checkAuthPass(password.value)) {
|
||||
if (!(emptyOk && password.value.isEmpty()) && !Account.checkAuthPass(password.value)) {
|
||||
Toast.makeText(
|
||||
ctx,
|
||||
String.format(
|
||||
|
||||
@ -410,16 +410,15 @@ private fun MainScreen(
|
||||
ctx = ctx,
|
||||
showPasswordDialog = showPasswordDialog,
|
||||
password = password,
|
||||
emptyOk = true,
|
||||
keyboardController = keyboardController,
|
||||
title = passwordTitle.value,
|
||||
okAction = {
|
||||
if (password.value != "") {
|
||||
if (passwordTitle.value == encryptPasswordTitle)
|
||||
backup(ctx, password.value)
|
||||
else
|
||||
restore(ctx, password.value, onRestartClick)
|
||||
password.value = ""
|
||||
}
|
||||
},
|
||||
cancelAction = {
|
||||
if (downloadsOutputUri != null) {
|
||||
|
||||
@ -100,10 +100,9 @@ object Utils {
|
||||
fun getNameValue(string: String, name: String): ArrayList<String> {
|
||||
val lines = string.split("\n")
|
||||
val result = ArrayList<String>()
|
||||
for (line in lines) {
|
||||
for (line in lines)
|
||||
if (line.startsWith(name))
|
||||
result.add((line.substring(name.length).trim()).split(" \t")[0])
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@ -178,8 +177,7 @@ object Utils {
|
||||
ctx.getString(R.string.anonymous)
|
||||
else if (host == "unknown.invalid")
|
||||
ctx.getString(R.string.unknown)
|
||||
else
|
||||
if (params.isEmpty())
|
||||
else if (params.isEmpty())
|
||||
"$user@$host"
|
||||
else
|
||||
"$user@$host;" + params.joinToString(";")
|
||||
@ -750,7 +748,7 @@ object Utils {
|
||||
}
|
||||
|
||||
fun encryptToUri(ctx: Context, uri: Uri, content: ByteArray, password: String): Boolean {
|
||||
val obj = encrypt(content, password.toCharArray())
|
||||
val obj = if (password == "") content else encrypt(content, password.toCharArray())
|
||||
try {
|
||||
val stream = ctx.contentResolver.openOutputStream(uri)
|
||||
if (stream != null)
|
||||
@ -781,7 +779,7 @@ object Utils {
|
||||
try {
|
||||
ObjectInputStream(stream).use {
|
||||
val content = it.readObject() as ByteArray
|
||||
plainData = decrypt(content, password.toCharArray())
|
||||
plainData = if (password == "") content else decrypt(content, password.toCharArray())
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "decryptFromUri as ByteArray failed: $e")
|
||||
|
||||
Reference in New Issue
Block a user