diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt index afac816a0..7d1be72c9 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt @@ -168,6 +168,16 @@ class UserPreference : AppCompatActivity() { callingActivity.exportPasswordsWithPermissions() 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() { @@ -183,6 +193,8 @@ class UserPreference : AppCompatActivity() { )?.isNotEmpty() ?: false findPreference("hotp_remember_clear_choice").isEnabled = 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 selectedKeys: Array = ArrayList( sharedPreferences.getStringSet( diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt index 9be1f1707..9828f43a1 100644 --- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt @@ -612,8 +612,6 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { if (findViewById(R.id.crypto_password_show) == null) return - setTimer() - val clip = ClipData.newPlainText("pgp_handler_result_pm", passwordEntry?.password) clipboard.primaryClip = clip @@ -624,7 +622,13 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { // ignore and keep default } - showToast(this.resources.getString(R.string.clipboard_password_toast_text, clearAfter)) + if (settings.getBoolean("clear_after_copy", true) && clearAfter != 0) { + setTimer() + 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) { @@ -743,20 +747,18 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound { if (skip) return checkAndIncrementHotp() - // only clear the clipboard if we automatically copied the password to it - if (settings.getBoolean("copy_on_decrypt", true)) { - Log.d("DELAY_SHOW", "Clearing the clipboard") - val clip = ClipData.newPlainText("pgp_handler_result_pm", "") - clipboard.primaryClip = clip - if (settings.getBoolean("clear_clipboard_20x", false)) { - val handler = Handler() - for (i in 0..18) { - val count = i.toString() - handler.postDelayed( - { clipboard.primaryClip = ClipData.newPlainText(count, count) }, - (i * 500).toLong() - ) - } + // No need to validate clear_after_copy. It was validated in copyPasswordToClipBoard() + Log.d("DELAY_SHOW", "Clearing the clipboard") + val clip = ClipData.newPlainText("pgp_handler_result_pm", "") + clipboard.primaryClip = clip + if (settings.getBoolean("clear_clipboard_20x", false)) { + val handler = Handler() + for (i in 0..18) { + val count = i.toString() + handler.postDelayed( + { clipboard.primaryClip = ClipData.newPlainText(count, count) }, + (i * 500).toLong() + ) } } diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 1131616d1..392be07f4 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -30,6 +30,7 @@ ¡No se ha seleccionado ningún proveedor OpenGPG! Contraseña copiada al portapapeles, tienes %d segundos para pegarla. + Contraseña copiada al portapapeles Nombre de usuario copiado al portapapeles Código OTP copiado al portapapeles Por favor selecciona un nombre de archivo @@ -122,7 +123,7 @@ Ninguna llave seleccionada General Tiempo para mostrar contraseña - Establece el tiempo antes de limpiar la contraseña del portapapeles. + Establece el tiempo antes de limpiar la contraseña del portapapeles. Un valor de cero deshabilita el limpiado. Copiar contraseña automáticamente Automáticamente copia la contraseña al portapapeles si el descifrado fue exitoso. Llave SSH importada diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ddcb5da42..0b1afda15 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -38,6 +38,7 @@ No OpenPGP Provider selected! Password copied to clipboard, you have %d seconds to paste it somewhere. + Password copied to clipboard Username copied to clipboard OTP code copied to clipboard Please provide a file name @@ -136,7 +137,7 @@ No key selected General Password Show Time - Set the time you want the password to be in clipboard + Set the time you want the password to be in clipboard. 0 means forever. Automatically Copy Password Automatically copy the password to the clipboard after decryption was successful. SSH-key imported