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? {
|
private fun findOtpDigits(decryptedContent: String): String? {
|
||||||
decryptedContent.split("\n".toRegex()).forEach { line ->
|
decryptedContent.split("\n".toRegex()).forEach { line ->
|
||||||
if (line.startsWith("otpauth://totp/")) {
|
if (line.startsWith("optauth://totp/") ||
|
||||||
return Uri.parse(line).getQueryParameter("digits")
|
line.startsWith("otpauth://hotp/"))
|
||||||
}
|
return Uri.parse(line).getQueryParameters("digits").toString()
|
||||||
if (line.startsWith("otpauth://hotp/")) {
|
|
||||||
return Uri.parse(line).getQueryParameter("digits")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return "6"
|
return "6"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findTotpPeriod(decryptedContent: String): Long {
|
private fun findTotpPeriod(decryptedContent: String): Long {
|
||||||
decryptedContent.split("\n".toRegex()).forEach { line ->
|
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")!!)
|
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 {
|
private fun findTotpAlgorithm(decryptedContent: String): String {
|
||||||
decryptedContent.split("\n".toRegex()).forEach { line ->
|
decryptedContent.split("\n".toRegex()).forEach { line ->
|
||||||
if (line.startsWith("otpauth://totp/") && Uri.parse(line).getQueryParameter("algorithm") != null) {
|
if (line.startsWith("otpauth://totp/") &&
|
||||||
return Uri.parse(line).getQueryParameter("algorithm")
|
Uri.parse(line).getQueryParameter("algorithm") != null) {
|
||||||
|
return Uri.parse(line).getQueryParameter("algorithm")!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "sha1"
|
return "sha1"
|
||||||
|
|
|
@ -312,7 +312,11 @@ class PgpActivity : AppCompatActivity(), OpenPgpServiceConnection.OnBound {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
crypto_otp_show.text =
|
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 {
|
} 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 {
|
||||||
|
|
Loading…
Reference in a new issue