mirror of
https://github.com/yogeshpaliyal/KeyPass.git
synced 2026-05-09 10:59:43 -05:00
TOTP: copy generated OTP code to clipboard instead of the secret key
This commit is contained in:
@@ -58,13 +58,20 @@ class HomeFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun getPassword(model: AccountModel): String {
|
||||
if (model.type == AccountType.TOTP) {
|
||||
return model.getOtp()
|
||||
}
|
||||
return model.password.orEmpty()
|
||||
}
|
||||
|
||||
override fun onCopyClicked(model: AccountModel) {
|
||||
val clipboard =
|
||||
ContextCompat.getSystemService(
|
||||
requireContext(),
|
||||
ClipboardManager::class.java
|
||||
)
|
||||
val clip = ClipData.newPlainText("KeyPass", model.password)
|
||||
val clip = ClipData.newPlainText("KeyPass", getPassword(model))
|
||||
clipboard?.setPrimaryClip(clip)
|
||||
Toast.makeText(context, getString(R.string.copied_to_clipboard), Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
|
||||
Reference in New Issue
Block a user