Clipboard now is cleared with manual copy (#464)
* Clipboard now is cleared after manual copy * Spanish translation added * Spanish translations for commit messages updated * Validation of value 0 in general_show_time before start timer The clear_after_copy preference is disabled according with that value. * Like clear_after_copy, clear_clipboard_20x now depends on the value of general_show_time too
This commit is contained in:
parent
d09de8bbf5
commit
723a40a216
4 changed files with 35 additions and 19 deletions
|
@ -168,6 +168,16 @@ class UserPreference : AppCompatActivity() {
|
||||||
callingActivity.exportPasswordsWithPermissions()
|
callingActivity.exportPasswordsWithPermissions()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
findPreference("general_show_time").onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any? ->
|
||||||
|
try {
|
||||||
|
findPreference("clear_after_copy").isEnabled = newValue.toString().toInt() != 0
|
||||||
|
findPreference("clear_clipboard_20x").isEnabled = newValue.toString().toInt() != 0
|
||||||
|
true
|
||||||
|
} catch (e: NumberFormatException) {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
@ -183,6 +193,8 @@ class UserPreference : AppCompatActivity() {
|
||||||
)?.isNotEmpty() ?: false
|
)?.isNotEmpty() ?: false
|
||||||
findPreference("hotp_remember_clear_choice").isEnabled =
|
findPreference("hotp_remember_clear_choice").isEnabled =
|
||||||
sharedPreferences.getBoolean("hotp_remember_check", false)
|
sharedPreferences.getBoolean("hotp_remember_check", false)
|
||||||
|
findPreference("clear_after_copy").isEnabled = sharedPreferences.getString("general_show_time", "45")?.toInt() != 0
|
||||||
|
findPreference("clear_clipboard_20x").isEnabled = sharedPreferences.getString("general_show_time", "45")?.toInt() != 0
|
||||||
val keyPref = findPreference("openpgp_key_id_pref")
|
val keyPref = findPreference("openpgp_key_id_pref")
|
||||||
val selectedKeys: Array<String> = ArrayList<String>(
|
val selectedKeys: Array<String> = ArrayList<String>(
|
||||||
sharedPreferences.getStringSet(
|
sharedPreferences.getStringSet(
|
||||||
|
|
|
@ -612,8 +612,6 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
||||||
if (findViewById<TextView>(R.id.crypto_password_show) == null)
|
if (findViewById<TextView>(R.id.crypto_password_show) == null)
|
||||||
return
|
return
|
||||||
|
|
||||||
setTimer()
|
|
||||||
|
|
||||||
val clip = ClipData.newPlainText("pgp_handler_result_pm", passwordEntry?.password)
|
val clip = ClipData.newPlainText("pgp_handler_result_pm", passwordEntry?.password)
|
||||||
clipboard.primaryClip = clip
|
clipboard.primaryClip = clip
|
||||||
|
|
||||||
|
@ -624,7 +622,13 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
||||||
// ignore and keep default
|
// ignore and keep default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings.getBoolean("clear_after_copy", true) && clearAfter != 0) {
|
||||||
|
setTimer()
|
||||||
showToast(this.resources.getString(R.string.clipboard_password_toast_text, clearAfter))
|
showToast(this.resources.getString(R.string.clipboard_password_toast_text, clearAfter))
|
||||||
|
} else {
|
||||||
|
showToast(this.resources.getString(R.string.clipboard_password_no_clear_toast_text))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun copyUsernameToClipBoard(username: String) {
|
private fun copyUsernameToClipBoard(username: String) {
|
||||||
|
@ -743,8 +747,7 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
||||||
if (skip) return
|
if (skip) return
|
||||||
checkAndIncrementHotp()
|
checkAndIncrementHotp()
|
||||||
|
|
||||||
// only clear the clipboard if we automatically copied the password to it
|
// No need to validate clear_after_copy. It was validated in copyPasswordToClipBoard()
|
||||||
if (settings.getBoolean("copy_on_decrypt", true)) {
|
|
||||||
Log.d("DELAY_SHOW", "Clearing the clipboard")
|
Log.d("DELAY_SHOW", "Clearing the clipboard")
|
||||||
val clip = ClipData.newPlainText("pgp_handler_result_pm", "")
|
val clip = ClipData.newPlainText("pgp_handler_result_pm", "")
|
||||||
clipboard.primaryClip = clip
|
clipboard.primaryClip = clip
|
||||||
|
@ -758,7 +761,6 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (crypto_password_show != null) {
|
if (crypto_password_show != null) {
|
||||||
// clear password; if decrypt changed to encrypt layout via edit button, no need
|
// clear password; if decrypt changed to encrypt layout via edit button, no need
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
<!-- PGPHandler -->
|
<!-- PGPHandler -->
|
||||||
<string name="provider_toast_text">¡No se ha seleccionado ningún proveedor OpenGPG!</string>
|
<string name="provider_toast_text">¡No se ha seleccionado ningún proveedor OpenGPG!</string>
|
||||||
<string name="clipboard_password_toast_text">Contraseña copiada al portapapeles, tienes %d segundos para pegarla.</string>
|
<string name="clipboard_password_toast_text">Contraseña copiada al portapapeles, tienes %d segundos para pegarla.</string>
|
||||||
|
<string name="clipboard_password_no_clear_toast_text">Contraseña copiada al portapapeles</string>
|
||||||
<string name="clipboard_username_toast_text">Nombre de usuario copiado al portapapeles</string>
|
<string name="clipboard_username_toast_text">Nombre de usuario copiado al portapapeles</string>
|
||||||
<string name="clipboard_otp_toast_text">Código OTP copiado al portapapeles</string>
|
<string name="clipboard_otp_toast_text">Código OTP copiado al portapapeles</string>
|
||||||
<string name="file_toast_text">Por favor selecciona un nombre de archivo</string>
|
<string name="file_toast_text">Por favor selecciona un nombre de archivo</string>
|
||||||
|
@ -122,7 +123,7 @@
|
||||||
<string name="pref_no_key_selected">Ninguna llave seleccionada</string>
|
<string name="pref_no_key_selected">Ninguna llave seleccionada</string>
|
||||||
<string name="pref_general_title">General</string>
|
<string name="pref_general_title">General</string>
|
||||||
<string name="pref_password_title">Tiempo para mostrar contraseña</string>
|
<string name="pref_password_title">Tiempo para mostrar contraseña</string>
|
||||||
<string name="pref_password_dialog_title">Establece el tiempo antes de limpiar la contraseña del portapapeles.</string>
|
<string name="pref_password_dialog_title">Establece el tiempo antes de limpiar la contraseña del portapapeles. Un valor de cero deshabilita el limpiado.</string>
|
||||||
<string name="pref_copy_title">Copiar contraseña automáticamente</string>
|
<string name="pref_copy_title">Copiar contraseña automáticamente</string>
|
||||||
<string name="pref_copy_dialog_title">Automáticamente copia la contraseña al portapapeles si el descifrado fue exitoso.</string>
|
<string name="pref_copy_dialog_title">Automáticamente copia la contraseña al portapapeles si el descifrado fue exitoso.</string>
|
||||||
<string name="ssh_key_success_dialog_title">Llave SSH importada</string>
|
<string name="ssh_key_success_dialog_title">Llave SSH importada</string>
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
<!-- PGPHandler -->
|
<!-- PGPHandler -->
|
||||||
<string name="provider_toast_text">No OpenPGP Provider selected!</string>
|
<string name="provider_toast_text">No OpenPGP Provider selected!</string>
|
||||||
<string name="clipboard_password_toast_text">Password copied to clipboard, you have %d seconds to paste it somewhere.</string>
|
<string name="clipboard_password_toast_text">Password copied to clipboard, you have %d seconds to paste it somewhere.</string>
|
||||||
|
<string name="clipboard_password_no_clear_toast_text">Password copied to clipboard</string>
|
||||||
<string name="clipboard_username_toast_text">Username copied to clipboard</string>
|
<string name="clipboard_username_toast_text">Username copied to clipboard</string>
|
||||||
<string name="clipboard_otp_toast_text">OTP code copied to clipboard</string>
|
<string name="clipboard_otp_toast_text">OTP code copied to clipboard</string>
|
||||||
<string name="file_toast_text">Please provide a file name</string>
|
<string name="file_toast_text">Please provide a file name</string>
|
||||||
|
@ -136,7 +137,7 @@
|
||||||
<string name="pref_no_key_selected">No key selected</string>
|
<string name="pref_no_key_selected">No key selected</string>
|
||||||
<string name="pref_general_title">General</string>
|
<string name="pref_general_title">General</string>
|
||||||
<string name="pref_password_title">Password Show Time</string>
|
<string name="pref_password_title">Password Show Time</string>
|
||||||
<string name="pref_password_dialog_title">Set the time you want the password to be in clipboard</string>
|
<string name="pref_password_dialog_title">Set the time you want the password to be in clipboard. 0 means forever.</string>
|
||||||
<string name="pref_copy_title">Automatically Copy Password</string>
|
<string name="pref_copy_title">Automatically Copy Password</string>
|
||||||
<string name="pref_copy_dialog_title">Automatically copy the password to the clipboard after decryption was successful.</string>
|
<string name="pref_copy_dialog_title">Automatically copy the password to the clipboard after decryption was successful.</string>
|
||||||
<string name="ssh_key_success_dialog_title">SSH-key imported</string>
|
<string name="ssh_key_success_dialog_title">SSH-key imported</string>
|
||||||
|
|
Loading…
Reference in a new issue