minor spelling mistake fix

This commit is contained in:
Dan Ho 2019-03-15 22:49:14 +08:00
parent f5139320db
commit 9137dadcbd
2 changed files with 9 additions and 6 deletions

View file

@ -11,7 +11,7 @@ import java.io.UnsupportedEncodingException
class PasswordEntry(private val content: String) { class PasswordEntry(private val content: String) {
val password: String val password: String
val username: String? val username: String?
val digits: String? val digits: String
val totpSecret: String? val totpSecret: String?
val totpPeriod: Long val totpPeriod: Long
val totpAlgorithm: String val totpAlgorithm: String
@ -87,11 +87,13 @@ class PasswordEntry(private val content: String) {
return null return null
} }
private fun findOtpDigits(decryptedContent: String): String? { private fun findOtpDigits(decryptedContent: String): String {
decryptedContent.split("\n".toRegex()).forEach { line -> decryptedContent.split("\n".toRegex()).forEach { line ->
if (line.startsWith("optauth://totp/") || if (line.startsWith("otpauth://totp/") ||
line.startsWith("otpauth://hotp/")) line.startsWith("otpauth://hotp/") &&
return Uri.parse(line).getQueryParameters("digits").toString() Uri.parse(line).getQueryParameter("digits") != null) {
return Uri.parse(line).getQueryParameter("digits")!!
}
} }
return "6" return "6"
} }

View file

@ -316,7 +316,8 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
entry.totpSecret, entry.totpSecret,
Date().time / (1000 * entry.totpPeriod), Date().time / (1000 * entry.totpPeriod),
entry.totpAlgorithm, entry.totpAlgorithm,
entry.digits) entry.digits
)
} else { } else {
// we only want to calculate and show HOTP if the user requests it // we only want to calculate and show HOTP if the user requests it
crypto_copy_otp.setOnClickListener { crypto_copy_otp.setOnClickListener {