break several lines to limit the line length
This commit is contained in:
parent
b2eb150c0f
commit
f5139320db
2 changed files with 13 additions and 10 deletions
|
@ -89,19 +89,17 @@ class PasswordEntry(private val content: String) {
|
|||
|
||||
private fun findOtpDigits(decryptedContent: String): String? {
|
||||
decryptedContent.split("\n".toRegex()).forEach { line ->
|
||||
if (line.startsWith("otpauth://totp/")) {
|
||||
return Uri.parse(line).getQueryParameter("digits")
|
||||
}
|
||||
if (line.startsWith("otpauth://hotp/")) {
|
||||
return Uri.parse(line).getQueryParameter("digits")
|
||||
}
|
||||
if (line.startsWith("optauth://totp/") ||
|
||||
line.startsWith("otpauth://hotp/"))
|
||||
return Uri.parse(line).getQueryParameters("digits").toString()
|
||||
}
|
||||
return "6"
|
||||
}
|
||||
|
||||
private fun findTotpPeriod(decryptedContent: String): Long {
|
||||
decryptedContent.split("\n".toRegex()).forEach { line ->
|
||||
if (line.startsWith("otpauth://totp/") && Uri.parse(line).getQueryParameter("period") != null) {
|
||||
if (line.startsWith("otpauth://totp/") &&
|
||||
Uri.parse(line).getQueryParameter("period") != null) {
|
||||
return java.lang.Long.parseLong(Uri.parse(line).getQueryParameter("period")!!)
|
||||
}
|
||||
}
|
||||
|
@ -110,8 +108,9 @@ class PasswordEntry(private val content: String) {
|
|||
|
||||
private fun findTotpAlgorithm(decryptedContent: String): String {
|
||||
decryptedContent.split("\n".toRegex()).forEach { line ->
|
||||
if (line.startsWith("otpauth://totp/") && Uri.parse(line).getQueryParameter("algorithm") != null) {
|
||||
return Uri.parse(line).getQueryParameter("algorithm")
|
||||
if (line.startsWith("otpauth://totp/") &&
|
||||
Uri.parse(line).getQueryParameter("algorithm") != null) {
|
||||
return Uri.parse(line).getQueryParameter("algorithm")!!
|
||||
}
|
||||
}
|
||||
return "sha1"
|
||||
|
|
|
@ -312,7 +312,11 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
|||
)
|
||||
}
|
||||
crypto_otp_show.text =
|
||||
Otp.calculateCode(entry.totpSecret, Date().time / (1000 * entry.totpPeriod), entry.totpAlgorithm, entry.digits)
|
||||
Otp.calculateCode(
|
||||
entry.totpSecret,
|
||||
Date().time / (1000 * entry.totpPeriod),
|
||||
entry.totpAlgorithm,
|
||||
entry.digits)
|
||||
} else {
|
||||
// we only want to calculate and show HOTP if the user requests it
|
||||
crypto_copy_otp.setOnClickListener {
|
||||
|
|
Loading…
Reference in a new issue