aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDan Ho <igaryhe@gmail.com>2019-03-15 22:20:30 +0800
committerDan Ho <igaryhe@gmail.com>2019-03-15 22:20:30 +0800
commitf5139320dbb8be38af7b5b519a29cd06ec5cd30a (patch)
tree058d29055f1859d811e13b1be7494b8a6a243502 /app
parentb2eb150c0faff4cf1c1c3bc6c1da23695914d47f (diff)
break several lines to limit the line length
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordEntry.kt17
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt6
2 files changed, 13 insertions, 10 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordEntry.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordEntry.kt
index 82204317..2b1f1eee 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordEntry.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordEntry.kt
@@ -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"
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 055f50bf..dc9d399f 100644
--- a/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PgpActivity.kt
@@ -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 {